Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java
new file mode 100644
index 00000000000..790efdb7c0c
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.handlers;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Simple superclass for handlers. It converts a selection into an EObject.
+ * Used by C++ code generator and Qompass designer
+ */
+public abstract class CmdHandler extends AbstractHandler {
+
+ /**
+ * Convert selected elements within model explorer or diagram to an eObject
+ */
+ public void updateSelectedEObject() {
+ // Retrieve selected elements
+ IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+
+ if (selection != null) {
+ selectedEObject = EMFHelper.getEObject(selection.getFirstElement());
+ }
+ }
+
+ /**
+ * Store the selected EObject. Accessible for subclasses
+ */
+ protected EObject selectedEObject;
+}

Back to the top