diff options
Diffstat (limited to 'plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org')
13 files changed, 141 insertions, 285 deletions
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/Activator.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/Activator.java index e5fd501bc61..3fe63a6b332 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/Activator.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/Activator.java @@ -4,7 +4,6 @@ package org.eclipse.papyrus.uml.modelexplorer;
import org.eclipse.emf.ecore.EValidator;
-import org.eclipse.emf.facet.infra.facet.validation.EValidatorAdapter;
import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.uml2.uml.UMLPackage;
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/factory/ModelElementItemFactory.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/factory/ModelElementItemFactory.java index 97329bd4545..5cd026de12e 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/factory/ModelElementItemFactory.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/factory/ModelElementItemFactory.java @@ -3,22 +3,16 @@ */
package org.eclipse.papyrus.uml.modelexplorer.factory;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
public class ModelElementItemFactory implements IAdapterFactory {
public Object getAdapter(Object adaptableObject, Class adapterType) {
- if(adaptableObject instanceof IAdaptable) {
- EObject eobject = (EObject)((IAdaptable)adaptableObject).getAdapter(EObject.class);
- if(adapterType.isInstance(eobject)) {
+ EObject eobject = EMFHelper.getEObject(adaptableObject);
return eobject;
- }
- }
- // TODO Auto-generated method stub
- return null;
}
public Class<?>[] getAdapterList() {
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerHandler.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerHandler.java index 0018675c9fd..265e4ca5643 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerHandler.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerHandler.java @@ -19,9 +19,10 @@ import java.util.List; import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
-import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
import org.eclipse.papyrus.views.modelexplorer.Activator;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.swt.widgets.Event;
@@ -54,25 +55,30 @@ public class ToggleAdvancedModelExplorerHandler extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException {
- //State state = event.getCommand().getState("org.eclipse.papyrus.uml.modelexplorer.customization.advanced.state");
-
-
- CustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
+ ICustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
if(customizationManager != null) {
if(event.getTrigger() instanceof Event) {
if(((Event)event.getTrigger()).widget instanceof ToolItem) {
ToolItem item = (ToolItem)((Event)event.getTrigger()).widget;
+ ICustomizationCatalogManager customCatalog = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(customizationManager.getResourceSet());
+ Customization simpleUMLCustomization = null;
+
+ //look for SIMPLE UML Customization
+ for(Customization customization : customCatalog.getRegisteredCustomizations()) {
+ if(SIMPLE_UML_CUSTOMIZATION.equals(customization.getName())){
+ simpleUMLCustomization= customization;
+ }
+ }
- MetamodelView simpleUMLCustomization = CustomizationsCatalog.getInstance().getCustomization(SIMPLE_UML_CUSTOMIZATION);
if(simpleUMLCustomization != null) {
if(item.getSelection()) {
//Advanced view
- List<MetamodelView> registeredCustomizations = new LinkedList<MetamodelView>(customizationManager.getRegisteredCustomizations());
+ List<Customization> registeredCustomizations = new LinkedList<Customization>(customizationManager.getManagedCustomizations());
if(registeredCustomizations.remove(simpleUMLCustomization)) {
- customizationManager.clearCustomizations();
- for(MetamodelView customization : registeredCustomizations) {
- customizationManager.registerCustomization(customization);
+ customizationManager.getManagedCustomizations().clear();
+ for(Customization customization : registeredCustomizations) {
+ customizationManager.getManagedCustomizations().add(customization);
}
} else {
//No change
@@ -81,14 +87,13 @@ public class ToggleAdvancedModelExplorerHandler extends AbstractHandler { } else {
//Simple view
- if(customizationManager.getRegisteredCustomizations().contains(simpleUMLCustomization)) {
+ if(customizationManager.getManagedCustomizations().contains(simpleUMLCustomization)) {
return null; //No change
}
- customizationManager.registerCustomization(simpleUMLCustomization);
+ customizationManager.getManagedCustomizations().add(0,simpleUMLCustomization);
}
- customizationManager.loadCustomizations();
//Save the current state of the customizations
org.eclipse.papyrus.infra.emf.Activator.getDefault().saveCustomizationManagerState();
}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerState.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerState.java index 6926348ec69..809c40cd80f 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerState.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/handler/ToggleAdvancedModelExplorerState.java @@ -14,9 +14,10 @@ package org.eclipse.papyrus.uml.modelexplorer.handler;
import org.eclipse.core.commands.State;
-import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
-import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
import org.eclipse.papyrus.views.modelexplorer.Activator;
/**
@@ -33,19 +34,28 @@ public class ToggleAdvancedModelExplorerState extends State { @Override
public Boolean getValue() {
- MetamodelView simpleUMLCustomization = CustomizationsCatalog.getInstance().getCustomization(ToggleAdvancedModelExplorerHandler.SIMPLE_UML_CUSTOMIZATION);
+ ICustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
+ ICustomizationCatalogManager customCatalog = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(customizationManager.getResourceSet());
+ Customization simpleUMLCustomization = null;
+
+ //look for SIMPLE UML Customization
+ for(Customization customization : customCatalog.getRegisteredCustomizations()) {
+ if(ToggleAdvancedModelExplorerHandler.SIMPLE_UML_CUSTOMIZATION.equals(customization.getName())){
+ simpleUMLCustomization= customization;
+ }
+ }
+
if(simpleUMLCustomization == null) {
//The SimpleUML Customization doesn't exist. The advanced mode is activated
return true;
}
- CustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
if(customizationManager == null) {
//Should not happen, this is a singleton
return false;
}
-
- return !customizationManager.getRegisteredCustomizations().contains(simpleUMLCustomization);
+ return false;
+ //return !customizationManager.getRegisteredCustomizations().contains(simpleUMLCustomization);
}
}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/DisplayUMLStructuralFeature.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/DisplayUMLStructuralFeature.java new file mode 100644 index 00000000000..7bbf381e588 --- /dev/null +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/DisplayUMLStructuralFeature.java @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright (c) 2013 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) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.modelexplorer.queries; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.papyrus.views.modelexplorer.queries.IsContainmentStructuralFeature; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.UMLPackage; +/** + * this query is used to return false, if the given object is a references that is not containment or if it is a attribute. + * it return true if the the feature is also a facetReferences + * + */ +public class DisplayUMLStructuralFeature extends IsContainmentStructuralFeature implements IJavaQuery2<EObject, Boolean> { + public Boolean evaluate(final EObject context, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + ParameterValue parameterValue= (ParameterValue)parameterValues.getParameterValueByName("eStructuralFeature"); + EStructuralFeature eStructuralFeature=(EStructuralFeature)parameterValue.getValue(); + // This is an UML element? + if(context instanceof Element){ + + + //the eStructure is a containmentReference or Facet Reference? + if(eStructuralFeature instanceof EReference){ + if(UMLPackage.eINSTANCE.getPackageImport_ImportedPackage().equals(eStructuralFeature)){ + return true; + } + if(UMLPackage.eINSTANCE.getElementImport_ImportedElement().equals(eStructuralFeature)){ + return true; + } + if(UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(eStructuralFeature)){ + return false; + } + if(UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(eStructuralFeature)){ + return false; + } + if(UMLPackage.eINSTANCE.getPackage_ProfileApplication().equals(eStructuralFeature)){ + return false; + } + if(UMLPackage.eINSTANCE.getBehavior_Postcondition().equals(eStructuralFeature)){ + return false; + } + if(UMLPackage.eINSTANCE.getBehavior_Precondition().equals(eStructuralFeature)){ + return false; + } + if(UMLPackage.eINSTANCE.getOperation_BodyCondition().equals(eStructuralFeature)){ + return false; + } + } + + } + return super.evaluate(context, parameterValues, facetManager); + } +}
\ No newline at end of file diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexName.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexName.java index a7db6897f64..4623ad5a8c1 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexName.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetComplexName.java @@ -5,28 +5,33 @@ package org.eclipse.papyrus.uml.modelexplorer.queries; import java.util.List; -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.Stereotype; /** get the name + the list of applied stereotypes */ -public class GetComplexName implements IJavaModelQuery<NamedElement, String> { +public class GetComplexName implements IJavaQuery2<NamedElement, String> { /** left Stereotype delimiters ('Guillemets francais'). */ public static String ST_LEFT = String.valueOf("\u00AB"); //$NON-NLS-1$ /** Right Stereotype delimiters ('Guillemets francais'). */ public static String ST_RIGHT = String.valueOf("\u00BB"); //$NON-NLS-1$ - public String evaluate(final NamedElement context, - final ParameterValueList parameterValues) - throws ModelQueryExecutionException { - // TODO Auto-generated method stub + + public String evaluate(NamedElement source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException { + ParameterValue parameterValue= (ParameterValue)parameterValues.getParameterValueByName("eObject"); + if(parameterValue.getValue() instanceof EStructuralFeature){ + return ((EStructuralFeature)parameterValue.getValue()).getName(); + } String txt = ""; //$NON-NLS-1$ - List<Stereotype> stereoList = context.getAppliedStereotypes(); + List<Stereotype> stereoList = source.getAppliedStereotypes(); if (stereoList.size() == 0) { - return context.getName(); + return source.getName(); } else { for (int i = 0; i < stereoList.size(); i++) { txt = txt + stereoList.get(i).getName(); @@ -34,7 +39,7 @@ public class GetComplexName implements IJavaModelQuery<NamedElement, String> { txt = txt + ", "; //$NON-NLS-1$ } } - txt = ST_LEFT + txt + ST_RIGHT + " " + context.getName(); //$NON-NLS-1$ + txt = ST_LEFT + txt + ST_RIGHT + " " + source.getName(); //$NON-NLS-1$ return txt; } } diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java deleted file mode 100644 index 7354ad1f1c6..00000000000 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetContainedDiagrams.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2011 Atos. - * - * 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: - * Atos - Initial API and implementation - * - */ -package org.eclipse.papyrus.uml.modelexplorer.queries; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils; -import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery; -import org.eclipse.uml2.uml.Element; - -/** - * Get the collection of all contained diagrams - * FIXME : delete this class when the bug EMF-Facet 365744 will be corrected! - * - * @Deprecated : use oep.infra.gmfdiag.modelexplorer#queries.GetContainedDiagrams - */ -@Deprecated -public class GetContainedDiagrams extends AbstractEditorContainerQuery implements IJavaModelQuery<Element, Collection<org.eclipse.gmf.runtime.notation.Diagram>> { - - public Collection<Diagram> evaluate(final Element context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { - List<Diagram> result = new ArrayList<Diagram>(); - Iterator<EObject> roots = NavigatorUtils.getNotationRoots(context); - if(roots == null) { - return result; - } - - while(roots.hasNext()) { - EObject root = roots.next(); - if(root instanceof Diagram) { - if(EcoreUtil.equals(((Diagram)root).getElement(), context)) { - result.add((Diagram)root); - } - } - } - return result; - } -} diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetDiagramIcon.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetDiagramIcon.java deleted file mode 100644 index 296d5eb3eb5..00000000000 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetDiagramIcon.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2011 Atos. - * - * 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: - * Atos - Initial API and implementation - * - */ -package org.eclipse.papyrus.uml.modelexplorer.queries; - -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.views.modelexplorer.queries.AbstractGetEditorIconQuery; - -/** - * Return the path to the icon of the corresponding diagram * FIXME : delete this class when the bug EMF-Facet 365744 will be corrected! - * - * @Deprecated : use oep.infra.gmfdiag.modelexplorer#queries.GetDiagramIcon - */ -@Deprecated -public class GetDiagramIcon extends AbstractGetEditorIconQuery implements IJavaModelQuery<Diagram, String> { - - public String evaluate(final Diagram context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { - return "/" + getEditorRegistry(context).getEditorURLIcon(context); //$NON-NLS-1$ - } -} diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetName.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetName.java deleted file mode 100644 index 78f63761749..00000000000 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/GetName.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * - */ -package org.eclipse.papyrus.uml.modelexplorer.queries; -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; -import org.eclipse.uml2.uml.NamedElement; - -/** get the name + the list of stereotypes from a named Element */ -public class GetName implements IJavaModelQuery<NamedElement, String> { - public String evaluate(final NamedElement context, final ParameterValueList parameterValues) - throws ModelQueryExecutionException { - // TODO Auto-generated method stub - return context.getName(); - } -} diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagram.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagram.java deleted file mode 100644 index 2caeceaa3d6..00000000000 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagram.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2011 Atos. - * - * 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: - * Atos - Initial API and implementation - * - */ -package org.eclipse.papyrus.uml.modelexplorer.queries; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException; -import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery; -import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList; -import org.eclipse.gmf.runtime.notation.Diagram; - -/** - * Return tru eif the element is a diagram * FIXME : delete this class when the bug EMF-Facet 365744 will be corrected! - * - * @Deprecated : use oep.infra.gmfdiag.modelexplorer#queries.IsDiagram - */ -@Deprecated -public class IsDiagram implements IJavaModelQuery<EObject, Boolean> { - - public Boolean evaluate(final EObject context, final ParameterValueList parameterValues) throws ModelQueryExecutionException { - - return context instanceof Diagram; - } -} diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java deleted file mode 100644 index 09086c714b5..00000000000 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsDiagramContainer.java +++ /dev/null @@ -1,51 +0,0 @@ -/**
- * Copyright (c) 2011 Atos.
- *
- * 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:
- * Atos - Initial API and implementation
- *
- */
-package org.eclipse.papyrus.uml.modelexplorer.queries;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
-import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
-import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
-import org.eclipse.papyrus.views.modelexplorer.queries.AbstractEditorContainerQuery;
-
-/**
- * FIXME : delete this class when the bug EMF-Facet 365744 will be corrected!
- *
- * @Deprecated : use oep.infra.gmfdiag.modelexplorer#queries.IsDiagramContainer
- */
-@Deprecated
-public class IsDiagramContainer extends AbstractEditorContainerQuery implements IJavaModelQuery<EObject, Boolean> {
-
-
- public Boolean evaluate(final EObject context, ParameterValueList parameterValues) throws ModelQueryExecutionException {
- Iterator<EObject> roots = NavigatorUtils.getNotationRoots(context);
- if(roots == null) {
- return false;
- }
-
- while(roots.hasNext()) {
- EObject root = roots.next();
- if(root instanceof Diagram) {
- if(EcoreUtil.equals(((Diagram)root).getElement(), context)) {
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsReadOnly.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsReadOnly.java deleted file mode 100644 index 68067243454..00000000000 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/queries/IsReadOnly.java +++ /dev/null @@ -1,43 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2011 Atos.
- *
- *
- * 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:
- * Atos - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.modelexplorer.queries;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
-import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
-import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
-
-/**
- * Create a query which will return true if the ressource is in read only mode.
- *
- * @author "Arthur Daussy <a href="mailto:arthur.daussy@atos.net">arthur.daussy@atos.net</a>"
- * FIXME : delete this class when the bug EMF-Facet 365744 will be corrected!
- * @deprecated use org.eclipse.papyrus.views.modelexploer#queries.IsReadOnly
- */
-@Deprecated
-public class IsReadOnly implements IJavaModelQuery<EObject, Boolean> {
-
- public Boolean evaluate(EObject context, ParameterValueList parameterValues) throws ModelQueryExecutionException {
- EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(context);
- if(editingDomain != null) {
- if(editingDomain.isReadOnly(context.eResource())) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/util/ModelExplorerUtils.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/util/ModelExplorerUtils.java index b3d9b140921..4bdaec2a680 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/util/ModelExplorerUtils.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/util/ModelExplorerUtils.java @@ -14,8 +14,9 @@ package org.eclipse.papyrus.uml.modelexplorer.util; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.service.types.utils.CommandContext;
import org.eclipse.papyrus.uml.service.types.utils.ICommandContext;
import org.eclipse.ui.IWorkbenchWindow;
@@ -53,19 +54,17 @@ public class ModelExplorerUtils { EObject container = null;
EReference reference = null;
- if(selection instanceof IAdaptable) {
- container = (EObject)((IAdaptable)selection).getAdapter(EObject.class);
+ container = EMFHelper.getEObject(selection);
- if(container == null) {
- reference = (EReference)((IAdaptable)selection).getAdapter(EReference.class);
+ if(container == null) {
+ reference = (EReference)((IAdaptable)selection).getAdapter(EReference.class);
- // The following part introduce a dependency to EMF Facet.
- // Although the selection can be adapted to EReference, the link parent is required but
- // no API allows to get this element except LinkItem or ITreeElement.
- if((reference != null) && (selection instanceof LinkItem)) {
- container = ((LinkItem)selection).getParent();
- }
+ // The following part introduce a dependency to EMF Facet.
+ // Although the selection can be adapted to EReference, the link parent is required but
+ // no API allows to get this element except LinkItem or ITreeElement.
+ if((reference != null) && (selection instanceof EReferenceTreeElement )) {
+ container = ((EReferenceTreeElement)selection).getParent();
}
}
|