svn commit: r13523 - trunk/src_new/org/argouml/kernel
[email protected] 9 Sep 2007 22:34:52 -0000
Newsgroups
gmane.comp.lang.uml.argouml.cvs
Message-ID
<[email protected] >
Author: bobtarling
Date: 2007-09-09 15:34:52-0700
New Revision: 13523
Modified:
trunk/src_new/org/argouml/kernel/DefaultUndoManager.java
trunk/src_new/org/argouml/kernel/ProjectManager.java
Log:
Propogate isRedoable from model to undomanager
Modified: trunk/src_new/org/argouml/kernel/DefaultUndoManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/DefaultUndoManager.java?view=diff&rev=13523&p1=trunk/src_new/org/argouml/kernel/DefaultUndoManager.java&p2=trunk/src_new/org/argouml/kernel/DefaultUndoManager.java&r1=13522&r2=13523
==============================================================================
--- trunk/src_new/org/argouml/kernel/DefaultUndoManager.java (original)
+++ trunk/src_new/org/argouml/kernel/DefaultUndoManager.java 2007-09-09 15:34:52-0700
@@ -86,6 +86,12 @@
}
public void addCommand(Command command) {
+
+ System.out.println("command " + command);
+ if (!command.isRedoable()) {
+ System.out.println("It's not redoable");
+ }
+
ProjectManager.getManager().setSaveEnabled(true);
if (undoMax == 0) {
@@ -123,9 +129,10 @@
public void undo() {
final Interaction command = undoStack.pop();
command.undo();
- if (command.isRedoable()) {
- redoStack.push(command);
+ if (!command.isRedoable()) {
+ redoStack.clear();
}
+ redoStack.push(command);
}
/**
@@ -231,7 +238,11 @@
// TODO: i18n
private String getRedoLabel() {
- return "Redo " + label;
+ if (isRedoable()) {
+ return "Redo " + label;
+ } else {
+ return "Can't Redo " + label;
+ }
}
List<Command> getCommands() {
@@ -241,19 +252,16 @@
private abstract class InteractionStack extends Stack<Interaction> {
- private String enabledProperty;
private String labelProperty;
private String addedProperty;
private String removedProperty;
private String sizeProperty;
public InteractionStack(
- String enabledProperty,
String labelProperty,
String addedProperty,
String removedProperty,
String sizeProperty) {
- this.enabledProperty = enabledProperty;
this.labelProperty = labelProperty;
this.addedProperty = addedProperty;
this.removedProperty = removedProperty;
@@ -265,9 +273,6 @@
fireLabel();
fire(addedProperty, item);
fire(sizeProperty, size());
- if (item.isUndoable()) {
- fire(enabledProperty, true);
- }
return item;
}
@@ -276,17 +281,9 @@
fireLabel();
fire(removedProperty, item);
fire(sizeProperty, size());
- if (size() == 0 || !peek().isUndoable()) {
- fire(enabledProperty, false);
- }
return item;
}
- public void clear() {
- super.clear();
- fire(sizeProperty, size());
- }
-
private void fireLabel() {
fire(labelProperty, getLabel());
}
@@ -298,13 +295,34 @@
public UndoStack() {
super(
- "undoable",
"undoLabel",
"undoAdded",
"undoRemoved",
"undoSize");
}
+ public Interaction push(Interaction item) {
+ super.push(item);
+ if (item.isUndoable()) {
+ fire("undoable", true);
+ }
+ return item;
+ }
+
+ public Interaction pop() {
+ Interaction item = super.pop();
+ if (size() == 0 || !peek().isUndoable()) {
+ fire("undoable", false);
+ }
+ return item;
+ }
+
+ public void clear() {
+ super.clear();
+ fire("undoSize", size());
+ fire("undoable", false);
+ }
+
protected String getLabel() {
if (empty()) {
return Translator.localize("action.undo");
@@ -318,13 +336,35 @@
public RedoStack() {
super(
- "redoable",
"redoLabel",
"redoAdded",
"redoRemoved",
"redoSize");
}
+
+ public Interaction push(Interaction item) {
+ super.push(item);
+ if (item.isRedoable()) {
+ fire("redoable", true);
+ }
+ return item;
+ }
+
+ public Interaction pop() {
+ Interaction item = super.pop();
+ if (size() == 0 || !peek().isRedoable()) {
+ fire("redoable", false);
+ }
+ return item;
+ }
+
+ public void clear() {
+ super.clear();
+ fire("redoSize", size());
+ fire("redoable", false);
+ }
+
protected String getLabel() {
if (empty()) {
return Translator.localize("action.redo");
Modified: trunk/src_new/org/argouml/kernel/ProjectManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectManager.java?view=diff&rev=13523&p1=trunk/src_new/org/argouml/kernel/ProjectManager.java&p2=trunk/src_new/org/argouml/kernel/ProjectManager.java&r1=13522&r2=13523
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProjectManager.java (original)
+++ trunk/src_new/org/argouml/kernel/ProjectManager.java 2007-09-09 15:34:52-0700
@@ -351,20 +351,26 @@
* @param memento the memento.
* @see org.argouml.model.ModelCommandCreationObserver#modelCommandCreated(org.argouml.model.ModelCommand)
*/
- public Object execute(final ModelCommand memento) {
+ public Object execute(final ModelCommand command) {
if (saveAction != null) {
saveAction.setEnabled(true);
}
AbstractCommand wrappedMemento = new AbstractCommand() {
- private ModelCommand modelMemento = memento;
+ private ModelCommand modelCommand = command;
public void undo() {
- modelMemento.undo();
+ modelCommand.undo();
+ }
+ public boolean isUndoable() {
+ return modelCommand.isUndoable();
+ }
+ public boolean isRedoable() {
+ return modelCommand.isRedoable();
}
public Object execute() {
- return modelMemento.execute();
+ return modelCommand.execute();
}
public String toString() {
- return modelMemento.toString();
+ return modelCommand.toString();
}
};
return getCurrentProject().getUndoManager().execute(wrappedMemento);