Merge branch 'change/7154/3'
diff --git a/org.eclipse.opencert.infra.dashboard/plugin.xml b/org.eclipse.opencert.infra.dashboard/plugin.xml
index 8e07d1b..61a60ad 100644
--- a/org.eclipse.opencert.infra.dashboard/plugin.xml
+++ b/org.eclipse.opencert.infra.dashboard/plugin.xml
@@ -370,7 +370,7 @@
id="org.eclipse.opencert.infra.dashboard.activity.import.requirements.chess"
image="icons/systemdesignanalysis/requirement_diagram.png"
index="3"
- name="Import requirements in Papyrus CHESS">
+ name="Import system entities/requirements from a Papyrus CHESS model">
<Description>
Import requirements in Papyrus CHESS.
</Description>
diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessDiagramHyperLinkAdapter.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessDiagramHyperLinkAdapter.java
index b82a8f0..e102ce9 100644
--- a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessDiagramHyperLinkAdapter.java
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessDiagramHyperLinkAdapter.java
@@ -1,95 +1,125 @@
-/*******************************************************************************
- * Copyright (c) 2018 ALL4TEC.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Thanh Liem PHAN (ALL4TEC) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.opencert.infra.dashboard.pages.adapters;
-
-import java.util.Objects;
-
-import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
-import org.eclipse.opencert.infra.dashboard.helpers.EclipseHelper;
-import org.eclipse.papyrus.commands.Activator;
-import org.eclipse.papyrus.commands.ICreationCommand;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.uml2.uml.Model;
-
-/**
- * A {@link HyperlinkAdapter} to create a new CHESS diagram.
- */
-public abstract class AbstractCreateNewChessDiagramHyperLinkAdapter
- extends AbstractCreateNewChessElementHyperLinkAdapter {
-
- /**
- * {@inheritDoc}
- *
- * Overridden to create a new diagram.
- */
- @Override
- protected void createChessElement() {
- // Create a new diagram command
- ICreationCommand vCreationCommand = getDiagramCreationCommand();
-
- // Get the first opened Chess Papyrus editor
- IMultiDiagramEditor vActivePapyrusEditor = (IMultiDiagramEditor) EclipseHelper.getFirstPapyrusDiagramEditorPart();
-
- // If there is one Chess graphical editor is opened,
- // try to goto the right package and create the new diagram there
- if (Objects.nonNull(vActivePapyrusEditor)) {
- ServicesRegistry vRegistry = vActivePapyrusEditor.getServicesRegistry();
-
- if (Objects.nonNull(vRegistry)) {
- ModelSet vModelSet = null;
- try {
- vModelSet = vRegistry.getService(ModelSet.class);
- } catch (ServiceException pException) {
- Activator.log.error(pException);
- }
-
- if (Objects.nonNull(vModelSet)) {
- // Get the root model
- Model vRootModel = ChessPapyrusHelper.INSTANCE.getUmlModelFromModelSet(vModelSet);
-
- // Get the target view package
- org.eclipse.uml2.uml.Package vTargetViewPackage = getTargetPackage(vRootModel);
-
- if (Objects.nonNull(vTargetViewPackage)) {
- // Create the new diagram inside the target view package
- vCreationCommand.createDiagram(vModelSet, vTargetViewPackage, null);
-
- // Then goto the active Papyrus editor
- EclipseHelper.getActiveWorkbenchPage().activate(vActivePapyrusEditor);
- }
- }
- }
- } else {
- // Otherwise, no Chess graphical editor is already opened, ask user to open one
- ChessPapyrusHelper.INSTANCE.openNoActivePapyrusEditorMessageBox();
- }
- }
-
- /**
- * @return The creation command to create a diagram
- */
- protected abstract ICreationCommand getDiagramCreationCommand();
-
- /**
- * Get the target package in which the new diagram will be created.
- *
- * @param pRootModel The root model
- * @return The target package
- */
- protected abstract org.eclipse.uml2.uml.Package getTargetPackage(Model pRootModel);
-}
+/*******************************************************************************
+ * Copyright (c) 2018 ALL4TEC.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thanh Liem PHAN (ALL4TEC) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.opencert.infra.dashboard.pages.adapters;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
+import org.eclipse.opencert.infra.dashboard.helpers.EclipseHelper;
+import org.eclipse.papyrus.commands.Activator;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPage;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.uml2.uml.Model;
+
+/**
+ * A {@link HyperlinkAdapter} to create a new CHESS diagram.
+ */
+public abstract class AbstractCreateNewChessDiagramHyperLinkAdapter
+ extends AbstractCreateNewChessElementHyperLinkAdapter {
+
+ /**
+ * {@inheritDoc}
+ *
+ * Overridden to create a new diagram.
+ */
+ @Override
+ protected void createChessElement() {
+ // Create a new diagram command
+ ICreationCommand vCreationCommand = getDiagramCreationCommand();
+
+ // Get the first opened Chess Papyrus editor
+ IMultiDiagramEditor vActivePapyrusEditor = (IMultiDiagramEditor) EclipseHelper.getFirstPapyrusDiagramEditorPart();
+
+ // If there is one Chess graphical editor is opened,
+ // try to goto the right package and create the new diagram there
+ if (Objects.nonNull(vActivePapyrusEditor)) {
+ ServicesRegistry vRegistry = vActivePapyrusEditor.getServicesRegistry();
+
+ if (Objects.nonNull(vRegistry)) {
+ ModelSet vModelSet = null;
+ try {
+ vModelSet = vRegistry.getService(ModelSet.class);
+ } catch (ServiceException pException) {
+ Activator.log.error(pException);
+ }
+
+ if (Objects.nonNull(vModelSet)) {
+ // Get the root model
+ Model vRootModel = ChessPapyrusHelper.INSTANCE.getUmlModelFromModelSet(vModelSet);
+
+ // Get the target packageable element
+ org.eclipse.uml2.uml.PackageableElement vTargetElement = getTargetElement(vRootModel);
+
+ if (Objects.nonNull(vTargetElement)) {
+ // First goto the active Papyrus editor
+ EclipseHelper.getActiveWorkbenchPage().activate(vActivePapyrusEditor);
+
+ // Then select the target element before creating a new diagram
+ IViewPart vModelExplorer = null;
+ try {
+ vModelExplorer = EclipseHelper.getActiveWorkbenchPage().showView(MODEL_EXPLORER_VIEW_ID);
+ } catch (PartInitException pException) {
+ Activator.log.error(pException);
+ }
+
+ if (vModelExplorer instanceof ModelExplorerPageBookView) {
+ ModelExplorerPageBookView vMEPBView = (ModelExplorerPageBookView) vModelExplorer;
+
+ if (vMEPBView.getCurrentPage() instanceof ModelExplorerPage) {
+ ModelExplorerPage vMEPage = (ModelExplorerPage) vMEPBView.getCurrentPage();
+
+ ModelExplorerView vMEView = (ModelExplorerView) vMEPage.getViewer();
+ List<EObject> vSelectElements = new ArrayList<>();
+ vSelectElements.add(vTargetElement);
+ vMEView.revealSemanticElement(vSelectElements);
+ }
+
+ // Create the new diagram inside the target element
+ vCreationCommand.createDiagram(vModelSet, vTargetElement, null);
+ }
+ }
+ }
+ }
+ } else {
+ // Otherwise, no Chess graphical editor is already opened, ask user to open one
+ ChessPapyrusHelper.INSTANCE.openNoActivePapyrusEditorMessageBox();
+ }
+ }
+
+ /**
+ * @return The creation command to create a diagram
+ */
+ protected abstract ICreationCommand getDiagramCreationCommand();
+
+ /**
+ * Get the target packageable element in which the new diagram will be created.
+ *
+ * @param pRootModel
+ * The root model
+ * @return The target package
+ */
+ protected abstract org.eclipse.uml2.uml.PackageableElement getTargetElement(Model pRootModel);
+}
diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessBlockDefinitionDiagram.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessBlockDefinitionDiagram.java
index ca41c56..214663d 100644
--- a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessBlockDefinitionDiagram.java
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessBlockDefinitionDiagram.java
@@ -1,44 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2018 ALL4TEC.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Thanh Liem PHAN (ALL4TEC) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.opencert.infra.dashboard.pages.adapters;
-
-import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
-import org.eclipse.papyrus.commands.ICreationCommand;
-import org.eclipse.papyrus.sysml.diagram.blockdefinition.BlockDefinitionDiagramCreateCommand;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.Package;
-
-/**
- * A {@link HyperlinkAdapter} to create a new CHESS block definition diagram.
- */
-public class CreateNewChessBlockDefinitionDiagram extends AbstractCreateNewChessDiagramHyperLinkAdapter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ICreationCommand getDiagramCreationCommand() {
- return new BlockDefinitionDiagramCreateCommand();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Package getTargetPackage(final Model pRootModel) {
- return ChessPapyrusHelper.INSTANCE.getPackageFromModelByName(pRootModel,
- ChessPapyrusHelper.MODEL_SYSTEM_VIEW_NAME);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2018 ALL4TEC.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thanh Liem PHAN (ALL4TEC) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.opencert.infra.dashboard.pages.adapters;
+
+import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.sysml.diagram.blockdefinition.BlockDefinitionDiagramCreateCommand;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * A {@link HyperlinkAdapter} to create a new CHESS block definition diagram.
+ */
+public class CreateNewChessBlockDefinitionDiagram extends AbstractCreateNewChessDiagramHyperLinkAdapter {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICreationCommand getDiagramCreationCommand() {
+ return new BlockDefinitionDiagramCreateCommand();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected PackageableElement getTargetElement(final Model pRootModel) {
+ return ChessPapyrusHelper.INSTANCE.getPackageFromModelByName(pRootModel,
+ ChessPapyrusHelper.MODEL_SYSTEM_VIEW_NAME);
+ }
+}
diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessRequirementDiagram.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessRequirementDiagram.java
index dc9569f..bfa8a7e 100644
--- a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessRequirementDiagram.java
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessRequirementDiagram.java
@@ -1,45 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2018 ALL4TEC.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Thanh Liem PHAN (ALL4TEC) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.opencert.infra.dashboard.pages.adapters;
-
-import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
-import org.eclipse.papyrus.commands.ICreationCommand;
-import org.eclipse.papyrus.sysml.diagram.requirement.RequirementDiagramCreateCommand;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.Package;
-
-/**
- * A {@link HyperlinkAdapter} to create a new CHESS requirement diagram.
- */
-public class CreateNewChessRequirementDiagram extends AbstractCreateNewChessDiagramHyperLinkAdapter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ICreationCommand getDiagramCreationCommand() {
- return new RequirementDiagramCreateCommand();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Package getTargetPackage(final Model pRootModel) {
- // TODO Auto-generated method stub
- return ChessPapyrusHelper.INSTANCE.getPackageFromModelByName(pRootModel,
- ChessPapyrusHelper.MODEL_REQUIREMENT_VIEW_NAME);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2018 ALL4TEC.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Thanh Liem PHAN (ALL4TEC) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.opencert.infra.dashboard.pages.adapters;
+
+import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
+import org.eclipse.papyrus.commands.ICreationCommand;
+import org.eclipse.papyrus.sysml.diagram.requirement.RequirementDiagramCreateCommand;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * A {@link HyperlinkAdapter} to create a new CHESS requirement diagram.
+ */
+public class CreateNewChessRequirementDiagram extends AbstractCreateNewChessDiagramHyperLinkAdapter {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICreationCommand getDiagramCreationCommand() {
+ return new RequirementDiagramCreateCommand();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected PackageableElement getTargetElement(final Model pRootModel) {
+ return ChessPapyrusHelper.INSTANCE.getPackageFromModelByName(pRootModel,
+ ChessPapyrusHelper.MODEL_REQUIREMENT_VIEW_NAME);
+ }
+}