Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-06-05 08:58:56 +0000
committercletavernie2012-06-05 08:58:56 +0000
commit3f329eeda226ac35f9511636a0b2aa54bb50159d (patch)
tree07a4b62133de5968647f73bedb486a88d7fe06ee /sandbox
parent665457970dd795e43b73823e02fa12c94836cad7 (diff)
downloadorg.eclipse.papyrus-3f329eeda226ac35f9511636a0b2aa54bb50159d.tar.gz
org.eclipse.papyrus-3f329eeda226ac35f9511636a0b2aa54bb50159d.tar.xz
org.eclipse.papyrus-3f329eeda226ac35f9511636a0b2aa54bb50159d.zip
370819: [Global] A Flexible Drag & Drop framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370819
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.classpath7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.project28
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/about.html28
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/plugin.xml27
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/schema/dropStrategy.exsd102
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/Activator.java69
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java231
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java44
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/DropStrategyManager.java371
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferences.java17
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferencesPage.java64
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyEditor.java271
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyLabelProvider.java75
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/AbstractDropStrategy.java145
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/CompositeDropStrategy.java51
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java95
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java77
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/MoveDropStrategy.java122
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/ServiceEditDropStrategy.java65
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/SetValueDropStrategy.java51
-rw-r--r--sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java83
24 files changed, 0 insertions, 2058 deletions
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.classpath b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.classpath
deleted file mode 100644
index 2d1a4302f04..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.project b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.project
deleted file mode 100644
index 324cb4fce86..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.infra.gmfdiag.dnd</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.settings/org.eclipse.jdt.core.prefs b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 44217f8c068..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF
deleted file mode 100644
index 6669d17ee74..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,21 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Customizable Drag and Drop (Incubation)
-Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.dnd;singleton:=true
-Bundle-Version: 0.9.0.qualifier
-Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.dnd.Activator
-Bundle-Vendor: Eclipse Modeling Project
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.infra.core.log;bundle-version="0.9.0",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.emf;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.9.0",
- org.eclipse.papyrus.uml.service.types;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.services.edit;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="0.9.0",
- org.eclipse.core.databinding;bundle-version="1.4.1"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.papyrus.infra.gmfdiag.dnd.strategy
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/about.html b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/about.html
deleted file mode 100644
index dd02e0be168..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>December 2, 2009</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties
deleted file mode 100644
index e3693a3b66e..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/build.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- about.html,\
- plugin.xml
-src.includes = about.html
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/plugin.xml b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/plugin.xml
deleted file mode 100644
index 42edca84941..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/plugin.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse version="3.0"?>
-
-<!--
--->
-<plugin>
- <extension-point id="dropStrategy" name="dropStrategy" schema="schema/dropStrategy.exsd"/>
- <extension
- point="org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders">
- <editpolicyProvider
- class="org.eclipse.papyrus.infra.gmfdiag.dnd.policy.CustomizableDropEditPolicyProvider">
- <Priority
- name="Medium">
- </Priority>
- </editpolicyProvider>
- </extension>
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
- class="org.eclipse.papyrus.infra.gmfdiag.dnd.preferences.DNDPreferencesPage"
- id="org.eclipse.papyrus.infra.gmfdiag.dnd.preferences"
- name="Drag and drop">
- </page>
- </extension>
-
-</plugin>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/schema/dropStrategy.exsd b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/schema/dropStrategy.exsd
deleted file mode 100644
index 61b7dfd3f94..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/schema/dropStrategy.exsd
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.dnd" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.dnd" id="dropStrategy" name="dropStrategy"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="strategy" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="strategy">
- <complexType>
- <attribute name="strategy" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/Activator.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/Activator.java
deleted file mode 100644
index 79f8e15c826..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/Activator.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*****************************************************************************
- * 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;
-
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.gmfdiag.dnd"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- public static LogHelper log;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java
deleted file mode 100644
index eb07256dfda..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*****************************************************************************
- * 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 java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultActionHandler;
-import org.eclipse.papyrus.infra.gmfdiag.common.commands.SelectAndExecuteCommand;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.Activator;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DefaultDropStrategy;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * An EditPolicy to handle Drop in Papyrus diagrams.
- * This edit policy can be customized from an extension point. If a customization
- * is not available, it will delegate the behavior to the default Drop edit policy
- *
- * @author Camille Letavernier
- *
- */
-public class CustomizableDropEditPolicy extends DragDropEditPolicy {
-
- public static final String EXTENSION_ID = Activator.PLUGIN_ID + ".dropStrategy";
-
- protected EditPolicy defaultDropEditPolicy;
-
- protected EditPolicy defaultCreationEditPolicy;
-
- //FIXME: This comes from oep.uml.diagram.common.listener.DropTargetListener
- //This should be merged to oep.infra.gmfdiag.common, as this is not specific to UML
- public static final String EVENT_DETAIL = "EVENT_DETAIL";
-
- @Override
- public void activate() {
- //Nothing
- }
-
- /**
- * Instantiates a new CustomizableDropEditPolicy
- *
- * @param defaultEditPolicy
- * The default editPolicy, to be called when no custom Drop strategy is available
- */
- public CustomizableDropEditPolicy(EditPolicy defaultDropEditPolicy, EditPolicy defaultCreationEditPolicy) {
- this.defaultDropEditPolicy = defaultDropEditPolicy;
- this.defaultCreationEditPolicy = defaultCreationEditPolicy;
- }
-
- @Override
- public Command getCommand(final Request request) {
- Command command;
-
- if(super.understandsRequest(request)) {
- //Drag & Drop request
- try {
- command = super.getCommand(request); //Will call this.getDropObjectsCommand() eventually
- } catch (Exception ex) {
- command = getCustomCommand(request);
- }
- } else if(this.understands(request)) {
- //Add request
- command = getCreationCommand(request);
- } else if(defaultCreationEditPolicy != null) {
- //Creation request
- command = defaultCreationEditPolicy.getCommand(request);
- } else {
- command = null;
- }
-
- if(command == null) {
- return null;
- }
-
- return command;
- }
-
- @Override
- public boolean understandsRequest(Request request) {
- return this.understands(request) || (defaultCreationEditPolicy != null && defaultCreationEditPolicy.understandsRequest(request)) || (defaultDropEditPolicy != null && defaultDropEditPolicy.understandsRequest(request));
- }
-
- protected boolean understands(Request request) {
- return RequestConstants.REQ_ADD.equals(request.getType());
- }
-
- protected Command getCreationCommand(Request request) {
- return getCustomCommand(request);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Command getDropObjectsCommand(DropObjectsRequest request) {
- return getCustomCommand(request);
- }
-
- /**
- * Returns the command from a Custom DropStrategy
- *
- * @param request
- * @return
- */
- protected Command getCustomCommand(Request request) {
- final Map<DropStrategy, Command> matchingStrategies = findStrategies(request);
-
- //Only one strategy: return the associated command
- if(matchingStrategies.size() == 1) {
- return matchingStrategies.values().iterator().next();
- }
-
- //More than one strategy
- if(matchingStrategies.size() > 1) {
- boolean useDefault = true;
-
- //FIXME: What's the exact semantic of EVENT_DETAIL=DND_COPY in Papyrus?
- //Currently, DND_COPY corresponds to Ctrl + Drag/Drop
- if(request.getExtendedData().containsKey(EVENT_DETAIL)) {
- int eventDetailValue = (Integer)request.getExtendedData().get(EVENT_DETAIL);
- if((eventDetailValue & DND.DROP_COPY) != 0) {
- useDefault = false;
- }
- }
-
- //Search for a default strategy
- if(useDefault) {
- DropStrategy defaultStrategy = DropStrategyManager.instance.getDefaultDropStrategy(matchingStrategies.keySet());
- if(defaultStrategy != null) {
- return matchingStrategies.get(defaultStrategy);
- }
- }
-
- //If there is no default choice, ask user (Open a choice List)
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- DefaultActionHandler handler = new DefaultActionHandler() {
-
- public void defaultActionSelected(Command defaultCommand) {
- DropStrategy defaultStrategy = findStrategy(matchingStrategies, defaultCommand);
- if(defaultStrategy != null) {
- DropStrategyManager.instance.setDefaultDropStrategy(matchingStrategies.keySet(), defaultStrategy);
- }
- }
-
- public String getLabel() {
- return "Change the default strategy";
- }
- };
-
- SelectAndExecuteCommand command = new SelectAndExecuteCommand("Select drop", shell, new LinkedList<Command>(matchingStrategies.values()), handler);
- return new ICommandProxy(command);
- }
-
- //No matching strategy
- return null;
- }
-
- private static DropStrategy findStrategy(Map<DropStrategy, Command> matchingStrategies, Command command) {
- for(Map.Entry<DropStrategy, Command> entry : matchingStrategies.entrySet()) {
- if(entry.getValue() == command) {
- return entry.getKey();
- }
- }
- return null;
- }
-
- /**
- * Returns a map of DropStrategy / Command, for each Strategy which can handle
- * the given request. All the returned commands are executable. The map may be empty.
- *
- * @param request
- * @return
- */
- protected Map<DropStrategy, Command> findStrategies(Request request) {
- Map<DropStrategy, Command> matchingStrategies = new LinkedHashMap<DropStrategy, Command>();
-
- boolean useDefault = false;
-
- for(DropStrategy strategy : DropStrategyManager.instance.getActiveStrategies()) {
- if(strategy instanceof DefaultDropStrategy) {
- useDefault = true;
- }
- Command command = strategy.getCommand(request, getHost());
- if(command != null && command.canExecute()) {
- matchingStrategies.put(strategy, command);
- }
- }
-
- if(useDefault) {
- DropStrategy defaultStrategy = new DefaultDropStrategy(defaultDropEditPolicy, defaultCreationEditPolicy);
- Command command = defaultStrategy.getCommand(request, getHost());
- if(command != null && command.canExecute()) {
- matchingStrategies.put(defaultStrategy, command);
- }
- }
-
- return matchingStrategies;
- }
-
- /**
- * @see org.eclipse.gef.EditPolicy#showTargetFeedback(org.eclipse.gef.Request)
- */
- @Override
- public void showTargetFeedback(Request request) {
- if(!(getHost() instanceof DiagramEditPart)) {
- super.showTargetFeedback(request);
- }
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
deleted file mode 100644
index 3eaa41d59de..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*****************************************************************************
- * 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);
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/DropStrategyManager.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/DropStrategyManager.java
deleted file mode 100644
index 21e03c8e727..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/DropStrategyManager.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*****************************************************************************
- * 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 java.text.Collator;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.Activator;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Singleton instance. This class is used to read and manage the various
- * DropStrategies: activation, order (priority)
- *
- *
- * @author Camille Letavernier
- *
- */
-public class DropStrategyManager {
-
- /**
- * The drop strategy extension point
- */
- public static final String EXTENSION_ID = Activator.PLUGIN_ID + ".dropStrategy";
-
- /**
- * The priority property suffix (For preferences)
- */
- public static final String PRIORITY_KEY = "priority"; //$NON-NLS-1$
-
- /**
- * The isActive property suffix (For preferences)
- */
- public static final String IS_ACTIVE_KEY = "isActive"; //$NON-NLS-1$
-
- /**
- * The default strategy property suffix (For preferences)
- */
- public static final String DEFAULT_STRATEGY_KEY = "defaultStrategy"; //$NON-NLS-1$
-
- /**
- * All DropStrategies, defined through an extension point
- * The values are grouped by priority.
- *
- * (Including the DefaultDropStrategy)
- */
- private final SortedMap<Integer, List<DropStrategy>> allAvailableStrategies;
-
- /**
- * A map to indicate whether each DropStrategy is active
- */
- private final Map<DropStrategy, Boolean> activeStrategies;
-
- /**
- * The map of default strategies for each known conflicting case
- */
- private final Map<Set<DropStrategy>, DropStrategy> defaultStrategies;
-
- /**
- * Stores a map of String/Integer (Strategy id / priority)
- * and String/Boolean (Strategy id / boolean)
- *
- * The ids are suffixed by the property name, e.g. :
- *
- * oep.myStrategy.isActive=true
- * oep.myStrategy.priority=12
- */
- private final IPreferenceStore preferences;
-
- private DropStrategyManager() {
- allAvailableStrategies = new TreeMap<Integer, List<DropStrategy>>();
- activeStrategies = new HashMap<DropStrategy, Boolean>();
- defaultStrategies = new HashMap<Set<DropStrategy>, DropStrategy>();
- preferences = Activator.getDefault().getPreferenceStore();
- init();
- }
-
- private void init() {
- initStrategies(); //Init all available strategies, reads the priorities
- initActiveStrategies(); //Reads whether each available strategy is active
- initDefaultPreferences(); //Inits the preference store's default values (priority + isActive)
- initDefaultDropStrategies(); //Inits the default drop strategies
- }
-
- private void initStrategies() {
- IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
-
- //Loads all strategies from the extension point.
- for(IConfigurationElement e : config) {
- try {
- if("strategy".equals(e.getName())) {
- DropStrategy strategy = (DropStrategy)e.createExecutableExtension("strategy"); //$NON-NLS-1$
- int priority = findPriority(strategy);
- getStrategies(priority).add(strategy);
- }
- } catch (Exception ex) {
- Activator.log.error("The plugin " + e.getContributor() + " contributed an invalid extension for " + EXTENSION_ID, ex); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- private void initActiveStrategies() {
- for(List<DropStrategy> strategies : allAvailableStrategies.values()) {
- for(DropStrategy strategy : strategies) {
- activeStrategies.put(strategy, isActive(strategy));
- }
- }
- }
-
- private void initDefaultPreferences() {
- for(Collection<DropStrategy> strategies : allAvailableStrategies.values()) {
- for(DropStrategy strategy : strategies) {
- preferences.setDefault(getPriorityKey(strategy), strategy.getPriority());
- preferences.setDefault(getIsActiveKey(strategy), true);
- }
- }
- }
-
- private void initDefaultDropStrategies() {
- try {
- for(String key : InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).keys()) {
- if(key.endsWith(DEFAULT_STRATEGY_KEY)) {
- parseDefaultDropStrategy(key);
- }
- }
- } catch (BackingStoreException ex) {
- Activator.log.error("Could not initialize the default Drag & Drop strategy choices", ex);
- }
- }
-
- private DropStrategy findStrategy(String id) {
- for(DropStrategy strategy : getAllStrategies()) {
- if(strategy.getID().equals(id)) {
- return strategy;
- }
- }
- return null;
- }
-
- private void parseDefaultDropStrategy(String key) {
- String[] strategyIds = key.substring(0, key.lastIndexOf(":")).split(":");
-
- Set<DropStrategy> strategies = new HashSet<DropStrategy>();
- for(String strategyId : strategyIds) {
- DropStrategy strategy = findStrategy(strategyId);
- if(strategy == null) {
- return; //Invalid preference ; skip
- }
- strategies.add(strategy);
- }
-
- if(strategies.size() > 1) {
- defaultStrategies.put(strategies, findStrategy(preferences.getString(key)));
- }
- }
-
- /**
- * Returns a collection of all DropStrategy with the given priority.
- * Never returns null
- *
- * @param priority
- * @return
- */
- private List<DropStrategy> getStrategies(int priority) {
- if(!allAvailableStrategies.containsKey(priority)) {
- allAvailableStrategies.put(priority, new LinkedList<DropStrategy>());
- }
- return allAvailableStrategies.get(priority);
- }
-
- /**
- * Returns a list of all active DropStrategy, ordered by priority. Never returns null.
- *
- * @return
- */
- public List<DropStrategy> getActiveStrategies() {
- List<DropStrategy> orderedActiveStrategies = new LinkedList<DropStrategy>();
- for(List<DropStrategy> strategies : allAvailableStrategies.values()) {
- for(DropStrategy strategy : strategies) {
- if(isActive(strategy)) {
- orderedActiveStrategies.add(strategy);
- }
- }
- }
- return orderedActiveStrategies;
- }
-
- /**
- * All DropStrategies
- * The values are grouped by priority.
- *
- * (Including the DefaultDropStrategy)
- */
- public Map<Integer, List<DropStrategy>> getAllAvailableStrategies() {
- return allAvailableStrategies;
- }
-
- public static String getPriorityKey(DropStrategy strategy) {
- return strategy.getID() + "." + PRIORITY_KEY;
- }
-
- public static String getIsActiveKey(DropStrategy strategy) {
- return strategy.getID() + "." + IS_ACTIVE_KEY;
- }
-
- public static String getDefaultStrategyKey(Collection<DropStrategy> conflict) {
- List<DropStrategy> orderedStrategies = new LinkedList<DropStrategy>(conflict);
-
- Collections.sort(orderedStrategies, new Comparator<DropStrategy>() {
-
- public int compare(DropStrategy strategy1, DropStrategy strategy2) {
- return Collator.getInstance().compare(strategy1.getID(), strategy2.getID());
- }
-
- });
-
- String key = ""; //$NON-NLS-1$
- for(DropStrategy strategy : conflict) {
- key += strategy.getID() + ":";
- }
- key += DEFAULT_STRATEGY_KEY;
-
- return key;
- }
-
- public int findPriority(DropStrategy strategy) {
- String preferenceKey = getPriorityKey(strategy);
- if(preferences.contains(preferenceKey)) {
- return preferences.getInt(preferenceKey);
- }
-
- return strategy.getPriority(); //Default
- }
-
- public boolean isActive(DropStrategy strategy) {
- String preferenceKey = getIsActiveKey(strategy);
- if(preferences.contains(preferenceKey)) {
- return preferences.getBoolean(preferenceKey);
- }
-
- return true; //Default
- }
-
- public void setActive(DropStrategy strategy, boolean active) {
- preferences.setValue(getIsActiveKey(strategy), active);
- activeStrategies.put(strategy, active);
- }
-
- public void setPriority(DropStrategy strategy, int priority) {
- //Remove the DropStrategy from its previous priority
- getStrategies(findPriority(strategy)).remove(strategy);
-
- //Add it again at the right priority
- preferences.setValue(getPriorityKey(strategy), priority);
- getStrategies(priority).add(strategy);
- }
-
- public static final DropStrategyManager instance = new DropStrategyManager();
-
- /**
- * Returns a flat list of all available strategies.
- *
- * The strategies are ordered by priority
- *
- * @return
- */
- public List<DropStrategy> getAllStrategies() {
- List<DropStrategy> result = new LinkedList<DropStrategy>();
- for(List<DropStrategy> strategies : allAvailableStrategies.values()) {
- result.addAll(strategies);
- }
- return result;
- }
-
- /**
- * Restores the default preferences
- */
- public void restoreDefaults() {
- try {
- IEclipsePreferences preferenceStore = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- preferenceStore.clear();
- preferenceStore.flush();
- } catch (BackingStoreException ex) {
- Activator.log.error(ex);
- }
- activeStrategies.clear();
- allAvailableStrategies.clear();
- defaultStrategies.clear();
- initStrategies();
- initActiveStrategies();
- initDefaultDropStrategies();
- }
-
- /**
- * Returns the default drop strategy among the given list, or null if there is
- * no default.
- *
- * @param strategies
- * @return
- */
- public DropStrategy getDefaultDropStrategy(Collection<DropStrategy> strategies) {
- if(strategies.isEmpty()) {
- return null;
- }
-
- DropStrategy defaultStrategy;
-
- if(strategies.size() == 1) {
- defaultStrategy = strategies.iterator().next();
- } else {
- Set<DropStrategy> conflictingStrategies = new HashSet<DropStrategy>(strategies);
- defaultStrategy = defaultStrategies.get(conflictingStrategies);
- }
-
- if(defaultStrategy == null) {
- return null;
- }
-
- return isActive(defaultStrategy) ? defaultStrategy : null;
- }
-
- /**
- * Sets the default drop strategy for a set of conflicting strategies
- *
- * @param conflictingStrategies
- * @param defaultStrategy
- */
- public void setDefaultDropStrategy(Collection<DropStrategy> conflictingStrategies, DropStrategy defaultStrategy) {
- if(conflictingStrategies.size() < 2) {
- return;
- }
-
- Set<DropStrategy> conflict = new HashSet<DropStrategy>(conflictingStrategies);
- defaultStrategies.put(conflict, defaultStrategy);
- preferences.putValue(getDefaultStrategyKey(conflict), defaultStrategy.getID());
-
- //Save the preferences
- IEclipsePreferences preferenceStore = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
- try {
- preferenceStore.flush();
- } catch (BackingStoreException ex) {
- Activator.log.error(ex);
- }
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferences.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferences.java
deleted file mode 100644
index d2d7ba1895c..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferences.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*****************************************************************************
- * 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.preferences;
-
-
-public interface DNDPreferences {
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferencesPage.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferencesPage.java
deleted file mode 100644
index 09697653d21..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DNDPreferencesPage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
- * 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.preferences;
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.Activator;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.policy.DropStrategyManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-
-public class DNDPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private DropStrategyEditor editor;
-
- /**
- *
- * Constructor.
- *
- */
- public DNDPreferencesPage() {
- super("Drag and Drop", org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImageDescriptor("/icons/papyrus.png"));
- }
-
- public void init(IWorkbench workbench) {
- setPreferenceStore(Activator.getDefault().getPreferenceStore());
- setDescription("Papyrus drag and drop configuration.\nSelect the drop strategies you wish to activate.");
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Composite self = new Composite(parent, SWT.NONE);
- self.setLayout(new GridLayout(1, true));
-
- editor = new DropStrategyEditor(self, SWT.NONE);
- editor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- return self;
- }
-
- @Override
- protected void performDefaults() {
- if(editor != null && !editor.isDisposed()) {
- DropStrategyManager.instance.restoreDefaults();
- editor.refresh();
- }
- super.performDefaults();
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyEditor.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyEditor.java
deleted file mode 100644
index d1d09d74fae..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyEditor.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*****************************************************************************
- * 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.preferences;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.databinding.observable.list.WritableList;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.policy.DropStrategyManager;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TreeEditor;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-
-
-public class DropStrategyEditor extends MultipleReferenceEditor {
-
- // protected Button toggle;
-
- public static final int ACTIVATION_COLUMN = 0;
-
- public static final int LABEL_COLUMN = 1;
-
- private final Map<DropStrategy, Button> checkboxes;
-
- public DropStrategyEditor(Composite parent, int style) {
- super(parent, style, true, true, "Strategies");
-
- List<DropStrategy> values = DropStrategyManager.instance.getAllStrategies();
-
- IStaticContentProvider provider = new StaticContentProvider(values.toArray());
- ColumnViewerToolTipSupport.enableFor(treeViewer, ToolTip.NO_RECREATE);
- setProviders(provider, new DropStrategyLabelProvider());
- setModelObservable(new DropStrategyObservableList(values));
-
- TableLayout layout = new TableLayout();
-
- new TreeColumn(tree, SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(10, 25, false));
-
- new TreeColumn(tree, SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(100, 250, true));
-
- tree.setLayout(layout);
- tree.setHeaderVisible(false);
-
- setToolTipText("Strategies");
-
- treeViewer.refresh();
-
- //Adds a checkbox for each DropStrategy, to toggle it
- checkboxes = new HashMap<DropStrategy, Button>();
-
- for(TreeItem item : tree.getItems()) {
- if(item.getData() instanceof DropStrategy) {
- TreeEditor editor = new TreeEditor(tree);
- final Button button = new Button(tree, SWT.CHECK);
- final TreeItem currentItem = item;
-
- final DropStrategy strategy = (DropStrategy)currentItem.getData();
- button.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- updateStrategy(strategy, button);
- treeViewer.refresh();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- //Nothing
- }
-
- });
-
- checkboxes.put(strategy, button);
-
- button.setSelection(DropStrategyManager.instance.isActive(strategy));
-
- editor.setEditor(button, item, ACTIVATION_COLUMN);
- editor.horizontalAlignment = SWT.CENTER;
- editor.grabHorizontal = true;
- }
- }
-
- //Adds a space-key listener to edit a list of selected checkboxes
- tree.addKeyListener(new KeyListener() {
-
- public void keyReleased(KeyEvent e) {
- if(e.keyCode == SWT.SPACE) {
- ISelection selection = treeViewer.getSelection();
- if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
-
- Boolean isActive = findIsActive(structuredSelection);
-
- Iterator<?> iterator = structuredSelection.iterator();
- while(iterator.hasNext()) {
- Object element = iterator.next();
- if(element instanceof DropStrategy) {
- DropStrategy strategy = (DropStrategy)element;
- Button button = checkboxes.get(strategy);
-
- updateStrategy(strategy, button, isActive);
- }
- }
-
- treeViewer.refresh();
- }
- }
- }
-
- public void keyPressed(KeyEvent e) {
- //Nothing
- }
- });
- }
-
- //Returns the new status of the first DropStrategy in the selection.
- //Returns null if the selection doesn't contain any DropStrategy
- private Boolean findIsActive(IStructuredSelection selection) {
- Iterator<?> iterator = selection.iterator();
- while(iterator.hasNext()) {
- Object element = iterator.next();
- if(element instanceof DropStrategy) {
- boolean isActive = DropStrategyManager.instance.isActive((DropStrategy)element); //Current status
- return !isActive; //New status (Toggle)
- }
- }
- return null; //No DropStrategy found in the selection
- }
-
- private void updateStrategy(DropStrategy strategy, Button button, boolean isActive) {
- DropStrategyManager.instance.setActive(strategy, isActive);
- button.setSelection(isActive);
- }
-
- private void updateStrategy(DropStrategy strategy, Button button) {
- boolean isActive = DropStrategyManager.instance.isActive(strategy);
- updateStrategy(strategy, button, !isActive);
- }
-
- @Override
- public void createListControls() {
- super.createListControls();
- edit.dispose();
- remove.dispose();
- add.dispose();
- up.dispose();
- down.dispose();
-
- // toggle = new Button(controlsSection, SWT.TOGGLE);
- // toggle.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/Add_12x12.gif"));
- // toggle.addSelectionListener(this);
- // toggle.setToolTipText("Toggle the selected strategies");
-
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- updateControls();
- }
- });
- }
-
- protected Object[] getSelectedElements() {
- IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
- return selection.toArray();
- }
-
- @Override
- public void widgetSelected(SelectionEvent event) {
- // if(event.widget == toggle) {
- // toggleAction(toggle.getSelection());
- // } else {
- super.widgetSelected(event);
- // }
- }
-
- protected void toggleAction(boolean activate) {
- Object[] selectedElements = getSelectedElements();
- for(Object selected : selectedElements) {
- if(selected instanceof DropStrategy) {
- DropStrategyManager.instance.setActive((DropStrategy)selected, activate);
- }
- }
- treeViewer.refresh();
- }
-
- @Override
- protected void updateControls() {
- //Skip super.updateControls ; this is not configurable. Avoids a widget disposed exception
-
- // boolean activate = false;
- //
- // Object[] selectedElements = getSelectedElements();
- // for(Object selected : selectedElements) {
- // if(selected instanceof DropStrategy) {
- // if(DropStrategyManager.instance.isActive((DropStrategy)selected)) {
- // activate = true;
- // break;
- // }
- // }
- // }
-
- // toggle.setSelection(activate);
- }
-
- private class DropStrategyObservableList extends WritableList {
-
- public DropStrategyObservableList(List<DropStrategy> values) {
- super();
- addAll(values);
- }
-
- @Override
- public Object move(int oldIndex, int newIndex) {
- Object objectToMove = get(oldIndex);
- Object other = get(newIndex);
-
- if(objectToMove instanceof DropStrategy && other instanceof DropStrategy) {
- DropStrategy strategyToMove = (DropStrategy)objectToMove;
- DropStrategy otherStrategy = (DropStrategy)other;
-
- int priority = DropStrategyManager.instance.findPriority(otherStrategy);
- int newPriority = (newIndex > oldIndex) ? priority + 1 : priority - 1;
-
- DropStrategyManager.instance.setPriority(strategyToMove, newPriority);
- }
-
- return super.move(oldIndex, newIndex);
- }
- }
-
- /**
- * Refreshes the widget's contents, based on the DropStrategyManager's current values
- */
- public void refresh() {
- for(Map.Entry<DropStrategy, Button> entry : checkboxes.entrySet()) {
- boolean isActive = DropStrategyManager.instance.isActive(entry.getKey());
- updateStrategy(entry.getKey(), entry.getValue(), isActive);
- }
- treeViewer.refresh();
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyLabelProvider.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyLabelProvider.java
deleted file mode 100644
index 14cefed18c9..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/preferences/DropStrategyLabelProvider.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*****************************************************************************
- * 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.preferences;
-
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.policy.DropStrategyManager;
-import org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * A LabelProvider for DropStrategy
- *
- * @author Camille Letavernier
- */
-public class DropStrategyLabelProvider extends ColumnLabelProvider {
-
- @Override
- public String getText(Object element) {
- if(element instanceof DropStrategy) {
- return ((DropStrategy)element).getLabel();
- }
- return super.getText(element);
- }
-
- @Override
- public Image getImage(Object element) {
- if(element instanceof DropStrategy) {
- return ((DropStrategy)element).getImage();
- }
- return super.getImage(element);
- }
-
- @Override
- public String getToolTipText(Object element) {
- if(element instanceof DropStrategy) {
- return ((DropStrategy)element).getDescription();
- }
- return null;
- }
-
-
- @Override
- public void update(ViewerCell cell) {
- Object element = cell.getElement();
-
- if(element instanceof DropStrategy) {
- DropStrategy strategy = (DropStrategy)element;
- if(cell.getColumnIndex() == DropStrategyEditor.LABEL_COLUMN) {
- cell.setImage(strategy.getImage());
-
- int foreground;
-
- if(DropStrategyManager.instance.isActive(strategy)) {
- foreground = SWT.COLOR_BLACK;
- } else {
- foreground = SWT.COLOR_GRAY;
- }
- cell.setForeground(Display.getCurrent().getSystemColor(foreground));
- cell.setText(strategy.getLabel());
- }
- }
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/AbstractDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/AbstractDropStrategy.java
deleted file mode 100644
index 3eeb2d47cdf..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/AbstractDropStrategy.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gef.tools.ToolUtilities;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
-import org.eclipse.swt.dnd.DND;
-
-/**
- * An abstract implementation of a DropStrategy, which provides helper methods
- *
- * @author Camille Letavernier
- */
-public abstract class AbstractDropStrategy implements DropStrategy {
-
- /**
- * Returns the Semantic element which is the drop target
- *
- * @param targetEditPart
- * The drop target edit part
- * @return
- * The drop target semantic element
- */
- protected EObject getTargetSemanticElement(EditPart targetEditPart) {
- return EMFHelper.getEObject(targetEditPart);
- }
-
- /**
- * Returns the Notation View which is the drop target
- *
- * @param targetEditPart
- * The drop target edit part
- * @return
- * The drop target notation View
- */
- protected View getTargetView(EditPart targetEditPart) {
- return NotationHelper.findView(targetEditPart);
- }
-
- /**
- * Returns the list of selected objects. The objects can be of any type.
- *
- * @param request
- * The drop request
- * @return
- * The list of dropped Objects
- */
- protected List<Object> getSourceObjects(Request request) {
- List<Object> result = new LinkedList<Object>();
- if(request instanceof DropObjectsRequest) {
- result.addAll(((DropObjectsRequest)request).getObjects());
- } else if(request instanceof GroupRequest) {
- result.addAll(((ChangeBoundsRequest)request).getEditParts());
- }
- return result;
- }
-
- /**
- * Returns the list of semantic EObjects being dropped. If some of the dropped elements
- * cannot be resolved to EObjects, they are ignored.
- *
- * @param request
- * The drop request
- * @return
- * The list of dropped EObjects
- */
- protected List<EObject> getSourceEObjects(Request request) {
- List<EObject> result = new LinkedList<EObject>();
-
- for(Object object : getSourceObjects(request)) {
- EObject eObject = EMFHelper.getEObject(object);
- if(eObject instanceof View) {
- eObject = ((View)eObject).getElement();
- }
-
- if(eObject != null) {
- result.add(eObject);
- }
- }
-
- return result;
- }
-
- /**
- * Returns a DropObjectsRequest corresponding to the given request,
- * or null is such an operation is not possible.
- *
- * @param request
- * @return
- */
- protected DropObjectsRequest getDropObjectsRequest(Request request) {
- if(request instanceof DropObjectsRequest) {
- return (DropObjectsRequest)request;
- }
-
- //Adapted from org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy#castToDropObjectsRequest
- if(request instanceof ChangeBoundsRequest) {
- ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest)request;
- Iterator<EditPart> editParts = ToolUtilities.getSelectionWithoutDependants(changeBoundsRequest.getEditParts()).iterator();
-
- List<EObject> elements = new LinkedList<EObject>();
- while(editParts.hasNext()) {
- EditPart editPart = editParts.next();
- if(editPart instanceof IGraphicalEditPart) {
- EObject element = ViewUtil.resolveSemanticElement((View)((IGraphicalEditPart)editPart).getModel());
- if(element != null) {
- elements.add(element);
- }
- }
- }
-
- DropObjectsRequest req = new DropObjectsRequest();
- req.setObjects(elements);
- req.setAllowedDetail(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK);
- req.setLocation(changeBoundsRequest.getLocation());
- req.setRequiredDetail(DND.DROP_COPY); //FIXME: Handle drop links (DND.DROP_LINK)
- return req;
- }
-
- return null;
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/CompositeDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/CompositeDropStrategy.java
deleted file mode 100644
index 9c45d956304..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/CompositeDropStrategy.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.swt.graphics.Image;
-
-
-public abstract class CompositeDropStrategy implements DropStrategy {
-
- protected final List<DropStrategy> strategies = new LinkedList<DropStrategy>();
-
- public Image getImage() {
- return null;
- }
-
- public void setOptions(Map<String, Object> options) {
- // TODO Auto-generated method stub
- }
-
- public Command getCommand(Request request, EditPart targetEditPart) {
- Command command = new CompoundCommand();
-
- for(DropStrategy strategy : strategies) {
- command.chain(strategy.getCommand(request, targetEditPart));
- }
-
- return command;
- }
-
- public void addStrategy(DropStrategy strategy) {
- strategies.add(strategy);
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java
deleted file mode 100644
index 5069134d57d..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import java.util.Map;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * A drop strategy which delegates to the hard-coded Drop edit policy
- * Called when no other strategy is available (Lowest priority)
- *
- * @author Camille Letavernier
- *
- */
-public class DefaultDropStrategy implements DropStrategy {
-
- protected EditPolicy baseDropEditPolicy;
-
- protected EditPolicy baseCreationEditPolicy;
-
- /**
- * Constructs a generic instance of DefaultDropStrategy.
- * This instance can only be used as a descriptor.
- */
- public DefaultDropStrategy() {
-
- }
-
- /**
- * Constructs an instance of DefaultDropStrategy for a specific edit policy
- *
- * @param baseDropEditPolicy
- * @param baseCreationEditPolicy
- */
- public DefaultDropStrategy(EditPolicy baseDropEditPolicy, EditPolicy baseCreationEditPolicy) {
- this.baseDropEditPolicy = baseDropEditPolicy;
- this.baseCreationEditPolicy = baseCreationEditPolicy;
- }
-
- public String getLabel() {
- return "Default";
- }
-
- public String getID() {
- return "default";
- }
-
- public String getDescription() {
- return "Default drop strategy";
- }
-
- public Command getCommand(Request request, final EditPart targetEditPart) {
- if(baseDropEditPolicy == null) {
- if(baseCreationEditPolicy == null) {
- return null;
- }
- return baseCreationEditPolicy.getCommand(request);
- }
-
- Command command = baseDropEditPolicy.getCommand(request);
-
- if(command == null && baseCreationEditPolicy != null) {
- command = baseCreationEditPolicy.getCommand(request);
- }
-
- return command;
- }
-
- public Image getImage() {
- return null;
- }
-
- public int getPriority() {
- return 100; //Low priority
- }
-
- public void setOptions(Map<String, Object> options) {
- //Nothing
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java
deleted file mode 100644
index 28757ca3bd9..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * A strategy to be applied when dropping elements
- *
- * @author Camille Letavernier
- */
-public interface DropStrategy {
-
- /**
- * A user-readable label
- *
- * @return
- */
- public String getLabel();
-
- /**
- * A user-readable description
- *
- * @return
- */
- public String getDescription();
-
- /**
- * An image to associate to this strategy
- *
- * @return
- */
- public Image getImage();
-
- /**
- * A unique ID for this strategy
- *
- * @return
- */
- public String getID();
-
- /**
- * The command to be executed when the strategy is applied.
- * Should return null if the strategy cannot handle the request.
- *
- * @param request
- * The drop request
- * @param targetEditPart
- * The target edit part
- * @return
- * A command, or null if the strategy cannot handle the request
- */
- public Command getCommand(Request request, EditPart targetEditPart);
-
- /**
- * The default priority for this strategy. Might be overridden by a user
- * preference.
- *
- * @return
- * @deprecated The priority mechanism isn't used anymore
- */
- @Deprecated
- public int getPriority();
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/MoveDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/MoveDropStrategy.java
deleted file mode 100644
index 7249f782351..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/MoveDropStrategy.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.swt.graphics.Image;
-
-
-public abstract class MoveDropStrategy extends TransactionalDropStrategy {
-
- // public final static String TARGET_FEATURE = "targetFeature";
-
- protected EStructuralFeature feature;
-
- public String getLabel() {
- return "Move element";
- }
-
- public String getDescription() {
- return "Move the selected element in one of the target's properties";
- }
-
- public Image getImage() {
- return null;
- }
-
- protected EStructuralFeature getTargetFeature(Request request, EditPart targetEditPart) {
- return feature;
- }
-
- public void setTargetFeature(EStructuralFeature targetFeature) {
- this.feature = targetFeature;
- }
-
- //parameters:
- //what element should be dropped ? (Extract the right value from the selection)
- //where should it be dropped ?
- // - Target object
- // - Target property
- // - Target view (Compartment, ...)
- // public void setOptions(Map<String, Object> options) {
- // if(options.containsKey(TARGET_FEATURE)) {
- // Object targetFeature = options.get(TARGET_FEATURE);
- // if(targetFeature instanceof EStructuralFeature) {
- // setTargetFeature((EStructuralFeature)targetFeature);
- // }
- // }
- // }
-
- @Override
- public Command doGetCommand(Request request, EditPart targetEditPart) {
- List<EObject> objectsToDrop = getSourceEObjects(request);
- if(objectsToDrop.isEmpty()) {
- return null;
- }
-
- Object newValue; //Single or multi-valued
-
- EObject targetElement = getTargetSemanticElement(targetEditPart);
-
- EStructuralFeature targetFeature = getTargetFeature(request, targetEditPart);
- if(targetFeature == null) {
- return null;
- }
-
- if(targetFeature.getUpperBound() == 1) {
- newValue = objectsToDrop.get(0);
- } else {
- EList<?> currentValues = (EList<?>)targetElement.eGet(targetFeature);
- List<? extends Object> values = new LinkedList<Object>(currentValues);
- values.addAll((List)objectsToDrop);
- newValue = values;
- }
-
- EditingDomain domain = getEditingDomain(targetEditPart);
- SetRequest setRequest = new SetRequest((TransactionalEditingDomain)domain, targetElement, targetFeature, newValue);
-
- ICommand command = new SetValueCommand(setRequest);
-
- Command graphicalCommand = getGraphicalCommand(request, targetEditPart);
- if(graphicalCommand != null) {
- command = command.compose(new CommandProxy(graphicalCommand));
- }
-
- return new ICommandProxy(command);
- }
-
- /**
- *
- * @param request
- * @param targetEditPart
- * @return A command to edit the graphical view
- */
- protected Command getGraphicalCommand(Request request, EditPart targetEditPart) {
- return null;
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/ServiceEditDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/ServiceEditDropStrategy.java
deleted file mode 100644
index c1ab24636c3..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/ServiceEditDropStrategy.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-
-/**
- * An abstract DropStrategy relying on the ServiceEdit. This strategy should
- * only be used for semantic drops.
- *
- * @author Camille Letavernier
- */
-public abstract class ServiceEditDropStrategy extends TransactionalDropStrategy {
-
- @Override
- public final Command doGetCommand(Request request, EditPart targetEditPart) {
- try {
- EObject targetElement = getTargetSemanticElement(targetEditPart);
-
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetElement);
-
- if(provider != null) {
- IEditCommandRequest editRequest = getEditRequest(request, targetEditPart);
- if(editRequest == null) {
- return null;
- }
-
- ICommand createGMFCommand = provider.getEditCommand(editRequest);
-
- if(createGMFCommand == null) {
- return null;
- }
-
- Command command = new ICommandProxy(createGMFCommand);
-
- return command;
- }
- } catch (Exception ex) {
- Activator.log.error(ex);
- }
-
- return null;
- }
-
- public abstract IEditCommandRequest getEditRequest(Request request, EditPart targetEditPart);
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/SetValueDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/SetValueDropStrategy.java
deleted file mode 100644
index 63578ee193b..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/SetValueDropStrategy.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.swt.graphics.Image;
-
-
-public abstract class SetValueDropStrategy extends TransactionalDropStrategy {
-
- protected EStructuralFeature feature;
-
- public String getLabel() {
- return "Set value";
- }
-
- public String getDescription() {
- return "Change a propertie's value on the target element";
- }
-
- public Image getImage() {
- return null;
- }
-
- @Override
- public Command doGetCommand(Request request, EditPart targetEditPart) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setTargetFeature(EStructuralFeature targetFeature) {
- this.feature = targetFeature;
- }
-
- protected EStructuralFeature getTargetFeature(Request request, EditPart targetEditPart) {
- return feature;
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java b/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java
deleted file mode 100644
index bfde65e647f..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*****************************************************************************
- * 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.strategy;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
-
-/**
- * An abstract implementation for TransactionalDropStrategies. Extenders do not
- * need to implement their commands' #undo and #redo methods.
- *
- * @author Camille Letavernier
- */
-public abstract class TransactionalDropStrategy extends AbstractDropStrategy {
-
- public final Command getCommand(Request request, EditPart targetEditPart) {
-
- final Command command = doGetCommand(request, targetEditPart);
-
- if(command == null) {
- return null;
- }
-
- String label = command.getLabel();
- if(label == null || "".equals(label)) {
- label = getLabel();
- }
-
- AbstractTransactionalCommand transactionalCommand = new AbstractTransactionalCommand(getTransactionalEditingDomain(targetEditPart), label, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- try {
- command.execute();
- return CommandResult.newOKCommandResult();
- } catch (Exception ex) {
- Activator.log.error(ex);
- return CommandResult.newErrorCommandResult(ex);
- }
- }
- };
-
- return new ICommandProxy(transactionalCommand);
- }
-
- protected boolean isTransactional(EditPart targetEditPart) {
- return getTransactionalEditingDomain(targetEditPart) != null;
- }
-
- protected TransactionalEditingDomain getTransactionalEditingDomain(EditPart targetEditPart) {
- EditingDomain domain = getEditingDomain(targetEditPart);
- if(domain instanceof TransactionalEditingDomain) {
- return (TransactionalEditingDomain)domain;
- }
- return null;
- }
-
- protected EditingDomain getEditingDomain(EditPart targetEditPart) {
- return EMFHelper.resolveEditingDomain(targetEditPart);
- }
-
- public abstract Command doGetCommand(Request request, EditPart targetEditPart);
-}

Back to the top