Author: b00__1
Date: 2007-08-03 01:54:14-0700
New Revision: 13209
Modified:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java
Log:
Return the copied element and stop UML events when the copy cannot be done
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java?view=diff&rev=13209&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java&r1=13208&r2=13209
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java 2007-08-03 01:54:14-0700
@@ -31,7 +31,6 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.edit.command.CopyToClipboardCommand;
import org.eclipse.emf.edit.command.PasteFromClipboardCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.AssociationClass;
import org.eclipse.uml2.uml.Element;
@@ -41,8 +40,7 @@
/**
* This class exposes protected methods from
- * {@link org.eclipse.uml2.uml.UMLUtil}
- * and adds additional util methods
+ * {@link org.eclipse.uml2.uml.UMLUtil} and adds additional util methods
*
* @author Bogdan Pistol
*/
@@ -61,10 +59,13 @@
public static EList<Operation> getOwnedOperations(Type type) {
return org.eclipse.uml2.uml.util.UMLUtil.getOwnedOperations(type);
}
-
- public static boolean copy(EditingDomain editingDomain, Element source, Element destination) {
- Command copyToClipboard = CopyToClipboardCommand.create(editingDomain, source);
- Command pasteFromClipboard = PasteFromClipboardCommand.create(editingDomain, destination, null);
+
+ public static Element copy(EUMLModelImplementation modelImplementation,
+ Element source, Element destination) {
+ Command copyToClipboard = CopyToClipboardCommand.create(
+ modelImplementation.getEditingDomain(), source);
+ Command pasteFromClipboard = PasteFromClipboardCommand.create(
+ modelImplementation.getEditingDomain(), destination, null);
StrictCompoundCommand copyCommand = new StrictCompoundCommand() {
{
isPessimistic = true;
@@ -72,12 +73,23 @@
};
copyCommand.append(copyToClipboard);
copyCommand.append(pasteFromClipboard);
- if (!copyCommand.canExecute()) {
- return false;
- } else {
- editingDomain.getCommandStack().execute(copyCommand);
- return true;
+ if (copyCommand.canExecute()) {
+ modelImplementation.getModelEventPump().getRootContainer().setHoldEvents(
+ true);
+ modelImplementation.getEditingDomain().getCommandStack().execute(
+ copyCommand);
+ if (modelImplementation.getEditingDomain().getCommandStack().getMostRecentCommand().getAffectedObjects().size() == 1) {
+ modelImplementation.getModelEventPump().getRootContainer().setHoldEvents(
+ false);
+ return (Element) modelImplementation.getEditingDomain().getCommandStack().getMostRecentCommand().getAffectedObjects().iterator().next();
+ } else {
+ modelImplementation.getEditingDomain().getCommandStack().undo();
+ modelImplementation.getModelEventPump().getRootContainer().clearHeldEvents();
+ modelImplementation.getModelEventPump().getRootContainer().setHoldEvents(
+ false);
+ }
}
+ return null;
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.