5e1315e7df52d327452ddc75ac715feba212cbec
[jalviewjs.git] / site / swingjs / j2s / javax / swing / undo / CompoundEdit.js
1 Clazz.declarePackage ("javax.swing.undo");
2 Clazz.load (["javax.swing.undo.AbstractUndoableEdit"], "javax.swing.undo.CompoundEdit", ["java.util.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.inProgress = false;
5 this.edits = null;
6 Clazz.instantialize (this, arguments);
7 }, javax.swing.undo, "CompoundEdit", javax.swing.undo.AbstractUndoableEdit);
8 Clazz.makeConstructor (c$, 
9 function () {
10 Clazz.superConstructor (this, javax.swing.undo.CompoundEdit);
11 this.inProgress = true;
12 this.edits =  new java.util.Vector ();
13 });
14 Clazz.defineMethod (c$, "undo", 
15 function () {
16 Clazz.superCall (this, javax.swing.undo.CompoundEdit, "undo", []);
17 var i = this.edits.size ();
18 while (i-- > 0) {
19 var e = this.edits.elementAt (i);
20 e.undo ();
21 }
22 });
23 Clazz.defineMethod (c$, "redo", 
24 function () {
25 Clazz.superCall (this, javax.swing.undo.CompoundEdit, "redo", []);
26 var cursor = this.edits.elements ();
27 while (cursor.hasMoreElements ()) {
28 (cursor.nextElement ()).redo ();
29 }
30 });
31 Clazz.defineMethod (c$, "lastEdit", 
32 function () {
33 var count = this.edits.size ();
34 if (count > 0) return this.edits.elementAt (count - 1);
35  else return null;
36 });
37 Clazz.defineMethod (c$, "die", 
38 function () {
39 var size = this.edits.size ();
40 for (var i = size - 1; i >= 0; i--) {
41 var e = this.edits.elementAt (i);
42 e.die ();
43 }
44 Clazz.superCall (this, javax.swing.undo.CompoundEdit, "die", []);
45 });
46 Clazz.overrideMethod (c$, "addEdit", 
47 function (anEdit) {
48 if (!this.inProgress) {
49 return false;
50 } else {
51 var last = this.lastEdit ();
52 if (last == null) {
53 this.edits.addElement (anEdit);
54 } else if (!last.addEdit (anEdit)) {
55 if (anEdit.replaceEdit (last)) {
56 this.edits.removeElementAt (this.edits.size () - 1);
57 }this.edits.addElement (anEdit);
58 }return true;
59 }}, "javax.swing.undo.UndoableEdit");
60 Clazz.defineMethod (c$, "end", 
61 function () {
62 this.inProgress = false;
63 });
64 Clazz.defineMethod (c$, "canUndo", 
65 function () {
66 return !this.isInProgress () && Clazz.superCall (this, javax.swing.undo.CompoundEdit, "canUndo", []);
67 });
68 Clazz.defineMethod (c$, "canRedo", 
69 function () {
70 return !this.isInProgress () && Clazz.superCall (this, javax.swing.undo.CompoundEdit, "canRedo", []);
71 });
72 Clazz.defineMethod (c$, "isInProgress", 
73 function () {
74 return this.inProgress;
75 });
76 Clazz.overrideMethod (c$, "isSignificant", 
77 function () {
78 var cursor = this.edits.elements ();
79 while (cursor.hasMoreElements ()) {
80 if ((cursor.nextElement ()).isSignificant ()) {
81 return true;
82 }}
83 return false;
84 });
85 Clazz.defineMethod (c$, "getPresentationName", 
86 function () {
87 var last = this.lastEdit ();
88 if (last != null) {
89 return last.getPresentationName ();
90 } else {
91 return Clazz.superCall (this, javax.swing.undo.CompoundEdit, "getPresentationName", []);
92 }});
93 Clazz.defineMethod (c$, "getUndoPresentationName", 
94 function () {
95 var last = this.lastEdit ();
96 if (last != null) {
97 return last.getUndoPresentationName ();
98 } else {
99 return Clazz.superCall (this, javax.swing.undo.CompoundEdit, "getUndoPresentationName", []);
100 }});
101 Clazz.defineMethod (c$, "getRedoPresentationName", 
102 function () {
103 var last = this.lastEdit ();
104 if (last != null) {
105 return last.getRedoPresentationName ();
106 } else {
107 return Clazz.superCall (this, javax.swing.undo.CompoundEdit, "getRedoPresentationName", []);
108 }});
109 Clazz.defineMethod (c$, "toString", 
110 function () {
111 return Clazz.superCall (this, javax.swing.undo.CompoundEdit, "toString", []) + " inProgress: " + this.inProgress + " edits: " + this.edits;
112 });
113 });