Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java
new file mode 100644
index 00000000000..556bd7aa562
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/UndoRedoStack.java
@@ -0,0 +1,48 @@
+package org.eclipse.papyrus.uml.properties.xtext.sheet;
+
+import java.util.Stack;
+
+/**
+ * Encapsulation of the Undo and Redo stack(s)
+ * @author Petr Bodnar
+ */
+public class UndoRedoStack<T> {
+
+ private Stack<T> undo;
+ private Stack<T> redo;
+
+ public UndoRedoStack() {
+ undo = new Stack<T>();
+ redo = new Stack<T>();
+ }
+
+ public void pushUndo(T delta) {
+ undo.add(delta);
+ }
+
+ public void pushRedo(T delta) {
+ redo.add(delta);
+ }
+
+ public T popUndo() {
+ T res = undo.pop();
+ return res;
+ }
+
+ public T popRedo() {
+ T res = redo.pop();
+ return res;
+ }
+
+ public void clearRedo() {
+ redo.clear();
+ }
+
+ public boolean hasUndo() {
+ return !undo.isEmpty();
+ }
+
+ public boolean hasRedo() {
+ return !redo.isEmpty();
+ }
+}

Back to the top