- Disable (remove from build) import module
- Add new ContentProvider
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/plugin.xml b/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/plugin.xml
index 19dd433..183c2f4 100644
--- a/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/plugin.xml
+++ b/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/plugin.xml
@@ -11,122 +11,6 @@
realization="org.polarsys.esf.core.diagram.esfarchitectureconcepts.listener.ESFModelListener">
</listener>
</extension>
-
- <extension point="org.eclipse.ui.handlers">
- <handler
- class="org.polarsys.esf.core.diagram.esfarchitectureconcepts.handler.CreateESFArchitectureConceptsDiagramHandler"
- commandId="org.polarsys.esf.core.diagram.esfarchitectureconcepts.editPart.creationCommand">
- <activeWhen>
- <with variable="selection">
- <test
- property="org.polarsys.esf.core.diagram.esfarchitectureconcepts.propertyTester.isSBlockOrSPart"
- value="true">
- </test>
- </with>
- </activeWhen>
- </handler>
-
- <handler
- class="org.polarsys.esf.core.diagram.esfarchitectureconcepts.handler.CreateESFArchitectureConceptsDiagramHandler"
- commandId="org.polarsys.esf.core.diagram.esfarchitectureconcepts.modelExplorer.creationCommand">
- <activeWhen>
- <and>
- <with variable="selection">
- <iterate>
- <adapt
- type="org.eclipse.emf.ecore.EObject">
- <or>
- <instanceof
- value="org.eclipse.uml2.uml.Property">
- </instanceof>
- <instanceof
- value="org.eclipse.uml2.uml.Class">
- </instanceof>
- </or>
- </adapt>
- </iterate>
- </with>
- <count
- value="1">
- </count>
- </and>
- </activeWhen>
- </handler>
- </extension>
-
- <extension point="org.eclipse.ui.commands">
- <command
- description="%menucontext.diagram.esfarchitectureconcepts.creation.description"
- id="org.polarsys.esf.core.diagram.esfarchitectureconcepts.editPart.creationCommand"
- name="%menucontext.diagram.esfarchitectureconcepts.creation.label">
- </command>
- <command
- description="%menucontext.diagram.esfarchitectureconcepts.creation.description"
- id="org.polarsys.esf.core.diagram.esfarchitectureconcepts.modelExplorer.creationCommand"
- name="%menucontext.diagram.esfarchitectureconcepts.creation.label">
- </command>
- </extension>
- <extension point="org.eclipse.ui.commandImages">
- <image
- commandId="org.polarsys.esf.core.diagram.esfarchitectureconcepts.editPart.creationCommand"
- icon="src/main/resources/icons/icon_diagram_ architectureconcepts.png">
- </image>
- <image
- commandId="org.polarsys.esf.core.diagram.esfarchitectureconcepts.modelExplorer.creationCommand"
- icon="src/main/resources/icons/icon_diagram_ architectureconcepts.png">
- </image>
- </extension>
-
- <extension point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu?after=filtersMenu">
- <command
- commandId="org.polarsys.esf.core.diagram.esfarchitectureconcepts.editPart.creationCommand"
- icon="src/main/resources/icons/icon_diagram_ architectureconcepts.png"
- label="%menucontext.diagram.esfarchitectureconcepts.creation.label"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <and>
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- <with
- variable="selection">
- <test
- property="org.polarsys.esf.core.diagram.esfarchitectureconcepts.propertyTester.isSBlockOrSPart"
- value="true">
- </test>
- </with>
- </and>
- </visibleWhen>
- </command>
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?before=esf.general.bottom">
- <command
- commandId="org.polarsys.esf.core.diagram.esfarchitectureconcepts.modelExplorer.creationCommand"
- icon="src/main/resources/icons/icon_diagram_ architectureconcepts.png"
- label="%menucontext.diagram.esfarchitectureconcepts.creation.label"
- style="push">
- </command>
- </menuContribution>
- </extension>
-
- <extension point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.polarsys.esf.core.diagram.esfarchitectureconcepts.tester.ESFArchitectureConceptsDiagramTester"
- id="org.polarsys.esf.core.diagram.esfarchitectureconcepts.propertyTester"
- namespace="org.polarsys.esf.core.diagram.esfarchitectureconcepts.propertyTester"
- properties="isSBlockOrSPart"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- </extension>
<extension point="org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration">
<elementTypeSet
diff --git a/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/src/main/java/org/polarsys/esf/core/diagram/esfarchitectureconcepts/handler/CreateESFArchitectureConceptsDiagramHandler.java b/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/src/main/java/org/polarsys/esf/core/diagram/esfarchitectureconcepts/handler/CreateESFArchitectureConceptsDiagramHandler.java
deleted file mode 100644
index 8c2f9ff..0000000
--- a/core/diagram/org.polarsys.esf.core.diagram.esfarchitectureconcepts/src/main/java/org/polarsys/esf/core/diagram/esfarchitectureconcepts/handler/CreateESFArchitectureConceptsDiagramHandler.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.diagram.esfarchitectureconcepts.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.util.UMLUtil;
-import org.polarsys.esf.core.diagram.esfarchitectureconcepts.util.ESFArchitectureConceptsDiagramUtil;
-import org.polarsys.esf.core.utils.ModelUtil;
-import org.polarsys.esf.esfarchitectureconcepts.ISBlock;
-import org.polarsys.esf.esfarchitectureconcepts.ISPart;
-
-/**
- * Handler class for the creation of the ESF Architecture Concepts Diagram.
- *
- * @author $Author: ymunoz $
- * @version $Revision: 168 $
- */
-public class CreateESFArchitectureConceptsDiagramHandler
- extends AbstractHandler {
-
- @Override
- public Object execute(ExecutionEvent pEvent) throws ExecutionException {
- ISelection vSelection = HandlerUtil.getCurrentSelection(pEvent);
-
- // get the Property selected by the user
- final Property vSelectedProperty =
- (Property) ModelUtil.getSelectedEObjectOfType(vSelection, UMLPackage.eINSTANCE.getProperty());
-
- // check if the selected property exists
- if (vSelectedProperty != null) {
- // check if property is stereotyped SPart
- if (UMLUtil.getStereotypeApplication(vSelectedProperty, ISPart.class) != null) {
- // get its type
- Class vType = (Class) (vSelectedProperty.getType());
- // check if its type is stereotyped SBlock
- if ((vType != null) && (UMLUtil.getStereotypeApplication(vType, ISBlock.class) != null)) {
- TransactionalEditingDomain vDomain = ModelUtil.getTransactionalEditingDomain(vType);
-
- // create ESF Architecture Concepts Diagram in type
- ESFArchitectureConceptsDiagramUtil.createDiagram(vType, vDomain);
- }
- }
- } else {
- // get the Class selected by the user
- final Class vSelectedClass =
- (Class) ModelUtil.getSelectedEObjectOfType(vSelection, UMLPackage.eINSTANCE.getClass_());
-
- // check if the selected class exists
- if (vSelectedClass != null) {
- // check if class is stereotyped SBlock
- if (UMLUtil.getStereotypeApplication(vSelectedClass, ISBlock.class) != null) {
- TransactionalEditingDomain vDomain = ModelUtil.getTransactionalEditingDomain(vSelectedClass);
-
- // create ESF Architecture Concepts Diagram
- ESFArchitectureConceptsDiagramUtil.createDiagram(vSelectedClass, vDomain);
- }
- }
- }
-
- return null;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF b/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF
index 257ff8f..08aa58d 100644
--- a/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF
+++ b/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF
@@ -12,7 +12,8 @@
org.eclipse.ui.ide;bundle-version="3.11.0",
org.eclipse.ui.navigator.resources;bundle-version="3.4.700",
org.eclipse.ui.navigator;bundle-version="3.5.400",
- org.eclipse.uml2.uml;bundle-version="5.1.0"
+ org.eclipse.uml2.uml;bundle-version="5.1.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="3.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Localization: src/main/resources/properties/plugin
Bundle-ActivationPolicy: lazy
@@ -26,6 +27,7 @@
org.polarsys.esf.core.common.ui.fieldeditor,
org.polarsys.esf.core.common.ui.filter,
org.polarsys.esf.core.common.ui.job,
+ org.polarsys.esf.core.common.ui.provider,
org.polarsys.esf.core.common.ui.selection,
org.polarsys.esf.core.common.ui.statusline,
org.polarsys.esf.core.common.ui.treeviewer,
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/provider/ESFContentProvider.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/provider/ESFContentProvider.java
new file mode 100644
index 0000000..f40af8e
--- /dev/null
+++ b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/provider/ESFContentProvider.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2016 ALL4TEC & CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ALL4TEC & CEA LIST - initial API and implementation
+ ******************************************************************************/
+
+package org.polarsys.esf.core.common.ui.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.resource.UMLResource;
+
+/**
+ * Similar to Papyrus MetaClassContentProvider: filter elements based on wanted meta-classes
+ * but only navigate to packages, if there is a
+ * dependency to it.
+ *
+ * TODO: move to Papyrus core (Similar code in UCM and Papyrus4Robotics
+ *
+ */
+public class ESFContentProvider extends AbstractStaticContentProvider implements IStaticContentProvider {
+
+ public ESFContentProvider(Package rootPkg, EClass metaClass) {
+ this.rootPkg = rootPkg;
+ this.metaClass = metaClass;
+ }
+
+ protected Package rootPkg;
+
+ protected EClass metaClass;
+
+ @Override
+ public Object[] getElements() {
+ List<Element> results = new ArrayList<Element>();
+ List<Package> visitedPkgs = new ArrayList<Package>();
+ if (rootPkg.eResource() != null) {
+ // search in all resources, see Bug 522365 ... definition list is empty
+ ResourceSet rs = rootPkg.eResource().getResourceSet();
+ for (Resource resource : rs.getResources()) {
+ if (resource instanceof UMLResource) {
+ if (resource.getContents().size() > 0) {
+ EObject topLevelElem = resource.getContents().get(0);
+ // look into packages, but not profiles
+ if (topLevelElem instanceof Package && !(topLevelElem instanceof Profile)) {
+ getElements(rootPkg, results, visitedPkgs);
+ }
+ }
+ }
+ }
+ }
+ else {
+ getElements(rootPkg, results, visitedPkgs);
+ }
+ return results.toArray();
+ }
+
+ public void getElements(Package pkg, List<Element> results, List<Package> visitedPkgs) {
+ if (!visitedPkgs.contains(pkg)) {
+ visitedPkgs.add(pkg);
+ for (Element el : pkg.getPackagedElements()) {
+ if (el instanceof Dependency) {
+ Dependency dep = (Dependency) el;
+ if (dep.getTargets().size() > 0 && (dep.getTargets().get(0) instanceof Package)) {
+ getElements((Package) dep.getTargets().get(0), results, visitedPkgs);
+ }
+ }
+ if (el instanceof Package) {
+ getElements((Package) el, results, visitedPkgs);
+ }
+ if (metaClass.isInstance(el)) {
+ results.add(el);
+ }
+ }
+ }
+ }
+
+ Class<? extends EObject> stereoApp;
+}
diff --git a/core/pom.xml b/core/pom.xml
index 07ecdf2..81a8576 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@
<!-- MODULES -->
<modules>
<module>diagram</module>
- <module>importmodel</module>
+ <!-- <module>importmodel</module> -->
<module>metamodel</module>
<module>profile</module>
<module>releng</module>
diff --git a/core/profile/pom.xml b/core/profile/pom.xml
index 483eda3..096e22a 100644
--- a/core/profile/pom.xml
+++ b/core/profile/pom.xml
@@ -22,11 +22,11 @@
<modules>
<module>org.polarsys.esf.core.profile.esfarchitectureconcepts</module>
<module>org.polarsys.esf.core.profile.esfarchitectureconcepts.tests</module>
- <module>org.polarsys.esf.core.profile.esfarchitectureconcepts.application</module>
+ <!-- <module>org.polarsys.esf.core.profile.esfarchitectureconcepts.application</module> -->
<module>org.polarsys.esf.core.profile.esfbehaviours</module>
<module>org.polarsys.esf.core.profile.esfcore</module>
<module>org.polarsys.esf.core.profile.esfproperties</module>
<module>org.polarsys.esf.core.profile.esfsafetyconcepts</module>
</modules>
-</project>
\ No newline at end of file
+</project>