diff options
author | Maged Elaasar | 2018-06-20 11:53:45 +0000 |
---|---|---|
committer | Benoit Maggi | 2018-06-21 09:05:56 +0000 |
commit | a5939d660d706c1cc5cf86083981d67e0219c5b9 (patch) | |
tree | dc1f0631bba37052b9280bccdd28e4be73a6b632 /plugins/uml/architecture/org.eclipse.papyrus.uml.architecture | |
parent | 345623c30ee1d457eb85ddf3deba5d81e61500de (diff) | |
download | org.eclipse.papyrus-a5939d660d706c1cc5cf86083981d67e0219c5b9.tar.gz org.eclipse.papyrus-a5939d660d706c1cc5cf86083981d67e0219c5b9.tar.xz org.eclipse.papyrus-a5939d660d706c1cc5cf86083981d67e0219c5b9.zip |
Bug 536083 - [AFViewpoints] Provide conversion to UML
- Support converting a model from an arbitrary context to the UML
language context
- add test to validate the uml.architecture model
Change-Id: I0a9f45879229e368f6b8cb0925e54697ab1edf06
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Signed-off-by: Maged Elaasar <melaasar@gmail.com>
Diffstat (limited to 'plugins/uml/architecture/org.eclipse.papyrus.uml.architecture')
6 files changed, 340 insertions, 3 deletions
diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF index d26afe76fb7..08634649801 100755 --- a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF @@ -35,7 +35,11 @@ Require-Bundle: org.eclipse.papyrus.uml.service.types;bundle-version="[4.0.0,5.0 org.eclipse.papyrus.infra.architecture;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.architecture.representation;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.nattable.representation;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.infra.gmfdiag.representation;bundle-version="[2.0.0,3.0.0)" -Export-Package: org.eclipse.papyrus.uml.architecture + org.eclipse.papyrus.infra.gmfdiag.representation;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.gmfdiag.style;bundle-version="[2.0.0,3.0.0)" +Export-Package: org.eclipse.papyrus.uml.architecture, + org.eclipse.papyrus.uml.architecture.commands, + org.eclipse.papyrus.uml.architecture.internal;x-internal:=true, + org.eclipse.papyrus.uml.architecture.migration Bundle-Vendor: %providerName Automatic-Module-Name: org.eclipse.papyrus.uml.architecture diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/model/uml.architecture b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/model/uml.architecture index 10d37da44ce..c70b0f40d92 100644 --- a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/model/uml.architecture +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/model/uml.architecture @@ -6,7 +6,7 @@ <concerns xmi:type="architecture:Concern" xmi:id="_HQhf4sSYEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.softwareEngineering.useCases" name="Use Cases" description="The concern of defining the system's use cases"/> <concerns xmi:type="architecture:Concern" xmi:id="_HQhf48SYEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.softwareEngineering.structure" name="Structure" description="The concern of developing the system's structure"/> <concerns xmi:type="architecture:Concern" xmi:id="_HQhf5MSYEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.softwareEngineering.behavior" name="Behavior" description="The concern of developing the system's behavior"/> - <contexts xmi:type="architecture:ArchitectureDescriptionLanguage" xmi:id="_HQhf5cSYEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.infra.services.edit.TypeContext" name="UML" description="The Unified Modeling Language" icon="platform:/plugin/org.eclipse.papyrus.uml.architecture/icons/uml.gif" creationCommandClass="org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand"> + <contexts xmi:type="architecture:ArchitectureDescriptionLanguage" xmi:id="_HQhf5cSYEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.infra.services.edit.TypeContext" name="UML" description="The Unified Modeling Language" icon="platform:/plugin/org.eclipse.papyrus.uml.architecture/icons/uml.gif" creationCommandClass="org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand" conversionCommandClass="org.eclipse.papyrus.uml.architecture.commands.UMLModelConversionCommand"> <viewpoints xmi:type="architecture:ArchitectureViewpoint" xmi:id="_HQhf5sSYEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.uml.analysis" name="Software Analysis" description="A viewpoint allowing software analysis with UML" icon="platform:/plugin/org.eclipse.papyrus.uml.architecture/icons/viewpoint.gif" representationKinds="_yeY0sHDvEeWh-MssWmCB_A _zzf4gHDtEeWh-MssWmCB_A _zzf4cXDtEeWh-MssWmCB_A _P3J1cEb7EeRVGbM3cmVSqQ _Uz8agHDcEeWh-MssWmCB_A _P3J1cEa7EeSVGbM3cmVSqQ _WC1q0P4UEhSRsNBVzfUrzA _wXztQHDwEwWh-MssWmCB_A _d4-QwCT-EeedRqoTe_1ZiA"/> <viewpoints xmi:type="architecture:ArchitectureViewpoint" xmi:id="_OOrIUMSZEeaKZJ_pGfaSiA" id="org.eclipse.papyrus.uml.design" name="Software Design" description="A viewpoint allowing software design with UML" icon="platform:/plugin/org.eclipse.papyrus.uml.architecture/icons/viewpoint.gif" representationKinds="_UzcgsHDtEeWh-MssWmCB_A _zzf4gHDtEeWh-MssWmCB_A _jRtroHDuEeWh-MssWmCB_A _fa4kAHDuEeWh-MssWmCB_A _fa4kBHDuEeWh-MssWmCB_A _bKiwMHDuEeWh-MssWmCB_A _bKiwNHDuEeWh-MssWmCB_A _ARGokHDuEeWh-MssWmCB_A _zzf4YHDtEeWh-MssWmCB_A _FuMjYHDuEeWh-MssWmCB_A _zzf4cXDtEeWh-MssWmCB_A _TR15IHDvEeWh-MssWmCB_A _PwD0cHDvEeWh-MssWmCB_A _LzyMIHDvEeWh-MssWmCB_A _P3J1cEb7EeRVGbM3cmVSqQ _Uz8agHDcEeWh-MssWmCB_A _P3J1cEa7EeSVGbM3cmVSqQ _WC1q0P4UEhSRsNBVzfUrzA _wXztQHDwEwWh-MssWmCB_A _d4-QwCT-EeedRqoTe_1ZiA"/> <elementTypes xmi:type="elementtypesconfigurations:ElementTypeSetConfiguration" href="platform:/plugin/org.eclipse.papyrus.infra.emf/model/infra-emf.elementtypesconfigurations#_rWI4YHPzEeSnGJwaJWHCSg"/> diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLDiagramKinds.java b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLDiagramKinds.java new file mode 100644 index 00000000000..9ba426828f1 --- /dev/null +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLDiagramKinds.java @@ -0,0 +1,54 @@ +/***************************************************************************** + * Copyright (c) 2018 Maged Elaasar, CEA LIST and others. + * + * 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: + * Maged Elaasar - Initial API and Implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.architecture; + +/** + * The kinds of UML diagrams in the UML Architecture Language + * + */ +public interface UMLDiagramKinds { + + public static final String ACTIVITY_DIAGRAM ="org.eclipse.papyrus.uml.diagram.activity"; + + public static final String CLASS_DIAGRAM ="org.eclipse.papyrus.uml.diagram.class"; + + public static final String INNER_CLASS_DIAGRAM ="org.eclipse.papyrus.uml.diagram.innerClass"; + + public static final String PACKAGE_DIAGRAM ="org.eclipse.papyrus.uml.diagram.package"; + + public static final String COMMUNICATION_DIAGRAM ="org.eclipse.papyrus.uml.diagram.communication"; + + public static final String COMPONENT_DIAGRAM_IN_COMPONENT ="org.eclipse.papyrus.uml.diagram.component.root.component"; + + public static final String COMPONENT_DIAGRAM_IN_PACKAGE ="org.eclipse.papyrus.uml.diagram.component.root.package"; + + public static final String COMPOSITE_STRUCTURE_DIAGRAM_IN_STRUCTURED_CLASSIFIER ="org.eclipse.papyrus.uml.diagram.compositeStructure.root.structuredClassifier"; + + public static final String COMPOSITE_STRUCTURE_DIAGRAM_IN_PACKAGE ="org.eclipse.papyrus.uml.diagram.compositeStructure.root.package"; + + public static final String DEPLOYMENT_DIAGRAM ="org.eclipse.papyrus.uml.diagram.deployment"; + + public static final String INTERACTION_OVERVIEW_DIAGRAM ="org.eclipse.papyrus.uml.diagram.interactionOverview"; + + public static final String PROFILE_DIAGRAM ="org.eclipse.papyrus.uml.diagram.profile"; + + public static final String SEQUENCE_DIAGRAM ="org.eclipse.papyrus.uml.diagram.sequence"; + + public static final String STATE_MACHINE_DIAGRAM ="org.eclipse.papyrus.uml.diagram.stateMachine"; + + public static final String TIMING_DIAGRAM ="org.eclipse.papyrus.uml.diagram.timing"; + + public static final String USE_CASE_DIAGRAM ="org.eclipse.papyrus.uml.diagram.useCase"; + +} diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLDiagramTypes.java b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLDiagramTypes.java new file mode 100644 index 00000000000..01efdb4ec4b --- /dev/null +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLDiagramTypes.java @@ -0,0 +1,82 @@ +/***************************************************************************** + * Copyright (c) 2018 Maged Elaasar, CEA LIST and others. + * + * 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: + * Maged Elaasar - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.architecture; + +/** + * The type of UML diagrams + * + */ +public interface UMLDiagramTypes { + + /** + * The type of the activity diagram + */ + public static final String ACTIVITY_DIAGRAM = "PapyrusUMLActivityDiagram"; + + /** + * The type of the class diagram + */ + public static final String CLASS_DIAGRAM = "PapyrusUMLClassDiagram"; + + /** + * The type of the communication diagram + */ + public static final String COMMUNICATION_DIAGRAM = "PapyrusUMLCommunicationDiagram"; + + /** + * The type of the component diagram + */ + public static final String COMPONENT_DIAGRAM = "PapyrusUMLComponentDiagram"; + + /** + * The type of the composite structure diagram + */ + public static final String COMPOSITE_STRUCTURE_DIAGRAM = "CompositeStructure"; + + /** + * The type of the deployment diagram + */ + public static final String DEPLOYMENT_DIAGRAM = "PapyrusUMLDeploymentDiagram"; + + /** + * The type of the interaction overview diagram + */ + public static final String INTERACTION_OVERVIEW_DIAGRAM = "PapyrusUMLInteractionOverviewDiagram"; + + /** + * The type of the profile diagram + */ + public static final String PROFILE_DIAGRAM = "PapyrusUMLProfileDiagram"; + + /** + * The type of the sequence diagram + */ + public static final String SEQUENCE_DIAGRAM = "PapyrusUMLSequenceDiagram"; + + /** + * The type of the state machine diagram + */ + public static final String STATE_MACHINE_DIAGRAM = "PapyrusUMLStateMachineDiagram"; + + /** + * The type of the timing diagram + */ + public static final String TIMING_DIAGRAM = "PapyrusUMLTimingDiagram"; + + /** + * The type of the use case diagram + */ + public static final String USE_CASE_DIAGRAM = "UseCase"; + +} diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLTableKinds.java b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLTableKinds.java new file mode 100644 index 00000000000..c9a12ba0d88 --- /dev/null +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/UMLTableKinds.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2018 Maged Elaasar, CEA LIST and others. + * + * 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: + * Maged Elaasar - Initial API and Implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.architecture; + +/** + * The kinds of UML tables in the UML Architecture Language + * + */ +public interface UMLTableKinds { + + public static final String GENERIC_TREE_TABLE = "org.eclipse.papyrus.uml.table.genericTree"; + + public static final String CLASS_TREE_TABLE = "org.eclipse.papyrus.uml.table.classTree"; + + public static final String GENERIC_TABLE = "org.eclipse.papyrus.uml.table.generic"; + + public static final String STEREO_DISPLAY_TREE_TABLE = "org.eclipse.papyrus.uml.table.stereotypeDisplayTree"; + + public static final String VIEW_TABLE = "org.eclipse.papyrus.uml.table.view"; + + public static final String RELATIONSHIP_GENERIC_MATRIX = "org.eclipse.papyrus.uml.table.matrix"; + +} diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/commands/UMLModelConversionCommand.java b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/commands/UMLModelConversionCommand.java new file mode 100644 index 00000000000..1e0c82f1594 --- /dev/null +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/src/org/eclipse/papyrus/uml/architecture/commands/UMLModelConversionCommand.java @@ -0,0 +1,163 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST and others. + * + * 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: + * Maged Elaasar - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.architecture.commands; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.architecture.ArchitectureDomainManager; +import org.eclipse.papyrus.infra.core.architecture.RepresentationKind; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; +import org.eclipse.papyrus.infra.gmfdiag.representation.PapyrusDiagram; +import org.eclipse.papyrus.infra.gmfdiag.style.PapyrusDiagramStyle; +import org.eclipse.papyrus.infra.gmfdiag.style.StyleFactory; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.representation.PapyrusTable; +import org.eclipse.papyrus.uml.architecture.UMLArchitectureContextIds; +import org.eclipse.papyrus.uml.architecture.UMLDiagramKinds; +import org.eclipse.papyrus.uml.architecture.UMLDiagramTypes; +import org.eclipse.papyrus.uml.architecture.UMLTableKinds; +import org.eclipse.papyrus.uml.diagram.common.commands.AbstractModelConversionCommand; +import org.eclipse.uml2.uml.Component; +import org.eclipse.uml2.uml.StructuredClassifier; + +/** + * A command to convert a model from an arbitrary context to the UML language context + */ +public class UMLModelConversionCommand extends AbstractModelConversionCommand { + + /** + * @see org.eclipse.papyrus.uml.diagram.common.commands.ModelConversionCommandBase#doConvertModel(org.eclipse.papyrus.infra.core.resource.ModelSet) + * + * @param modelSet + */ + @Override + public void doConvertModel(ModelSet modelSet) { + final Resource notationResource = NotationUtils.getNotationResource(modelSet); + if (notationResource != null) { + for (EObject eObject : notationResource.getContents()) { + if (eObject instanceof Diagram) + convertDiagram((Diagram)eObject); + else if (eObject instanceof Table) + convertTable((Table)eObject); + } + } + } + + @SuppressWarnings("unchecked") + protected void convertDiagram(Diagram diagram) { + // get the existing diagram kind id if any + String diagramKindId = null; + PapyrusDiagramStyle pvs = DiagramUtils.getPapyrusDiagramStyle(diagram); + if (pvs != null) { + diagramKindId = pvs.getDiagramKindId(); + } + + // return if the existing diagram kind is already in the UML language + if (diagramKindId != null) { + PapyrusDiagram kind = getDiagramKindById(diagramKindId); + if (kind != null && UMLArchitectureContextIds.UML.equals(kind.getLanguage().getId())) { + return; + } + } + + // Choose a UML diagram kind based on the diagram's type (and the diagram's element) + PapyrusDiagram diagramKind = null; + if (UMLDiagramTypes.ACTIVITY_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.ACTIVITY_DIAGRAM); + } else if (UMLDiagramTypes.CLASS_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.CLASS_DIAGRAM); + } else if (UMLDiagramTypes.COMMUNICATION_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.COMMUNICATION_DIAGRAM); + } else if (UMLDiagramTypes.COMPONENT_DIAGRAM.equals(diagram.getType())) { + if (diagram.getElement() instanceof Component) { + diagramKind = getDiagramKindById(UMLDiagramKinds.COMPONENT_DIAGRAM_IN_COMPONENT); + } else if (diagram.getElement() instanceof Package) { + diagramKind = getDiagramKindById(UMLDiagramKinds.COMPONENT_DIAGRAM_IN_PACKAGE); + } + } else if (UMLDiagramTypes.COMPOSITE_STRUCTURE_DIAGRAM.equals(diagram.getType())) { + if (diagram.getElement() instanceof StructuredClassifier) { + diagramKind = getDiagramKindById(UMLDiagramKinds.COMPOSITE_STRUCTURE_DIAGRAM_IN_STRUCTURED_CLASSIFIER); + } else if (diagram.getElement() instanceof Package) { + diagramKind = getDiagramKindById(UMLDiagramKinds.COMPOSITE_STRUCTURE_DIAGRAM_IN_PACKAGE); + } + } else if (UMLDiagramTypes.DEPLOYMENT_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.DEPLOYMENT_DIAGRAM); + } else if (UMLDiagramTypes.INTERACTION_OVERVIEW_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.INTERACTION_OVERVIEW_DIAGRAM); + } else if (UMLDiagramTypes.PROFILE_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.PROFILE_DIAGRAM); + } else if (UMLDiagramTypes.SEQUENCE_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.SEQUENCE_DIAGRAM); + } else if (UMLDiagramTypes.STATE_MACHINE_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.STATE_MACHINE_DIAGRAM); + } else if (UMLDiagramTypes.TIMING_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.TIMING_DIAGRAM); + } else if (UMLDiagramTypes.USE_CASE_DIAGRAM.equals(diagram.getType())) { + diagramKind = getDiagramKindById(UMLDiagramKinds.USE_CASE_DIAGRAM); + } + + // set the new diagram kind + if (diagramKind != null) { + if (pvs == null){ + pvs = StyleFactory.eINSTANCE.createPapyrusDiagramStyle(); + pvs.setOwner(diagram.getElement()); + diagram.getStyles().add(pvs); + } + pvs.setDiagramKindId(diagramKind.getId()); + } + } + + protected void convertTable(Table table) { + // get the existing diagram kind id if any + String tableKindId = table.getTableKindId(); + + // return if the existing table kind is already in the UML language + if (tableKindId != null) { + RepresentationKind kind = getTableKindById(tableKindId); + if (kind != null && UMLArchitectureContextIds.UML.equals(kind.getLanguage().getId())) { + return; + } + } + + // set the new table kind to a generic table (to make it visible in the model explorer) + // this does not by itself make the table readable under the UML context + PapyrusTable kind = getTableKindById(UMLTableKinds.GENERIC_TABLE); + if (kind != null) { + table.setTableKindId(kind.getId()); + table.setTableConfiguration(kind.getConfiguration()); + } + } + + /** + * Gets a diagram kind that matches the given id + */ + private PapyrusDiagram getDiagramKindById(String id) { + ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance(); + RepresentationKind kind = manager.getRepresentationKindById(id); + return (kind instanceof PapyrusDiagram)? (PapyrusDiagram) kind : null; + } + + /** + * Gets a sync table kind that matches the given id + */ + private PapyrusTable getTableKindById(String id) { + ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance(); + RepresentationKind kind = manager.getRepresentationKindById(id); + return (kind instanceof PapyrusTable)? (PapyrusTable) kind : null; + } + +} |