Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-04-20 22:46:04 +0000
committerChristian W. Damus2015-04-20 23:00:16 +0000
commit96bb1415cf8f840af6cbebd4c63401749ae5597c (patch)
tree9c2d61f25ef0846ba7820dd20b2b13fbb088df47 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus
parentc1ffffa11f43504e908d65abb47fb57e7c71178e (diff)
downloadorg.eclipse.papyrus-96bb1415cf8f840af6cbebd4c63401749ae5597c.tar.gz
org.eclipse.papyrus-96bb1415cf8f840af6cbebd4c63401749ae5597c.tar.xz
org.eclipse.papyrus-96bb1415cf8f840af6cbebd4c63401749ae5597c.zip
Revert "Bug 464844: [drag and drop] improve the initial dnd framework to allow"
This reverts commit 2855d324c846660b5febf2b10b24c2c1c42240d1 because it causes all of the diagram tests to hang on a pop-up menu asking whether to "Drop" or to "Change the default strategy -> Drop" (bug 465025).
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java53
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java33
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java17
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalCommandsDropStrategy.java107
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java28
5 files changed, 22 insertions, 216 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java
index 8fa58d8fc3d..77d12badcf8 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicy.java
@@ -12,7 +12,6 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.dnd.policy;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -226,15 +225,15 @@ public class CustomizableDropEditPolicy extends DragDropEditPolicy {
* @return
*/
protected Command getCustomCommand(Request request) {
- final Map<DropStrategy, List<Command>> matchingStrategies = findStrategies(request);
+ final Map<DropStrategy, Command> matchingStrategies = findStrategies(request);
// Only one strategy: return the associated command
- if (matchingStrategies.size() == 1 && matchingStrategies.values().iterator().next().size()==1) {
- return matchingStrategies.values().iterator().next().get(0);
+ if (matchingStrategies.size() == 1) {
+ return matchingStrategies.values().iterator().next();
}
// More than one strategy
- if (matchingStrategies.size() > 1 || matchingStrategies.values().iterator().next().size()>1) {
+ if (matchingStrategies.size() > 1) {
boolean useDefault = true;
// FIXME: What's the exact semantic of EVENT_DETAIL=DND_COPY in Papyrus?
@@ -250,7 +249,7 @@ public class CustomizableDropEditPolicy extends DragDropEditPolicy {
if (useDefault) {
DropStrategy defaultStrategy = DropStrategyManager.instance.getDefaultDropStrategy(matchingStrategies.keySet());
if (defaultStrategy != null) {
- return matchingStrategies.get(defaultStrategy).get(0);
+ return matchingStrategies.get(defaultStrategy);
}
}
@@ -270,17 +269,8 @@ public class CustomizableDropEditPolicy extends DragDropEditPolicy {
return "Change the default strategy";
}
};
-
- ArrayList<Command> proposalCommands = new ArrayList<Command>();
- for(List<Command> cs: matchingStrategies.values()){
- for(Command c : cs){
- if(c!=null){
- proposalCommands.add(c);
- }
- }
- }
- Activator.log.info("proposalCommands"+proposalCommands.size());;
- SelectAndExecuteCommand command = new SelectAndExecuteCommand("Select drop", shell, new LinkedList<Command>(proposalCommands), handler);
+
+ SelectAndExecuteCommand command = new SelectAndExecuteCommand("Select drop", shell, new LinkedList<Command>(matchingStrategies.values()), handler);
return new ICommandProxy(command);
}
@@ -288,8 +278,8 @@ public class CustomizableDropEditPolicy extends DragDropEditPolicy {
return null;
}
- private static DropStrategy findStrategy(Map<DropStrategy, List<Command>> matchingStrategies, Command command) {
- for (Map.Entry<DropStrategy, List<Command>> entry : matchingStrategies.entrySet()) {
+ 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();
}
@@ -304,27 +294,20 @@ public class CustomizableDropEditPolicy extends DragDropEditPolicy {
* @param request
* @return
*/
- protected Map<DropStrategy, List<Command>> findStrategies(Request request) {
- Map<DropStrategy, List<Command>> matchingStrategies = new LinkedHashMap<DropStrategy, List<Command>>();
+ protected Map<DropStrategy, Command> findStrategies(Request request) {
+ Map<DropStrategy, Command> matchingStrategies = new LinkedHashMap<DropStrategy, Command>();
- //Retrieve strategies
for (DropStrategy strategy : DropStrategyManager.instance.getActiveStrategies()) {
- List<Command> cs = strategy.getCommands(request, getHost());
- ArrayList<Command> selectedCommands = new ArrayList<Command>();
- for(Command command : cs){
- if (command != null && command.canExecute()) {
- selectedCommands.add(command);
-
- }
+ Command command = strategy.getCommand(request, getHost());
+ if (command != null && command.canExecute()) {
+ matchingStrategies.put(strategy, command);
}
- matchingStrategies.put(strategy, selectedCommands);
-
}
- //Retrieve defaultStrategy
- ArrayList<Command> selectedCommands = new ArrayList<Command>();
- selectedCommands.add(defaultDropStrategy.getCommand(request, getHost()));
- matchingStrategies.put(defaultDropStrategy, selectedCommands);
+ Command command = defaultDropStrategy.getCommand(request, getHost());
+ if (command != null && command.canExecute()) {
+ matchingStrategies.put(defaultDropStrategy, command);
+ }
return matchingStrategies;
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java
index 3dac3c0841f..cbd788506b4 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DefaultDropStrategy.java
@@ -11,8 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.dnd.strategy;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import org.eclipse.gef.EditPart;
@@ -65,14 +63,12 @@ public class DefaultDropStrategy implements DropStrategy {
return "Default drop strategy";
}
- public List<Command> getCommands(Request request, final EditPart targetEditPart) {
- ArrayList<Command> c = new ArrayList<Command>();
+ public Command getCommand(Request request, final EditPart targetEditPart) {
if (baseDropEditPolicy == null) {
if (baseCreationEditPolicy == null) {
return null;
}
- c.add(baseCreationEditPolicy.getCommand(request));
- return c;
+ return baseCreationEditPolicy.getCommand(request);
}
Command command = baseDropEditPolicy.getCommand(request);
@@ -80,31 +76,8 @@ public class DefaultDropStrategy implements DropStrategy {
if (command == null && baseCreationEditPolicy != null) {
command = baseCreationEditPolicy.getCommand(request);
}
- c.add(command);
- return c;
- }
-
- /**
- * The default 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){
- List<Command> commands = getCommands( request, targetEditPart);
- if(commands != null && commands.size()>0){
- return commands.get(0);
- }
- else{
- return null;
- }
-
+ return command;
}
public Image getImage() {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java
index 08f72278eea..55c3db639f7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/DropStrategy.java
@@ -11,8 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.dnd.strategy;
-import java.util.List;
-
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
@@ -54,20 +52,7 @@ public interface DropStrategy {
public String getID();
/**
- * The commands 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 List<Command> getCommands(Request request, EditPart targetEditPart);
-
- /**
- * The default command to be executed when the strategy is applied.
+ * The command to be executed when the strategy is applied.
* Should return null if the strategy cannot handle the request.
*
* @param request
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalCommandsDropStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalCommandsDropStrategy.java
deleted file mode 100644
index 2231397d41a..00000000000
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalCommandsDropStrategy.java
+++ /dev/null
@@ -1,107 +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.ArrayList;
-import java.util.List;
-
-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.dnd.Activator;
-
-/**
- * An abstract implementation for TransactionalCommandsDropStrategy. Extenders do not
- * need to implement their commands' #undo and #redo methods.
- * The differences with TransactionalDropStrategy is the fact that this class give the priority to the CommandS rather to the Command
- *
- * @author Camille Letavernier
- */
-public abstract class TransactionalCommandsDropStrategy extends AbstractDropStrategy {
-
- 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);
- }
-
- protected abstract List<Command> doGetCommands(Request request, EditPart targetEditPart);
-
-
- /**
- * 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
- */
- protected Command doGetCommand(Request request, EditPart targetEditPart) {
- List<Command> commands = doGetCommands(request, targetEditPart);
- if(commands!=null && commands.size()>0){
- return commands.get(0);
- }
- return null;
- }
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getCommands(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
- *
- * @param request
- * @param targetEditPart
- * @return
- */
- public List<Command> getCommands(Request request, EditPart targetEditPart) {
- List<Command> commands = new ArrayList<Command>();
- if(doGetCommands(request,targetEditPart)!=null && doGetCommands(request,targetEditPart).size()!=0){
- commands.addAll(doGetCommands(request,targetEditPart));
- }
- return commands;
- }
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
- *
- * @param request
- * @param targetEditPart
- * @return
- */
- public Command getCommand(Request request, EditPart targetEditPart) {
- List<Command> commands = doGetCommands(request,targetEditPart);
- if(commands!=null && commands.size()>0){
- return commands.get(0);
- }
- return null;
- }
-}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java
index 3f6751b899c..a4b0fd5e25b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/strategy/TransactionalDropStrategy.java
@@ -11,9 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.dnd.strategy;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -94,29 +91,4 @@ public abstract class TransactionalDropStrategy extends AbstractDropStrategy {
* A command, or null if the strategy cannot handle the request
*/
protected abstract Command doGetCommand(Request request, EditPart targetEditPart);
-
- protected List<Command> doGetCommands(Request request, EditPart targetEditPart) {
- List<Command> commands = new ArrayList<Command>();
- Command c = doGetCommand(request, targetEditPart);
- if(c!=null){
- commands.add(c);
- }
- return commands;
- }
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.dnd.strategy.DropStrategy#getCommands(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
- *
- * @param request
- * @param targetEditPart
- * @return
- */
- public List<Command> getCommands(Request request, EditPart targetEditPart) {
- List<Command> commands = new ArrayList<Command>();
- Command c = getCommand(request, targetEditPart);
- if(c!=null){
- commands.add(c);
- }
- return commands;
- }
}

Back to the top