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