Merge "Bug 531303 - Resource classes are not imported for extended resources in external spec"
diff --git a/org.eclipse.lyo.tools.toolchain.design/description/ToolChainModel.odesign b/org.eclipse.lyo.tools.toolchain.design/description/ToolChainModel.odesign
index 18037fd..f343992 100644
--- a/org.eclipse.lyo.tools.toolchain.design/description/ToolChainModel.odesign
+++ b/org.eclipse.lyo.tools.toolchain.design/description/ToolChainModel.odesign
@@ -212,8 +212,24 @@
<elementView name="elementView"/>
<containerView name="containerView"/>
<initialOperation>
- <firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="[elementView/]">
- <subModelOperations xsi:type="tool_1:DeleteView"/>
+ <firstModelOperations xsi:type="tool_1:Let" variableName="deleteFromModel" valueExpression="service:deleteFromModel()">
+ <subModelOperations xsi:type="tool_1:Switch">
+ <cases conditionExpression="[deleteFromModel.oclIsUndefined()/]"/>
+ <cases conditionExpression="[deleteFromModel/]">
+ <subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="[element.namespacePrefix/]">
+ <subModelOperations xsi:type="tool_1:RemoveElement"/>
+ </subModelOperations>
+ <subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="[element/]">
+ <subModelOperations xsi:type="tool_1:RemoveElement"/>
+ </subModelOperations>
+ </cases>
+ <cases conditionExpression="[not deleteFromModel/]">
+ <subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:elementView">
+ <subModelOperations xsi:type="tool_1:DeleteView"/>
+ </subModelOperations>
+ </cases>
+ <default/>
+ </subModelOperations>
</firstModelOperations>
</initialOperation>
</ownedTools>
@@ -1001,7 +1017,20 @@
<elementView name="elementView"/>
<containerView name="containerView"/>
<initialOperation>
- <firstModelOperations xsi:type="tool_1:RemoveElement"/>
+ <firstModelOperations xsi:type="tool_1:Let" variableName="deleteFromModel" valueExpression="service:deleteFromModel()">
+ <subModelOperations xsi:type="tool_1:Switch">
+ <cases conditionExpression="[deleteFromModel.oclIsUndefined()/]"/>
+ <cases conditionExpression="[deleteFromModel/]">
+ <subModelOperations xsi:type="tool_1:RemoveElement"/>
+ </cases>
+ <cases conditionExpression="[not deleteFromModel/]">
+ <subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:elementView">
+ <subModelOperations xsi:type="tool_1:DeleteView"/>
+ </subModelOperations>
+ </cases>
+ <default/>
+ </subModelOperations>
+ </firstModelOperations>
</initialOperation>
</ownedTools>
<ownedTools xsi:type="tool:DeleteElementDescription" name="Vocabularies.DeleteSubClassOf">
@@ -1062,5 +1091,6 @@
<ownedJavaExtensions qualifiedClassName="org::eclipse::lyo::tools::toolchain::design::DialogInputServices"/>
<ownedJavaExtensions qualifiedClassName="org.eclipse.lyo.tools.toolchain.design.EmfResourcesLoaderService"/>
<ownedJavaExtensions qualifiedClassName="org.eclipse.lyo.tools.codegenerator.ui.popupMenus.AcceleoGenerateCodegeneratorAction"/>
+ <ownedJavaExtensions qualifiedClassName="org.eclipse.lyo.tools.toolchain.design.ConfirmDeletionServices"/>
</ownedViewpoints>
</description:Group>
diff --git a/org.eclipse.lyo.tools.toolchain.design/src/org/eclipse/lyo/tools/toolchain/design/ConfirmDeletionServices.java b/org.eclipse.lyo.tools.toolchain.design/src/org/eclipse/lyo/tools/toolchain/design/ConfirmDeletionServices.java
new file mode 100644
index 0000000..0913b77
--- /dev/null
+++ b/org.eclipse.lyo.tools.toolchain.design/src/org/eclipse/lyo/tools/toolchain/design/ConfirmDeletionServices.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Yash Khatri.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
+ *
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *
+ * Yash Khatri - Initial implementation of loading imported models.
+ *
+ *******************************************************************************/
+package org.eclipse.lyo.tools.toolchain.design;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import adaptorinterface.DomainSpecification;
+import vocabulary.Vocabulary;
+
+/**
+ * @author Yash Khatri
+ * @version $version-stub$
+ * @since 2.4.0-SNAPSHOT
+ */
+
+public class ConfirmDeletionServices {
+
+ Boolean deletefromModel;
+
+ public ConfirmDeletionServices() {
+ }
+
+ /**
+ * <p>
+ * This method is used for prompting the user to decide whether the
+ * <{@link Vocabulary}}> or <{@link DomainSpecification}}> he/she is trying to
+ * delete should be deleted from the graphical diagram only or from the
+ * underlying model as well.
+ * </p>
+ *
+ * @param self
+ * The EObject that is in question to be deleted.
+ * @return boolean true; if the EObject should be deleted from model and from
+ * all diagrams. false; if the EObject should be deleted from graphical
+ * diagram only. null; if the operation is cancelled.
+ */
+ public boolean deleteFromModel(EObject self) {
+
+ Boolean cancelled = null;
+ ConfirmDeleteDialog dialog = new ConfirmDeleteDialog(Display.getCurrent().getActiveShell());
+ int status = dialog.open();
+ if (status == Dialog.OK) {
+ return deletefromModel;
+ }
+ return cancelled;
+ }
+
+ class ConfirmDeleteDialog extends Dialog {
+
+ public ConfirmDeleteDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ Button deleteFromDiagramButton = new Button(container, SWT.RADIO);
+ deleteFromDiagramButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ deleteFromDiagramButton.setText("Delete from Diagram");
+ deleteFromDiagramButton.setToolTipText(
+ "This will only delete the item from the current graphical diagram. The item will remain in the underlying model, and all other diagrams are not affected.");
+ deleteFromDiagramButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (deleteFromDiagramButton.getSelection()) {
+ deletefromModel = false;
+ }
+ }
+ });
+
+ Button deleteFromModelButton = new Button(container, SWT.RADIO);
+ deleteFromModelButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ deleteFromModelButton.setText("Delete from Model");
+ deleteFromModelButton.setToolTipText(
+ "This will delete the item from the underlying model, as well as all graphical diagram.");
+ deleteFromModelButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (deleteFromModelButton.getSelection()) {
+ deletefromModel = true;
+ }
+ }
+ });
+
+ return container;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Confirm Delete");
+ }
+
+ @Override
+ protected Point getInitialSize() {
+ return new Point(450, 150);
+ }
+
+ }
+}
\ No newline at end of file