File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package actions ;
2+
3+ import java .awt .Dimension ;
4+
5+ import ui .PaintPanel ;
6+ import ui .helper .historyui .undoredoLog .UndoredoLog ;
7+
8+ public class ShowHistory extends PaintAction {
9+
10+
11+ public ShowHistory (PaintPanel panel ) {
12+ super (panel );
13+ // TODO Auto-generated constructor stub
14+ }
15+
16+ @ Override
17+ public boolean canPerformAction () {
18+ // TODO Auto-generated method stub
19+ return true ;
20+ }
21+
22+ @ Override
23+ public void performAction () {
24+ // TODO Auto-generated method stub
25+
26+ UndoredoLog .sharedInstance ().setVisible (true );
27+
28+ }
29+
30+ @ Override
31+ public String locationString () {
32+ // TODO Auto-generated method stub
33+ return "View/Show/History" ;
34+ }
35+
36+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ public class SharedUndoRedoActionManager {
1212 private static SharedUndoRedoActionManager sharedInstance = new SharedUndoRedoActionManager ();
1313 private Stack <UndoRedoableInterface > undoStack ;
1414 private Stack <UndoRedoableInterface > redoStack ;
15+ private SharedUndoRedoActionManagerDelegate delegate ;
1516
1617 /** Static instance method */
1718 public static SharedUndoRedoActionManager getSharedInstance (){
@@ -31,12 +32,14 @@ public void undo() {
3132 UndoRedoableInterface undoableAction = undoStack .pop ();
3233 undoableAction .undoAction ();
3334 redoStack .add (undoableAction );
35+ delegate .didUndoAction (undoableAction );
3436 }
3537
3638 public void redo () {
3739 UndoRedoableInterface redoableAction = redoStack .pop ();
3840 redoableAction .redoAction ();
3941 undoStack .add (redoableAction );
42+ delegate .didUndoAction (redoableAction );
4043 }
4144
4245 public boolean canUndo () {
@@ -52,4 +55,12 @@ public void pushUndoableAction( UndoRedoableInterface undoredoableAction ) {
5255 redoStack .clear ();
5356 }
5457
58+ public SharedUndoRedoActionManagerDelegate getDelegate () {
59+ return delegate ;
60+ }
61+
62+ public void setDelegate (SharedUndoRedoActionManagerDelegate delegate ) {
63+ this .delegate = delegate ;
64+ }
65+
5566}
Original file line number Diff line number Diff line change 1+ package actions .edit .undoredo ;
2+
3+ public interface SharedUndoRedoActionManagerDelegate {
4+
5+ public void didUndoAction (UndoRedoableInterface obj );
6+ public void didRedoAction (UndoRedoableInterface obj );
7+ }
Original file line number Diff line number Diff line change 11package actions .edit .undoredo ;
22
3+ import ui .helper .historyui .HistoryDataObject ;
4+
5+ public abstract class UndoRedoableInterface extends HistoryDataObject {
36
4- public abstract class UndoRedoableInterface {
57 public abstract void undoAction ();
68 public abstract void redoAction ();
79 public String description (){
Original file line number Diff line number Diff line change 3030import actions .PaintAction ;
3131import actions .RemoveAnnotationAction ;
3232import actions .RemovePaintComponent ;
33+ import actions .ShowHistory ;
3334import actions .UpdateDataDisplayBoxAction ;
3435import actions .singleinstanceoperations .SetPointSizeOperation ;
3536import actions .singleinstanceoperations .UpdateFontSizeOperation ;
@@ -65,6 +66,7 @@ public ActionsMenuBar(PaintPanel panel){
6566 addAction (new EditUndoAction (panel ));
6667 addAction (new ZoomInAction (panel ));
6768 addAction (new ZoomOutAction (panel ));
69+
6870
6971 //haskell
7072 addAction (new AddHaskellComponent (panel ));
@@ -84,6 +86,9 @@ public ActionsMenuBar(PaintPanel panel){
8486 // add data annotation
8587 addAction (new AddAnnotationAction (panel ));
8688 addAction (new RemoveAnnotationAction (panel ));
89+
90+ //view
91+ addAction (new ShowHistory (panel ));
8792 }
8893
8994 private void addAction (PaintAction action ) {
Original file line number Diff line number Diff line change @@ -142,5 +142,10 @@ public ActionsMenuBarTitles Annotations() {
142142 append ("Annotations" );
143143 return this ;
144144 }
145+
146+ public ActionsMenuBarTitles RedoUndoHisotry (){
147+ append ("Redo/Undo Hisotry" );
148+ return this ;
149+ }
145150
146151}
Original file line number Diff line number Diff line change 11package ui .helper .historyui ;
22
3+ import java .security .UnrecoverableEntryException ;
34
45/**
56 *
910public class HistoryDataObject {
1011
1112 String data ;
13+ int row ;
14+ boolean untraced ;
15+ public HistoryDataObject (){
16+
17+ }
1218
1319 public HistoryDataObject (String data ){
1420 this .data = data ;
21+ untraced = false ;
1522 }
1623
1724
1825 public String toString (){
26+ if (untraced ){
27+ return "[untraced] " + data ;
28+ }
1929 return data ;
2030 }
2131
32+ public void setRow (int i ){
33+ row = i ;
34+ }
2235
36+ public int getRow (){
37+ return row ;
38+ }
2339
40+ public void setUntraced (boolean truth ){
41+ untraced = truth ;
42+ }
43+
44+ public boolean getUntraced (){
45+ return untraced ;
46+ }
2447}
You can’t perform that action at this time.
0 commit comments