Author: b00__1
Date: 2007-08-14 13:48:21-0700
New Revision: 13353
Added:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java (contents, props changed)
Modified:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java
Log:
support the new interface org.argouml.model.CommandStack (to be commited)
Added: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java?view=auto&rev=13353
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/CommandStackImpl.java 2007-08-14 13:48:21-0700
@@ -0,0 +1,69 @@
+// $Id$
+// Copyright (c) 2007, The ArgoUML Project
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of the ArgoUML Project nor the
+// names of its contributors may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE ArgoUML PROJECT ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE ArgoUML PROJECT BE LIABLE FOR ANY
+// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package org.argouml.model.euml;
+
+import org.argouml.model.CommandStack;
+
+public class CommandStackImpl implements CommandStack {
+
+ private EUMLModelImplementation modelImplementation;
+
+ public CommandStackImpl(EUMLModelImplementation modelImplementation) {
+ this.modelImplementation = modelImplementation;
+ }
+
+ public boolean canRedo() {
+ return modelImplementation.getEditingDomain().getCommandStack().canRedo();
+ }
+
+ public boolean canUndo() {
+ return modelImplementation.getEditingDomain().getCommandStack().canUndo();
+ }
+
+ public String getRedoLabel() {
+ return canRedo() ? modelImplementation.getEditingDomain().getCommandStack().getRedoCommand().getLabel()
+ : null;
+ }
+
+ public String getUndoLabel() {
+ return canUndo() ? modelImplementation.getEditingDomain().getCommandStack().getUndoCommand().getLabel()
+ : null;
+ }
+
+ public boolean isCommandStackCapabilityAvailable() {
+ return true;
+ }
+
+ public void redo() {
+ modelImplementation.getEditingDomain().getCommandStack().redo();
+ }
+
+ public void undo() {
+ modelImplementation.getEditingDomain().getCommandStack().undo();
+ }
+
+}
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java?view=diff&rev=13353&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&r1=13352&r2=13353
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java 2007-08-14 13:48:21-0700
@@ -47,6 +47,7 @@
import java.util.Map;
import org.apache.log4j.Logger;
+import org.argouml.model.CommandStack;
import org.argouml.model.DiagramInterchangeModel;
import org.argouml.model.ModelImplementation;
import org.argouml.model.UmlException;
@@ -156,6 +157,8 @@
private UseCasesHelperEUMLImpl theUseCasesHelper;
private VisibilityKindEUMLImpl theVisibilityKind;
+
+ private CommandStackImpl theCommandStack;
/**
* This keeps track of the editing domain that is used to track all changes
@@ -172,50 +175,6 @@
}
/**
- * Verifies if the editing domain can undo the last changes in the UML
- * model.
- *
- * @return true if undo is possible, false otherwise
- */
- public boolean canUndo() {
- return editingDomain.getCommandStack().canUndo();
- }
-
- /**
- * Verifies if the editing domain can redo the last undone command.
- * @return true if redo is possible, false otherwise
- */
- public boolean canRedo() {
- return editingDomain.getCommandStack().canRedo();
- }
-
- /**
- * Undo the last command
- * <p>
- * If {@link #canUndo()} returns false, nothing will happen
- */
- public void undo() {
- if (!canUndo()) {
- LOG.debug("!!! canUndo() == false !!!"); //$NON-NLS-1$
- return;
- }
- editingDomain.getCommandStack().undo();
- }
-
- /**
- * Redo the last command
- * <p>
- * If {@link #canRedo()} returns false, nothing will happen
- */
- public void redo() {
- if (!canRedo()) {
- LOG.debug("!!! canRedo() == false !!!"); //$NON-NLS-1$
- return;
- }
- editingDomain.getCommandStack().redo();
- }
-
- /**
* This sets up the editing domain for the model editor.
*/
private void initializeEditingDomain() {
@@ -551,4 +510,11 @@
return null;
}
+ public CommandStack getCommandStack() {
+ if (theCommandStack == null) {
+ theCommandStack = new CommandStackImpl(this);
+ }
+ return theCommandStack;
+ }
+
}
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java?view=diff&rev=13353&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java&r1=13352&r2=13353
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java 2007-08-14 13:48:21-0700
@@ -42,6 +42,7 @@
import org.argouml.model.AbstractModelEventPump;
import org.argouml.model.AddAssociationEvent;
import org.argouml.model.AttributeChangeEvent;
+import org.argouml.model.CommandStack;
import org.argouml.model.DeleteInstanceEvent;
import org.argouml.model.RemoveAssociationEvent;
import org.eclipse.emf.common.command.CommandStackListener;
@@ -122,8 +123,6 @@
public static final int COMMAND_STACK_UPDATE = Notification.EVENT_TYPE_COUNT + 1;
- public static final String COMMAND_STACK_UPDATE_STRING = "COMMAND_STACK_UPDATE"; //$NON-NLS-1$
-
/**
* Constructor.
*
@@ -170,7 +169,7 @@
public void addModelEventListener(PropertyChangeListener listener,
Object modelelement, String[] propertyNames) {
if (!(modelelement instanceof EObject)
- && !(modelelement instanceof String && modelelement.equals(COMMAND_STACK_UPDATE_STRING))) {
+ && !(modelelement instanceof String && modelelement.equals(CommandStack.COMMAND_STACK_UPDATE_EVENT))) {
throw new IllegalArgumentException(
"The modelelement must be instance of EObject."); //$NON-NLS-1$
}
@@ -232,7 +231,7 @@
public void removeModelEventListener(PropertyChangeListener listener,
Object modelelement, String[] propertyNames) {
if (!(modelelement instanceof EObject)
- && !(modelelement instanceof String && modelelement.equals(COMMAND_STACK_UPDATE_STRING))) {
+ && !(modelelement instanceof String && modelelement.equals(CommandStack.COMMAND_STACK_UPDATE_EVENT))) {
throw new IllegalArgumentException();
}
unregisterListener(
@@ -382,8 +381,9 @@
} else if (notification.getEventType() == COMMAND_STACK_UPDATE) {
events.add(new EventAndListeners(
new PropertyChangeEvent(
- this, COMMAND_STACK_UPDATE_STRING, false, false),
- getListeners(COMMAND_STACK_UPDATE_STRING)));
+ this, CommandStack.COMMAND_STACK_UPDATE_EVENT,
+ false, false),
+ getListeners(CommandStack.COMMAND_STACK_UPDATE_EVENT)));
}
for (EventAndListeners e : events) {
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.