Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.handlers/src/org/eclipse/papyrus/requirements/sysml/assistant/handlers/AddDerivedLinkReqHandler.java')
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.handlers/src/org/eclipse/papyrus/requirements/sysml/assistant/handlers/AddDerivedLinkReqHandler.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.handlers/src/org/eclipse/papyrus/requirements/sysml/assistant/handlers/AddDerivedLinkReqHandler.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.handlers/src/org/eclipse/papyrus/requirements/sysml/assistant/handlers/AddDerivedLinkReqHandler.java
new file mode 100644
index 00000000000..a39495d168f
--- /dev/null
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.handlers/src/org/eclipse/papyrus/requirements/sysml/assistant/handlers/AddDerivedLinkReqHandler.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (patrick.tessier@cea.fr) CEA LIST. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.requirements.sysml.assistant.handlers;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.requirements.sysml.assistant.commands.AddDerivedLinkReqCommand;
+import org.eclipse.papyrus.requirements.sysml.assistant.commands.DerivationReqCreateCommand;
+import org.eclipse.papyrus.requirements.common.PapyrusAbstractHandler;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Executes the addition of DerivedReqt links
+ *
+ */
+public class AddDerivedLinkReqHandler extends PapyrusAbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ super.execute(event);
+ ArrayList<Element> selectedElements = getSelectionSet();
+ if (selectedElements.size() == 2) {
+ DerivationReqCreateCommand addDerivedLinkReqCommand = new DerivationReqCreateCommand(
+ transactionalEditingDomain, (NamedElement) selectedElements.get(1),
+ (NamedElement) selectedElements.get(0));
+ transactionalEditingDomain.getCommandStack().execute(addDerivedLinkReqCommand);
+ } else {
+
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ AddDerivedLinkReqCommand addDerivedLinkReqCommand = new AddDerivedLinkReqCommand(
+ transactionalEditingDomain, selectedElement);
+ transactionalEditingDomain.getCommandStack().execute(addDerivedLinkReqCommand);
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return true if the handler is possible
+ */
+ @Override
+ public boolean isEnabled() {
+ Element selectedElement = getSelection();
+ if (selectedElement != null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+} \ No newline at end of file

Back to the top