Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-01-12 16:33:35 +0000
committercletavernie2012-01-12 16:33:35 +0000
commitaaa0f0a63bf9890ee7911e638a41d8b721d7c2fd (patch)
treec3a0567c109cba2de3406ef18fc683e569603484
parent76fbe55c1db8045c1be47e31f59296ecac6ae157 (diff)
downloadorg.eclipse.papyrus-aaa0f0a63bf9890ee7911e638a41d8b721d7c2fd.tar.gz
org.eclipse.papyrus-aaa0f0a63bf9890ee7911e638a41d8b721d7c2fd.tar.xz
org.eclipse.papyrus-aaa0f0a63bf9890ee7911e638a41d8b721d7c2fd.zip
359794: [UML - Tools] Content/Label providers
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359794
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/plugin.xml2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ContextEditorActionBarContributor.java2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ConstraintDescriptorContentProvider.java4
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/DataContextElementContentProvider.java4
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java4
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/PropertyContentProvider.java12
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/TabContentProvider.java4
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java3
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java (renamed from plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EcoreEnumeratorContentProvider.java)17
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java (renamed from plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/GraphicalModelExplorerBasedContentProvider.java)157
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HierarchicViewerFilter.java147
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/IMetaclassFilteredContentProvider.java39
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java19
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java293
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java186
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/StrategyBasedContentProvider.java98
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java41
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java (renamed from plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/HistoryUtil.java)21
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java57
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/.project4
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/providers/ConstraintTypeContentProvider.java4
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/AggregatedObservable.java (renamed from plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/AggregatedObservable.java)2
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/MultipleObservableValue.java1
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java41
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF5
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/CLabelObservableValue.java1
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/ComboObservableValue.java1
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/GrayedCheckboxObservableValue.java1
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/TextObservableValue.java1
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/BooleanCheckbox.java2
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java10
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueSelectorDialog.java13
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceCombo.java2
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java6
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java2
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java65
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractStaticContentProvider.java4
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractTreeFilter.java37
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CollectionContentProvider.java16
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EmptyContentProvider.java11
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EncapsulatedContentProvider.java85
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/HierarchicToFlatContentProvider.java7
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IAdaptableContentProvider.java2
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IStaticContentProvider.java4
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/TreeToFlatContentProvider.java7
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/selectors/ReferenceSelector.java140
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/AbstractTreeBrowseStrategy.java31
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/IStrategyBasedContentProvider.java22
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/ProviderBasedBrowseStrategy.java133
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/TreeBrowseStrategy.java41
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/ui/InterfaceManagerDialog.java28
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/ServiceEditContentProvider.java11
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/ui/InterfaceManagerDialog.java48
-rw-r--r--plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/.project4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/ui/InterfaceManagerDialog.java48
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/ui/InterfaceManagerDialog.java48
-rw-r--r--plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/.project6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/Util.java118
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/HasStereotypeConstraint.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/UmlInstanceOfConstraint.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java4
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElementFactory.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceFactory.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationFactory.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java4
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java76
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElementFactory.java11
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java57
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElementFactory.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueContentProvider.java63
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/UMLContentProvider.java88
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/util/UMLUtil.java350
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationPropertyEditor.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ProfileUtil.java217
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/UMLUtil.java (renamed from plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ui/helper/UMLHelper.java)41
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ApplicableStereotypeContentProvider.java (renamed from plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/ApplicableStereotypeContentProvider.java)2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/InstanceValueContentProvider.java (renamed from plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueViewerFilter.java)54
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java (renamed from plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/ProfileLabelProvider.java)7
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/SemanticUMLContentProvider.java142
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ServiceEditFilteredContentProvider.java (renamed from plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ServiceEditFilteredUMLContentProvider.java)21
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainerContentProvider.java72
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainmentBrowseStrategy.java75
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java127
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLElementMEBContentProvider.java182
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLHierarchicViewerFilter.java40
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLLabelProvider.java81
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/DatabindingUtil.java44
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/UMLProviderHelper.java60
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/AdvancedMETreeDialog.java158
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/ModelExplorerBasedTreeSelectorDialog.java145
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF1
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java2
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/CompositeModelElement.java2
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java4
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/ContainerContentProvider.java17
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EncapsulatedComboViewer.java2
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java24
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/EnumCombo.java14
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ReferenceCombo.java5
110 files changed, 2207 insertions, 2146 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/plugin.xml b/plugins/customization/org.eclipse.papyrus.customization.properties/plugin.xml
index 67ef5f92eb1..6774a9d3314 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/plugin.xml
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/plugin.xml
@@ -34,7 +34,7 @@
</environment>
</extension>
<extension point="org.eclipse.papyrus.views.properties.context">
- <context contextModel="Model/Customization.ctx" loadDefault="true">
+ <context contextModel="Model/Customization.ctx">
</context>
</extension>
<extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ContextEditorActionBarContributor.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ContextEditorActionBarContributor.java
index 4e232a3ff2a..90a70c41652 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ContextEditorActionBarContributor.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/editor/ContextEditorActionBarContributor.java
@@ -225,7 +225,7 @@ public class ContextEditorActionBarContributor extends EcoreActionBarContributor
* The list of newly created {@link IAction}s
*/
protected Collection<IAction> createChildForView(ISelection selection, View view) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
// Collection<IAction> actions = new LinkedList<IAction>();
// if(view.getContext() == null) {
// return actions;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ConstraintDescriptorContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ConstraintDescriptorContentProvider.java
index e9d6f0f073e..7bc2139cb37 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ConstraintDescriptorContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ConstraintDescriptorContentProvider.java
@@ -70,4 +70,8 @@ public class ConstraintDescriptorContentProvider extends AbstractContextualConte
return result;
}
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
+
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/DataContextElementContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/DataContextElementContentProvider.java
index eafd418e3bd..c48fa4efd1e 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/DataContextElementContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/DataContextElementContentProvider.java
@@ -120,4 +120,8 @@ public class DataContextElementContentProvider extends AbstractFilteredContentPr
return elements.toArray(new DataContextElement[elements.size()]);
}
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
+
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java
index 9522d188aae..e070c7ab8d9 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/EnvironmentContentProvider.java
@@ -49,4 +49,8 @@ public class EnvironmentContentProvider extends AbstractFilteredContentProvider
return contents;
}
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
+
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/PropertyContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/PropertyContentProvider.java
index 5e24b035403..50541fdfb33 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/PropertyContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/PropertyContentProvider.java
@@ -11,7 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.customization.properties.providers;
-import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -45,17 +44,6 @@ public class PropertyContentProvider extends AbstractContextualContentProvider i
return contexts.toArray();
}
- private Collection<Property> findProperties(DataContextElement element) {
- List<Property> result = new LinkedList<Property>();
- result.addAll(element.getProperties());
- if(element instanceof DataContextPackage) {
- for(DataContextElement subElement : ((DataContextPackage)element).getElements()) {
- result.addAll(findProperties(subElement));
- }
- }
- return result;
- }
-
public Object[] getElements(Object inputElement) {
return getElements();
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/TabContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/TabContentProvider.java
index 97394acc087..e50515b6b62 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/TabContentProvider.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/TabContentProvider.java
@@ -58,4 +58,8 @@ public class TabContentProvider extends AbstractContextualContentProvider {
return true;
}
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
+
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
index 89d7a07b484..a1e65b2873d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
@@ -22,11 +22,12 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.emf.facet.infra.browser.custom;bundle-version="0.2.0",
org.eclipse.emf.facet.infra.facet.core;bundle-version="0.2.0",
org.eclipse.emf.facet.infra.browser.custom.core;bundle-version="0.2.0",
+ org.eclipse.papyrus.infra.tools;bundle-version="0.9.0",
org.eclipse.emf.transaction;bundle-version="1.4.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.infra.emf,
- org.eclipse.papyrus.infra.emf.commands,
org.eclipse.papyrus.infra.emf.databinding,
org.eclipse.papyrus.infra.emf.providers,
+ org.eclipse.papyrus.infra.emf.providers.strategy,
org.eclipse.papyrus.infra.emf.utils
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
index 705f3c00482..c91107c5e55 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
@@ -28,8 +28,9 @@ import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider
* A Content provider for EMF references
*
* @author Camille Letavernier
+ * @deprecated Use the new ContentProvider tools
*/
-//TODO : Implement IHierarchicContentProvider, IGraphicalContentProvider
+@Deprecated
public class EMFContentProvider extends AbstractStaticContentProvider {
private EObject eObject;
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EcoreEnumeratorContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
index 4ee880b9316..a4d5f0c9d1d 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EcoreEnumeratorContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
@@ -9,22 +9,21 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.views.properties.providers;
+package org.eclipse.papyrus.infra.emf.providers;
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
/**
* An IStaticContentProvider for EMF enumerators.
*
* @author Camille Letavernier
*/
-public class EcoreEnumeratorContentProvider implements IStaticContentProvider {
+public class EMFEnumeratorContentProvider extends AbstractStaticContentProvider {
/**
* The feature representing the Enumerator for this ContentProvider
@@ -36,18 +35,10 @@ public class EcoreEnumeratorContentProvider implements IStaticContentProvider {
*
* @param feature
*/
- public EcoreEnumeratorContentProvider(EStructuralFeature feature) {
+ public EMFEnumeratorContentProvider(EStructuralFeature feature) {
this.feature = feature;
}
- public void dispose() {
- //Nothing here
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- //Nothing here
- }
-
public Object[] getElements() {
EClassifier type = feature.getEType();
EEnum enumerated = (EEnum)type;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/GraphicalModelExplorerBasedContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
index 4524924576d..ddfc7a43cbe 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/GraphicalModelExplorerBasedContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
@@ -18,22 +18,20 @@ package org.eclipse.papyrus.infra.emf.providers;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
@@ -46,9 +44,8 @@ import org.eclipse.papyrus.infra.emf.Activator;
import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IDetailLabelProvider;
-import org.eclipse.papyrus.infra.widgets.providers.IGraphicalContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
@@ -62,28 +59,19 @@ import org.eclipse.swt.widgets.Table;
* this is a content provider based on the model explorer on which we can filter wanted meta-classes
* It can only filter if wantedMetaclass and metaclassNotWanted are Eclass
*/
-public class GraphicalModelExplorerBasedContentProvider extends ModelContentProvider implements IMetaclassFilteredContentProvider, IHierarchicContentProvider, IGraphicalContentProvider, ISelectionChangedListener, ICommitListener {
+public class EMFGraphicalContentProvider extends EncapsulatedContentProvider implements ISelectionChangedListener {
-
- private static final String DIALOG_SETTINGS = GraphicalModelExplorerBasedContentProvider.class.getName();
-
- /** The not wanted. */
- protected ArrayList<Object> metaClassNotWantedList = new ArrayList<Object>();
-
- /** The wanted. */
- protected Object metaClassWanted = null;
-
- /**
- * a bridge to find the semantic element behind an object of the model explorer
- */
- protected SemanticFromModelExplorer brige = new SemanticFromModelExplorer();
+ private static final String DIALOG_SETTINGS = EMFGraphicalContentProvider.class.getName();
protected String historyId;
- /**
- * The current metaclass viewer filter
- */
- protected ViewerFilter currentMetaclassViewerFilter;
+ //Unused (yet)
+ //TODO : Add a preference or a collapsible composite for this feature (Or both)
+ //
+ // /**
+ // * The current metaclass viewer filter
+ // */
+ // protected ViewerFilter currentMetaclassViewerFilter;
protected ViewerFilter patternFilter;
@@ -97,6 +85,8 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
protected Object selectedObject;
+ protected StructuredViewer viewer;
+
private static final int HISTORY_MAX_SIZE = 5;
private String currentFilterPattern = ""; //$NON-NLS-1$
@@ -107,88 +97,16 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
/**
* the constructor
- *
- * @param semanticRoot
- * the root that we want to display at top
*/
- public GraphicalModelExplorerBasedContentProvider(EObject semanticRoot, String historyId) {
- super(semanticRoot);
+ public EMFGraphicalContentProvider(IStructuredContentProvider semanticProvider, String historyId) {
+ super(semanticProvider);
this.historyId = historyId;
}
/**
* {@inheritDoc}
*/
- public void setMetaClassNotWanted(List<Object> metaClassNotWanted) {
- metaClassNotWantedList.clear();
- metaClassNotWantedList.addAll(metaClassNotWanted);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setMetaClassWanted(Object metaClassWanted) {
- this.metaClassWanted = metaClassWanted;
- }
-
-
- /**
- * get Wanted metaclasse
- *
- * @return Eclass that reprensent the wanted metaclass
- */
- public Object getMetaClassWanted() {
- return metaClassWanted;
- }
-
- public boolean isValidValue(Object element) {
-
- //to filter, test if the wanted metaclass is not null
- if(metaClassWanted != null) {
- // get the semantic object form the element
- EObject semanticObject = null;
-
- if(element instanceof IAdaptable) {
- semanticObject = (EObject)brige.getSemanticElement(element);
- }
- if(element instanceof EObject) {
- semanticObject = (EObject)element;
- }
- //return false for Ereference
- if(element instanceof EReference || semanticObject instanceof EReference) {
- return false;
- }
- //the semantic object is not null
- if(semanticObject != null) {
- //test if this is an Eclass
- if(metaClassWanted instanceof EClass) {
- //test if the semanticobject is instance of metaclassWanted
- // and not an instance of metaclassNotWanted
- if(((EClass)metaClassWanted).isSuperTypeOf(semanticObject.eClass())) {
- if(metaClassNotWantedList.size() > 0) {
- Iterator<Object> iternotwanted = metaClassNotWantedList.iterator();
- while(iternotwanted.hasNext()) {
- Object notWanted = iternotwanted.next();
- if(notWanted instanceof EClass) {
- if(((EClass)notWanted).isSuperTypeOf(semanticObject.eClass())) {
- return false;
- }
- }
- }
- }
- return true;
- }
- }
- return false;
- }
-
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
+ @Override
public void createBefore(Composite parent) {
createPatternFilter(parent);
}
@@ -210,7 +128,7 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
if(!("".equals(filterPattern) || currentFilterPattern.equals(filterPattern))) {
Object firstMatch = getFirstMatchingElement(null);
if(firstMatch != null) {
- viewer.reveal(firstMatch);
+ revealSemanticElement(Collections.singletonList(firstMatch));
}
currentFilterPattern = filterPattern;
}
@@ -266,6 +184,7 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
/**
* {@inheritDoc}
*/
+ @Override
public void createAfter(Composite parent) {
parent.setLayout(new GridLayout(1, false));
// createMetaclassFilter(parent); //Disabled
@@ -306,19 +225,7 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
Object selectedObject = selection.getFirstElement();
if(selectedObject instanceof EObject) {
EObject eObject = ((EObject)selectedObject);
- // select the element in the model explorer
- Object containerValue = getContainerValue(eObject);
- if(containerValue == null) {
- viewer.setSelection(StructuredSelection.EMPTY);
- } else {
- viewer.setSelection(new StructuredSelection(containerValue), true);
- }
-
- // update current selection
- // ModelElementItem item = (ModelElementItem)((IStructuredSelection)viewer.getSelection()).getFirstElement();
- // if(item != null) {
- // setCurrentValueItem(item);
- // }
+ revealSemanticElement(Collections.singletonList(eObject));
}
}
});
@@ -510,16 +417,20 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
- if(this.viewer != null && newInput != null && this.viewer.getControl() != null && !this.viewer.getControl().isDisposed()) {
- this.viewer.setFilters(new ViewerFilter[]{ new HierarchicViewerFilter(this) });
- this.viewer.addSelectionChangedListener(this);
+ encapsulated.inputChanged(viewer, oldInput, newInput);
+
+ if(viewer instanceof StructuredViewer) {
+ this.viewer = (StructuredViewer)viewer;
+ if(newInput != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
+ this.viewer.addSelectionChangedListener(this);
+ }
+ } else {
+ this.viewer = null;
}
}
public void selectionChanged(SelectionChangedEvent event) {
selectedObject = ((IStructuredSelection)event.getSelection()).getFirstElement();
- selectedObject = getAdaptedValue(selectedObject);
updateDetailLabel();
}
@@ -544,15 +455,17 @@ public class GraphicalModelExplorerBasedContentProvider extends ModelContentProv
detailLabel.getParent().getParent().layout();
}
+ @Override
public void commit(AbstractEditor editor) {
- if(selectedObject instanceof EObject) {
- storeDialog(getDialogSettings(), (EObject)selectedObject);
+ Object semanticElement = getAdaptedValue(selectedObject);
+ if(semanticElement instanceof EObject) {
+ storeDialog(getDialogSettings(), (EObject)semanticElement);
}
}
@Override
public void dispose() {
- viewer.removeSelectionChangedListener(this);
super.dispose();
+ viewer.removeSelectionChangedListener(this);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HierarchicViewerFilter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HierarchicViewerFilter.java
deleted file mode 100644
index a4c407fb4c9..00000000000
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HierarchicViewerFilter.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Adaptation to AbstractTreeFilter
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.providers;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.facet.infra.browser.uicore.internal.model.BigListItem;
-import org.eclipse.emf.facet.infra.facet.FacetReference;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.widgets.providers.AbstractTreeFilter;
-import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
-
-/**
- *
- * This a View Filter that use a IHierarchicContentProvider
- *
- */
-public class HierarchicViewerFilter extends AbstractTreeFilter {
-
- /**
- * a constructor
- * @param contentProvider that contains isValidValue() in order to know element to filter
- */
- public HierarchicViewerFilter(IHierarchicContentProvider contentProvider) {
- super();
- this.contentProvider = contentProvider;
- }
-
- /**
- * the content provider
- */
- protected IHierarchicContentProvider contentProvider;
-
- @Override
- public boolean hasOneVisibleChild(Viewer viewer, Object element, ITreeContentProvider contentProvider, Set<Object> visitedElements) {
- //TODO : divide this method
- if(useCache && visibleChild.containsKey(element)) {
- return visibleChild.get(element);
- }
-
- boolean result = false;
-
- if(visitedElements.add(element)) {
- SemanticFromModelExplorer bridge = new SemanticFromModelExplorer();
-
- EObject semanticObject = null;
- if(element instanceof IAdaptable) {
- semanticObject = (EObject)bridge.getSemanticElement(element);
- }
- if(element instanceof EObject) {
- semanticObject = (EObject)element;
- }
-
- if(element instanceof BigListItem) {
- Object[] children = contentProvider.getChildren(element);
- for(Object child : children) {
- if(isVisible(viewer, element, child) || hasOneVisibleChild(viewer, child, contentProvider, visitedElements)) {
- result = true;
- }
- }
- } else if(semanticObject != null) {//it contains nothing
- if(semanticObject instanceof EReference) {
- //Do not display references that are not containment kind
- EReference eReference = (EReference)semanticObject;
- if(isValidReference(eReference)) {
- //this an ereference maybe it references something that is interesting
- Object[] children = contentProvider.getChildren(element);
- for(Object child : children) {
- if(isVisible(viewer, element, child) || hasOneVisibleChild(viewer, child, contentProvider, visitedElements)) {
- result = true;
- }
- }
- }
- }
-
- if(!result) {
-
- //it contains something so we have to test children before
- Iterator<EObject> iter = semanticObject.eAllContents();
- while(iter.hasNext()) {
- EObject subEObject = iter.next();
- if(isVisible(viewer, semanticObject, subEObject) || hasOneVisibleChild(viewer, subEObject, contentProvider, visitedElements)) {
- result = true;
- break;
- }
- }
-
- if(!result) {
- for(EReference eReference : getReferencesToBrowse(semanticObject)) {
- Object values = semanticObject.eGet(eReference);
- if(values instanceof EList) {
- for(Object value : (EList<?>)values) {
- if(isVisible(viewer, semanticObject, value) || hasOneVisibleChild(viewer, value, contentProvider, visitedElements)) {
- result = true;
- break;
- }
- }
- } else if(isVisible(viewer, semanticObject, values) || hasOneVisibleChild(viewer, values, contentProvider, visitedElements)) {
- result = true;
- }
- }
- }
- }
- }
-
- }
-
- if(useCache) {
- visibleChild.put(element, result);
- }
-
- return result;
- }
-
- protected Set<EReference> getReferencesToBrowse(EObject element) {
- return new HashSet<EReference>();
- }
-
- protected boolean isValidReference(EReference eReference) {
- return eReference.isContainment() || eReference instanceof FacetReference || getReferencesToBrowse(null).contains(eReference);
- }
-
- @Override
- public boolean isVisible(Viewer viewer, Object parentElement, Object element) {
- return contentProvider.isValidValue(element);
- }
-
-}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/IMetaclassFilteredContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/IMetaclassFilteredContentProvider.java
deleted file mode 100644
index 00f3db2289c..00000000000
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/IMetaclassFilteredContentProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.providers;
-
-import java.util.List;
-
-import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
-
-
-/**
- * this is a content provider on which we can filter wanted meta-classes
- * So the method is valid has to take in account the list of metaclasses
- */
-public interface IMetaclassFilteredContentProvider extends
-IHierarchicContentProvider {
- /**
- * set the list of meta-classes that we do not want to display.
- * It could be interesting to look for a kind of metaclasses without sub metaclasses.
- * @param metaClassNotWanted list of metaclasses that are not wanted
- *
- */
- public void setMetaClassNotWanted(List<Object> metaClassNotWanted);
- /**
- * a the kind of metaclasses wanted
- * @param metaClassWanted
- */
- public void setMetaClassWanted(Object metaClassWanted);
-}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
index cde77467d83..b98efd6feab 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
@@ -20,25 +20,28 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.core.IElementWithSemantic;
/**
- * This class is used to obtain the semantic element for element of the model explorer
+ * This class is used to obtain the semantic element for element of the model explorer
+ *
+ * @deprecated See EMFHelper#getEObject(Object)
*/
+@Deprecated
public class SemanticFromModelExplorer implements IElementWithSemantic {
/**
* {@inheritDoc}
*/
public Object getSemanticElement(Object wrapper) {
- if( wrapper instanceof IAdaptable){
- Object obj= ((IAdaptable)wrapper).getAdapter(EObject.class);
- if(obj==null){
- obj= ((IAdaptable)wrapper).getAdapter(EReference.class);
+ if(wrapper instanceof IAdaptable) {
+ Object obj = ((IAdaptable)wrapper).getAdapter(EObject.class);
+ if(obj == null) {
+ obj = ((IAdaptable)wrapper).getAdapter(EReference.class);
}
- if(obj!=null){
+ if(obj != null) {
return obj;
}
}
-
- if( wrapper instanceof Diagram){
+
+ if(wrapper instanceof Diagram) {
return wrapper;
}
return null;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
new file mode 100644
index 00000000000..0f6d94d3894
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
@@ -0,0 +1,293 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.providers.strategy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.facet.infra.facet.FacetReference;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider;
+import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * A TreeBrowseStrategy based on the semantic model.
+ * It can also retrieve a semantic element in a MoDisco tree, when the tree structure is close
+ * to the semantic one (With optional EReferences).
+ *
+ * Container1::Container2::EObject1 can be retrieved in a Tree representing
+ * Container1::(Reference1)::Container2::(Reference2)::EObject1
+ *
+ * @author Camille Letavernier
+ */
+public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
+
+ protected IAdaptableContentProvider adaptableProvider;
+
+ protected TreeViewer viewer;
+
+ public ContainmentBrowseStrategy(ITreeContentProvider provider) {
+ if(!(provider instanceof IAdaptableContentProvider)) {
+ throw new IllegalArgumentException("The provider must be an IAdaptableContentProvider");
+ }
+
+ setProvider(provider);
+ this.adaptableProvider = (IAdaptableContentProvider)super.provider;
+ }
+
+ //
+ // Elements filtering
+ //
+
+ @Override
+ protected boolean browseElement(Object containerElement) {
+ Object semanticElement = adaptableProvider.getAdaptedValue(containerElement);
+
+ if(semanticElement instanceof EReference && !(semanticElement instanceof FacetReference)) {
+ //Only browse Containment references and Facet references
+ return ((EReference)semanticElement).isContainment();
+ }
+
+ return true;
+ }
+
+ //
+ // Elements search
+ //
+
+ // /**
+ // * {@inheritDoc}
+ // */
+ // @Override
+ // public TreePath findPath(Object semanticElement, Object[] rootElements) {
+ // List<Object> semanticPath = new LinkedList<Object>();
+ // findSemanticPath(semanticElement, semanticPath);
+ // return searchPath(semanticPath, rootElements);
+ // }
+
+ // /**
+ // * Fills the semantic path to the given element
+ // *
+ // * @param element
+ // * The element to retrieve
+ // * @param currentPath
+ // * The path to fill (in-out)
+ // */
+ // protected void findSemanticPath(Object element, List<Object> currentPath) {
+ // if(element != null && element instanceof EObject) {
+ // findSemanticPath(getSemanticParent(element), currentPath);
+ // currentPath.add(element);
+ // }
+ // }
+ //
+ // protected Object getSemanticParent(Object element) {
+ // if(element instanceof EObject) {
+ // return ((EObject)element).eContainer();
+ // }
+ // return null;
+ // }
+ //
+ // /**
+ // * Retrieve the graphical TreePath from the given semantic path
+ // *
+ // * @param semanticPath
+ // * @return
+ // */
+ // protected TreePath searchPath(List<Object> semanticPath, Object input) {
+ // List<Object> graphicalPath = new LinkedList<Object>();
+ // Object[] graphicalRootObjects = (Object[])input;
+ // if(!searchPath(semanticPath, graphicalPath, graphicalRootObjects)) {
+ // //Object not found
+ // graphicalPath.clear();
+ // }
+ //
+ // return new TreePath(graphicalPath.toArray());
+ // }
+ //
+ // protected boolean searchPath(List<Object> semanticPath, List<Object> graphicalPath, Object[] graphicalRootObjects) {
+ // if(semanticPath.isEmpty()) {
+ // return true;
+ // }
+ //
+ // if(graphicalRootObjects == null) {
+ // return false;
+ // }
+ //
+ // Object currentElement = semanticPath.get(0);
+ // for(Object graphicalElement : graphicalRootObjects) {
+ // Object semanticValue = adaptableProvider.getAdaptedValue(graphicalElement);
+ //
+ // //Specific case for containment EReference
+ // if(semanticValue instanceof EReference) {
+ // EReference referenceToBrowse = (EReference)semanticValue;
+ // if(referenceToBrowse.isContainment()) {
+ // graphicalPath.add(graphicalElement);
+ //
+ // if(searchPath(semanticPath, graphicalPath, provider.getChildren(graphicalElement))) {
+ // //The element has been found
+ // return true;
+ // }
+ //
+ // //The element has not been found ; we revert the modifications
+ // graphicalPath.remove(graphicalElement);
+ // }
+ // }
+ //
+ // if(semanticValue == currentElement) {
+ // semanticPath.remove(0);
+ // graphicalPath.add(graphicalElement);
+ // if(searchPath(semanticPath, graphicalPath, provider.getChildren(graphicalElement))) {
+ // return true;
+ // }
+ // }
+ // }
+ //
+ // return false;
+ // }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if(viewer instanceof TreeViewer) {
+ this.viewer = (TreeViewer)viewer;
+ }
+ super.inputChanged(viewer, oldInput, newInput);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void revealSemanticElement(List<?> elementList) {
+ //for each element we reveal it
+ Iterator<?> elementListIterator = elementList.iterator();
+ ArrayList<Object> treeElementToSelect = new ArrayList<Object>();
+ while(elementListIterator.hasNext()) {
+ Object currentElement = elementListIterator.next();
+ //test if the type is an EObject
+ if(currentElement instanceof EObject) {
+ EObject currentEObject = (EObject)currentElement;
+ //the content provider exist?
+ if(provider != null) {
+ //need the root in order to find all element in the tree
+ Object root = provider.getElements(null)[0];
+ //look for the path in order to access to this element
+ List<Object> path = searchPath(currentEObject, Arrays.asList(provider.getElements(root)));
+ if(path.size() > 0) {
+ //expand in the common viewer the path
+ expandItems(path, viewer.getTree().getItems());
+ treeElementToSelect.add(path.get(path.size() - 1));
+ }
+ }
+ }
+ selectReveal(new StructuredSelection(treeElementToSelect));
+ }
+ }
+
+ public void expandItems(List<Object> treeElementList, TreeItem[] list) {
+ //the treeElement has more tan one element
+ if(treeElementList.size() > 0) {
+ for(int i = 0; i < list.length; i++) {
+ if(list[i].getData() != null && list[i].getData().equals(treeElementList.get(0))) {
+ if(treeElementList.size() > 1) {//Do no expand the last
+ Object[] toexpand = { treeElementList.get(0) };
+ viewer.setExpandedElements(toexpand);
+ }
+ ArrayList<Object> tmpList = new ArrayList<Object>();
+ tmpList.addAll(treeElementList);
+ tmpList.remove(tmpList.get(0));
+ expandItems(tmpList, list[i].getItems());
+ }
+ }
+ }
+ }
+
+ public void selectReveal(ISelection selection) {
+ if(viewer != null) {
+ viewer.setSelection(selection, true);
+ }
+ }
+
+
+ /**
+ * look for the path the list of element (comes from the content provider) to go the eObject
+ *
+ * @param eobject
+ * that we look for.
+ * @param objects
+ * a list of elements where eobject can be wrapped.
+ * @return the list of modelElementItem ( from the root to the element that wrap the eobject)
+ */
+ protected List<Object> searchPath(EObject eobject, List<Object> objects) {
+ List<Object> path = new ArrayList<Object>();
+
+ for(Object o : objects) {
+ // Search matches in this level
+ if(!(o instanceof Diagram) && o instanceof IAdaptable) {
+ if(eobject.equals(((IAdaptable)o).getAdapter(EObject.class))) {
+ path.add(o);
+ return path;
+ }
+ }
+
+ // Find childs only for feature container
+ for(int i = 0; i < provider.getChildren(o).length; i++) {
+ Object treeItem = provider.getChildren(o)[i];
+
+ List<Object> tmppath = new ArrayList<Object>();
+ Object element = EMFHelper.getEObject(treeItem);
+ if(element != null) {
+ if(element instanceof EReference) {
+ if(((EReference)element).isContainment() && (!((EReference)element).isDerived())) {
+ List<Object> childs = new ArrayList<Object>();
+ childs.add(treeItem);
+ tmppath = searchPath(eobject, childs);
+ }
+ }
+
+ else {
+ if(element instanceof EObject) {
+ List<Object> childs = new ArrayList<Object>();
+ childs.add(treeItem);
+ tmppath = searchPath(eobject, childs);
+ }
+ }
+ }
+
+ // if tmppath contains the wrapped eobject we have find the good path
+ if(tmppath.size() > 0) {
+ if(tmppath.get(tmppath.size() - 1) instanceof IAdaptable) {
+ if(eobject.equals(((IAdaptable)(tmppath.get(tmppath.size() - 1))).getAdapter(EObject.class))) {
+ path.add(o);
+ path.addAll(tmppath);
+ return path;
+ }
+ }
+ }
+ }
+ }
+
+ return new ArrayList<Object>();
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
new file mode 100644
index 00000000000..d02db422d39
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
@@ -0,0 +1,186 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.providers.strategy;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelContentProvider;
+import org.eclipse.papyrus.infra.emf.Activator;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+
+
+public class SemanticEMFContentProvider extends CustomizableModelContentProvider implements IAdaptableContentProvider, IHierarchicContentProvider, IStaticContentProvider {
+
+ protected EObject[] roots;
+
+ protected List<?> metaclasses = new LinkedList<Object>();
+
+ protected List<?> notWantedMetaclasses = new LinkedList<Object>();
+
+ protected EObject eObject;
+
+ protected EStructuralFeature feature;
+
+ protected AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, EObject[] roots) {
+ super(Activator.getDefault().getCustomizationManager());
+
+ this.roots = roots;
+
+ configureMetaclasses(feature);
+
+ this.eObject = editedEObject;
+ this.feature = feature;
+ }
+
+ protected void configureMetaclasses(EStructuralFeature feature) {
+ if(feature != null) {
+ setWantedMetaclasses(Collections.singletonList(feature.getEType()));
+ }
+ }
+
+ public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature) {
+ this(editedEObject, feature, findRoots(editedEObject));
+ }
+
+ public SemanticEMFContentProvider(EObject[] roots) {
+ this(null, null, roots);
+ }
+
+ public SemanticEMFContentProvider(ResourceSet root) {
+ this(null, null, root);
+ }
+
+ public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, ResourceSet root) {
+ this(editedEObject, feature, getRoots(root));
+ }
+
+ protected static EObject[] getRoots(ResourceSet root) {
+ List<EObject> roots = new LinkedList<EObject>();
+ for(Resource resource : root.getResources()) {
+ roots.addAll(resource.getContents());
+ }
+ return roots.toArray(new EObject[roots.size()]);
+ }
+
+ protected static EObject[] findRoots(EObject source) {
+
+ //The EObject is not contained in a resource : we return the top-level EObject
+ if(source.eResource() == null) {
+ while(source.eContainer() != null) {
+ source = source.eContainer();
+ }
+
+ return new EObject[]{ source };
+ }
+
+ //The resource is not contained in a resource set : we return the resource's contents
+ if(source.eResource().getResourceSet() == null) {
+ return source.eResource().getContents().toArray(new EObject[0]);
+ }
+
+ //We have a full resourceSet : we return its contents
+ return getRoots(source.eResource().getResourceSet());
+ }
+
+ @Override
+ public EObject[] getRootElements(final Object inputElement) {
+ return roots;
+ }
+
+ public Object getAdaptedValue(Object containerElement) {
+ return EMFHelper.getEObject(containerElement);
+ }
+
+ @Override
+ public boolean hasChildren(Object parent) {
+ //May be expensive
+ return getChildren(parent).length > 0;
+ }
+
+ public boolean isValidValue(Object containerElement) {
+ // get the semantic object form the element
+ Object semanticObject = getAdaptedValue(containerElement);
+
+ //return false for EReference and non-semantic objects
+ if(semanticObject instanceof EReference || semanticObject == null) {
+ return false;
+ }
+
+ //Tests whether the element is compatible with at least one metaclass
+ if(metaclasses != null && !metaclasses.isEmpty()) {
+ boolean compatible = false;
+
+ for(Object metaclass : metaclasses) {
+ if(isCompatibleMetaclass(containerElement, metaclass)) {
+ compatible = true;
+ break;
+ }
+ }
+
+ if(!compatible) {
+ return false;
+ }
+ }
+
+ //If the element is compatible with at least one metaclass from notWanted, then it is not valid
+ for(Object metaclass : notWantedMetaclasses) {
+ if(isCompatibleMetaclass(containerElement, metaclass)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ protected boolean isCompatibleMetaclass(Object containerElement, Object metaclass) {
+ if(metaclass instanceof EClassifier) {
+ Object semanticElement = getAdaptedValue(containerElement);
+ return ((EClassifier)metaclass).isInstance(semanticElement);
+ }
+ return false;
+ }
+
+ public void setWantedMetaclasses(List<?> metaclasses) {
+ this.metaclasses = metaclasses;
+ }
+
+ public void setNotWantedMetaclasses(List<?> notWantedMetaclasses) {
+ this.notWantedMetaclasses = notWantedMetaclasses;
+ }
+
+ public Object[] getElements() {
+ return super.getElements(null);
+ }
+
+ public List<?> getWantedMetaclasses() {
+ return metaclasses;
+ }
+
+ public List<?> getNotWantedMetaclasses() {
+ return notWantedMetaclasses;
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/StrategyBasedContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/StrategyBasedContentProvider.java
new file mode 100644
index 00000000000..12d2f204e45
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/StrategyBasedContentProvider.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.providers.strategy;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
+import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
+
+
+public class StrategyBasedContentProvider extends EncapsulatedContentProvider {
+
+ protected TreeBrowseStrategy browseStrategy;
+
+ protected TreeBrowseStrategy revealStrategy;
+
+ protected StructuredViewer viewer;
+
+ public StrategyBasedContentProvider(TreeBrowseStrategy browseStrategy, TreeBrowseStrategy revealStrategy) {
+ setRevealStrategy(revealStrategy);
+ setBrowseStrategy(browseStrategy);
+ }
+
+ public void setBrowseStrategy(TreeBrowseStrategy strategy) {
+ if(strategy != null) {
+ browseStrategy = strategy;
+ encapsulated = browseStrategy;
+ }
+ }
+
+ public void setRevealStrategy(TreeBrowseStrategy strategy) {
+ if(strategy != null) {
+ revealStrategy = strategy;
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ browseStrategy = null;
+ revealStrategy = null;
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ if(viewer instanceof StructuredViewer) {
+ this.viewer = (StructuredViewer)viewer;
+ } else {
+ this.viewer = null;
+ }
+
+ revealStrategy.inputChanged(viewer, oldInput, newInput);
+ browseStrategy.inputChanged(viewer, oldInput, newInput);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Reveals and selects the given semantic elements
+ */
+ @Override
+ public void revealSemanticElement(List<?> semanticElementsList) {
+ revealStrategy.revealSemanticElement(semanticElementsList);
+ // List<Object> containerElements = new LinkedList<Object>();
+ //
+ // for(Object semanticElement : semanticElementsList) {
+ // TreePath path = revealStrategy.findPath(semanticElement, getElements(viewer.getInput()));
+ // if(path.getSegmentCount() > 0) {
+ // viewer.reveal(path);
+ // containerElements.add(path.getLastSegment());
+ // }
+ // }
+ //
+ // viewer.setSelection(new StructuredSelection(containerElements));
+ }
+
+ @Override
+ public TreeBrowseStrategy getBrowseStrategy() {
+ return browseStrategy;
+ }
+
+ @Override
+ public TreeBrowseStrategy getRevealStrategy() {
+ return revealStrategy;
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
index f33928e13cc..3c27da2b7ec 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
@@ -38,6 +39,7 @@ import org.eclipse.papyrus.infra.emf.Activator;
*
* @author Camille Letavernier
*/
+//TODO : Check implementations. Most of them are old and don't always match the specification
public class EMFHelper {
/**
@@ -146,24 +148,51 @@ public class EMFHelper {
if(source instanceof EObject) {
return (EObject)source;
} else if(source instanceof IAdaptable) {
- return (EObject)((IAdaptable)source).getAdapter(EObject.class);
+ EObject eObject = (EObject)((IAdaptable)source).getAdapter(EObject.class);
+ if(eObject == null) { //EMF Facet
+ eObject = (EObject)((IAdaptable)source).getAdapter(EReference.class);
+ }
+ return eObject;
}
return null;
}
/**
- * Return the eClass' qualified name. The qualified name is obtained by the concatenation
+ * Retrieve the EditingDomain for the given source object. The object is first
+ * resolved to an EObject through #getEObject when possible.
+ *
+ * @param source
+ * @return
+ * The source object's editing domain, or null if it couldn't be found
+ */
+ public static EditingDomain resolveEditingDomain(Object source) {
+ return resolveEditingDomain(getEObject(source));
+ }
+
+ /**
+ * Retrieve the EditingDomain for the given source EObject
+ *
+ * @param source
+ * @return
+ * The source eObject's editing domain, or null if it couldn't be found
+ */
+ public static EditingDomain resolveEditingDomain(EObject source) {
+ return AdapterFactoryEditingDomain.getEditingDomainFor(source);
+ }
+
+ /**
+ * Return the eClassifier' qualified name. The qualified name is obtained by the concatenation
* of its package hierarchy with the class name, separated by the given separator
*
- * @param eClass
+ * @param eClassifier
* @param separator
* The separator used between each package name
* @return
- * The EClass' qualified name
+ * The EClassifier' qualified name
*/
- public static String getQualifiedName(EClass eClass, String separator) {
- return getQualifiedName(eClass.getEPackage(), separator) + separator + eClass.getName();
+ public static String getQualifiedName(EClassifier eClassifier, String separator) {
+ return getQualifiedName(eClassifier.getEPackage(), separator) + separator + eClassifier.getName();
}
/**
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/HistoryUtil.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
index 7c61e8679ba..50d10a12b9f 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/HistoryUtil.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.uml.tools.helper;
+package org.eclipse.papyrus.infra.emf.utils;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -22,15 +22,26 @@ public class HistoryUtil {
*
* @param editedObject
* @param feature
- * @param semanticRoot
* @return
*/
- public static String getHistoryID(EObject editedObject, EStructuralFeature feature, EObject semanticRoot) {
+ public static String getHistoryID(EObject editedObject, EStructuralFeature feature) {
+ return getHistoryID(editedObject, feature, "");
+ }
+
+ /**
+ * Returns a String identifying the History of selected values for the given object/feature,
+ * and prepends the given prefix
+ *
+ * @param editedObject
+ * @param feature
+ * @return
+ */
+ public static String getHistoryID(EObject editedObject, EStructuralFeature feature, String prefix) {
// return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName()); //$NON-NLS-1$
if(editedObject.eResource() == null) {
- return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName());
+ return String.format("history_%s_%s:%s", prefix, EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
- return String.format("history_%s:%s:%s:%s", editedObject.eResource().getURI(), feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName());
+ return String.format("history_%s_%s:%s:%s", prefix, editedObject.eResource().getURI(), EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
new file mode 100644
index 00000000000..24d5b1865dc
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.strategy.ContainmentBrowseStrategy;
+import org.eclipse.papyrus.infra.emf.providers.strategy.StrategyBasedContentProvider;
+import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
+import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
+
+
+public class ProviderHelper {
+
+ /**
+ * Encapsulates the given content provider in a higher-level content provider
+ * The returned provider uses two different strategies to display and search
+ * elements, and adds a pattern filter and an History
+ *
+ * @param provider
+ * The ContentProvider to encapsulate
+ * @return
+ */
+ public static EMFGraphicalContentProvider encapsulateProvider(ITreeContentProvider provider, String historyId) {
+ TreeBrowseStrategy browseStrategy = new ProviderBasedBrowseStrategy(provider);
+ TreeBrowseStrategy revealStrategy = new ContainmentBrowseStrategy(provider);
+ IStructuredContentProvider strategyProvider = new StrategyBasedContentProvider(browseStrategy, revealStrategy);
+ EMFGraphicalContentProvider graphicalProvider = new EMFGraphicalContentProvider(strategyProvider, historyId);
+
+ return graphicalProvider;
+ }
+
+ /**
+ * Encapsulates the given content provider in a higher-level content provider
+ * The returned provider uses two different strategies to display and search
+ * elements, and adds a pattern filter and an History
+ *
+ * @param provider
+ * The ContentProvider to encapsulate
+ * @return
+ */
+ public static EMFGraphicalContentProvider encapsulateProvider(ITreeContentProvider provider, EObject editedEObject, EStructuralFeature feature) {
+ return encapsulateProvider(provider, HistoryUtil.getHistoryID(editedEObject, feature));
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
index 4328e67e529..4632849b758 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
@@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.emf.databinding;bundle-version="1.2.0",
org.eclipse.core.databinding.property;bundle-version="1.4.0",
org.eclipse.core.databinding.beans;bundle-version="1.2.100",
- org.eclipse.papyrus.uml.properties;bundle-version="0.9.0",
org.eclipse.papyrus.infra.core.log;bundle-version="0.9.0",
org.eclipse.emf.edit.ui;bundle-version="2.7.0",
org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
@@ -27,4 +26,3 @@ Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.properties.Activator
Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.properties;singleton:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/.project b/plugins/infra/org.eclipse.papyrus.infra.constraints/.project
index dd9eb68f4f8..68021fd18e9 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.constraints/.project
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/.project
@@ -21,13 +21,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.gmt.modisco.common.core.builder</name>
+ <name>org.eclipse.emf.facet.common.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.gmt.modisco.common.ProjectNature</nature>
+ <nature>org.eclipse.emf.facet.common.ProjectNature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/providers/ConstraintTypeContentProvider.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/providers/ConstraintTypeContentProvider.java
index ca67aa621da..b350660604a 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/providers/ConstraintTypeContentProvider.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/providers/ConstraintTypeContentProvider.java
@@ -14,4 +14,8 @@ public class ConstraintTypeContentProvider extends AbstractFilteredContentProvid
public Object[] getElements() {
return ConstraintsManager.instance.getConstraintTypes().toArray();
}
+
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF
index 17d7d58cccb..7fa28a51c1c 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF
@@ -8,8 +8,7 @@ Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.papyrus.infra.core.log;bundle-version="0.9.0",
- org.eclipse.core.databinding;bundle-version="1.4.1",
- org.eclipse.papyrus.infra.widgets;bundle-version="0.9.0"
+ org.eclipse.core.databinding;bundle-version="1.4.1"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.infra.tools.databinding,
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/AggregatedObservable.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/AggregatedObservable.java
index ecb8fc9f30a..ce180145b78 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/AggregatedObservable.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/AggregatedObservable.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.infra.widgets.databinding;
+package org.eclipse.papyrus.infra.tools.databinding;
import org.eclipse.core.databinding.observable.IObservable;
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/MultipleObservableValue.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/MultipleObservableValue.java
index 28198f51516..87546fa9db8 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/MultipleObservableValue.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/databinding/MultipleObservableValue.java
@@ -21,7 +21,6 @@ import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.ValueDiff;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
/**
* MultipleObservableValue is used to map a single element
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java
new file mode 100644
index 00000000000..196a7e346bf
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.tools.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ListHelper {
+
+ /**
+ * Converts an array to a List
+ *
+ * This method is similar to Arrays.asList, except that it returns
+ * a writeable list
+ *
+ * @param array
+ * The array to transform into a List
+ * @return
+ * A List containing the same elements as the array
+ */
+ public static <T> List<T> asList(T[] array) {
+ if(array == null) {
+ return new ArrayList<T>();
+ }
+
+ List<T> result = new ArrayList<T>(array.length);
+ for(T t : array) {
+ result.add(t);
+ }
+ return result;
+ }
+}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
index cfafcbc515f..15d86bf87bf 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
@@ -8,13 +8,16 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.100",
org.eclipse.core.resources;bundle-version="3.7.100",
org.eclipse.ui.ide;bundle-version="3.7.0",
- com.ibm.icu;bundle-version="4.4.2"
+ com.ibm.icu;bundle-version="4.4.2",
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.tools;bundle-version="0.9.0"
Export-Package: org.eclipse.papyrus.infra.widgets,
org.eclipse.papyrus.infra.widgets.creation,
org.eclipse.papyrus.infra.widgets.databinding,
org.eclipse.papyrus.infra.widgets.editors,
org.eclipse.papyrus.infra.widgets.providers,
org.eclipse.papyrus.infra.widgets.selectors,
+ org.eclipse.papyrus.infra.widgets.strategy,
org.eclipse.papyrus.infra.widgets.util
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/CLabelObservableValue.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/CLabelObservableValue.java
index 64031f2a893..b98449d4c6d 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/CLabelObservableValue.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/CLabelObservableValue.java
@@ -15,6 +15,7 @@ import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.messages.Messages;
import org.eclipse.swt.custom.CLabel;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/ComboObservableValue.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/ComboObservableValue.java
index 03e0988c2c6..69f1e88b2aa 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/ComboObservableValue.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/ComboObservableValue.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.providers.ComboLabelProvider;
import org.eclipse.papyrus.infra.widgets.providers.UnchangedObject;
import org.eclipse.papyrus.infra.widgets.providers.UnsetObject;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/GrayedCheckboxObservableValue.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/GrayedCheckboxObservableValue.java
index db3ca5b4dd0..f7ee5bd120c 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/GrayedCheckboxObservableValue.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/GrayedCheckboxObservableValue.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.infra.widgets.databinding;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/TextObservableValue.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/TextObservableValue.java
index 8799a33033d..eaa4b861cd5 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/TextObservableValue.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/databinding/TextObservableValue.java
@@ -4,6 +4,7 @@ import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.providers.UnchangedObject;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/BooleanCheckbox.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/BooleanCheckbox.java
index 9a99333e888..cac6c487131 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/BooleanCheckbox.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/BooleanCheckbox.java
@@ -13,7 +13,7 @@ package org.eclipse.papyrus.infra.widgets.editors;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.databinding.GrayedCheckboxObservableValue;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java
index 810743971be..a0b1f961809 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java
@@ -354,11 +354,6 @@ public class MultipleValueEditor extends AbstractListEditor implements Selection
}
if(modelProperty != null) {
- // Object[] initialSelection = new Object[modelProperty.size()];
- // int i = 0;
- // for(Object semanticObject : modelProperty) {
- // initialSelection[i++] = containObject(semanticObject);
- // }
dialog.setInitialSelections(modelProperty.toArray());
} else {
dialog.setInitialSelections(new Object[0]);
@@ -376,11 +371,6 @@ public class MultipleValueEditor extends AbstractListEditor implements Selection
return;
}
- // List<Object> resultElements = new LinkedList<Object>();
- // for(Object r : result) {
- // resultElements.add(adaptResult(r));
- // }
-
modelProperty.addAll(Arrays.asList(result));
commit();
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueSelectorDialog.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueSelectorDialog.java
index 508293c8f22..9e9d2811d61 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueSelectorDialog.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueSelectorDialog.java
@@ -21,8 +21,9 @@ import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.papyrus.infra.widgets.Activator;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.messages.Messages;
@@ -36,8 +37,8 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.dialogs.SelectionDialog;
/**
@@ -72,12 +73,12 @@ public class MultipleValueSelectorDialog extends SelectionDialog implements Sele
/**
* The listViewer for chosen elements
*/
- protected ListViewer selectedElementsViewer;
+ protected StructuredViewer selectedElementsViewer;
/**
* The list for chosen elements
*/
- protected List selectedElements;
+ protected Tree selectedElements;
/**
* The add action button
@@ -309,11 +310,11 @@ public class MultipleValueSelectorDialog extends SelectionDialog implements Sele
*/
private void createListSection(Composite parent) {
- selectedElements = new List(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ selectedElements = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
selectedElements.addSelectionListener(this);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
selectedElements.setLayoutData(data);
- selectedElementsViewer = new ListViewer(selectedElements);
+ selectedElementsViewer = new TreeViewer(selectedElements);
selectedElementsViewer.setContentProvider(CollectionContentProvider.instance);
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceCombo.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceCombo.java
index 8213bd6c1d0..1b4bd4ffebc 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceCombo.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceCombo.java
@@ -17,7 +17,7 @@ import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.databinding.ComboObservableValue;
import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java
index fa3b8291d77..913baf3f66a 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.widgets.Activator;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
@@ -274,6 +275,11 @@ public class ReferenceDialog extends AbstractValueEditor implements SelectionLis
* The label provider
*/
public void setLabelProvider(ILabelProvider provider) {
+ if(provider == null) {
+ setLabelProvider(new LabelProvider());
+ return;
+ }
+
dialog.setLabelProvider(provider);
this.labelProvider = provider;
if(widgetObservable != null) {
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java
index 5fb10328026..62c70d2b5f1 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringCombo.java
@@ -14,7 +14,7 @@ package org.eclipse.papyrus.infra.widgets.editors;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.ValueDiff;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.UnchangedObject;
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
index b773c6aeedc..f15c1b8b114 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
@@ -13,7 +13,6 @@ package org.eclipse.papyrus.infra.widgets.editors;
import java.util.Collections;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -28,6 +27,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement;
import org.eclipse.papyrus.infra.widgets.Activator;
import org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IGraphicalContentProvider;
@@ -95,20 +95,28 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
public void setContentProvider(ITreeContentProvider provider) {
contentProvider = provider;
if(treeViewer != null) {
- treeViewer.setContentProvider(contentProvider);
- if(treeViewer.getInput() == null) {
- doSetInput();
- }
- List<?> initialSelection = getInitialElementSelections();
- if(!initialSelection.isEmpty()) {
- treeViewer.setSelection(new StructuredSelection(initialSelection.get(0)), true);
- }
+ initViewerAndProvider();
}
if(contentProvider instanceof ICommitListener) {
commitListeners.add((ICommitListener)contentProvider);
}
}
+ protected void initViewerAndProvider() {
+ treeViewer.setContentProvider(contentProvider);
+ if(treeViewer.getInput() == null) {
+ doSetInput();
+ }
+ List<?> initialSelection = getInitialElementSelections();
+ if(contentProvider instanceof IRevealSemanticElement) {
+ ((IRevealSemanticElement)contentProvider).revealSemanticElement(initialSelection);
+ } else if(!initialSelection.isEmpty()) {
+ //FIXME : When we use an EncapsulatedContentProvider, we'll not get into this case,
+ //even if the encapsulated provider is not a IRevealSemanticElement
+ treeViewer.setSelection(new StructuredSelection(initialSelection.get(0)), true);
+ }
+ }
+
@Override
protected Composite getDialogArea() {
return (Composite)super.getDialogArea();
@@ -127,15 +135,7 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
treeViewer.setLabelProvider(labelProvider);
}
if(contentProvider != null) {
- treeViewer.setContentProvider(contentProvider);
- if(treeViewer.getInput() == null) {
- doSetInput();
- }
-
- List<?> initialSelection = getInitialElementSelections();
- if(!initialSelection.isEmpty() && initialSelection.get(0) != null) {
- treeViewer.setSelection(new StructuredSelection(initialSelection.get(0)), true);
- }
+ initViewerAndProvider();
}
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -151,6 +151,9 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
if(contentProvider instanceof IHierarchicContentProvider) {
boolean isValidValue = ((IHierarchicContentProvider)contentProvider).isValidValue(selectedElement);
+ if(contentProvider instanceof IAdaptableContentProvider) {
+ selectedElement = ((IAdaptableContentProvider)contentProvider).getAdaptedValue(selectedElement);
+ }
if(isValidValue) {
setResult(Collections.singletonList(selectedElement));
} else {
@@ -192,8 +195,6 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
graphicalContentProvider.createAfter(afterTreeComposite);
}
- treeViewer.setSelection(new StructuredSelection(getAdaptedInitialSelection()));
-
getShell().setDefaultButton(null);
getButton(OK).setFocus();
getShell().setImage(Activator.getDefault().getImage("/icons/papyrus.png")); //$NON-NLS-1$
@@ -230,17 +231,19 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
this.input = input;
}
- public List<Object> getAdaptedInitialSelection() {
- if(contentProvider instanceof IAdaptableContentProvider) {
- List<Object> result = new LinkedList<Object>();
- for(Object object : getInitialElementSelections()) {
- result.add(((IAdaptableContentProvider)contentProvider).getContainerValue(object));
- }
- return result;
- } else {
- return super.getInitialElementSelections();
- }
- }
+ // @Deprecated
+ // //Unused
+ // public List<Object> getAdaptedInitialSelection() {
+ // if(contentProvider instanceof IAdaptableContentProvider) {
+ // List<Object> result = new LinkedList<Object>();
+ // for(Object object : getInitialElementSelections()) {
+ // result.add(((IAdaptableContentProvider)contentProvider).getContainerValue(object));
+ // }
+ // return result;
+ // } else {
+ // return super.getInitialElementSelections();
+ // }
+ // }
private void doSetInput() {
if(input == null) {
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractStaticContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractStaticContentProvider.java
index 9d421be3bcd..a2bc101c076 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractStaticContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractStaticContentProvider.java
@@ -29,4 +29,8 @@ public abstract class AbstractStaticContentProvider implements IStaticContentPro
// Nothing
}
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
+
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractTreeFilter.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractTreeFilter.java
index 0ec3462cb48..8db89fe982a 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractTreeFilter.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/AbstractTreeFilter.java
@@ -21,6 +21,9 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.widgets.strategy.IStrategyBasedContentProvider;
+import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
+import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
/**
* An abstract ViewerFilter for TreeViewers.
@@ -75,32 +78,37 @@ public abstract class AbstractTreeFilter extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- ITreeContentProvider contentProvider = null;
+ TreeBrowseStrategy strategy = null;
if(viewer instanceof StructuredViewer) {
IContentProvider baseContentProvider = ((StructuredViewer)viewer).getContentProvider();
- if(baseContentProvider instanceof ITreeContentProvider) {
- contentProvider = (ITreeContentProvider)baseContentProvider;
+ if(baseContentProvider instanceof IStrategyBasedContentProvider) {
+ strategy = ((IStrategyBasedContentProvider)baseContentProvider).getRevealStrategy();
+ }
+
+ if(strategy == null && baseContentProvider instanceof ITreeContentProvider) {
+ strategy = new ProviderBasedBrowseStrategy((ITreeContentProvider)baseContentProvider);
}
}
- if(contentProvider == null) { //The contentProvider is not a TreeContentProvider
+ if(strategy == null) { //The contentProvider is not a TreeContentProvider
return isVisible(viewer, parentElement, element);
}
- return select(viewer, parentElement, element, contentProvider);
+ return select(viewer, parentElement, element, strategy);
}
- protected boolean select(Viewer viewer, Object parentElement, Object element, ITreeContentProvider contentProvider) {
+ protected boolean select(Viewer viewer, Object parentElement, Object element, TreeBrowseStrategy strategy) {
Set<Object> visitedChildren = new HashSet<Object>();
Set<Object> visitedParents = new HashSet<Object>();
if(useCache && visibleElement.containsKey(element)) {
return visibleElement.get(element);
}
- boolean isVisible = isVisible(viewer, parentElement, element) || hasOneVisibleChild(viewer, element, contentProvider, visitedChildren);
+
+ boolean isVisible = isVisible(viewer, parentElement, element) || hasOneVisibleChild(viewer, element, strategy, visitedChildren);
if(showIfHasVisibleParent) {
- isVisible = isVisible || hasOneVisibleParent(viewer, element, contentProvider, visitedParents);
+ isVisible = isVisible || hasOneVisibleParent(viewer, element, strategy, visitedParents);
}
if(useCache) {
@@ -110,7 +118,7 @@ public abstract class AbstractTreeFilter extends ViewerFilter {
return isVisible;
}
- protected boolean hasOneVisibleChild(Viewer viewer, Object element, ITreeContentProvider contentProvider, Set<Object> visitedElements) {
+ protected boolean hasOneVisibleChild(Viewer viewer, Object element, TreeBrowseStrategy strategy, Set<Object> visitedElements) {
//TODO : separate this method in -hasOneVisibleChild() and #doHasOneVisibleChild(), to handle the cache management in a private method,
//while letting the opportunity to override the method
if(useCache && visibleChild.containsKey(element)) {
@@ -121,8 +129,8 @@ public abstract class AbstractTreeFilter extends ViewerFilter {
if(!visitedElements.contains(element)) {
visitedElements.add(element);
- for(Object childElement : contentProvider.getChildren(element)) {
- if(isVisible(viewer, element, childElement) || hasOneVisibleChild(viewer, childElement, contentProvider, visitedElements)) {
+ for(Object childElement : strategy.getChildren(element)) {
+ if(isVisible(viewer, element, childElement) || hasOneVisibleChild(viewer, childElement, strategy, visitedElements)) {
result = true;
break;
}
@@ -135,7 +143,7 @@ public abstract class AbstractTreeFilter extends ViewerFilter {
return result;
}
- protected boolean hasOneVisibleParent(Viewer viewer, Object element, ITreeContentProvider contentProvider, Set<Object> visitedElements) {
+ protected boolean hasOneVisibleParent(Viewer viewer, Object element, TreeBrowseStrategy strategy, Set<Object> visitedElements) {
if(useCache && visibleParent.containsKey(element)) {
return visibleParent.get(element);
}
@@ -145,11 +153,11 @@ public abstract class AbstractTreeFilter extends ViewerFilter {
visitedElements.add(element);
- Object parentElement = contentProvider.getParent(element);
+ Object parentElement = strategy.getParent(element);
if(parentElement == element || parentElement == null) {
result = isVisible(viewer, parentElement, element);
} else {
- result = isVisible(viewer, null, parentElement) || hasOneVisibleParent(viewer, parentElement, contentProvider, visitedElements);
+ result = isVisible(viewer, null, parentElement) || hasOneVisibleParent(viewer, parentElement, strategy, visitedElements);
}
}
@@ -171,5 +179,4 @@ public abstract class AbstractTreeFilter extends ViewerFilter {
public void setShowIfHasVisibleParent(boolean showIfHasVisibleParent) {
this.showIfHasVisibleParent = showIfHasVisibleParent;
}
-
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CollectionContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CollectionContentProvider.java
index dda77df673a..252ba87cc6f 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CollectionContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CollectionContentProvider.java
@@ -13,7 +13,7 @@ package org.eclipse.papyrus.infra.widgets.providers;
import java.util.Collection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
@@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.Viewer;
* @author Camille Letavernier
*
*/
-public class CollectionContentProvider implements IStructuredContentProvider {
+public class CollectionContentProvider implements ITreeContentProvider {
private CollectionContentProvider() {
@@ -65,4 +65,16 @@ public class CollectionContentProvider implements IStructuredContentProvider {
* The Singleton instance
*/
public static CollectionContentProvider instance = new CollectionContentProvider();
+
+ public Object[] getChildren(Object parentElement) {
+ return new Object[0]; //Flat tree
+ }
+
+ public Object getParent(Object element) {
+ return null; //Flat tree
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EmptyContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EmptyContentProvider.java
index 6677b40bb9f..bbe00bb195e 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EmptyContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EmptyContentProvider.java
@@ -11,7 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.providers;
-import org.eclipse.jface.viewers.Viewer;
/**
* A ContentProvider returning empty collections
@@ -19,7 +18,7 @@ import org.eclipse.jface.viewers.Viewer;
* @author Camille Letavernier
*
*/
-public class EmptyContentProvider implements IStaticContentProvider {
+public class EmptyContentProvider extends AbstractStaticContentProvider {
/**
* Singleton instance
@@ -32,14 +31,6 @@ public class EmptyContentProvider implements IStaticContentProvider {
}
- public void dispose() {
- //Nothing
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- //Nothing
- }
-
/**
* @see org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider#getElements()
*
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EncapsulatedContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EncapsulatedContentProvider.java
index d2d6f154e3a..3997bd7d823 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EncapsulatedContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/EncapsulatedContentProvider.java
@@ -12,41 +12,53 @@
package org.eclipse.papyrus.infra.widgets.providers;
import java.util.LinkedHashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.tools.util.ListHelper;
import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
+import org.eclipse.papyrus.infra.widgets.strategy.IStrategyBasedContentProvider;
+import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
import org.eclipse.swt.widgets.Composite;
/**
- * A ContentProvider to adapt an IStaticContentProvider to an
- * IStructurecContentProvider Useful when you need to use a ContentProvider that
- * doesn't depend on its Input Object to return values in a JFace Viewer.
- * This content provider also supports temporary elements, which are added
- * to the list of static elements returned by the encapsulated provider.
+ * A ContentProvider encapsulate another ContentProvider.
+ * This class implements all Papyrus interfaces extending IContentProvider,
+ * and is thus compatible with all papyrus tools, even if the encapsulated
+ * provider is not.
+ *
+ * Moreover, the Encapsulated provider can handle temporary elements.
*
* @author Camille Letavernier
*
*/
-public class EncapsulatedContentProvider implements IHierarchicContentProvider, IGraphicalContentProvider, ICommitListener, IAdaptableContentProvider {
+//TODO : Move the temporary elements feature to another class.
+//This feature is only used by multi-reference dialogs
+public class EncapsulatedContentProvider implements IHierarchicContentProvider, IGraphicalContentProvider, ICommitListener, IAdaptableContentProvider, IRevealSemanticElement, IStrategyBasedContentProvider, IStaticContentProvider {
/**
* The encapsulated static content provider
*/
- protected IStaticContentProvider encapsulated;
+ protected IStructuredContentProvider encapsulated;
+
+ /**
+ * The set of temporaryElements, which are added from outside this ContentProvider
+ */
+ private Set<Object> temporaryElements = new LinkedHashSet<Object>();
/**
*
* Constructor.
*
* @param encapsulated
- * The encapsulated static content provider
+ * The encapsulated content provider, to which all calls will be forwarded
*/
- public EncapsulatedContentProvider(IStaticContentProvider encapsulated) {
+ public EncapsulatedContentProvider(IStructuredContentProvider encapsulated) {
this.encapsulated = encapsulated;
}
@@ -63,19 +75,17 @@ public class EncapsulatedContentProvider implements IHierarchicContentProvider,
* the objects returned by the wrapped StaticContentProvider and the temporary
* elements, which are not known by the wrapped provider.
*
+ * @param elements
+ * The Object[] returned by the encapsulated provider
* @return
* All elements known by this ContentProvider
*/
- private Object[] getAllElements() {
- Object[] elements = encapsulated.getElements();
+ private Object[] getAllElements(Object[] elements) {
if(temporaryElements.isEmpty()) {
return elements;
}
- List<Object> result = new LinkedList<Object>();
- for(Object object : elements) {
- result.add(object);
- }
+ List<Object> result = ListHelper.asList(elements);
result.addAll(temporaryElements);
return result.toArray();
}
@@ -84,21 +94,27 @@ public class EncapsulatedContentProvider implements IHierarchicContentProvider,
* {@inheritDoc}
*/
public void dispose() {
- //Nothing
+ //encapsulated.dispose();
+ //encapsulated = null;
}
/**
* {@inheritDoc}
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- encapsulated.inputChanged(viewer, oldInput, newInput);
+ if(encapsulated != null) {
+ encapsulated.inputChanged(viewer, oldInput, newInput);
+ }
}
/**
* {@inheritDoc}
*/
public Object[] getElements(Object inputElement) {
- return getElements();
+ if(encapsulated == null) {
+ return new Object[0];
+ }
+ return getAllElements(encapsulated.getElements(inputElement));
}
/**
@@ -108,15 +124,13 @@ public class EncapsulatedContentProvider implements IHierarchicContentProvider,
* all elements from the wrapped ContentProvider
*/
public Object[] getElements() {
- return getAllElements();
+ if(encapsulated instanceof IStaticContentProvider) {
+ return getAllElements(((IStaticContentProvider)encapsulated).getElements());
+ }
+ return getElements(null);
}
/**
- * The set of temporaryElements, which are added from outside this ContentProvider
- */
- private Set<Object> temporaryElements = new LinkedHashSet<Object>();
-
- /**
* Adds a Temporary element to this ContentProvider
*
* @param newObject
@@ -218,10 +232,23 @@ public class EncapsulatedContentProvider implements IHierarchicContentProvider,
return selection;
}
- public Object getContainerValue(Object selection) {
- if(encapsulated instanceof IAdaptableContentProvider) {
- return ((IAdaptableContentProvider)encapsulated).getContainerValue(selection);
+ public void revealSemanticElement(List<?> elementList) {
+ if(encapsulated instanceof IRevealSemanticElement) {
+ ((IRevealSemanticElement)encapsulated).revealSemanticElement(elementList);
}
- return selection;
+ }
+
+ public TreeBrowseStrategy getBrowseStrategy() {
+ if(encapsulated instanceof IStrategyBasedContentProvider) {
+ return ((IStrategyBasedContentProvider)encapsulated).getBrowseStrategy();
+ }
+ return null;
+ }
+
+ public TreeBrowseStrategy getRevealStrategy() {
+ if(encapsulated instanceof IStrategyBasedContentProvider) {
+ return ((IStrategyBasedContentProvider)encapsulated).getRevealStrategy();
+ }
+ return null;
}
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/HierarchicToFlatContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/HierarchicToFlatContentProvider.java
index 7ba654007c9..01b9cbaa3b4 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/HierarchicToFlatContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/HierarchicToFlatContentProvider.java
@@ -18,7 +18,7 @@ import java.util.Set;
import org.eclipse.jface.viewers.Viewer;
-
+//FIXME : Adapt this code to TreeBrowseStrategy
public class HierarchicToFlatContentProvider extends TreeToFlatContentProvider {
private IHierarchicContentProvider contentProvider;
@@ -43,11 +43,6 @@ public class HierarchicToFlatContentProvider extends TreeToFlatContentProvider {
}
@Override
- public Object[] getElements() {
- return getElementsList().toArray();
- }
-
- @Override
protected Collection<Object> getElementsList() {
Collection<Object> result = new LinkedHashSet<Object>();
Set<Object> browsedElements = new HashSet<Object>();
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IAdaptableContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IAdaptableContentProvider.java
index 07e684e9c00..213f89192d5 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IAdaptableContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IAdaptableContentProvider.java
@@ -38,5 +38,5 @@ public interface IAdaptableContentProvider extends IStructuredContentProvider {
* @return
* The container object wrapping the semantic element
*/
- public Object getContainerValue(Object semanticElement);
+ // public Object getContainerValue(Object semanticElement);
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IStaticContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IStaticContentProvider.java
index 107248f9ce1..199a60bb2ae 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IStaticContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/IStaticContentProvider.java
@@ -11,7 +11,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.providers;
-import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
/**
* A ContentProvider which returns values that don't depend
@@ -24,7 +24,7 @@ import org.eclipse.jface.viewers.IContentProvider;
* @see AbstractStaticContentProvider
*
*/
-public interface IStaticContentProvider extends IContentProvider {
+public interface IStaticContentProvider extends IStructuredContentProvider {
/**
* @return the elements provided by this class
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/TreeToFlatContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/TreeToFlatContentProvider.java
index 569c1903143..bdee78719c4 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/TreeToFlatContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/TreeToFlatContentProvider.java
@@ -21,8 +21,8 @@ import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
-public class TreeToFlatContentProvider implements IStaticContentProvider {
+//FIXME : Adapt this code to TreeBrowseStrategy
+public class TreeToFlatContentProvider extends AbstractStaticContentProvider {
private ITreeContentProvider contentProvider;
@@ -35,10 +35,12 @@ public class TreeToFlatContentProvider implements IStaticContentProvider {
this.contentProvider = provider;
}
+ @Override
public void dispose() {
contentProvider.dispose();
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if(viewer instanceof StructuredViewer) {
this.viewer = (StructuredViewer)viewer;
@@ -106,5 +108,4 @@ public class TreeToFlatContentProvider implements IStaticContentProvider {
}
}
}
-
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/selectors/ReferenceSelector.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/selectors/ReferenceSelector.java
index 50bbfb8a9a8..dbf80f91fd1 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/selectors/ReferenceSelector.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/selectors/ReferenceSelector.java
@@ -123,39 +123,39 @@ public class ReferenceSelector implements IElementSelector {
if(selection instanceof IStructuredSelection) {
Object[] containerElementsToMove = getElementsToMove(((IStructuredSelection)selection).toArray());
Object[] semanticElementsToMove = getSemanticElements(containerElementsToMove);
- addSelectedElements(containerElementsToMove);
+ addSelectedElements(semanticElementsToMove);
return semanticElementsToMove;
}
return new Object[0];
}
- /**
- * This method is used for handling correctly the IAdaptableContentProvider
- * The objects can be in two different forms :
- * - The semantic element
- * - The container element
- *
- * This methods returns an array of container elements from an array of
- * semantic elements. This is useful when specifying a selection to a
- * viewer using an IAdaptableContentProvider
- *
- * @param semanticElements
- * The array of semantic elements to be converted
- * @return
- * The array of elements wrapped in their container
- *
- * @see #getSemanticElements(Object[])
- * @see org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider
- */
- private Object[] getContainerElements(Object[] semanticElements) {
- Object[] containerElements = new Object[semanticElements.length];
- int i = 0;
- for(Object semanticElement : semanticElements) {
- containerElements[i++] = contentProvider.getContainerValue(semanticElement);
- }
- return containerElements;
- }
+ // /**
+ // * This method is used for handling correctly the IAdaptableContentProvider
+ // * The objects can be in two different forms :
+ // * - The semantic element
+ // * - The container element
+ // *
+ // * This methods returns an array of container elements from an array of
+ // * semantic elements. This is useful when specifying a selection to a
+ // * viewer using an IAdaptableContentProvider
+ // *
+ // * @param semanticElements
+ // * The array of semantic elements to be converted
+ // * @return
+ // * The array of elements wrapped in their container
+ // *
+ // * @see #getSemanticElements(Object[])
+ // * @see org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider
+ // */
+ // private Object[] getContainerElements(Object[] semanticElements) {
+ // Object[] containerElements = new Object[semanticElements.length];
+ // int i = 0;
+ // for(Object semanticElement : semanticElements) {
+ // containerElements[i++] = contentProvider.getContainerValue(semanticElement);
+ // }
+ // return containerElements;
+ // }
/**
* This method is used for handling correctly the IAdaptableContentProvider
@@ -213,9 +213,9 @@ public class ReferenceSelector implements IElementSelector {
*
* @param elements
*/
- private void addSelectedElements(Object[] containerElements) {
- if(containerElements.length > 0) {
- selectedElements.addAll(Arrays.asList(containerElements));
+ private void addSelectedElements(Object[] semanticElements) {
+ if(semanticElements.length > 0) {
+ selectedElements.addAll(Arrays.asList(semanticElements));
fTree.getViewer().refresh();
}
}
@@ -250,7 +250,7 @@ public class ReferenceSelector implements IElementSelector {
// Object[] containerElementsToMove = getElementsToMove(((IStructuredSelection)fTree.getViewer().getSelection()).toArray());
Object[] containerElementsToMove = getElementsToMove(visibleElements.toArray());
Object[] semanticElementsToMove = getSemanticElements(containerElementsToMove);
- addSelectedElements(containerElementsToMove);
+ addSelectedElements(semanticElementsToMove);
return semanticElementsToMove;
}
@@ -275,7 +275,7 @@ public class ReferenceSelector implements IElementSelector {
*/
public void setSelectedElements(Object[] semanticElements) {
selectedElements.clear();
- selectedElements.addAll(Arrays.asList(getContainerElements(semanticElements)));
+ selectedElements.addAll(Arrays.asList(semanticElements));
fTree.getViewer().refresh();
}
@@ -357,10 +357,10 @@ public class ReferenceSelector implements IElementSelector {
fTree.getViewer().addFilter(new ViewerFilter() {
@Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
+ public boolean select(Viewer viewer, Object parentElement, Object containerElement) {
if(unique) {
//TODO : check if the selected element has selectable children
- return !selectedElements.contains(element);
+ return !selectedElements.contains(contentProvider.getAdaptedValue(containerElement));
} else {
return true;
}
@@ -394,76 +394,4 @@ public class ReferenceSelector implements IElementSelector {
elementSelectionListeners.add(listener);
}
- // /**
- // * A Text field to let the user type its own filter
- // *
- // * @author Camille Letavernier
- // *
- // */
- // private class Filter extends Composite implements KeyListener {
- //
- // /**
- // * The text box used to edit the filter
- // */
- // private Text text;
- //
- // /**
- // * @param parent
- // * The composite in which the filter should be created
- // * @param style
- // * The style applied to this filter's text box
- // */
- // public Filter(Composite parent, int style) {
- // super(parent, SWT.NONE);
- // setLayout(new FillLayout());
- // text = new Text(this, style);
- // text.addKeyListener(this);
- // listeners = new LinkedList<Listener>();
- // }
- //
- // /**
- // * @return this filter as a String
- // */
- // public String getFilter() {
- // return text.getText();
- // }
- //
- // /**
- // * Adds a listener on this filter. The listener is notified
- // * each time the filter changes
- // *
- // * @param listener
- // */
- // public void addChangeListener(Listener listener) {
- // listeners.add(listener);
- // }
- //
- // /**
- // * Ignored
- // */
- // public void keyPressed(KeyEvent e) {
- // //Nothing
- // }
- //
- // /**
- // * Handles the filter change event
- // */
- // public void keyReleased(KeyEvent e) {
- // for(Listener listener : listeners) {
- // listener.handleEvent(null);
- // }
- // }
- //
- // @Override
- // public void dispose() {
- // listeners.clear();
- // super.dispose();
- // }
- //
- // /**
- // * All registered listeners
- // */
- // private Collection<Listener> listeners;
- // }
-
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/AbstractTreeBrowseStrategy.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/AbstractTreeBrowseStrategy.java
new file mode 100644
index 00000000000..9bae275fa94
--- /dev/null
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/AbstractTreeBrowseStrategy.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.widgets.strategy;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.Viewer;
+
+
+public abstract class AbstractTreeBrowseStrategy implements TreeBrowseStrategy {
+
+ public void dispose() {
+ //Nothing
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ //Nothing
+ }
+
+ abstract public void revealSemanticElement(List<?> elementsList);
+
+}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/IStrategyBasedContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/IStrategyBasedContentProvider.java
new file mode 100644
index 00000000000..47ea97567e7
--- /dev/null
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/IStrategyBasedContentProvider.java
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.widgets.strategy;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+
+
+public interface IStrategyBasedContentProvider extends IStructuredContentProvider {
+
+ public TreeBrowseStrategy getBrowseStrategy();
+
+ public TreeBrowseStrategy getRevealStrategy();
+}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/ProviderBasedBrowseStrategy.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/ProviderBasedBrowseStrategy.java
new file mode 100644
index 00000000000..6bab3b7fe21
--- /dev/null
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/ProviderBasedBrowseStrategy.java
@@ -0,0 +1,133 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.widgets.strategy;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.papyrus.infra.tools.util.ListHelper;
+import org.eclipse.papyrus.infra.widgets.Activator;
+import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+
+
+public class ProviderBasedBrowseStrategy extends EncapsulatedContentProvider implements TreeBrowseStrategy {
+
+ protected ITreeContentProvider provider;
+
+ protected boolean filterElements = false;
+
+ protected final Map<Object, Boolean> cache = new HashMap<Object, Boolean>();
+
+ protected final Map<Object, Boolean> visibleChildCache = new HashMap<Object, Boolean>();
+
+ public ProviderBasedBrowseStrategy(ITreeContentProvider provider) {
+ setProvider(provider);
+ }
+
+ public ProviderBasedBrowseStrategy() {
+
+ }
+
+ public void setProvider(ITreeContentProvider provider) {
+ encapsulated = provider;
+ this.provider = provider;
+ filterElements = provider instanceof IHierarchicContentProvider;
+ clearCache();
+ }
+
+ @Override
+ public Object[] getChildren(Object parent) {
+ if(provider == null) {
+ Activator.log.warn("The provider has not been initialized");
+ return new Object[0];
+ }
+
+ return filterElements ? getValidChildren(parent, new HashSet<Object>()) : super.getChildren(parent);
+ }
+
+ @Override
+ public boolean hasChildren(Object parent) {
+ //May be expensive
+ return getChildren(parent).length > 0;
+ }
+
+ protected Object[] getValidChildren(Object parent, Set<Object> visitedElements) {
+ List<?> children = ListHelper.asList(super.getChildren(parent));
+ Iterator<?> childrenIterator = children.iterator();
+ while(childrenIterator.hasNext()) {
+ Object child = childrenIterator.next();
+ if(!isValid(child, visitedElements)) {
+ childrenIterator.remove();
+ }
+ }
+
+ return children.toArray();
+ }
+
+ protected boolean isValid(Object containerElement, Set<Object> visitedElements) {
+ if(!cache.containsKey(containerElement)) {
+ boolean isVisible;
+
+ if(browseElement(containerElement)) {
+ isVisible = isValidValue(containerElement) || hasOneVisibleChild(containerElement, visitedElements);
+ } else {
+ isVisible = false;
+ }
+
+ cache.put(containerElement, isVisible);
+ }
+ return cache.get(containerElement);
+ }
+
+ protected boolean browseElement(Object containerElement) {
+ return true;
+ }
+
+ protected boolean hasOneVisibleChild(Object element, Set<Object> visitedElements) {
+ if(!visibleChildCache.containsKey(element)) {
+ boolean result = false;
+ if(visitedElements.add(element)) {
+ for(Object child : super.getChildren(element)) {
+ if(isValid(child, visitedElements)) {
+ result = true;
+ break;
+ }
+ }
+ }
+
+ visibleChildCache.put(element, result);
+ }
+ return visibleChildCache.get(element);
+ }
+
+ public TreePath findPath(Object semanticElement, Object[] rootElements) {
+ return TreePath.EMPTY; //TODO : Naive search
+ }
+
+ protected void clearCache() {
+ cache.clear();
+ visibleChildCache.clear();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ clearCache();
+ }
+}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/TreeBrowseStrategy.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/TreeBrowseStrategy.java
new file mode 100644
index 00000000000..2a36a60429c
--- /dev/null
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/strategy/TreeBrowseStrategy.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.widgets.strategy;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement;
+
+
+/**
+ * An interface to define a strategy for browsing a Tree
+ *
+ * @author Camille Letavernier
+ */
+public interface TreeBrowseStrategy extends ITreeContentProvider, IRevealSemanticElement {
+
+ /**
+ * Finds a path to the given element
+ *
+ * @param element
+ * The semanticElement to find
+ * @parem input
+ * The root Elements
+ * @return
+ * @deprecated See {@link #revealSemanticElement(java.util.List)} instead
+ */
+ @Deprecated
+ public TreePath findPath(Object semanticElement, Object[] roots);
+
+
+
+}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/ui/InterfaceManagerDialog.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/ui/InterfaceManagerDialog.java
index 7cb4513c6af..a411e64c508 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/ui/InterfaceManagerDialog.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/ui/InterfaceManagerDialog.java
@@ -50,6 +50,7 @@ import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.editors.IElementSelector;
import org.eclipse.papyrus.infra.widgets.editors.SelectionEditor;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.selectors.ReferenceSelector;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.messages.Messages;
@@ -350,32 +351,15 @@ public class InterfaceManagerDialog extends SelectionDialog {
tmp.addAll(interfaceRepresentations);
return tmp.toArray();
}
+
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
});
//the required selector
this.requiredSelector = new ReferenceSelector(true);
this.requiredSelector.setLabelProvider(selectorLabelProvider);
- this.requiredSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.requiredSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/ServiceEditContentProvider.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/ServiceEditContentProvider.java
index 6954f33f411..732de5fe9fd 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/ServiceEditContentProvider.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/dialogs/ServiceEditContentProvider.java
@@ -19,20 +19,19 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeValidator;
-import org.eclipse.papyrus.uml.tools.providers.UMLElementMEBContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.SemanticUMLContentProvider;
/**
* A content provider that takes into account the nature of the searched element
- * (adapted from org.eclipse.papyrus.uml.modelexplorer.widgets.ServiceEditFilteredUMLContentProvider).
+ * (org.eclipse.papyrus.uml.tools.providers.ServiceEditFilteredContentProvider).
*/
-public class ServiceEditContentProvider extends UMLElementMEBContentProvider {
+public class ServiceEditContentProvider extends SemanticUMLContentProvider {
private ElementTypeValidator validator;
public ServiceEditContentProvider(IElementType elementType, EStructuralFeature feature, EObject semanticRoot) {
- super(semanticRoot, "history_" + feature.getEType().getEPackage().getName() + ":" + feature.getEType().getName() + ":" + feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- setMetaClassWanted(feature.getEType());
- setMetaClassNotWanted(Collections.emptyList());
+ super(semanticRoot.eResource().getResourceSet());
+ setWantedMetaclasses(Collections.singletonList(feature.getEType()));
validator = new ElementTypeValidator(elementType);
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/ui/InterfaceManagerDialog.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/ui/InterfaceManagerDialog.java
index 7c5cb553d0f..027ac5b2f7f 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/ui/InterfaceManagerDialog.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/ui/InterfaceManagerDialog.java
@@ -50,7 +50,7 @@ import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.editors.IElementSelector;
import org.eclipse.papyrus.infra.widgets.editors.SelectionEditor;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.selectors.ReferenceSelector;
import org.eclipse.papyrus.sysml.diagram.internalblock.messages.Messages;
import org.eclipse.papyrus.sysml.portandflows.FlowSpecification;
@@ -311,28 +311,7 @@ public class InterfaceManagerDialog extends SelectionDialog {
//the provided selector
this.providedSelector = new ReferenceSelector(true);
this.providedSelector.setLabelProvider(selectorLabelProvider);
- this.providedSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.providedSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
@@ -354,28 +333,7 @@ public class InterfaceManagerDialog extends SelectionDialog {
//the required selector
this.requiredSelector = new ReferenceSelector(true);
this.requiredSelector.setLabelProvider(selectorLabelProvider);
- this.requiredSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.requiredSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
diff --git a/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/.project b/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/.project
index c5af07c464c..2708796e745 100644
--- a/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/.project
+++ b/plugins/sysml/modelexplorer/org.eclipse.papyrus.sysml.modelexplorer/.project
@@ -21,13 +21,13 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.gmt.modisco.common.core.builder</name>
+ <name>org.eclipse.emf.facet.common.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.gmt.modisco.common.ProjectNature</nature>
+ <nature>org.eclipse.emf.facet.common.ProjectNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/ui/InterfaceManagerDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/ui/InterfaceManagerDialog.java
index 37582982110..305271c2364 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/ui/InterfaceManagerDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/ui/InterfaceManagerDialog.java
@@ -50,7 +50,7 @@ import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.editors.IElementSelector;
import org.eclipse.papyrus.infra.widgets.editors.SelectionEditor;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.selectors.ReferenceSelector;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.util.Util;
@@ -306,28 +306,7 @@ public class InterfaceManagerDialog extends SelectionDialog {
//the provided selector
this.providedSelector = new ReferenceSelector(true);
this.providedSelector.setLabelProvider(selectorLabelProvider);
- this.providedSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.providedSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
@@ -349,28 +328,7 @@ public class InterfaceManagerDialog extends SelectionDialog {
//the required selector
this.requiredSelector = new ReferenceSelector(true);
this.requiredSelector.setLabelProvider(selectorLabelProvider);
- this.requiredSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.requiredSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/ui/InterfaceManagerDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/ui/InterfaceManagerDialog.java
index 469391a761c..d686969e2f1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/ui/InterfaceManagerDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/ui/InterfaceManagerDialog.java
@@ -50,7 +50,7 @@ import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.editors.IElementSelector;
import org.eclipse.papyrus.infra.widgets.editors.SelectionEditor;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.selectors.ReferenceSelector;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.util.Util;
@@ -310,28 +310,7 @@ public class InterfaceManagerDialog extends SelectionDialog {
//the provided selector
this.providedSelector = new ReferenceSelector(true);
this.providedSelector.setLabelProvider(selectorLabelProvider);
- this.providedSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.providedSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
@@ -353,28 +332,7 @@ public class InterfaceManagerDialog extends SelectionDialog {
//the required selector
this.requiredSelector = new ReferenceSelector(true);
this.requiredSelector.setLabelProvider(selectorLabelProvider);
- this.requiredSelector.setContentProvider(new IStaticContentProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
-
- }
+ this.requiredSelector.setContentProvider(new AbstractStaticContentProvider() {
/**
*
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/.project b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/.project
index 20e43a140cf..bba99dab4a1 100644
--- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/.project
+++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/.project
@@ -21,11 +21,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.gmt.modisco.common.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.emf.facet.common.core.builder</name>
<arguments>
</arguments>
@@ -33,7 +28,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.emf.facet.common.ProjectNature</nature>
- <nature>org.eclipse.gmt.modisco.common.ProjectNature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/Util.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/Util.java
index bba2a8fa7fa..147bab875fd 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/Util.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/Util.java
@@ -20,18 +20,15 @@ import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.papyrus.uml.profile.Activator;
import org.eclipse.papyrus.uml.profile.Message;
import org.eclipse.papyrus.uml.profile.definition.IPapyrusVersionConstants;
import org.eclipse.papyrus.uml.profile.definition.PapyrusDefinitionAnnotation;
import org.eclipse.papyrus.uml.profile.definition.Version;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Element;
@@ -109,8 +106,7 @@ public class Util {
suffix = " (ProfileApplication)";
cNE = cPA.getAppliedProfile();
- }
- else if(object instanceof Comment) {
+ } else if(object instanceof Comment) {
Comment cCom = (Comment)object;
suffix = " (Comment)";
String cComBody = cCom.getBody();
@@ -119,33 +115,29 @@ public class Util {
} else {
cComLabel = cComBody;
}
- }
- else if (object instanceof TemplateSignature) {
- TemplateableElement te = ((TemplateSignature) object).getTemplate();
+ } else if(object instanceof TemplateSignature) {
+ TemplateableElement te = ((TemplateSignature)object).getTemplate();
suffix = " (TemplateSignature owner)";
- if (te instanceof NamedElement) {
- cNE = (NamedElement) te;
+ if(te instanceof NamedElement) {
+ cNE = (NamedElement)te;
}
- }
- else if (object instanceof TemplateBinding) {
- TemplateableElement te = ((TemplateBinding) object).getBoundElement();
+ } else if(object instanceof TemplateBinding) {
+ TemplateableElement te = ((TemplateBinding)object).getBoundElement();
suffix = " (TemplateBinding bound-element)";
- if (te instanceof NamedElement) {
- cNE = (NamedElement) te;
+ if(te instanceof NamedElement) {
+ cNE = (NamedElement)te;
}
}
if(shortLabel) {
if(object instanceof Comment) {
cName = cComLabel;
- }
- else if (cNE != null) {
+ } else if(cNE != null) {
cName = cNE.getName();
}
} else {
if(object instanceof Comment) {
cName = cComLabel + suffix;
- }
- else if (cNE != null) {
+ } else if(cNE != null) {
cName = cNE.getQualifiedName() + suffix;
}
}
@@ -172,9 +164,7 @@ public class Util {
public static boolean isMetaclass(Type type) {
boolean isMetaclass = false;
- if((type instanceof org.eclipse.uml2.uml.Class)
- && (type.getAppliedStereotypes() != null)
- && (type.getAppliedStereotypes().size() > 0)) {
+ if((type instanceof org.eclipse.uml2.uml.Class) && (type.getAppliedStereotypes() != null) && (type.getAppliedStereotypes().size() > 0)) {
Stereotype firstStereotype = type.getAppliedStereotypes().get(0);
@@ -288,15 +278,14 @@ public class Util {
/**
* Helper function used by getInstancesFilteredByType
*/
- private static void checkAndAddElement (EObject currentEObj, @SuppressWarnings("rawtypes") Class metaType, Stereotype appliedStereotype, ArrayList<Element> filteredElements)
- {
- if (currentEObj instanceof Element) {
- Element piCurrentElt = (Element) currentEObj;
- if (appliedStereotype != null) {
+ private static void checkAndAddElement(EObject currentEObj, @SuppressWarnings("rawtypes") Class metaType, Stereotype appliedStereotype, ArrayList<Element> filteredElements) {
+ if(currentEObj instanceof Element) {
+ Element piCurrentElt = (Element)currentEObj;
+ if(appliedStereotype != null) {
// It is not sufficient to call getAppliedStereotypes, since we also want to
// retrieve elements that apply a sub-stereotype
- if (piCurrentElt.getAppliedSubstereotype(appliedStereotype, null) != null) {
+ if(piCurrentElt.getAppliedSubstereotype(appliedStereotype, null) != null) {
filteredElements.add(piCurrentElt);
}
Iterator<Stereotype> appStIter = piCurrentElt.getAppliedStereotypes().iterator();
@@ -318,8 +307,8 @@ public class Util {
Iterator<EObject> eIter = ((ElementImport)piCurrentElt).getImportedElement().eAllContents();
while(eIter.hasNext()) {
EObject currentEIelt = eIter.next();
- if ((currentEIelt instanceof Element) && (metaType.isInstance(currentEIelt))) {
- filteredElements.add((Element) currentEIelt);
+ if((currentEIelt instanceof Element) && (metaType.isInstance(currentEIelt))) {
+ filteredElements.add((Element)currentEIelt);
}
}
}
@@ -353,24 +342,24 @@ public class Util {
// If currentElt is an ElementImport, it is replaced by the imported
// Element.
if(currentEObj instanceof ElementImport) {
- ElementImport elementImport = (ElementImport) currentEObj;
+ ElementImport elementImport = (ElementImport)currentEObj;
currentEObj = elementImport.getImportedElement();
}
/* package imports treatment */
else if(currentEObj instanceof PackageImport) {
- Package importedPkg = ((PackageImport) currentEObj).getImportedPackage();
- if (importedPkg != null) {
+ Package importedPkg = ((PackageImport)currentEObj).getImportedPackage();
+ if(importedPkg != null) {
Iterator<EObject> piIter = importedPkg.eAllContents();
while(piIter.hasNext()) {
EObject piCurrentEObj = piIter.next();
- checkAndAddElement (piCurrentEObj, metaType, appliedStereotype, filteredElements);
+ checkAndAddElement(piCurrentEObj, metaType, appliedStereotype, filteredElements);
}
}
}
// Filtering elements
- checkAndAddElement (currentEObj, metaType, appliedStereotype, filteredElements);
+ checkAndAddElement(currentEObj, metaType, appliedStereotype, filteredElements);
}
return filteredElements;
@@ -642,63 +631,4 @@ public class Util {
}
return profileApplication;
}
-
- /**
- * Checks if the profile applied has been changed since last application (definition does not match.
- *
- * @param _package
- * on which the profile is applied
- * @param _profile
- * the applied profile
- * @return true if the profile has changed
- */
- public static boolean isDirty(Package _package, Profile _profile) {
- boolean isDirty = false;
- if(_profile == null || _profile.eResource() == null) {
- return false;
- }
-
- // Retrieve model resourceSet
- ResourceSet pkge_resourceSet = _package.eResource().getResourceSet();
-
- // Retrieve profile resource
- URI prof_URI = _profile.eResource().getURI();
- Resource modelResource = pkge_resourceSet.getResource(prof_URI, true);
-
- if(modelResource.getContents().get(0) instanceof Profile) {
-
- // ckeck applied profile application definition vs profile definition referenced in file
- Profile profileInFile = (Profile)(modelResource.getContents().get(0));
-
- if(_package.getProfileApplication(_profile) != null) {
- EPackage appliedProfileDefinition = _package.getProfileApplication(_profile).getAppliedDefinition();
- EPackage fileProfileDefinition = null;
-
- // Check profiles qualified names to ensure the correct profiles are compared
- String appliedProfileName = _profile.getQualifiedName();
- String fileProfileName = profileInFile.getQualifiedName();
- if(!appliedProfileName.equals(fileProfileName)) {
-
- // The profile must be a subprofile
- Iterator<Profile> it = PackageUtil.getSubProfiles(profileInFile).iterator();
- while(it.hasNext()) {
- Profile current = it.next();
- fileProfileName = current.getQualifiedName();
- if(fileProfileName.equals(appliedProfileName)) {
- profileInFile = current;
- }
- }
- }
-
- fileProfileDefinition = profileInFile.getDefinition();
-
- if(appliedProfileDefinition != fileProfileDefinition) {
- isDirty = true;
- }
- }
-
- }
-
- return isDirty;
- }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
index 41b591cc573..4671b6a3d66 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.uml.tools;bundle-version="0.9.0",
org.eclipse.papyrus.infra.emf;bundle-version="0.9.0",
org.eclipse.papyrus.infra.tools;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.constraints;bundle-version="0.9.0"
+ org.eclipse.papyrus.infra.constraints;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.gmfdiag.properties;bundle-version="0.9.0"
Export-Package: org.eclipse.papyrus.uml.properties.constraints,
org.eclipse.papyrus.uml.properties.creation,
org.eclipse.papyrus.uml.properties.databinding,
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/HasStereotypeConstraint.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/HasStereotypeConstraint.java
index b1039ece8ff..3fbccb5255d 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/HasStereotypeConstraint.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/HasStereotypeConstraint.java
@@ -14,7 +14,7 @@ package org.eclipse.papyrus.uml.properties.constraints;
import org.eclipse.papyrus.infra.constraints.SimpleConstraint;
import org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint;
import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/UmlInstanceOfConstraint.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/UmlInstanceOfConstraint.java
index ff023cf3020..da03526f325 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/UmlInstanceOfConstraint.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/UmlInstanceOfConstraint.java
@@ -15,7 +15,7 @@ import org.eclipse.papyrus.infra.constraints.SimpleConstraint;
import org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint;
import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.uml2.uml.Element;
/**
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java
index 91acfa03fd2..7dc6d9f3c9c 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java
@@ -16,12 +16,12 @@ import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.properties.Activator;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
import org.eclipse.papyrus.uml.tools.databinding.AbstractUMLAggregatedObservableValue;
import org.eclipse.papyrus.uml.tools.databinding.CommandBasedObservableValue;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.uml.tools.utils.ui.command.AddMaskManagedLabelDisplayCommand;
import org.eclipse.papyrus.uml.tools.utils.ui.command.SetNameLabelIconCommand;
import org.eclipse.papyrus.uml.tools.utils.ui.command.SetQualifiedNameDepthCommand;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElementFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElementFactory.java
index 3b7be5af543..f04935346c5 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElementFactory.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElementFactory.java
@@ -17,7 +17,7 @@ import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.ModelUtils;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceFactory.java
index ffae95b7b9e..144a0f65950 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceFactory.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeAppearanceFactory.java
@@ -15,7 +15,7 @@ import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.EditPart;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationFactory.java
index 8fa252a54a4..40f1fc9cc75 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationFactory.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationFactory.java
@@ -14,7 +14,7 @@ package org.eclipse.papyrus.uml.properties.modelelement;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.EditPart;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java
index 875d6e896e5..981fdaaf69b 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java
@@ -19,10 +19,10 @@ import org.eclipse.gef.EditPart;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.uml.properties.databinding.StereotypeApplicationObservableList;
-import org.eclipse.papyrus.uml.properties.providers.ApplicableStereotypeContentProvider;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
import org.eclipse.papyrus.uml.tools.databinding.ProfileApplicationObservableList;
+import org.eclipse.papyrus.uml.tools.providers.ApplicableStereotypeContentProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java
index 8c4b99a3a6f..22926c67168 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java
@@ -11,35 +11,24 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
-import java.util.Collections;
-
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.databinding.EMFProperties;
import org.eclipse.emf.databinding.FeaturePath;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.uml.properties.datatype.DataTypeProvider;
import org.eclipse.papyrus.uml.properties.datatype.StructuredDataTypeObservableValue;
import org.eclipse.papyrus.uml.properties.providers.UMLFilteredLabelProvider;
import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
-import org.eclipse.papyrus.uml.tools.providers.ServiceEditFilteredUMLContentProvider;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.util.UMLUtil;
/**
* A Model Element for manipulating Stereotype properties
@@ -48,17 +37,22 @@ import org.eclipse.uml2.uml.util.UMLUtil;
*/
public class StereotypeModelElement extends EMFModelElement {
+ protected Stereotype stereotype;
+
/**
* Constructor.
*
- * @param source
+ * @param stereotypeApplication
* The StereotypeApplication being edited
+ * @param stereotype
+ * The Stereotype element
* @param domain
* The Editing domain on which the commands will be called
*
*/
- public StereotypeModelElement(EObject source, EditingDomain domain) {
- super(source, domain);
+ public StereotypeModelElement(EObject stereotypeApplication, Stereotype stereotype, EditingDomain domain) {
+ super(stereotypeApplication, domain);
+ this.stereotype = stereotype;
}
/**
@@ -103,58 +97,8 @@ public class StereotypeModelElement extends EMFModelElement {
*/
@Override
public IStaticContentProvider getContentProvider(String propertyPath) {
- FeaturePath featurePath = getFeaturePath(propertyPath);
- EStructuralFeature feature = getFeature(featurePath);
- EClassifier type = feature.getEType();
-
- if(isStereotype(type)) {
- return getStereotypedReferenceContentProvider(propertyPath);
- } else if(type instanceof EEnum || type instanceof EClass) {
- return super.getContentProvider(propertyPath);
- }
-
- return EmptyContentProvider.instance;
- }
-
- protected boolean isStereotype(EClassifier type) {
- if(type instanceof Stereotype) {
- return true;
- }
-
- if(type instanceof EClass) {
- EClass eClass = (EClass)type;
- return !EMFHelper.isSubclass(eClass, UMLPackage.eINSTANCE.getElement());
- }
-
- return false;
- }
-
- /**
- * Returns the content provider for reference properties typed
- * by a stereotype
- *
- * @param propertyPath
- * The name of the property being edited
- * @return
- * The Content Provider for properties typed by a stereotype
- */
- protected IStaticContentProvider getStereotypedReferenceContentProvider(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);
- Package root = null;
- if(source != null) {
- Element umlElement = UMLUtil.getBaseElement(source);
- if(umlElement != null) {
- if(umlElement.getNearestPackage() != null) {
- root = PackageUtil.getRootPackage(umlElement);
- }
- }
- }
-
- ServiceEditFilteredUMLContentProvider contentProvider = new ServiceEditFilteredUMLContentProvider(source, feature, root);
- contentProvider.setMetaClassWanted(feature.getEType());
- contentProvider.setMetaClassNotWanted(Collections.EMPTY_LIST);
-
- return contentProvider;
+ return new UMLContentProvider(source, feature, stereotype);
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElementFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElementFactory.java
index 26ed3f99860..e8230c7cf76 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElementFactory.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElementFactory.java
@@ -11,12 +11,11 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.uml.properties.Activator;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
@@ -45,11 +44,9 @@ import org.eclipse.uml2.uml.Stereotype;
public class StereotypeModelElementFactory implements ModelElementFactory {
public ModelElement createFromSource(Object source, DataContextElement context) {
+ Element umlElement = UMLUtil.resolveUMLElement(source);
- if(source instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable)source;
- Element umlElement = (Element)adaptable.getAdapter(EObject.class);
-
+ if(umlElement != null) {
Stereotype stereotype = UMLUtil.getAppliedStereotype(umlElement, getQualifiedName(context), false);
EObject stereotypeApplication = umlElement.getStereotypeApplication(stereotype);
@@ -58,7 +55,7 @@ public class StereotypeModelElementFactory implements ModelElementFactory {
} else {
EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(stereotypeApplication);
- return new StereotypeModelElement(stereotypeApplication, domain);
+ return new StereotypeModelElement(stereotypeApplication, stereotype, domain);
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java
index 6fc86f6c49a..e5be4b6a3be 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java
@@ -16,7 +16,6 @@ import static org.eclipse.uml2.uml.ParameterDirectionKind.IN_LITERAL;
import static org.eclipse.uml2.uml.ParameterDirectionKind.OUT_LITERAL;
import static org.eclipse.uml2.uml.ParameterDirectionKind.RETURN_LITERAL;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -32,34 +31,31 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
+import org.eclipse.papyrus.infra.emf.utils.ProviderHelper;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.uml.properties.creation.ConnectorTypeEditorFactory;
import org.eclipse.papyrus.uml.properties.creation.MessageValueSpecificationFactory;
import org.eclipse.papyrus.uml.properties.creation.OwnedRuleCreationFactory;
import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
-import org.eclipse.papyrus.uml.properties.providers.InstanceValueContentProvider;
import org.eclipse.papyrus.uml.properties.providers.UMLFilteredLabelProvider;
import org.eclipse.papyrus.uml.tools.databinding.ExtensionRequiredObservableValue;
import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
import org.eclipse.papyrus.uml.tools.databinding.ProvidedInterfaceObservableList;
import org.eclipse.papyrus.uml.tools.databinding.RequiredInterfaceObservableList;
-import org.eclipse.papyrus.uml.tools.helper.HistoryUtil;
-import org.eclipse.papyrus.uml.tools.providers.ServiceEditFilteredUMLContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLElementMEBContentProvider;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
-import org.eclipse.papyrus.views.properties.providers.ContainerContentProvider;
import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider;
import org.eclipse.uml2.uml.Connector;
-import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Extension;
-import org.eclipse.uml2.uml.InstanceValue;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.ParameterDirectionKind;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.UMLPackage;
@@ -154,39 +150,7 @@ public class UMLModelElement extends EMFModelElement {
public IStaticContentProvider getContentProvider(String propertyPath) {
EStructuralFeature feature = getFeature(propertyPath);
- if(feature == UMLPackage.eINSTANCE.getPort_Provided() || feature == UMLPackage.eINSTANCE.getPort_Required()) {
- Package root = null;
- if(((Element)source).getNearestPackage() != null) {
- root = PackageUtil.getRootPackage((Element)source);
- }
-
- String historyId = HistoryUtil.getHistoryID(source, feature, root);
- UMLElementMEBContentProvider contentProvider = new UMLElementMEBContentProvider(root, historyId);
- contentProvider.setMetaClassWanted(feature.getEType());
- return contentProvider;
- }
-
- if(feature instanceof EReference) {
- Package root = null;
- if(((Element)source).getNearestPackage() != null) {
- root = PackageUtil.getRootPackage((Element)source);
- }
-
- ServiceEditFilteredUMLContentProvider contentProvider;
-
- if(feature == UMLPackage.eINSTANCE.getInstanceValue_Instance()) {
- contentProvider = new InstanceValueContentProvider((InstanceValue)source, feature, root);
- } else {
- contentProvider = new ServiceEditFilteredUMLContentProvider(source, feature, root);
- }
-
- contentProvider.setMetaClassWanted(feature.getEType());
- contentProvider.setMetaClassNotWanted(Collections.EMPTY_LIST);
-
- return contentProvider;
- }
-
- return super.getContentProvider(propertyPath);
+ return new UMLContentProvider(source, feature);
}
@Override
@@ -251,8 +215,11 @@ public class UMLModelElement extends EMFModelElement {
factory.setContainerLabelProvider(new UMLFilteredLabelProvider());
factory.setReferenceLabelProvider(new EMFLabelProvider());
- IStaticContentProvider contentProvider = new ContainerContentProvider(type);
- factory.setContainerContentProvider(contentProvider);
+ ITreeContentProvider contentProvider = new UMLContainerContentProvider(source, reference);
+
+ EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, HistoryUtil.getHistoryID(source, feature, "container"));
+
+ factory.setContainerContentProvider(provider);
factory.setReferenceContentProvider(new FeatureContentProvider(type));
return factory;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElementFactory.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElementFactory.java
index bac9811aca6..cd3935cb68d 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElementFactory.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElementFactory.java
@@ -13,7 +13,7 @@ package org.eclipse.papyrus.uml.properties.modelelement;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.EMFModelElementFactory;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java
index 6065ea95a09..56ac86ec598 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLNotationModelElement.java
@@ -22,8 +22,8 @@ import org.eclipse.papyrus.uml.properties.Activator;
import org.eclipse.papyrus.uml.properties.databinding.ElementCustomizationObservableValue;
import org.eclipse.papyrus.uml.properties.databinding.ElementCustomizationObservableValue.Property;
import org.eclipse.papyrus.uml.properties.messages.Messages;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement;
import org.eclipse.uml2.uml.NamedElement;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueContentProvider.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueContentProvider.java
deleted file mode 100644
index 6fbc958b401..00000000000
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueContentProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.providers;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.papyrus.uml.tools.providers.ServiceEditFilteredUMLContentProvider;
-import org.eclipse.uml2.uml.InstanceValue;
-
-/**
- * A Content provider for the value of an InstanceValue
- *
- * The valid instance specifications are filtered according to the type of the
- * InstanceValue
- *
- * @author Camille Letavernier
- *
- * @see InstanceValue#getType()
- * @see InstanceValueViewerFilter
- */
-public class InstanceValueContentProvider extends ServiceEditFilteredUMLContentProvider {
-
- private InstanceValue source;
-
- /**
- *
- * Constructor.
- *
- * @param source
- * The InstanceValue being edited
- * @param feature
- * The EStructuralFeature being edited
- * @param semanticRoot
- * The root EObject for the Tree representing the model
- */
- public InstanceValueContentProvider(InstanceValue source, EStructuralFeature feature, EObject semanticRoot) {
- super(source, feature, semanticRoot);
- this.source = source;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
- if(this.viewer != null) {
- this.viewer.setFilters(new ViewerFilter[]{ new InstanceValueViewerFilter(this, source) });
- }
- }
-
-}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/UMLContentProvider.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/UMLContentProvider.java
deleted file mode 100644
index 36ad539066f..00000000000
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/UMLContentProvider.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.providers;
-
-import java.util.Collections;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.infra.emf.providers.EMFContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.ServiceEditFilteredUMLContentProvider;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.papyrus.views.properties.providers.EcoreEnumeratorContentProvider;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.InstanceValue;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- *
- * A content provider for UML
- *
- * @deprecated
- */
-
-//TODO : To be refactored. There should be a single ContentProvider for UML
-@Deprecated
-public class UMLContentProvider extends EncapsulatedContentProvider implements IStaticContentProvider {
-
- /**
- *
- * Constructor.
- *
- * @param source
- * @param feature
- */
- public UMLContentProvider(final Element source, final EStructuralFeature feature) {
- IStaticContentProvider localProvider;
-
- if(feature instanceof EReference) {
- Package root = null;
- if(source.getNearestPackage() != null) {
- root = PackageUtil.getRootPackage(source);
- }
-
- ServiceEditFilteredUMLContentProvider contentProvider;
-
- if(feature == UMLPackage.eINSTANCE.getInstanceValue_Instance()) {
- contentProvider = new InstanceValueContentProvider((InstanceValue)source, feature, root);
- } else {
- contentProvider = new ServiceEditFilteredUMLContentProvider(source, feature, root);
- }
-
- contentProvider.setMetaClassWanted(feature.getEType());
- contentProvider.setMetaClassNotWanted(Collections.emptyList());
-
- localProvider = contentProvider;
- } else if(feature == null) {
- localProvider = EmptyContentProvider.instance;
- } else {
- EClassifier type = feature.getEType();
- if(type instanceof EEnum) {
- localProvider = new EcoreEnumeratorContentProvider(feature);
- } else if(type instanceof EClass) {
- localProvider = new EMFContentProvider(source, feature); //TODO : pas compris
- } else {
- localProvider = EmptyContentProvider.instance;
- }
- }
- this.encapsulated = localProvider;
-
- }
-}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/util/UMLUtil.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/util/UMLUtil.java
deleted file mode 100644
index 244e2040bca..00000000000
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/util/UMLUtil.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.util;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.databinding.EMFProperties;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.papyrus.infra.core.utils.PapyrusEcoreUtils;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.ConnectableElement;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEvent;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A Helper class for UML
- *
- * @author Camille Letavernier
- */
-//TODO : To be refactored
-//This class should be merged with other oep.umlutils classes.
-public class UMLUtil {
-
- /**
- * Retrieve the UML semantic element from the given Object
- *
- * @param source
- * The Object to resolve
- * @return
- * The UML semantic element, or null if it couldn't be resolved
- */
- public static Element resolveUMLElement(Object source) {
- EObject eElement = null;
- if(source instanceof EObject) {
- eElement = (EObject)source;
- }
- if(source instanceof IAdaptable) {
- eElement = (EObject)((IAdaptable)source).getAdapter(EObject.class);
- }
-
- if(EMFHelper.isInstance(eElement, "Element", umlMetamodel)) { //$NON-NLS-1$
- return (Element)eElement;
- }
-
- return null;
- }
-
- /**
- * Tests if a class is a subclass of another class. The classes are described
- * by their className, in the UML Metamodel.
- *
- * @param className
- * @param superclassName
- * @return
- * True if the class className is a subclass of the class superclassName
- */
- public static boolean isSubClass(String className, String superclassName) {
- EClass eClass = (EClass)umlMetamodel.getEClassifier(className);
- EClass superClass = (EClass)umlMetamodel.getEClassifier(superclassName);
- return superClass.isSuperTypeOf(eClass);
- }
-
- /**
- * Retrieve the IGraphicalEditPart from the given Object
- *
- * @param source
- * The object to resolve
- * @return
- * The IGraphicalEditPart, or null if it couldn't be resolved
- */
- public static IGraphicalEditPart resolveEditPart(Object source) {
- if(source instanceof IGraphicalEditPart) {
- return (IGraphicalEditPart)source;
- }
-
- if(source instanceof IAdaptable) {
- return (IGraphicalEditPart)((IAdaptable)source).getAdapter(IGraphicalEditPart.class);
- }
-
- return null;
- }
-
- /**
- * Retrieve the EditingDomain for the given source object
- *
- * @param source
- * @return
- * The source object's editing domain, or null if it couldn't be found
- */
- public static EditingDomain resolveEditingDomain(Object source) {
- return AdapterFactoryEditingDomain.getEditingDomainFor(resolveUMLElement(source));
- }
-
- /**
- * @return the UML EPackage
- */
- public static EPackage getUMLMetamodel() {
- return umlMetamodel;
- }
-
- /**
- * Search the given stereotype (By name) on the given UML Element.
- * If the search is not strict, the name may be the qualified name of a
- * sub-stereotype of an applied stereotype
- *
- * @param umlElement
- * The UML Element on which the stereotype is applied
- * @param stereotypeName
- * The qualified name of the stereotype
- * @param strict
- * If set to true, only a stereotype matching the exact qualified name
- * will be returned. Otherwise, any subtype of the given stereotype may be
- * returned. Note that if more than one stereotype is a substype of the
- * given stereotype, the first matching stereotype is returned.
- * @return
- * The first matching stereotype, or null if none was found
- */
- public static Stereotype getAppliedStereotype(Element umlElement, String stereotypeName, boolean strict) {
- Stereotype stereotype = umlElement.getAppliedStereotype(stereotypeName);
- if(strict || stereotype != null) {
- return stereotype;
- }
-
- //The parent stereotype is not always applicable...
- //stereotype = umlElement.getApplicableStereotype(stereotypeName);
-
- stereotype = findStereotype(umlElement, stereotypeName);
-
- //stereotype = umlElement.getApplicableStereotype(stereotypeName);
- if(stereotype == null) {
- return null;
- }
-
- // System.out.println("Looking for a substereotype of " + stereotype + "\n" + stereotype.eResource().getURI());
- // System.out.println("Applied stereotypes : " + umlElement.getAppliedStereotypes());
- // System.out.println("Parent stereotypes : ");
- // for(Stereotype appliedStereotype : umlElement.getAppliedStereotypes()) {
- // for(Classifier parentStereotype : appliedStereotype.allParents()) {
- // System.out.println(parentStereotype + "\n" + parentStereotype.eResource().getURI());
- // }
- // }
- // System.out.println();
- for(Stereotype appliedStereotype : umlElement.getAppliedSubstereotypes(stereotype)) {
- return appliedStereotype;
- }
-
- return null;
-
- // for(Stereotype appliedStereotype : umlElement.getAppliedStereotypes()) {
- // if(getAllSuperStereotypes(appliedStereotype).contains(stereotype)) {
- // return appliedStereotype;
- // }
- // }
- //
- // return null;
- }
-
- /**
- * Finds the Stereotype matching the given name.
- * The search is done in the context of the given UML Element
- * (i.e. the Profiles applied on the Element's nearest package)
- *
- * @param umlElement
- * @param stereotypeName
- * @return
- */
- public static Stereotype findStereotype(Element umlElement, String stereotypeName) {
- Stereotype stereotype = null;
- org.eclipse.uml2.uml.Package umlPackage = umlElement.getNearestPackage();
- if(umlPackage == null) {
- stereotype = umlElement.getApplicableStereotype(stereotypeName);
- } else {
- outerLoop: for(Profile profile : umlPackage.getAllAppliedProfiles()) {
- for(Stereotype ownedStereotype : profile.getOwnedStereotypes()) {
- if(ownedStereotype.getQualifiedName().equals(stereotypeName)) {
- stereotype = ownedStereotype;
- break outerLoop;
- }
- }
- }
- }
- return stereotype;
- }
-
- /**
- * Returns a collection of all super stereotypes of the given stereotype
- * (Including itself)
- *
- * @param stereotype
- * @return
- * A collection of all super stereotypes
- */
- public static Collection<Stereotype> getAllSuperStereotypes(Stereotype stereotype) {
- Set<Stereotype> result = new HashSet<Stereotype>();
- if(stereotype != null) {
- getAllSuperStereotypes(stereotype, result);
- }
- return result;
- }
-
- private static void getAllSuperStereotypes(Stereotype stereotype, Set<Stereotype> result) {
- result.add(stereotype);
- for(Classifier superClassifier : stereotype.getGenerals()) {
- if(superClassifier instanceof Stereotype && !result.contains(superClassifier)) {
- getAllSuperStereotypes((Stereotype)superClassifier, result);
- }
- }
- }
-
- /**
- * Retrieves the UML Class associated to the given Message
- *
- * @param message
- * @return the UML Class associated to the given Message
- */
- public static org.eclipse.uml2.uml.Class getContextClassForMessage(Message message) {
- MessageOccurrenceSpecification receiveEvent = (MessageOccurrenceSpecification)message.getReceiveEvent();
-
- if(receiveEvent == null) {
- return null;
- }
-
- return getContextClassForMessageOccurrence(receiveEvent);
- }
-
- /**
- * Retrieves the UML Class associated to the given MessageOccurrenceSpecification
- *
- * @param messageOccurrence
- * @return the UML Class associated to the given MessageOccurrenceSpecification
- */
- public static org.eclipse.uml2.uml.Class getContextClassForMessageOccurrence(MessageOccurrenceSpecification messageOccurrence) {
- List<Lifeline> lifelines = messageOccurrence.getCovereds();
- if(lifelines.isEmpty()) {
- return null; //We can't find the context
- } else if(lifelines.size() == 1) {
- Lifeline lifeline = lifelines.get(0);
- ConnectableElement element = lifeline.getRepresents();
- if(element == null) {
- return null;
- }
- Type type = element.getType();
- if(type instanceof org.eclipse.uml2.uml.Class) {
- org.eclipse.uml2.uml.Class clazz = (org.eclipse.uml2.uml.Class)type;
- return clazz;
- } else {
- return null; //The type is not a Class
- }
- } else {
- return null; //Too many contexts : which one should we choose ?
- }
- }
-
- /**
- * Finds the UML Class associated to the given MessageEvent
- *
- * @param event
- * @return the Class associated to the given MessageEvent
- */
- public static Class getContextClassForMessageEvent(MessageEvent event) {
- Collection<EStructuralFeature.Setting> settings = PapyrusEcoreUtils.getUsages(event);
- if(settings.isEmpty()) {
- return null;
- }
-
- if(settings.size() == 1) {
- EObject referer = settings.iterator().next().getEObject();
- if(referer instanceof MessageOccurrenceSpecification) {
- return UMLUtil.getContextClassForMessageOccurrence((MessageOccurrenceSpecification)referer);
- } else {
- return null;
- }
- }
-
- MessageOccurrenceSpecification referer = null;
- EObject newReferer = null;
-
- for(EStructuralFeature.Setting setting : settings) {
- newReferer = setting.getEObject();
- if(!(newReferer instanceof MessageOccurrenceSpecification)) {
- continue;
- }
-
- if(referer == null || referer == newReferer) {
- referer = (MessageOccurrenceSpecification)newReferer;
- } else {
- referer = null;
- break;
- }
- }
-
- if(referer == null) {
- return null;
- }
-
- return UMLUtil.getContextClassForMessageOccurrence(referer);
- }
-
- /**
- * Returns an IObservableValue for the given feature and EObject
- *
- * If the EditingDomain is set, the IObservableValue will use the Papyrus ServiceEdit ;
- * otherwise, a standard EMFObservableValue will be used
- *
- * @param source
- * The EObject to observe
- * @param feature
- * The feature to observe
- * @param domain
- * The editing domain on which the commands will be executed. If null, direct
- * object modifications will be used.
- * @return
- * The IObservableValue
- */
- public static IObservableValue getObservableValue(EObject source, EStructuralFeature feature, EditingDomain domain) {
- return domain == null ? EMFProperties.value(feature).observe(source) : new PapyrusObservableValue(source, feature, domain);
- }
-
- private static EPackage umlMetamodel = UMLPackage.eINSTANCE;
-}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationPropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationPropertyEditor.java
index 6be0a9861ac..86368dd7315 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationPropertyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationPropertyEditor.java
@@ -13,7 +13,7 @@ package org.eclipse.papyrus.uml.properties.widgets;
import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
import org.eclipse.papyrus.uml.properties.Activator;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.papyrus.views.properties.widgets.AbstractPropertyEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.uml2.uml.Element;
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ProfileUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ProfileUtil.java
new file mode 100644
index 00000000000..90fbec1db61
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ProfileUtil.java
@@ -0,0 +1,217 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A class containing static utility method regarding UML profiles
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class ProfileUtil {
+
+
+ /**
+ * Checks if the profile applied has been changed since last application (definition does not match.
+ *
+ * @param _package
+ * on which the profile is applied
+ * @param _profile
+ * the applied profile
+ * @return true if the profile has changed
+ */
+ public static boolean isDirty(Package _package, Profile _profile) {
+ boolean isDirty = false;
+ if(_profile == null || _profile.eResource() == null) {
+ return false;
+ }
+
+ // Retrieve model resourceSet
+ ResourceSet pkge_resourceSet = _package.eResource().getResourceSet();
+
+ // Retrieve profile resource
+ URI prof_URI = _profile.eResource().getURI();
+ Resource modelResource = pkge_resourceSet.getResource(prof_URI, true);
+
+ if(modelResource.getContents().get(0) instanceof Profile) {
+
+ // ckeck applied profile application definition vs profile definition referenced in file
+ Profile profileInFile = (Profile)(modelResource.getContents().get(0));
+
+ if(_package.getProfileApplication(_profile) != null) {
+ EPackage appliedProfileDefinition = _package.getProfileApplication(_profile).getAppliedDefinition();
+ EPackage fileProfileDefinition = null;
+
+ // Check profiles qualified names to ensure the correct profiles are compared
+ String appliedProfileName = _profile.getQualifiedName();
+ String fileProfileName = profileInFile.getQualifiedName();
+ if(!appliedProfileName.equals(fileProfileName)) {
+
+ // The profile must be a subprofile
+ Iterator<Profile> it = PackageUtil.getSubProfiles(profileInFile).iterator();
+ while(it.hasNext()) {
+ Profile current = it.next();
+ fileProfileName = current.getQualifiedName();
+ if(fileProfileName.equals(appliedProfileName)) {
+ profileInFile = current;
+ }
+ }
+ }
+
+ fileProfileDefinition = profileInFile.getDefinition();
+
+ if(appliedProfileDefinition != fileProfileDefinition) {
+ isDirty = true;
+ }
+ }
+
+ }
+
+ return isDirty;
+ }
+
+ public static List<Stereotype> findAllSubStereotypes(Stereotype parentStereotype, Package umlPackage, boolean concreteOnly) {
+ Collection<Stereotype> result = new LinkedHashSet<Stereotype>();
+
+ for(Profile profile : umlPackage.getAllAppliedProfiles()) {
+ List<Stereotype> allStereotypes = new LinkedList<Stereotype>();
+ findAllStereotypes(profile, allStereotypes);
+ for(Stereotype stereotype : allStereotypes) {
+ if(concreteOnly && stereotype.isAbstract()) {
+ continue; //Skip abstract stereotypes
+ }
+
+ if(isSubStereotype(parentStereotype, stereotype)) {
+ result.add(stereotype);
+ }
+ }
+
+ }
+
+ return new LinkedList<Stereotype>(result);
+ }
+
+ public static boolean isSubStereotype(Stereotype parentStereotype, Stereotype childStereotype) {
+ if(parentStereotype == childStereotype) {
+ return true;
+ }
+ return childStereotype.getGenerals().contains(parentStereotype); //TODO : This is probably not recursive...
+ }
+
+ /**
+ * Finds recursively all stereotypes contained in this profile
+ *
+ * @param profile
+ *
+ * @param result
+ */
+ public static void findAllStereotypes(Profile profile, List<Stereotype> result) {
+ for(Stereotype stereotype : profile.getOwnedStereotypes()) {
+ result.add(stereotype);
+ }
+ for(Package subPackage : profile.getNestedPackages()) {
+ if(subPackage instanceof Profile) {
+ Profile subProfile = (Profile)subPackage;
+ findAllStereotypes(subProfile, result);
+ }
+ }
+ }
+
+ private static EPackage umlMetamodel = UMLPackage.eINSTANCE;
+
+ public static List<EClass> getAllExtendedMetaclasses(Stereotype stereotype, boolean concreteClassesOnly) {
+ List<Class> extendedMetaclasses = stereotype.getAllExtendedMetaclasses();
+ Set<EClass> allMetaclasses = new LinkedHashSet<EClass>();
+ for(Class extendedMetaclass : extendedMetaclasses) {
+ EClass UMLEClass = findEClass(extendedMetaclass);
+ allMetaclasses.addAll(EMFHelper.getSubclassesOf(UMLEClass, concreteClassesOnly));
+ }
+
+ return new LinkedList<EClass>(allMetaclasses);
+ }
+
+ private static EClass findEClass(Class metaclass) {
+ for(EClassifier classifier : umlMetamodel.getEClassifiers()) {
+ if(classifier instanceof EClass) {
+ if(classifier.getName().equals(metaclass.getName())) {
+ return (EClass)classifier;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searchs the association containing a member end matching the given name
+ * in the given stereotype, and returns it if it is typed by a stereotype
+ *
+ * TODO : This method can probably be used in a single specific case and should probably not be here
+ *
+ * @param stereotype
+ * @param associationName
+ * @return
+ */
+ public static Property findStereotypedProperty(Stereotype stereotype, String associationName) {
+ //associations loop
+ associations: for(Association association : stereotype.getAssociations()) {
+ //memberEnds loop
+ for(Property memberEnd : association.getMemberEnds()) {
+ if(memberEnd.getType() == stereotype) {
+ //oppositeEnds loop
+ for(Property oppositeEnd : association.getMemberEnds()) {
+ if(oppositeEnd != memberEnd && oppositeEnd.getName().equals(associationName) && !association.getOwnedEnds().contains(oppositeEnd)) {
+ if(oppositeEnd.getType() instanceof Stereotype) {
+ return oppositeEnd;
+ }
+ break associations;
+ }
+ }
+ }
+ }
+ }
+
+ //FIXME : Do we really need to browse associations first ?
+
+ //Search for properties which are not associations
+ for(Property property : stereotype.getAllAttributes()) {
+ if(property.getName().equals(associationName)) {
+ if(property.getType() instanceof Stereotype) {
+ return property;
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ui/helper/UMLHelper.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/UMLUtil.java
index 35e920551ad..f5198ad671c 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ui/helper/UMLHelper.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/UMLUtil.java
@@ -9,19 +9,17 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils.ui.helper;
+package org.eclipse.papyrus.uml.tools.utils;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.core.utils.PapyrusEcoreUtils;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
@@ -43,10 +41,15 @@ import org.eclipse.uml2.uml.UMLPackage;
*
* @author Camille Letavernier
*/
-public class UMLHelper {
+//TODO/FIXME : Check implementations. Most of them are old and don't always match the
+//specification for some cases.
+public class UMLUtil {
/**
- * Retrieve the UML semantic element from the given Object
+ * Retrieve the UML semantic element from the given Object.
+ * This method relies on {@link EMFHelper#getEObject(Object)} to resolve
+ * an EObject from an Object, then checks if the resulting EObject is a
+ * UML Element.
*
* @param source
* The Object to resolve
@@ -54,15 +57,9 @@ public class UMLHelper {
* The UML semantic element, or null if it couldn't be resolved
*/
public static Element resolveUMLElement(Object source) {
- EObject eElement = null;
- if(source instanceof EObject) {
- eElement = (EObject)source;
- }
- if(source instanceof IAdaptable) {
- eElement = (EObject)((IAdaptable)source).getAdapter(EObject.class);
- }
+ EObject eElement = EMFHelper.getEObject(source);
- if(EMFHelper.isInstance(eElement, "Element", umlMetamodel)) { //$NON-NLS-1$
+ if(eElement instanceof Element) {
return (Element)eElement;
}
@@ -79,9 +76,9 @@ public class UMLHelper {
* True if the class className is a subclass of the class superclassName
*/
public static boolean isSubClass(String className, String superclassName) {
- EClass eClass = (EClass)umlMetamodel.getEClassifier(className);
- EClass superClass = (EClass)umlMetamodel.getEClassifier(superclassName);
- return superClass.isSuperTypeOf(eClass);
+ EClass eClass = (EClass)getUMLMetamodel().getEClassifier(className);
+ EClass superClass = (EClass)getUMLMetamodel().getEClassifier(superclassName);
+ return EMFHelper.isSubclass(eClass, superClass);
}
/**
@@ -92,14 +89,14 @@ public class UMLHelper {
* The source object's editing domain, or null if it couldn't be found
*/
public static EditingDomain resolveEditingDomain(Object source) {
- return AdapterFactoryEditingDomain.getEditingDomainFor(resolveUMLElement(source));
+ return EMFHelper.resolveEditingDomain(resolveUMLElement(source));
}
/**
* @return the UML EPackage
*/
public static EPackage getUMLMetamodel() {
- return umlMetamodel;
+ return UMLPackage.eINSTANCE;
}
/**
@@ -270,7 +267,7 @@ public class UMLHelper {
if(settings.size() == 1) {
EObject referer = settings.iterator().next().getEObject();
if(referer instanceof MessageOccurrenceSpecification) {
- return UMLHelper.getContextClassForMessageOccurrence((MessageOccurrenceSpecification)referer);
+ return UMLUtil.getContextClassForMessageOccurrence((MessageOccurrenceSpecification)referer);
} else {
return null;
}
@@ -297,10 +294,6 @@ public class UMLHelper {
return null;
}
- return UMLHelper.getContextClassForMessageOccurrence(referer);
+ return UMLUtil.getContextClassForMessageOccurrence(referer);
}
-
-
-
- private static EPackage umlMetamodel = UMLPackage.eINSTANCE;
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java
index 36cb4412632..9732eb47bb0 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java
@@ -14,7 +14,7 @@ package org.eclipse.papyrus.uml.tools.databinding;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
/**
* An Abstract Class for Papyrus Command-based observable values
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java
index 90dd63b947e..bc43d4768d0 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java
@@ -18,8 +18,8 @@ import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.tools.databinding.MultipleObservableValue;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
public class AggregatedPapyrusObservableValue extends MultipleObservableValue {
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java
index b8dd500b6dc..ee46bad776d 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java
@@ -28,7 +28,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.uml.tools.Activator;
import org.eclipse.papyrus.uml.tools.helper.UMLDatabindingHelper;
import org.eclipse.uml2.uml.UMLPackage;
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java
index bab8bbf9917..25176ba2402 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java
@@ -33,7 +33,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Property;
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java
index c71e4cb1e51..343ddd8424c 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java
@@ -32,7 +32,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.uml.tools.Activator;
import org.eclipse.uml2.uml.Artifact;
import org.eclipse.uml2.uml.Association;
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java
index 9b34faadc2b..fc4ec31c8e4 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java
@@ -26,7 +26,7 @@ import org.eclipse.papyrus.infra.emf.databinding.EMFObservableValue;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.uml.tools.Activator;
/**
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/ApplicableStereotypeContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ApplicableStereotypeContentProvider.java
index 7858535b232..cf675034a05 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/ApplicableStereotypeContentProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ApplicableStereotypeContentProvider.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.uml.properties.providers;
+package org.eclipse.papyrus.uml.tools.providers;
import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.uml2.uml.Element;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueViewerFilter.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/InstanceValueContentProvider.java
index b263d079977..bd6a937f547 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/InstanceValueViewerFilter.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/InstanceValueContentProvider.java
@@ -9,12 +9,12 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.uml.properties.providers;
+package org.eclipse.papyrus.uml.tools.providers;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
-import org.eclipse.papyrus.uml.properties.util.UMLUtil;
-import org.eclipse.papyrus.uml.tools.providers.UMLHierarchicViewerFilter;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Enumeration;
import org.eclipse.uml2.uml.InstanceSpecification;
@@ -22,13 +22,17 @@ import org.eclipse.uml2.uml.InstanceValue;
import org.eclipse.uml2.uml.Type;
/**
- * A viewer filter for {@link InstanceValue#getInstance()} values
- * The values are accepted only if they match the {@link InstanceValue#getType()}.
- * If the {@link InstanceValue#getType()} is not set, all values are accepted
+ * A Content provider for the value of an InstanceValue
+ *
+ * The valid instance specifications are filtered according to the type of the
+ * InstanceValue
*
* @author Camille Letavernier
+ *
+ * @see InstanceValue#getType()
+ * @see InstanceValueViewerFilter
*/
-public class InstanceValueViewerFilter extends UMLHierarchicViewerFilter {
+public class InstanceValueContentProvider extends ServiceEditFilteredContentProvider {
private InstanceValue source;
@@ -36,19 +40,37 @@ public class InstanceValueViewerFilter extends UMLHierarchicViewerFilter {
*
* Constructor.
*
- * @param contentProvider
- * The ContentProvider which provides the available values
* @param source
* The InstanceValue being edited
+ * @param feature
+ * The EStructuralFeature being edited
+ * @param root
+ * The root ResourceSet for the Tree representing the model
+ */
+ public InstanceValueContentProvider(InstanceValue source, EStructuralFeature feature, ResourceSet root) {
+ super(source, feature, root);
+ this.source = source;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param source
+ * The InstanceValue being edited
+ * @param feature
+ * The EStructuralFeature being edited
+ * @param roots
+ * The root EObjects for the Tree representing the model
*/
- public InstanceValueViewerFilter(IHierarchicContentProvider contentProvider, InstanceValue source) {
- super(contentProvider);
+ public InstanceValueContentProvider(InstanceValue source, EStructuralFeature feature, EObject[] roots) {
+ super(source, feature, roots);
this.source = source;
}
@Override
- public boolean isVisible(Viewer viewer, Object parentElement, Object element) {
- if(!super.isVisible(viewer, parentElement, element)) {
+ public boolean isValidValue(Object element) {
+ if(!super.isValidValue(element)) {
return false;
}
@@ -62,7 +84,7 @@ public class InstanceValueViewerFilter extends UMLHierarchicViewerFilter {
if(type instanceof Enumeration) {
return ((Enumeration)type).getOwnedLiterals().contains(instance);
- } else if (type instanceof Classifier){
+ } else if(type instanceof Classifier) {
Classifier classifier = (Classifier)type;
if(instance.getClassifiers().contains(classifier)) {
return true;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/ProfileLabelProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java
index 358c981d76a..8c785d235fa 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/ProfileLabelProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java
@@ -9,15 +9,16 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.uml.properties.providers;
+package org.eclipse.papyrus.uml.tools.providers;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.uml.profile.utils.Util;
+import org.eclipse.papyrus.uml.tools.utils.ProfileUtil;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
//TODO : To be refactored. Merge this class with UMLLabelProvider
+@Deprecated
public class ProfileLabelProvider extends EMFLabelProvider implements ILabelProvider {
private Package umlPackage;
@@ -38,7 +39,7 @@ public class ProfileLabelProvider extends EMFLabelProvider implements ILabelProv
if(name == null) {
name = UNKNOWN_PROFILE;
}
- if(Util.isDirty(umlPackage, profile)) {
+ if(ProfileUtil.isDirty(umlPackage, profile)) {
name += TAG_PROFILE_CHANGED;
}
return name;
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/SemanticUMLContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/SemanticUMLContentProvider.java
new file mode 100644
index 00000000000..86e33d1035b
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/SemanticUMLContentProvider.java
@@ -0,0 +1,142 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.providers;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.resource.uml.UmlUtils;
+import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
+import org.eclipse.papyrus.infra.widgets.Activator;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+public class SemanticUMLContentProvider extends SemanticEMFContentProvider {
+
+ public SemanticUMLContentProvider(EObject editedEObject, EStructuralFeature feature, EObject[] roots) {
+ super(editedEObject, feature, roots);
+ }
+
+ public SemanticUMLContentProvider(EObject editedEObject, EStructuralFeature feature) {
+ this(editedEObject, feature, findRoots(editedEObject));
+ }
+
+ public SemanticUMLContentProvider(EObject[] roots) {
+ super(roots);
+ }
+
+ public SemanticUMLContentProvider(ResourceSet root) {
+ this(null, null, root);
+ }
+
+ public SemanticUMLContentProvider(EObject editedEObject, EStructuralFeature feature, ResourceSet root) {
+ this(editedEObject, feature, getRoots(root));
+ }
+
+ protected static EObject[] findRoots(EObject source) {
+ if(source.eResource() == null || source.eResource().getResourceSet() == null) {
+ return SemanticEMFContentProvider.findRoots(source);
+ }
+
+ //We have a full resourceSet : we return its contents
+ return getRoots(source.eResource().getResourceSet());
+ }
+
+ protected static EObject[] getRoots(ResourceSet root) {
+ if(root instanceof ModelSet) {
+ ModelSet modelSet = (ModelSet)root;
+ //TODO : Find all semantic roots, including Models and Libraries
+ //This is related to the ModelSet evolution
+ try {
+ return new EObject[]{ UmlUtils.getUmlModel(modelSet).lookupRoot() };
+ } catch (NotFoundException ex) {
+ Activator.log.error(ex);
+ }
+ }
+
+ return SemanticEMFContentProvider.getRoots(root);
+ }
+
+ @Override
+ protected boolean isCompatibleMetaclass(Object containerElement, Object metaclass) {
+ Element semanticElement = UMLUtil.resolveUMLElement(containerElement);
+
+ if(semanticElement == null) {
+ return false;
+ }
+
+ if(metaclass instanceof Stereotype) {
+ Stereotype stereotype = (Stereotype)metaclass;
+
+ return semanticElement.getAppliedStereotype(stereotype.getQualifiedName()) != null;
+ }
+
+ //TODO : We should use super.isCompatibleMetaclass(), but the super-implementation
+ //may not be compatible with our implementation of getAdaptedValue()
+ if(metaclass instanceof EClassifier) {
+ return ((EClassifier)metaclass).isInstance(semanticElement);
+ }
+
+ return false;
+ }
+
+ /**
+ * This method should return either the StereotypeApplication (For Sto - Sto associations),
+ * or the UML Element (For Sto - UML associations)
+ *
+ * This depends on the wanted metaclass.
+ */
+ //TODO : In some cases, we may have a filter based on both a UML Metaclass and a Stereotype
+ //In such a specific case, a specific implementation is probably needed
+ //
+ //This case may especially occur in the case of dynamic creation of stereotype associations.
+ @Override
+ public Object getAdaptedValue(Object containerElement) {
+ Object semanticElement = super.getAdaptedValue(containerElement);
+
+ if(semanticElement instanceof Element) {
+ Element element = (Element)semanticElement;
+ //Looks for a compatible Stereotype application
+ for(Object metaclassWanted : getWantedMetaclasses()) {
+
+ if(metaclassWanted instanceof Stereotype) {
+ EObject stereotypeApplication = null;
+
+ stereotypeApplication = element.getStereotypeApplication((Stereotype)metaclassWanted);
+ if(stereotypeApplication == null) {
+ List<Stereotype> subStereotypes = element.getAppliedSubstereotypes((Stereotype)metaclassWanted);
+ for(Stereotype subSteretoype : subStereotypes) {
+ stereotypeApplication = element.getStereotypeApplication(subSteretoype);
+ if(stereotypeApplication != null) {
+ break;
+ }
+ }
+ }
+
+ if(stereotypeApplication != null) {
+ return stereotypeApplication;
+ }
+ }
+ }
+ }
+
+ //If no stereotype application is found, return the UML Element
+ return semanticElement;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ServiceEditFilteredUMLContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ServiceEditFilteredContentProvider.java
index 147df4104ba..e6b29cdbf1a 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ServiceEditFilteredUMLContentProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ServiceEditFilteredContentProvider.java
@@ -13,14 +13,27 @@ package org.eclipse.papyrus.uml.tools.providers;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.uml.tools.helper.HistoryUtil;
+import org.eclipse.emf.ecore.resource.ResourceSet;
-public class ServiceEditFilteredUMLContentProvider extends UMLElementMEBContentProvider {
+/**
+ * A SemanticContentProvider for Papyrus UML elements.
+ *
+ * This provider uses the Papyrus Service Edit to determine whether a value
+ * is valid or not for a given eObject/feature.
+ *
+ * @author Camille Letavernier
+ */
+public class ServiceEditFilteredContentProvider extends SemanticUMLContentProvider {
private EditServiceValidator validator;
- public ServiceEditFilteredUMLContentProvider(EObject editedObject, EStructuralFeature feature, EObject semanticRoot) {
- super(semanticRoot, HistoryUtil.getHistoryID(editedObject, feature, semanticRoot));
+ public ServiceEditFilteredContentProvider(EObject editedObject, EStructuralFeature feature, EObject[] roots) {
+ super(editedObject, feature, roots);
+ validator = new EditServiceValidator(editedObject, feature);
+ }
+
+ public ServiceEditFilteredContentProvider(EObject editedObject, EStructuralFeature feature, ResourceSet root) {
+ super(editedObject, feature, root);
validator = new EditServiceValidator(editedObject, feature);
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainerContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainerContentProvider.java
new file mode 100644
index 00000000000..d4e97b6df7c
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainerContentProvider.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.providers;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+
+public class UMLContainerContentProvider extends SemanticUMLContentProvider {
+
+ protected EClass type;
+
+ protected Object input;
+
+ public UMLContainerContentProvider(EObject editedEObject, EReference reference, EObject[] roots) {
+ super(editedEObject, reference, roots);
+ type = (EClass)reference.getEType();
+ }
+
+ public UMLContainerContentProvider(EObject editedEObject, EReference reference) {
+ super(editedEObject, reference);
+ type = (EClass)reference.getEType();
+ }
+
+ public UMLContainerContentProvider(EObject editedEObject, EReference reference, ResourceSet root) {
+ super(editedEObject, reference, root);
+ type = (EClass)reference.getEType();
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ this.input = newInput;
+ if(newInput instanceof EObject) {
+ this.type = ((EObject)newInput).eClass();
+ }
+ }
+
+ @Override
+ public boolean isValidValue(Object value) {
+ Object adaptedValue = getAdaptedValue(value);
+ if(adaptedValue instanceof EObject) {
+ //We cannot create objects in a read-only object
+ if(EMFHelper.isReadOnly((EObject)adaptedValue)) {
+ return false;
+ }
+
+ //We need at least one valid containment reference to store this
+ //type of object
+ for(EReference reference : ((EObject)adaptedValue).eClass().getEAllReferences()) {
+ if(reference.isContainment() && EMFHelper.isSubclass(this.type, reference.getEReferenceType())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainmentBrowseStrategy.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainmentBrowseStrategy.java
new file mode 100644
index 00000000000..28228586663
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContainmentBrowseStrategy.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.providers;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.papyrus.infra.emf.providers.strategy.ContainmentBrowseStrategy;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+
+public class UMLContainmentBrowseStrategy extends ContainmentBrowseStrategy {
+
+ public UMLContainmentBrowseStrategy(ITreeContentProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ protected boolean browseElement(Object containerElement) {
+ Object semanticElement = adaptableProvider.getAdaptedValue(containerElement);
+
+ if(semanticElement == UMLPackage.eINSTANCE.getPackageImport_ImportedPackage()) {
+ return true;
+ }
+
+ return super.browseElement(containerElement);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TreePath findPath(Object semanticElement, Object[] rootElements) {
+ //If element is a stereotype application, search for the base element instead
+ EObject source = EMFHelper.getEObject(semanticElement);
+ Element baseElement = UMLUtil.getBaseElement(source);
+ if(baseElement == null) {
+ return super.findPath(semanticElement, rootElements);
+ }
+
+ return super.findPath(baseElement, rootElements);
+ }
+
+ @Override
+ public void revealSemanticElement(List<?> elementsList) {
+ //For stereotypeApplication, we reveal the UML baseElement instead of the stereotypeApplication object
+ List<Object> umlElementsList = new LinkedList<Object>();
+ for(Object semanticElement : elementsList) {
+ EObject source = EMFHelper.getEObject(semanticElement);
+ Element baseElement = UMLUtil.getBaseElement(source);
+ if(baseElement == null) {
+ umlElementsList.add(semanticElement);
+ } else {
+ umlElementsList.add(baseElement);
+ }
+ }
+
+ super.revealSemanticElement(umlElementsList);
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java
index 68913f17cd7..05713c9e85b 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java
@@ -1,16 +1,133 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ *****************************************************************************/
package org.eclipse.papyrus.uml.tools.providers;
+import java.util.Collections;
+
+import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.ModelUtils;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.emf.providers.EMFEnumeratorContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.papyrus.uml.tools.util.UMLProviderHelper;
+import org.eclipse.papyrus.uml.tools.utils.ProfileUtil;
+import org.eclipse.uml2.uml.InstanceValue;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * A global content provider for UML
+ */
+public class UMLContentProvider extends EncapsulatedContentProvider {
+
+ protected EObject eObject;
+
+ protected EStructuralFeature feature;
+
+ protected Stereotype stereotype;
+
+ /**
+ * Constructor.
+ *
+ * @param source
+ * The edited EObject
+ * @param feature
+ * The edited EStructuralFeature
+ */
+ public UMLContentProvider(final EObject source, final EStructuralFeature feature) {
+ this(source, feature, null);
+ }
-public class UMLContentProvider extends ServiceEditFilteredUMLContentProvider {
+ /**
+ *
+ * @param source
+ * The edited {@link EObject} (Should be either a UML Element or a StereotypeApplication)
+ * @param feature
+ * The edited {@link EStructuralFeature}
+ * @param stereotype
+ * The {@link Stereotype} of the source EObject. May be null if the source is not a StereotypeApplication
+ */
+ public UMLContentProvider(final EObject source, final EStructuralFeature feature, final Stereotype stereotype) {
+ this.eObject = source;
+ this.feature = feature;
+ this.stereotype = stereotype;
- public UMLContentProvider(EObject editedObject, EStructuralFeature feature) {
- this(editedObject, feature, null);
+ IStructuredContentProvider semanticProvider = getSemanticProvider(source, feature, stereotype);
+
+ encapsulated = UMLProviderHelper.encapsulateProvider(semanticProvider, eObject, feature);
}
- public UMLContentProvider(EObject editedObject, EStructuralFeature feature, EObject semanticRoot) {
- super(editedObject, feature, semanticRoot);
+ /**
+ *
+ * @param source
+ * The edited {@link EObject} (Should be either a UML Element or a StereotypeApplication)
+ * @param feature
+ * The edited {@link EStructuralFeature}
+ * @param stereotype
+ * The {@link Stereotype} of the source {@link EObject}. May be null if the source is not a StereotypeApplication
+ * @return
+ */
+ protected IStructuredContentProvider getSemanticProvider(final EObject source, final EStructuralFeature feature, final Stereotype stereotype) {
+ if(UMLUtil.getBaseElement(source) != null) {
+ Property umlReference = ProfileUtil.findStereotypedProperty(stereotype, feature.getName());
+ if(umlReference != null) {
+ return getStereotypedReferenceContentProvider(source, feature, (Stereotype)umlReference.getType());
+ }
+ }
+
+ if(feature.getEType() instanceof EEnum) {
+ return new EMFEnumeratorContentProvider(feature);
+ }
+
+ try {
+ ModelSet root = ModelUtils.getModelSetChecked(EditorUtils.getServiceRegistry());
+
+ if(feature == UMLPackage.eINSTANCE.getPort_Provided() || feature == UMLPackage.eINSTANCE.getPort_Required()) {
+ //TODO : Use a specific content provider here, when it exists
+ return new ServiceEditFilteredContentProvider(source, feature, root);
+ } else if(feature == UMLPackage.eINSTANCE.getInstanceValue_Instance()) {
+ return new InstanceValueContentProvider((InstanceValue)source, feature, root);
+ } else {
+ return new ServiceEditFilteredContentProvider(source, feature, root);
+ }
+ } catch (ServiceException ex) {
+ throw new RuntimeException("Cannot instantiate the UMLContentProvider", ex);
+ }
}
+ /**
+ * Uses the content provider for reference properties typed by a stereotype
+ *
+ * @param propertyPath
+ * The name of the property being edited
+ * @return
+ * The Content Provider for properties typed by a stereotype
+ */
+ protected IHierarchicContentProvider getStereotypedReferenceContentProvider(EObject source, EStructuralFeature feature, Stereotype type) {
+ ResourceSet root = UMLUtil.getBaseElement(source).eResource().getResourceSet();
+
+ ServiceEditFilteredContentProvider contentProvider = new ServiceEditFilteredContentProvider(source, feature, root);
+ contentProvider.setWantedMetaclasses(Collections.singletonList(type));
+
+ return contentProvider;
+ }
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLElementMEBContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLElementMEBContentProvider.java
deleted file mode 100644
index d1b1b7faa54..00000000000
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLElementMEBContentProvider.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.providers;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.papyrus.infra.emf.providers.GraphicalModelExplorerBasedContentProvider;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.util.UMLUtil;
-
-
-/**
- * this content provider is specific for UML, it specifies getvalidValue by taking in account stereotypes
- *
- */
-public class UMLElementMEBContentProvider extends GraphicalModelExplorerBasedContentProvider {
-
- public UMLElementMEBContentProvider(EObject semanticRoot, String historyId) {
- super(semanticRoot, historyId);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.views.modelexplorer.widgets.EclassModelExplorerBasedContentProvider#isValidValue(java.lang.Object)
- *
- */
- @Override
- public boolean isValidValue(Object element) {
-
- if(metaClassWanted != null) {
- EObject semanticObject = null;
- if(element instanceof IAdaptable) {
- semanticObject = (EObject)brige.getSemanticElement(element);
- }
- if(element instanceof EObject) {
- semanticObject = (EObject)element;
- }
- //return false for Ereference
- if(element instanceof EReference || semanticObject instanceof EReference) {
- return false;
- }
-
- //this is a Eclass
- if(semanticObject != null) {
- if(metaClassWanted instanceof EClass) {
- if(((EClass)metaClassWanted).isSuperTypeOf(semanticObject.eClass())) {
- if(metaClassNotWantedList.size() > 0) {
- Iterator<Object> iternotwanted = metaClassNotWantedList.iterator();
- while(iternotwanted.hasNext()) {
- Object notWanted = iternotwanted.next();
- if(notWanted instanceof EClass) {
- if(((EClass)notWanted).isSuperTypeOf(semanticObject.eClass())) {
- return false;
- }
- }
- }
- }
- return true;
- }
- }
- //this is a stereotype (Dynamic profile)
- if(metaClassWanted instanceof Stereotype) {
- if(semanticObject instanceof Element) {
- Element selectedUMLelement = (Element)semanticObject;
- return selectedUMLelement.getAppliedStereotypes().contains(metaClassWanted);
- }
- }
- //This is a Stereotype (Static profile)
- if(metaClassWanted instanceof EClass && !(metaClassWanted instanceof Element)) {
- if(semanticObject instanceof Element) {
- Element selectedUMLElement = (Element)semanticObject;
- for(EObject stereotypeApplication : selectedUMLElement.getStereotypeApplications()) {
- if(((EClass)metaClassWanted).isInstance(stereotypeApplication)) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- return super.isValidValue(element);
- }
-
- @Override
- public Object getAdaptedValue(Object selection) {
- selection = super.getAdaptedValue(selection);
- if(isStereotype() && selection instanceof Element) {
- Element element = (Element)selection;
- EObject stereotypeApplication = null;
- if(metaClassWanted instanceof Stereotype) { //Dynamic profile
- stereotypeApplication = element.getStereotypeApplication((Stereotype)metaClassWanted);
- if(stereotypeApplication == null) {
- List<Stereotype> subStereotypes = element.getAppliedSubstereotypes((Stereotype)metaClassWanted);
- for(Stereotype subSteretoype : subStereotypes) {
- stereotypeApplication = element.getStereotypeApplication(subSteretoype);
- if(stereotypeApplication != null) {
- break;
- }
- }
- }
- } else { //Static profile
- for(EObject appliedStereotype : element.getStereotypeApplications()) {
- if(((EClass)metaClassWanted).isInstance(appliedStereotype)) {
- stereotypeApplication = appliedStereotype;
- }
- }
- }
-
- if(stereotypeApplication != null) {
- return stereotypeApplication;
- }
- }
- return selection;
- }
-
- @Override
- public Object getContainerValue(Object selection) {
- Object semanticElement = selection;;
- if(isStereotype() && selection instanceof EObject) {
- if(selection instanceof EObject) {
- semanticElement = UMLUtil.getBaseElement((EObject)selection);
- }
- }
- return super.getContainerValue(semanticElement);
- }
-
- protected boolean isStereotype() {
- boolean isStereotype = metaClassWanted instanceof Stereotype;
- boolean isUMLElement = false;
- if(metaClassWanted instanceof EClass) {
- EClass eClass = (EClass)metaClassWanted;
- isUMLElement = eClass.getEAllSuperTypes().contains(UMLPackage.eINSTANCE.getElement()) || eClass == UMLPackage.eINSTANCE.getElement();
- }
-
- return isStereotype || !isUMLElement;
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- super.inputChanged(viewer, oldInput, newInput);
- if(this.viewer != null) {
- this.viewer.setFilters(new ViewerFilter[]{ new UMLHierarchicViewerFilter(this) });
- }
- }
-
- // @Override
- // protected IStructuredContentProvider getMetamodelContentProvider() {
- // return new ProfileContentProvider();
- // }
- //
- // @Override
- // protected IStructuredContentProvider getMetaclassContentProvider() {
- // return new StereotypeContentProvider(metaClassWanted, metaClassNotWantedList);
- // }
- //
- // @Override
- // protected ViewerFilter getMetaclassViewerFilter(Object selectedMetaClass) {
- // return new StereotypeViewerFilter(selectedMetaClass);
- // }
-}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLHierarchicViewerFilter.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLHierarchicViewerFilter.java
deleted file mode 100644
index f76c9005321..00000000000
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLHierarchicViewerFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Adaptation to AbstractTreeFilter
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.providers;
-
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.papyrus.infra.emf.providers.HierarchicViewerFilter;
-import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.UMLPackage;
-
-public class UMLHierarchicViewerFilter extends HierarchicViewerFilter {
-
- public UMLHierarchicViewerFilter(IHierarchicContentProvider contentProvider) {
- super(contentProvider);
- }
-
- @Override
- protected Set<EReference> getReferencesToBrowse(EObject element) {
- Set<EReference> result = super.getReferencesToBrowse(element);
- if(element == null || element instanceof PackageImport) {
- result.add(UMLPackage.eINSTANCE.getPackageImport_ImportedPackage());
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLLabelProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLLabelProvider.java
index d6ac97c017a..692b68d7ed2 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLLabelProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLLabelProvider.java
@@ -1,10 +1,5 @@
package org.eclipse.papyrus.uml.tools.providers;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart;
@@ -39,12 +34,6 @@ import org.eclipse.uml2.uml.util.UMLUtil;
public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider {
- /**
- * We store the next index for the UML Element, which are not NamedElement
- * Key is a String representing the type of Element
- */
- private final Map<String, Integer> index = new HashMap<String, Integer>();
-
/** icon for metaclass */
public static final String ICON_METACLASS = "/icons/Metaclass.gif";//$NON-NLS-1$
@@ -65,6 +54,9 @@ public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider
*/
@Override
protected Image getImage(EObject element) {
+
+ element = resolveElement(element);
+
// test for Metaclass
if(element instanceof Class) {
if(TypeUtil.isMetaclass((Type)element)) {
@@ -102,6 +94,32 @@ public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider
}
/**
+ * If the inputElement is a StereotypeApplication, we want to provide the label
+ * of the stereotyped element, instead of the one of the StereotypeApplication
+ *
+ * @param inputElement
+ * The EObject for which we want to provide a label
+ * @return
+ * The Base Element if the input is a StereotypeApplication ; the inputElement instead
+ */
+ protected EObject resolveElement(EObject inputElement) {
+ if(inputElement == null) {
+ return null;
+ }
+
+ Element baseElement = UMLUtil.getBaseElement(inputElement);
+
+ if(baseElement != null) {
+ // Stereotype Application
+ // We return the label of the Stereotyped element, not the one of the
+ // StereotypeApplication itself
+ return baseElement;
+ }
+
+ return inputElement;
+ }
+
+ /**
*
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*
@@ -114,27 +132,13 @@ public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider
*/
@Override
protected String getText(EObject element) {
+ element = resolveElement(element);
+
if(element == null) {
return "<Undefined>";
}
- if(!(element instanceof EObject) && element instanceof IAdaptable) {
- EObject eObject = (EObject)((IAdaptable)element).getAdapter(EObject.class);
- if(eObject != null) {
- element = eObject;
- }
- }
-
- // if(element instanceof EditPart) {
- // element = ((View)((EditPart)element).getModel()).getElement();
- // }
-
- if(element instanceof EObject && UMLUtil.getBaseElement(element) != null) { // Stereotype
- // Application
- // We return the label of the Stereotyped element, not of the
- // Stereotype itself
- return getText(UMLUtil.getBaseElement(element));
- } else if(element instanceof org.eclipse.uml2.uml.Image) {
+ if(element instanceof org.eclipse.uml2.uml.Image) {
// imageName
// location
// imageName : location
@@ -171,8 +175,7 @@ public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider
return "<Element Import> " + importedElement.getName();
}
} else if(element instanceof NamedElement) {
- if(element instanceof ValueSpecification) { // Format :
- // [name=]value
+ if(element instanceof ValueSpecification) { // Format : [name=]value
String value = null;
if(element instanceof InstanceValue) {
InstanceSpecification specification = ((InstanceValue)element).getInstance();
@@ -204,19 +207,9 @@ public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider
return ((NamedElement)element).getName();
}
} else if(element instanceof Element) {
- // when the element is not a NamedElement, we return its Type + a
- // index
- String className = element.getClass().getName();
- int i = className.lastIndexOf(".");
- className = className.substring(i + 1);
- className = className.replace("Impl", "");
- Integer number = index.get(className);
- if(number == null) {
- number = 0;
- }
-
- index.put(className, number + 1);
- return className + " " + number;
+ // when the element is not a NamedElement, we return its Type name
+ String className = element.eClass().getName();
+ return className;
} else if(element instanceof Diagram) {
return ((Diagram)element).getName();
} else if(element instanceof View) { // maybe it is a view of a compartment
@@ -224,8 +217,6 @@ public class UMLLabelProvider extends EMFLabelProvider implements ILabelProvider
if(dummyEP instanceof ResizableCompartmentEditPart) {
return ((ResizableCompartmentEditPart)dummyEP).getCompartmentName();
}
- } else if(element instanceof EClass) {
- return ((EClass)element).getName();
}
return super.getText(element);
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/DatabindingUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/DatabindingUtil.java
new file mode 100644
index 00000000000..44eabb8221b
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/DatabindingUtil.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.util;
+
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
+
+
+public class DatabindingUtil {
+
+
+ /**
+ * Returns an IObservableValue for the given feature and EObject
+ *
+ * If the EditingDomain is set, the IObservableValue will use the Papyrus ServiceEdit ;
+ * otherwise, a standard EMFObservableValue will be used
+ *
+ * @param source
+ * The EObject to observe
+ * @param feature
+ * The feature to observe
+ * @param domain
+ * The editing domain on which the commands will be executed. If null, direct
+ * object modifications will be used.
+ * @return
+ * The IObservableValue
+ */
+ public static IObservableValue getObservableValue(EObject source, EStructuralFeature feature, EditingDomain domain) {
+ return domain == null ? EMFProperties.value(feature).observe(source) : new PapyrusObservableValue(source, feature, domain);
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/UMLProviderHelper.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/UMLProviderHelper.java
new file mode 100644
index 00000000000..633a99917b9
--- /dev/null
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/util/UMLProviderHelper.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.util;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.strategy.StrategyBasedContentProvider;
+import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
+import org.eclipse.papyrus.infra.widgets.strategy.IStrategyBasedContentProvider;
+import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
+import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
+import org.eclipse.papyrus.uml.tools.providers.UMLContainmentBrowseStrategy;
+
+
+public class UMLProviderHelper {
+
+ /**
+ * Encapsulates the given content provider in a higher-level content provider
+ * The returned provider uses two different strategies to display and search
+ * elements, and adds a pattern filter and an History
+ *
+ * @param provider
+ * The ContentProvider to encapsulate
+ * @return
+ */
+ public static EMFGraphicalContentProvider encapsulateProvider(IStructuredContentProvider provider, EObject editedEObject, EStructuralFeature feature) {
+ String historyId = HistoryUtil.getHistoryID(editedEObject, feature);
+
+ IStructuredContentProvider contentProvider;
+
+ if(provider instanceof ITreeContentProvider) {
+ contentProvider = getStrategyProvider((ITreeContentProvider)provider);
+ } else {
+ contentProvider = provider;
+ }
+
+ EMFGraphicalContentProvider graphicalProvider = new EMFGraphicalContentProvider(contentProvider, historyId);
+
+ return graphicalProvider;
+ }
+
+ public static IStrategyBasedContentProvider getStrategyProvider(ITreeContentProvider provider) {
+ TreeBrowseStrategy browseStrategy = new ProviderBasedBrowseStrategy(provider);
+ TreeBrowseStrategy revealStrategy = new UMLContainmentBrowseStrategy(provider);
+
+ return new StrategyBasedContentProvider(browseStrategy, revealStrategy);
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/AdvancedMETreeDialog.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/AdvancedMETreeDialog.java
deleted file mode 100644
index e6a504c1af4..00000000000
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/AdvancedMETreeDialog.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Added a lighter constructor
- *
- *****************************************************************************/
-package org.eclipse.papyrus.views.modelexplorer.widgets;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * this dialog box has the possibility to select by the user interface the kind of wanted meta-class.
- *
- * @deprecated You should now use the generic {@link org.eclipse.papyrus.widgets.editors.TreeSelectorDialog}
- */
-@Deprecated
-public class AdvancedMETreeDialog extends ModelExplorerBasedTreeSelectorDialog {
-
- protected Label metaclassLabel = null;
-
- protected Combo combo;
-
- protected EPackage metaModel;
-
- protected ArrayList<Object> metaclasses = new ArrayList<Object>();
-
- /**
- *
- * Constructor to display this dialog
- *
- * @param parentShell
- * a shell
- * @param root
- * the Eobject that will be the root of the Tree, it can be null
- * @param wantedEClass
- * , in order to filter the tree by taking in account only this kind of object
- * @param metaClassNotWanted
- * the list of not wanted object (to be pertinent, it has to be a subclass of wantedEclass
- * @param metaModel
- * an Epackage that represent the domain model
- */
- public AdvancedMETreeDialog(Shell parentShell, EObject root, Object wantedEClass, List<Object> metaClassNotWanted, EPackage metaModel) {
- super(parentShell, root, wantedEClass, metaClassNotWanted);
- this.metaModel = metaModel;
- }
-
- /**
- *
- * Constructor.
- *
- * @param parentShell
- * a shell
- * @param metaModel
- * an Epackage that represent the domain model
- */
- public AdvancedMETreeDialog(Shell parentShell, EPackage metaModel) {
- super(parentShell);
- this.metaModel = metaModel;
- }
-
- @Override
- public void create() {
- super.create();
- //install labels
- metaclassLabel = new Label(getDialogArea(), SWT.WRAP);
- metaclassLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- metaclassLabel.setText("Metaclass:");
- setDescription("Look for " + metaclassLabelProvider.getText(contentProvider.getMetaClassWanted()));
-
- //install combo
- combo = new Combo(getDialogArea(), SWT.NONE);
- combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- combo.addSelectionListener(new SelectionListener() {
-
- //creation of inner class for the selection
- public void widgetSelected(SelectionEvent e) {
- //look for the new wantedEClass
- int index = combo.getSelectionIndex();
- contentProvider.setMetaClassWanted(metaclasses.get(index));
- setDescription("Look for " + metaclassLabelProvider.getText(contentProvider.getMetaClassWanted()));
- contentProvider.setMetaClassNotWanted(new ArrayList<Object>());
- if(getViewer() != null) {
- getViewer().refresh();
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- fillmetaclassList(metaModel);
- fillMetaclassCombo(metaclasses, new EclassComparator());
- getShell().pack();
-
-
- }
-
- /**
- * Put into the list metaclasses all element from the Epackage
- * border effect the list metaclasses is filled
- *
- * @param ePackage
- * that represent the domain model
- */
- protected void fillmetaclassList(EPackage ePackage) {
- metaclasses.clear();
- for(Iterator<EObject> iterator = ePackage.eContents().iterator(); iterator.hasNext();) {
- EObject type = iterator.next();
- if(type instanceof EClass) {
- metaclasses.add(type);
- }
- }
- }
-
- /**
- * take in account all metaclasses and fill the combo by taking account order done by the comparator.
- * Border effect: the variable combo is filled by all element contained in the parameter metaclasses
- *
- * @param metaclasses
- * the list of metaclasses
- * @param comparator
- * a comparator
- */
- protected void fillMetaclassCombo(ArrayList<Object> metaclasses, Comparator<Object> comparator) {
- this.metaclasses = metaclasses;
- //fill the list of meta-classes
- combo.removeAll();
- Collections.sort(metaclasses, comparator);
- //fill the combo
- for(Iterator<Object> iterator = metaclasses.iterator(); iterator.hasNext();) {
- combo.add(metaclassLabelProvider.getText(iterator.next()));
- }
-
- }
-}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/ModelExplorerBasedTreeSelectorDialog.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/ModelExplorerBasedTreeSelectorDialog.java
deleted file mode 100644
index 24cb4b1b574..00000000000
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.widgets/src/org/eclipse/papyrus/views/modelexplorer/widgets/ModelExplorerBasedTreeSelectorDialog.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Added a lighter constructor
- *
- *****************************************************************************/
-package org.eclipse.papyrus.views.modelexplorer.widgets;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.infra.emf.providers.GraphicalModelExplorerBasedContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.HierarchicViewerFilter;
-import org.eclipse.papyrus.infra.emf.providers.SemanticFromModelExplorer;
-import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
-import org.eclipse.papyrus.views.modelexplorer.Activator;
-import org.eclipse.papyrus.views.modelexplorer.MoDiscoLabelProviderWTooltips;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * create a tree dialog box,with a specific researched meta-class. you can also specify the instance of the top element of your tree
- *
- * @deprecated You should now use the generic {@link TreeSelectorDialog}, with an {@link EclassModelExplorerBasedContentProvider}
- */
-@Deprecated
-public class ModelExplorerBasedTreeSelectorDialog extends TreeSelectorDialog {
-
- protected GraphicalModelExplorerBasedContentProvider contentProvider;
-
- protected EObject root = null;
-
- protected LabelProvider metaclassLabelProvider = new MetaclassLabelProvider();
-
-
- /**
- * get the label provider used to display metaclasses in the combo
- *
- * @return the label provider
- */
- public LabelProvider getMetaclassLabelProvider() {
- return metaclassLabelProvider;
- }
-
- /**
- * set the label provider that will display text in the combo that represent the available list of metaclasses
- *
- * @param metaclassLabelProvider
- */
- public void setMetaclassLabelProvider(LabelProvider metaclassLabelProvider) {
- this.metaclassLabelProvider = metaclassLabelProvider;
- }
-
- /**
- * {@inheritDoc}
- */
-
- @Override
- protected void setResult(@SuppressWarnings("rawtypes") List newResult) {
- ArrayList<Object> list= new ArrayList<Object>();
- SemanticFromModelExplorer bridge= new SemanticFromModelExplorer();
- Iterator<?> iterator=newResult.iterator();
- while (iterator.hasNext()) {
- Object wrappedObject = iterator.next();
- Object semantic=bridge.getSemanticElement(wrappedObject);
- if( semantic!=null){
- list.add(semantic);
- }
- }
-
- super.setResult(list);
- }
-
- /**
- *
- * Constructor.
- *
- * @param parentShell
- * a shell
- * @param root
- * the root of the tree , can be null
- * @param wantedEClass
- * the meta-classes wanted, can be null
- * @param metaClassNotWanted
- * , the list of sub meta-classes not wanted, can not be null
- */
- public ModelExplorerBasedTreeSelectorDialog(Shell parentShell, EObject root, Object wantedEClass, List<Object> metaClassNotWanted) {
- super(parentShell);
- init(root, wantedEClass, metaClassNotWanted);
- }
-
- /**
- *
- * Constructor.
- *
- * @param parentShell
- * a shell
- */
- public ModelExplorerBasedTreeSelectorDialog(Shell parentShell) {
- super(parentShell);
- }
-
- /**
- * Sets the preferences for initializing this Dialog's ContentProvider.
- *
- * @param root
- * the root of the tree , can be null
- * @param wantedEClass
- * the meta-classes wanted, can be null
- * @param metaClassNotWanted
- * , the list of sub meta-classes not wanted, can not be null
- */
- public void init(EObject root, Object wantedEClass, List<Object> metaClassNotWanted) {
- this.root = root;
- contentProvider = new GraphicalModelExplorerBasedContentProvider(root, ""); //$NON-NLS-1$
- contentProvider.setMetaClassWanted(wantedEClass);
- contentProvider.setMetaClassNotWanted(metaClassNotWanted);
- this.setContentProvider(contentProvider);
- this.setLabelProvider(new MoDiscoLabelProviderWTooltips());
- this.setInput(EditorUtils.getMultiDiagramEditor().getServicesRegistry());
- }
-
- @Override
- public void create() {
- // TODO Auto-generated method stub
- super.create();
- setDescription("Look for " + metaclassLabelProvider.getText(contentProvider.getMetaClassWanted()));
- ViewerFilter[] filters = { new HierarchicViewerFilter(contentProvider) };
- getViewer().setFilters(filters);
-
- Activator.getDefault().getCustomizationManager().installCustomPainter(getViewer().getTree());
- }
-}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF
index 4a64bf4c870..36e50a70678 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.emf.converter;bundle-version="2.5.0",
org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="0.9.0",
org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="0.9.0",
- org.eclipse.ltk.core.refactoring;bundle-version="3.5.100",
org.eclipse.emf.ecore.editor;bundle-version="2.6.0",
org.eclipse.emf.workspace.ui;bundle-version="1.3.0",
org.eclipse.core.expressions;bundle-version="3.4.200",
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java
index 66c608152e6..f9da5ab4928 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EcorePropertyEditorFactory.java
@@ -187,7 +187,7 @@ public class EcorePropertyEditorFactory extends PropertyEditorFactory {
@Override
public Object createObject(Control widget) {
Object instance;
- if (referenceIn.isContainment()){
+ if(referenceIn.isContainment()) {
instance = simpleCreateObject(widget);
} else {
instance = createObjectInDifferentContainer(widget);
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/CompositeModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/CompositeModelElement.java
index 664fbc7a174..0b4573a085f 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/CompositeModelElement.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/CompositeModelElement.java
@@ -17,8 +17,8 @@ import java.util.List;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.tools.databinding.MultipleObservableValue;
-import org.eclipse.papyrus.infra.widgets.databinding.AggregatedObservable;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
index e9be5b1ffeb..6ba799635b0 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
@@ -28,6 +28,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.emf.databinding.EMFObservableList;
import org.eclipse.papyrus.infra.emf.databinding.EMFObservableValue;
import org.eclipse.papyrus.infra.emf.providers.EMFContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFEnumeratorContentProvider;
import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
@@ -35,7 +36,6 @@ import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.creation.EcorePropertyEditorFactory;
-import org.eclipse.papyrus.views.properties.providers.EcoreEnumeratorContentProvider;
/**
* A ModelElement to manipulate EMF objects.
@@ -195,7 +195,7 @@ public class EMFModelElement extends AbstractModelElement {
}
EClassifier type = feature.getEType();
if(type instanceof EEnum) {
- return new EcoreEnumeratorContentProvider(feature);
+ return new EMFEnumeratorContentProvider(feature);
} else if(type instanceof EClass) {
return new EMFContentProvider(getSource(featurePath), feature);
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/ContainerContentProvider.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/ContainerContentProvider.java
index de03ebdb53e..55bbd184f09 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/ContainerContentProvider.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/ContainerContentProvider.java
@@ -15,25 +15,18 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.emf.providers.GraphicalModelExplorerBasedContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-
-
-public class ContainerContentProvider extends GraphicalModelExplorerBasedContentProvider {
+public class ContainerContentProvider extends SemanticEMFContentProvider {
protected EClass type;
protected Object input;
- public ContainerContentProvider(EClass wantedType) {
- super(null, getHistoryId(wantedType));
- this.type = wantedType;
- }
-
- private static String getHistoryId(EClass type) {
- return "history_createIn_" + type.getEPackage().getName() + ":" + type.getName(); //$NON-NLS-1$ //$NON-NLS-2$
-
+ public ContainerContentProvider(EObject source, EReference reference) {
+ super(source.eResource().getResourceSet());
+ type = (EClass)reference.getEType();
}
@Override
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EncapsulatedComboViewer.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EncapsulatedComboViewer.java
index a01a9193029..ebb08da38f9 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EncapsulatedComboViewer.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/providers/EncapsulatedComboViewer.java
@@ -14,7 +14,7 @@ package org.eclipse.papyrus.views.properties.providers;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
+@Deprecated
public class EncapsulatedComboViewer extends ComboViewer {
public EncapsulatedComboViewer(ComboViewer viewer) {
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java
index b248d5733d3..731c78a5691 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java
@@ -47,17 +47,21 @@ public class ConstraintFactory {
*/
public Constraint createFromModel(ConstraintDescriptor model) {
Constraint constraint = null;
- if(model instanceof CompositeConstraint) {
- CompoundConstraint cConstraint = new CompoundConstraint();
- cConstraint.setConstraintDescriptor(model);
- for(SimpleConstraint descriptor : ((CompositeConstraint)model).getConstraints()) {
- Constraint subConstraint = loadConstraint(descriptor);
- cConstraint.addConstraint(subConstraint);
- }
+ try {
+ if(model instanceof CompositeConstraint) {
+ CompoundConstraint cConstraint = new CompoundConstraint();
+ cConstraint.setConstraintDescriptor(model);
+ for(SimpleConstraint descriptor : ((CompositeConstraint)model).getConstraints()) {
+ Constraint subConstraint = loadConstraint(descriptor);
+ cConstraint.addConstraint(subConstraint);
+ }
- constraint = cConstraint;
- } else {
- constraint = loadConstraint((SimpleConstraint)model);
+ constraint = cConstraint;
+ } else {
+ constraint = loadConstraint((SimpleConstraint)model);
+ }
+ } catch (Exception ex) {
+ Activator.log.error(ex);
}
return constraint;
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/EnumCombo.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/EnumCombo.java
index 7dffabede92..2264781720d 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/EnumCombo.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/EnumCombo.java
@@ -11,6 +11,11 @@
*****************************************************************************/
package org.eclipse.papyrus.views.properties.widgets;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.HierarchicToFlatContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.TreeToFlatContentProvider;
import org.eclipse.swt.widgets.Composite;
/**
@@ -49,6 +54,15 @@ public class EnumCombo extends AbstractPropertyEditor {
*/
@Override
protected void doBinding() {
+
+ IStaticContentProvider provider = input.getContentProvider(propertyPath);
+
+ if(provider instanceof IHierarchicContentProvider) {
+ provider = new HierarchicToFlatContentProvider((IHierarchicContentProvider)provider);
+ } else if(provider instanceof ITreeContentProvider) {
+ provider = new TreeToFlatContentProvider((ITreeContentProvider)provider);
+ }
+
enumCombo.setProviders(input.getContentProvider(propertyPath), input.getLabelProvider(propertyPath));
enumCombo.setUnsettable(!input.isMandatory(propertyPath));
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ReferenceCombo.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ReferenceCombo.java
index a2d07345189..ade41f32ead 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ReferenceCombo.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ReferenceCombo.java
@@ -17,7 +17,6 @@ import org.eclipse.papyrus.infra.widgets.providers.HierarchicToFlatContentProvid
import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.TreeToFlatContentProvider;
-import org.eclipse.papyrus.views.properties.providers.EncapsulatedComboViewer;
import org.eclipse.swt.widgets.Composite;
/**
@@ -52,10 +51,10 @@ public class ReferenceCombo extends AbstractPropertyEditor {
IStaticContentProvider contentProvider = input.getContentProvider(propertyPath);
if(contentProvider instanceof IHierarchicContentProvider) {
contentProvider = new HierarchicToFlatContentProvider((IHierarchicContentProvider)contentProvider);
- combo.setViewer(new EncapsulatedComboViewer(combo.getViewer()));
+ //combo.setViewer(new EncapsulatedComboViewer(combo.getViewer()));
} else if(contentProvider instanceof ITreeContentProvider) {
contentProvider = new TreeToFlatContentProvider((ITreeContentProvider)contentProvider);
- combo.setViewer(new EncapsulatedComboViewer(combo.getViewer()));
+ //combo.setViewer(new EncapsulatedComboViewer(combo.getViewer()));
}
ILabelProvider labelProvider = input.getLabelProvider(propertyPath);

Back to the top