Merge branch 'change/7154/2'

diff --git a/org.eclipse.opencert.infra.dashboard/icons/systemdesignanalysis/block_definition_diagram.png b/org.eclipse.opencert.infra.dashboard/icons/systemdesignanalysis/block_definition_diagram.png
new file mode 100644
index 0000000..c4ce74b
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/icons/systemdesignanalysis/block_definition_diagram.png
Binary files differ
diff --git a/org.eclipse.opencert.infra.dashboard/icons/systemdesignanalysis/requirement_diagram.png b/org.eclipse.opencert.infra.dashboard/icons/systemdesignanalysis/requirement_diagram.png
new file mode 100644
index 0000000..077f896
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/icons/systemdesignanalysis/requirement_diagram.png
Binary files differ
diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/dialogs/PackageImportDialog.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/dialogs/PackageImportDialog.java
new file mode 100644
index 0000000..96b73be
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/dialogs/PackageImportDialog.java
@@ -0,0 +1,112 @@
+package org.eclipse.opencert.infra.dashboard.dialogs;

+

+import java.util.Collection;

+

+import org.eclipse.papyrus.uml.profile.ui.dialogs.PackageImportTreeSelectionDialog;

+import org.eclipse.swt.SWT;

+import org.eclipse.swt.events.SelectionAdapter;

+import org.eclipse.swt.events.SelectionEvent;

+import org.eclipse.swt.layout.RowLayout;

+import org.eclipse.swt.widgets.Button;

+import org.eclipse.swt.widgets.Composite;

+import org.eclipse.swt.widgets.Shell;

+import org.eclipse.uml2.uml.Package;

+

+/**

+ * This class is cloned from org.eclipse.papyrus.uml.importt.ui as it could not be imported directly.

+ */

+public class PackageImportDialog extends PackageImportTreeSelectionDialog {

+

+	/**

+	 * Default constructor.

+	 * 

+	 * @param pShell The parent shell

+	 * @param pPackage The package to import

+	 */

+	public PackageImportDialog(Shell pShell, Package pPackage) {

+		super(pShell, pPackage);

+	}

+

+	/**

+	 * Constructor with a collection of packages to import.

+	 *

+	 * @param pShell The parent shell

+	 * @param pPackages The packages to import

+	 */

+	public PackageImportDialog(Shell pShell, Collection<? extends Package> pPackages) {

+		super(pShell, pPackages);

+	}

+

+	/**

+	 * {@inheritDoc}

+	 */

+	@Override

+	public Composite createDialogArea(Composite pParent) {

+		Composite vResult = (Composite) super.createDialogArea(pParent);

+

+		Composite vButtons = new Composite(vResult, SWT.NONE);

+		vButtons.setLayout(new RowLayout());

+

+		Button vBtnLoadAll = new Button(vButtons, SWT.PUSH);

+		vBtnLoadAll.setText("Load All"); //$NON-NLS-1$

+		vBtnLoadAll.addSelectionListener(new SelectionAdapter() {

+

+			/**

+			 * {@inheritDoc}

+			 */

+			@Override

+			public void widgetSelected(SelectionEvent pEvent) {

+				selectAll(ImportAction.LOAD);

+			}

+		});

+

+		Button vBtnImportAll = new Button(vButtons, SWT.PUSH);

+		vBtnImportAll.setText("Import All");//$NON-NLS-1$

+		vBtnImportAll.addSelectionListener(new SelectionAdapter() {

+

+			/**

+			 * {@inheritDoc}

+			 */

+			@Override

+			public void widgetSelected(SelectionEvent pEvent) {

+				selectAll(ImportAction.IMPORT);

+			}

+		});

+

+		Button vBtnCopyAll = new Button(vButtons, SWT.PUSH);

+		vBtnCopyAll.setText("Copy All"); //$NON-NLS-1$

+		vBtnCopyAll.addSelectionListener(new SelectionAdapter() {

+

+			/**

+			 * {@inheritDoc}

+			 */

+			@Override

+			public void widgetSelected(SelectionEvent pEvent) {

+				selectAll(ImportAction.COPY);

+			}

+		});

+

+		Button vBtnDeselectAll = new Button(vButtons, SWT.PUSH);

+		vBtnDeselectAll.setText("Deselect All"); //$NON-NLS-1$

+		vBtnDeselectAll.addSelectionListener(new SelectionAdapter() {

+

+			/**

+			 * {@inheritDoc}

+			 */

+			@Override

+			public void widgetSelected(SelectionEvent pEvent) {

+				selectAll(ImportAction.NONE);

+			}

+		});

+

+		return vResult;

+	}

+

+	/**

+	 * {@inheritDoc}

+	 */

+	@Override

+	protected boolean isResizable() {

+		return true;

+	}

+}

diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/handlers/OpenDashboardHandler.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/handlers/OpenDashboardHandler.java
index 072910e..6b4ba60 100644
--- a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/handlers/OpenDashboardHandler.java
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/handlers/OpenDashboardHandler.java
@@ -43,8 +43,11 @@
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Concrete implementation for command part in Command pattern. Open the
- * dashboard for the current active project.
+ * Concrete implementation for command part in Command pattern. Open the dashboard for the current active project.
+ *
+ * TODO:
+ * - handle the opened diagram editor for CDO project
+ * - handle multiple graphical editors opened from different CHESS models
  */
 public final class OpenDashboardHandler extends AbstractHandler {
 
@@ -97,15 +100,15 @@
 			}
 		} else {
 			// Otherwise, the selected element could be a CDOResource (for OpenCert project)
-			Object selectedObject = getFirstSelectionObject(pEvent);
-			if (selectedObject instanceof CDOResource) {
+			Object vSelectedObject = getFirstSelectionObject(pEvent);
+			if (vSelectedObject instanceof CDOResource) {
 				// TODO: handle the CDO resource
 			}
 		}
 
 		// Finally, if a session is found or created, open the corresponding activity explorer
 		if (Objects.nonNull(vSession)) {
-				OpenSessionAction.openActivityExplorer(vSession);
+			OpenSessionAction.openActivityExplorer(vSession);
 		} else {
 			// Otherwise, open the dashboard for a null session
 			IWorkbenchPage vActivePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/ChessPapyrusHelper.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/ChessPapyrusHelper.java
new file mode 100644
index 0000000..c9af856
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/ChessPapyrusHelper.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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.helpers;
+
+import java.util.Objects;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.commands.Activator;
+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.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.uml2.uml.Model;
+
+/**
+ * Helper methods to work with Papyrus CHESS Uml model elements.
+ */
+public final class ChessPapyrusHelper {
+
+	/** Singleton instance of this class. */
+	public static final ChessPapyrusHelper INSTANCE = new ChessPapyrusHelper();
+
+	/** Text for warning there is no active Chess editor. */
+	private final String NO_ACTIVE_CHESS_EDITOR_WARNING_TEXT = "Active Papyrus CHESS editor not found"; //$NON-NLS-1$
+
+	/** Message for warning there is no active Chess editor. */
+	private final String NO_ACTIVE_CHESS_EDITOR_WARNING_MESSAGE = "At least one Papyrus CHESS editor must be active to create a new diagram. Please open a Papyrus CHESS model."; //$NON-NLS-1$
+
+	/** Name of the model requirement view. */
+	public static final String MODEL_REQUIREMENT_VIEW_NAME = "modelRequirementView"; //$NON-NLS-1$
+
+	/** Name of the model system view. */
+	public static final String MODEL_SYSTEM_VIEW_NAME = "modelSystemView"; //$NON-NLS-1$
+
+	/**
+	 * Default constructor, private to avoid instantiation.
+	 */
+	private ChessPapyrusHelper() {
+		super();
+	}
+
+	/**
+	 * @return The root UML model element, which is the first node in the resource content
+	 */
+	public Model getUmlModelFromResource(final Resource pResource) {
+		Model vModel = null;
+
+		// Get the current Model from the resource content
+		if (!pResource.getContents().isEmpty()) {
+			// Get the root object of the resource
+			EObject vObject = pResource.getContents().get(0);
+
+			if (vObject instanceof Model) {
+				vModel = (Model) vObject;
+			}
+		}
+
+		return vModel;
+	}
+
+	/**
+	 * @return The root UML model element, which is the first node in the resource content, or {@code null} if not found
+	 */
+	public Model getUmlModelFromModelSet(final ModelSet pModelSet) {
+		Objects.requireNonNull(pModelSet);
+
+		Model vModel = null;
+
+		// Retrieve the Uml URI from the model set
+		URI vUmlURI = pModelSet.getURIWithoutExtension().appendFileExtension("uml"); //$NON-NLS-1$
+		Resource vResource = pModelSet.getResource(vUmlURI, false);
+
+		// Get the current model from the resource content
+		if (Objects.nonNull(vResource) && !vResource.getContents().isEmpty()) {
+			// Get the root object of the resource
+			EObject vObject = vResource.getContents().get(0);
+
+			if (vObject instanceof Model) {
+				vModel = (Model) vObject;
+			}
+		}
+
+		return vModel;
+	}
+
+	/**
+	 * Get the root UML model from the diagram editor.
+	 *
+	 * @return The found UML {@link Model}, otherwise {@code null}
+	 */
+	public Model getUmlModelFromDiagramEditor(final IMultiDiagramEditor vPapyrusDiagramEditor) {
+		Model vRootModel = null;
+
+		// Try to goto the right package and create the new diagram there
+		if (Objects.nonNull(vPapyrusDiagramEditor)) {
+			ServicesRegistry vRegistry = vPapyrusDiagramEditor.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
+					vRootModel = ChessPapyrusHelper.INSTANCE.getUmlModelFromModelSet(vModelSet);
+				}
+			}
+		}
+
+		return vRootModel;
+	}
+
+	/**
+	 * @return The root UML model element, which is the first node in the resource content
+	 */
+	public org.eclipse.uml2.uml.Package getPackageFromModelByName(final Model pModel, final String pPackageName) {
+		Objects.requireNonNull(pModel);
+		return pModel.getNestedPackage(pPackageName);
+	}
+
+	/**
+	 * Open the message box to warn user that no active Papyrus editor is opened.
+	 */
+	public void openNoActivePapyrusEditorMessageBox() {
+		MessageBox vMessageBox = new MessageBox(EclipseHelper.getActiveShell(), SWT.OK | SWT.ICON_WARNING);
+
+		vMessageBox.setText(NO_ACTIVE_CHESS_EDITOR_WARNING_TEXT);
+		vMessageBox.setMessage(NO_ACTIVE_CHESS_EDITOR_WARNING_MESSAGE);
+		vMessageBox.open();
+	}
+}
diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/EclipseHelper.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/EclipseHelper.java
index 860db70..454e652 100644
--- a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/EclipseHelper.java
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/helpers/EclipseHelper.java
@@ -5,11 +5,17 @@
  */
 package org.eclipse.opencert.infra.dashboard.helpers;
 
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Objects;
+import java.util.Set;
 
 import org.apache.commons.lang.ArrayUtils;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
