Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-10-30 06:40:36 -0400
committerCamille Letavernier2013-10-30 06:40:36 -0400
commitce8d43905ab54e40cc1d66045c51ea9ef57c78ca (patch)
treea26bbd4958ac0867d2a519e2b2ba5d2fafd9eb9d /plugins
parent7666f7d51342ad09fc437aeddf59e5d121b91489 (diff)
downloadorg.eclipse.papyrus-ce8d43905ab54e40cc1d66045c51ea9ef57c78ca.tar.gz
org.eclipse.papyrus-ce8d43905ab54e40cc1d66045c51ea9ef57c78ca.tar.xz
org.eclipse.papyrus-ce8d43905ab54e40cc1d66045c51ea9ef57c78ca.zip
420601: Papyrus Customizable Drop Edit Policy leads to positioning side
effects on other GMF diagrams https://bugs.eclipse.org/bugs/show_bug.cgi?id=420601
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF49
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java93
2 files changed, 74 insertions, 68 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF
index 8c0dd41ece5..6bb3fcf838f 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF
@@ -1,24 +1,25 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.emf;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.1",
- org.eclipse.papyrus.uml.service.types;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.services.edit;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1",
- org.eclipse.core.databinding;bundle-version="1.4.1"
-Export-Package: org.eclipse.papyrus.infra.gmfdiag.dnd.policy,
- org.eclipse.papyrus.infra.gmfdiag.dnd.strategy
-Bundle-Vendor: Eclipse Modeling Project
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 0.10.1.qualifier
-Bundle-Name: Customizable Drag and Drop (Incubation)
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.dnd.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.dnd;singleton:=
- true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.1",
+ org.eclipse.papyrus.uml.service.types;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.services.edit;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1",
+ org.eclipse.core.databinding;bundle-version="1.4.1",
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.1"
+Export-Package: org.eclipse.papyrus.infra.gmfdiag.dnd.policy,
+ org.eclipse.papyrus.infra.gmfdiag.dnd.strategy
+Bundle-Vendor: Eclipse Modeling Project
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.10.1.qualifier
+Bundle-Name: Customizable Drag and Drop (Incubation)
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.dnd.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.dnd;singleton:=
+ true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
index 3eaa41d59de..9fb5012cb77 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
@@ -1,44 +1,49 @@
-/*****************************************************************************
- * Copyright (c) 2012 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.dnd.policy;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
-
-
-public class CustomizableDropEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
-
- public boolean provides(IOperation operation) {
- // return false;
- CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation)operation;
-
- return true;
-
- // return !(epOperation.getEditPart() instanceof DiagramEditPart); //TODO: Detect Papyrus diagrams
- }
-
- public void createEditPolicies(EditPart editPart) {
- EditPolicy defaultDropEditPolicy = editPart.getEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE);
- EditPolicy defaultCreationEditPolicy = editPart.getEditPolicy(EditPolicyRoles.CREATION_ROLE);
-
- CustomizableDropEditPolicy dropEditPolicy = new CustomizableDropEditPolicy(defaultDropEditPolicy, defaultCreationEditPolicy);
-
- editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, null);
- editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, dropEditPolicy);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.dnd.policy;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
+
+
+public class CustomizableDropEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
+
+ public boolean provides(IOperation operation) {
+ CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation)operation;
+
+ try {
+ ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(epOperation.getEditPart());
+ return registry != null;
+ } catch (ServiceException e) {
+ return false;
+ }
+ }
+
+ public void createEditPolicies(EditPart editPart) {
+ EditPolicy defaultDropEditPolicy = editPart.getEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE);
+ EditPolicy defaultCreationEditPolicy = editPart.getEditPolicy(EditPolicyRoles.CREATION_ROLE);
+
+ CustomizableDropEditPolicy dropEditPolicy = new CustomizableDropEditPolicy(defaultDropEditPolicy, defaultCreationEditPolicy);
+
+ editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, null);
+ editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, dropEditPolicy);
+ }
+
+} \ No newline at end of file

Back to the top