Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2009-07-30 08:05:56 +0000
committerptessier2009-07-30 08:05:56 +0000
commitcd365ebf6dbaf2f5cd27226f6b94c38385d65e7a (patch)
treed23f9713e75588978ab5205d026c8be89688e6fd /plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension
parentc45099d7274ecfa02153c9db8cb910eb676c26b3 (diff)
downloadorg.eclipse.papyrus-cd365ebf6dbaf2f5cd27226f6b94c38385d65e7a.tar.gz
org.eclipse.papyrus-cd365ebf6dbaf2f5cd27226f6b94c38385d65e7a.tar.xz
org.eclipse.papyrus-cd365ebf6dbaf2f5cd27226f6b94c38385d65e7a.zip
NEW - bug 273417: [usability][general] navigation from one diagram to another
https://bugs.eclipse.org/bugs/show_bug.cgi?id=273417
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension')
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddHyperLinkPopupBarBehavior.java112
1 files changed, 112 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddHyperLinkPopupBarBehavior.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddHyperLinkPopupBarBehavior.java
new file mode 100644
index 00000000000..d8ee72fb156
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddHyperLinkPopupBarBehavior.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2009 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA LIST - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.papyrusgmfgenextension.popupaction;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.codegen.gmfgen.Behaviour;
+import org.eclipse.gmf.codegen.gmfgen.CustomBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * Implementation class for AddGenLinkStereotypeDisplayBehavior action
+ */
+public class AddHyperLinkPopupBarBehavior extends Action {
+
+ public static final String POPUP_POLICY_KEY = "org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE"; //$NON-NLS-1$
+ public static final String HYPERLINK_POPUPBAR_POLICY_CLASS = "org.eclipse.papyrus.diagram.common.editpolicies.HyperLinkPopupBarEditPolicy"; //$NON-NLS-1$
+
+
+ public static final String URI_NOTATION_GENMODEL = "org.eclipse.gmf.runtime.notation/model/notation.genmodel"; //$NON-NLS-1$
+
+ public static final String URI_UML_GENMODEL = "org.eclipse.uml2.uml/model/UML.genmodel"; //$NON-NLS-1$
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public void init(IViewPart view) {
+ // NO OP
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+
+ // Parse selected GenLink(s) and add the desired CustomBehavior
+ Iterator<EObject> it = getSelectedEObject().iterator();
+ while (it.hasNext()) {
+ EObject eObject = it.next();
+ if (eObject instanceof GenNode) {
+
+ // Create the behavior required by stereotype management (if not already created)
+ if (!hasCustomBehavior((GenNode) eObject)) {
+ addCustomBehavior((GenNode) eObject);
+ }
+
+ }
+ }
+ }
+
+ /**
+ * Add the CustomBehavior for Applied Stereotype label display to the GenLink node given as parameter
+ *
+ * @param genNode
+ * where the CustomBehavior is added
+ */
+ private void addCustomBehavior(GenNode genNode) {
+
+ CustomBehaviour behavior = GMFGenFactory.eINSTANCE.createCustomBehaviour();
+ behavior.setKey(POPUP_POLICY_KEY);
+ behavior.setEditPolicyQualifiedClassName(HYPERLINK_POPUPBAR_POLICY_CLASS);
+
+ genNode.getBehaviour().add(behavior);
+ }
+
+ /**
+ * Check if the CustomBehavior for Applied Stereotype label display is already added
+ *
+ * @param genNode
+ * the GenLink to test
+ * @return true if the behavior with correct key already exists
+ */
+ private boolean hasCustomBehavior(GenNode genNode) {
+
+ boolean hasCustomBehavior = false;
+
+ Iterator<Behaviour> it = genNode.getBehaviour().iterator();
+ while (it.hasNext() && !(hasCustomBehavior)) {
+ Behaviour behaviour = it.next();
+
+ if (behaviour instanceof CustomBehaviour) {
+ CustomBehaviour customBehavior = (CustomBehaviour) behaviour;
+ if (POPUP_POLICY_KEY.equals(customBehavior.getKey())) {
+ hasCustomBehavior = true;
+ }
+ }
+ }
+
+ return hasCustomBehavior;
+ }
+
+
+
+
+
+}

Back to the top