@@ -30,7 +36,7 @@
 	}
 
 	/**
-	 * Return the current active workbench window, or if none is active, the first workbench window known by eclipse.
+	 * Return the current active workbench window, or if none is active, the first workbench window known by Eclipse.
 	 *
 	 * @return The current workbench window
 	 */
@@ -138,4 +144,41 @@
 
 		return vActiveShell;
 	}
+
+	/**
+	 * Get all the editor references in all pages of all workbench windows.
+	 *
+	 * @return A set of all the editor references
+	 */
+	public static Set<IEditorReference> getAllEditorReferences() {
+		Set<IEditorReference> vAllEditorReferencesSet = new HashSet<>();
+
+		IWorkbench vWorkbench = PlatformUI.getWorkbench();
+
+		for (IWorkbenchWindow vWindow : vWorkbench.getWorkbenchWindows()) {
+			for (IWorkbenchPage vPage : vWindow.getPages()) {
+				vAllEditorReferencesSet.addAll(Arrays.asList(vPage.getEditorReferences()));
+			}
+		}
+
+		return vAllEditorReferencesSet;
+	}
+
+	/**
+	 * @return The first Papyrus diagram editor part from all editors, or {@code null} if not found
+	 */
+	public static IMultiDiagramEditor getFirstPapyrusDiagramEditorPart() {
+		IMultiDiagramEditor vEditorPart = null;
+		Iterator<IEditorReference> vIter = EclipseHelper.getAllEditorReferences().iterator();
+
+		while (vIter.hasNext() && Objects.isNull(vEditorPart)) {
+			IEditorReference vEditorReference = vIter.next();
+
+			if (vEditorReference.getEditor(false) instanceof IMultiDiagramEditor) {
+				vEditorPart = (IMultiDiagramEditor) vEditorReference.getEditor(false);
+			}
+		}
+
+		return vEditorPart;
+	}
 }
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
new file mode 100644
index 0000000..b82a8f0
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessDiagramHyperLinkAdapter.java
@@ -0,0 +1,95 @@
+/*******************************************************************************

+ * 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);

+}

diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessElementHyperLinkAdapter.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessElementHyperLinkAdapter.java
new file mode 100644
index 0000000..6b05e35
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/AbstractCreateNewChessElementHyperLinkAdapter.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+
+/**
+ * A {@link HyperlinkAdapter} to create a new CHESS element.
+ */
+public abstract class AbstractCreateNewChessElementHyperLinkAdapter extends HyperlinkAdapter {
+
+	/** ID of the model explorer view. */
+	protected static final String MODEL_EXPLORER_VIEW_ID = "org.eclipse.papyrus.views.modelexplorer.modelexplorer"; //$NON-NLS-1$
+
+	/**
+	 * Default constructor.
+	 */
+	public AbstractCreateNewChessElementHyperLinkAdapter() {
+		super();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void linkActivated(final HyperlinkEvent pEvent) {
+		createChessElement();
+	}
+
+	/**
+	 * Create a CHESS element when the link is pressed.
+	 */
+	protected abstract void createChessElement();
+}
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
new file mode 100644
index 0000000..ca41c56
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessBlockDefinitionDiagram.java
@@ -0,0 +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);

+	}

+}

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
new file mode 100644
index 0000000..dc9569f
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/CreateNewChessRequirementDiagram.java
@@ -0,0 +1,45 @@
+/*******************************************************************************

+ * 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);

+	}

+}

diff --git a/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/OpenImportUserModelDialogHyperLinkAdapter.java b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/OpenImportUserModelDialogHyperLinkAdapter.java
new file mode 100644
index 0000000..c3b38db
--- /dev/null
+++ b/org.eclipse.opencert.infra.dashboard/src/org/eclipse/opencert/infra/dashboard/pages/adapters/OpenImportUserModelDialogHyperLinkAdapter.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.window.Window;
+import org.eclipse.opencert.infra.dashboard.dialogs.PackageImportDialog;
+import org.eclipse.opencert.infra.dashboard.helpers.ChessPapyrusHelper;
+import org.eclipse.opencert.infra.dashboard.helpers.EclipseHelper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.uml.profile.ui.dialogs.ElementImportTreeSelectionDialog.ImportSpec;
+import org.eclipse.papyrus.uml.tools.importsources.PackageImportSourceDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * A {@link HyperLinkAdapter} to open the {@link PackageImportDialog} dialog.
+ */
+public class OpenImportUserModelDialogHyperLinkAdapter extends AbstractOpenDialogHyperLinkAdapter {
+
+	/**
+	 * Default constructor.
+	 */
+	public OpenImportUserModelDialogHyperLinkAdapter() {
+		super();
+	}
+
+	/**
+	 * Open a dialog when the link is pressed.
+	 */
+	@Override
+	protected void openDialog() {
+		// Retrieve shell instance
+		Shell vShell = EclipseHelper.getActiveShell();
+
+		// Get the first Papyrus diagram editor
+		IMultiDiagramEditor vPapyrusEditor = EclipseHelper.getFirstPapyrusDiagramEditorPart();
+
+		// Get the root model
+		Model vRootModel = ChessPapyrusHelper.INSTANCE.getUmlModelFromDiagramEditor(vPapyrusEditor);
+
+		if (Objects.nonNull(vRootModel)) {
+			Map<String, String> vExtensionFilters = new LinkedHashMap<String, String>();
+			vExtensionFilters.put("*.uml", "UML (*.uml)"); //$NON-NLS-1$
+			vExtensionFilters.put("*.profile.uml", "UML Profiles (*.profile.uml)"); //$NON-NLS-1$ //$NON-NLS-2$
+			vExtensionFilters.put("*", "All (*)"); //$NON-NLS-1$ //$NON-NLS-2$
+
+			Collection<EObject> vSelections = new ArrayList<>();
+			vSelections.add(vRootModel);
+
+			Collection<Package> vPackages = PackageImportSourceDialog.open(vShell, "Select the models to import", //$NON-NLS-1$
+					vSelections, vExtensionFilters);
+
+			if (Objects.nonNull(vPackages) && !vPackages.isEmpty()) {
+				PackageImportDialog vPackageImportDialog = new PackageImportDialog(vShell, vPackages);
+
+				if (Window.OK == vPackageImportDialog.open()) {
+					Collection<ImportSpec<Package>> vResult = vPackageImportDialog.getResult();
+
+					for (ImportSpec<Package> vResultElement : vResult) {
+						Package vSelectedPackage = vResultElement.getElement();
+						switch (vResultElement.getAction()) {
+						case COPY:
+							handleCopyPackage(vSelectedPackage, vRootModel);
+							break;
+						case IMPORT:
+							handleImportPackage(vSelectedPackage, vRootModel);
+							break;
+						default:
+							handleLoadPackage(vSelectedPackage, vRootModel);
+							break;
+						}
+					}
+
+					// Then goto the active Papyrus editor
+					EclipseHelper.getActiveWorkbenchPage().activate(vPapyrusEditor);
+				}
+			}
+		} else {
+			// Otherwise, no Chess graphical editor is already opened, ask user to open one
+			ChessPapyrusHelper.INSTANCE.openNoActivePapyrusEditorMessageBox();
+		}
+	}
+
+	/**
+	 * Load the Package resource into the target package.
+	 *
+	 * @param pPackage The selected package to import
+	 * @param pTargetPackage The target package
+	 */
+	protected void handleLoadPackage(final Package pPackage, final EObject pTargetPackage) {
+		EMFHelper.reloadIntoContext(pPackage, pTargetPackage);
+	}
+
+	/**
+	 * Create a PackageImport in the target package, which refers to the selected package.
+	 *
+	 * @param pSelectedPackage The selected package
+	 * @param pTargetPackage The target package
+	 */
+	protected void handleImportPackage(final Package pSelectedPackage, final EObject pTargetPackage) {
+		PackageImport vPackageImport = UMLFactory.eINSTANCE.createPackageImport();
+
+		Package vImportedPackage = EMFHelper.reloadIntoContext(pSelectedPackage, pTargetPackage);
+
+		((Package) pTargetPackage).getPackageImports().add(vPackageImport);
+		vPackageImport.setImportedPackage(vImportedPackage);
+	}
+
+	/**
+	 * Create a copy of the selected package in the target package.
+	 *
+	 * @param pSelectedPackage The selected package
+	 * @param pTargetPackage The target package
+	 */
+	protected void handleCopyPackage(Package pSelectedPackage, final EObject pTargetPackage) {
+		// FIXME: Stereotype applications are not copied
+		((Package) pTargetPackage).getNestedPackages().add(EcoreUtil.copy(pSelectedPackage));
+	}
+}