1 Clazz.declarePackage ("javax.swing.text");
\r
2 Clazz.load (["java.beans.PropertyChangeListener", "javax.swing.event.CaretListener", "javax.swing.text.DefaultEditorKit", "$.TextAction", "$.ViewFactory"], "javax.swing.text.StyledEditorKit", ["java.lang.IllegalArgumentException", "java.awt.Color", "javax.swing.JEditorPane", "$.UIManager", "javax.swing.text.BoxView", "$.ComponentView", "$.Document", "$.IconView", "$.JTextComponent", "$.LabelView", "$.ParagraphView", "$.SimpleAttributeSet", "$.StyleConstants", "$.StyledDocument"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.currentRun = null;
\r
5 this.currentParagraph = null;
\r
6 this.inputAttributes = null;
\r
7 this.inputAttributeUpdater = null;
\r
8 if (!Clazz.isClassDefined ("javax.swing.text.StyledEditorKit.AttributeTracker")) {
\r
9 javax.swing.text.StyledEditorKit.$StyledEditorKit$AttributeTracker$ ();
\r
11 Clazz.instantialize (this, arguments);
\r
12 }, javax.swing.text, "StyledEditorKit", javax.swing.text.DefaultEditorKit);
\r
13 Clazz.makeConstructor (c$,
\r
15 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit, []);
\r
16 this.createInputAttributeUpdated ();
\r
17 this.createInputAttributes ();
\r
19 Clazz.overrideMethod (c$, "getInputAttributes",
\r
21 return this.inputAttributes;
\r
23 Clazz.defineMethod (c$, "getCharacterAttributeRun",
\r
25 return this.currentRun;
\r
27 Clazz.defineMethod (c$, "getActions",
\r
29 return javax.swing.text.TextAction.augmentList (Clazz.superCall (this, javax.swing.text.StyledEditorKit, "getActions", []), javax.swing.text.StyledEditorKit.$defaultActions);
\r
31 Clazz.overrideMethod (c$, "createDefaultDocument",
\r
35 Clazz.overrideMethod (c$, "install",
\r
37 c.addCaretListener (this.inputAttributeUpdater);
\r
38 c.addPropertyChangeListener (this.inputAttributeUpdater);
\r
39 var caret = c.getCaret ();
\r
40 if (caret != null) {
\r
41 this.inputAttributeUpdater.updateInputAttributes (caret.getDot (), caret.getMark (), c);
\r
42 }}, "javax.swing.JEditorPane");
\r
43 Clazz.overrideMethod (c$, "deinstall",
\r
45 c.removeCaretListener (this.inputAttributeUpdater);
\r
46 c.removePropertyChangeListener (this.inputAttributeUpdater);
\r
47 this.currentRun = null;
\r
48 this.currentParagraph = null;
\r
49 }, "javax.swing.JEditorPane");
\r
50 Clazz.overrideMethod (c$, "getViewFactory",
\r
52 return javax.swing.text.StyledEditorKit.defaultFactory;
\r
54 Clazz.defineMethod (c$, "clone",
\r
56 var o = Clazz.superCall (this, javax.swing.text.StyledEditorKit, "clone", []);
\r
57 o.currentRun = o.currentParagraph = null;
\r
58 o.createInputAttributeUpdated ();
\r
59 o.createInputAttributes ();
\r
62 Clazz.defineMethod (c$, "createInputAttributes",
\r
64 this.inputAttributes = ((Clazz.isClassDefined ("javax.swing.text.StyledEditorKit$1") ? 0 : javax.swing.text.StyledEditorKit.$StyledEditorKit$1$ ()), Clazz.innerTypeInstance (javax.swing.text.StyledEditorKit$1, this, null));
\r
66 Clazz.defineMethod (c$, "createInputAttributeUpdated",
\r
68 this.inputAttributeUpdater = Clazz.innerTypeInstance (javax.swing.text.StyledEditorKit.AttributeTracker, this, null);
\r
70 Clazz.defineMethod (c$, "createInputAttributes",
\r
71 function (element, set) {
\r
72 if (element.getAttributes ().getAttributeCount () > 0 || element.getEndOffset () - element.getStartOffset () > 1 || element.getEndOffset () < element.getDocument ().getLength ()) {
\r
73 set.removeAttributes (set);
\r
74 set.addAttributes (element.getAttributes ());
\r
75 set.removeAttribute (javax.swing.text.StyleConstants.ComponentAttribute);
\r
76 set.removeAttribute (javax.swing.text.StyleConstants.IconAttribute);
\r
77 set.removeAttribute ("$ename");
\r
78 set.removeAttribute (javax.swing.text.StyleConstants.ComposedTextAttribute);
\r
79 }}, "javax.swing.text.Element,javax.swing.text.MutableAttributeSet");
\r
80 c$.$StyledEditorKit$AttributeTracker$ = function () {
\r
81 Clazz.pu$h(self.c$);
\r
82 c$ = Clazz.decorateAsClass (function () {
\r
83 Clazz.prepareCallback (this, arguments);
\r
84 Clazz.instantialize (this, arguments);
\r
85 }, javax.swing.text.StyledEditorKit, "AttributeTracker", null, [javax.swing.event.CaretListener, java.beans.PropertyChangeListener]);
\r
86 Clazz.defineMethod (c$, "updateInputAttributes",
\r
87 function (a, b, c) {
\r
88 var d = c.getDocument ();
\r
89 if (!(Clazz.instanceOf (d, javax.swing.text.StyledDocument))) {
\r
91 }var e = Math.min (a, b);
\r
94 this.b$["javax.swing.text.StyledEditorKit"].currentParagraph = f.getParagraphElement (e);
\r
95 if (this.b$["javax.swing.text.StyledEditorKit"].currentParagraph.getStartOffset () == e || a != b) {
\r
96 g = f.getCharacterElement (e);
\r
98 g = f.getCharacterElement (Math.max (e - 1, 0));
\r
99 }if (g !== this.b$["javax.swing.text.StyledEditorKit"].currentRun) {
\r
100 this.b$["javax.swing.text.StyledEditorKit"].currentRun = g;
\r
101 this.b$["javax.swing.text.StyledEditorKit"].createInputAttributes (this.b$["javax.swing.text.StyledEditorKit"].currentRun, this.b$["javax.swing.text.StyledEditorKit"].getInputAttributes ());
\r
102 }}, "~N,~N,javax.swing.text.JTextComponent");
\r
103 Clazz.overrideMethod (c$, "propertyChange",
\r
105 var b = a.getNewValue ();
\r
106 var c = a.getSource ();
\r
107 if ((Clazz.instanceOf (c, javax.swing.text.JTextComponent)) && (Clazz.instanceOf (b, javax.swing.text.Document))) {
\r
108 this.updateInputAttributes (0, 0, c);
\r
109 }}, "java.beans.PropertyChangeEvent");
\r
110 Clazz.overrideMethod (c$, "caretUpdate",
\r
112 this.updateInputAttributes (a.getDot (), a.getMark (), a.getSource ());
\r
113 }, "javax.swing.event.CaretEvent");
\r
116 c$.$StyledEditorKit$1$ = function () {
\r
117 Clazz.pu$h(self.c$);
\r
118 c$ = Clazz.declareAnonymous (javax.swing.text, "StyledEditorKit$1", javax.swing.text.SimpleAttributeSet);
\r
119 Clazz.overrideMethod (c$, "getResolveParent",
\r
121 return (this.b$["javax.swing.text.StyledEditorKit"].currentParagraph != null) ? this.b$["javax.swing.text.StyledEditorKit"].currentParagraph.getAttributes () : null;
\r
123 Clazz.overrideMethod (c$, "clone",
\r
125 return new javax.swing.text.SimpleAttributeSet (this);
\r
129 Clazz.pu$h(self.c$);
\r
130 c$ = Clazz.declareType (javax.swing.text.StyledEditorKit, "StyledViewFactory", null, javax.swing.text.ViewFactory);
\r
131 Clazz.overrideMethod (c$, "create",
\r
133 var b = a.getName ();
\r
135 if (b.equals ("content")) {
\r
136 return new javax.swing.text.LabelView (a);
\r
137 } else if (b.equals ("paragraph")) {
\r
138 return new javax.swing.text.ParagraphView (a);
\r
139 } else if (b.equals ("section")) {
\r
140 return new javax.swing.text.BoxView (a, 1);
\r
141 } else if (b.equals ("component")) {
\r
142 return new javax.swing.text.ComponentView (a);
\r
143 } else if (b.equals ("icon")) {
\r
144 return new javax.swing.text.IconView (a);
\r
145 }}return new javax.swing.text.LabelView (a);
\r
146 }, "javax.swing.text.Element");
\r
148 Clazz.pu$h(self.c$);
\r
149 c$ = Clazz.declareType (javax.swing.text.StyledEditorKit, "StyledTextAction", javax.swing.text.TextAction);
\r
150 Clazz.defineMethod (c$, "getEditor",
\r
152 var b = this.getTextComponent (a);
\r
153 if (Clazz.instanceOf (b, javax.swing.JEditorPane)) {
\r
156 }, "java.awt.event.ActionEvent");
\r
157 Clazz.defineMethod (c$, "getStyledDocument",
\r
159 var b = a.getDocument ();
\r
160 if (Clazz.instanceOf (b, javax.swing.text.StyledDocument)) {
\r
162 }throw new IllegalArgumentException ("document must be StyledDocument");
\r
163 }, "javax.swing.JEditorPane");
\r
164 Clazz.defineMethod (c$, "getStyledEditorKit",
\r
166 var b = a.getEditorKit ();
\r
167 if (Clazz.instanceOf (b, javax.swing.text.StyledEditorKit)) {
\r
169 }throw new IllegalArgumentException ("EditorKit must be StyledEditorKit");
\r
170 }, "javax.swing.JEditorPane");
\r
171 Clazz.defineMethod (c$, "setCharacterAttributes",
\r
172 function (a, b, c) {
\r
173 var d = a.getSelectionStart ();
\r
174 var e = a.getSelectionEnd ();
\r
176 var f = this.getStyledDocument (a);
\r
177 f.setCharacterAttributes (d, e - d, b, c);
\r
178 }var f = this.getStyledEditorKit (a);
\r
179 var g = f.getInputAttributes ();
\r
181 g.removeAttributes (g);
\r
182 }g.addAttributes (b);
\r
183 }, "javax.swing.JEditorPane,javax.swing.text.AttributeSet,~B");
\r
184 Clazz.defineMethod (c$, "setParagraphAttributes",
\r
185 function (a, b, c) {
\r
186 var d = a.getSelectionStart ();
\r
187 var e = a.getSelectionEnd ();
\r
188 var f = this.getStyledDocument (a);
\r
189 f.setParagraphAttributes (d, e - d, b, c);
\r
190 }, "javax.swing.JEditorPane,javax.swing.text.AttributeSet,~B");
\r
192 Clazz.pu$h(self.c$);
\r
193 c$ = Clazz.decorateAsClass (function () {
\r
194 this.family = null;
\r
195 Clazz.instantialize (this, arguments);
\r
196 }, javax.swing.text.StyledEditorKit, "FontFamilyAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
197 Clazz.makeConstructor (c$,
\r
199 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.FontFamilyAction, [a]);
\r
202 Clazz.overrideMethod (c$, "actionPerformed",
\r
204 var b = this.getEditor (a);
\r
206 var c = this.family;
\r
207 if ((a != null) && (a.getSource () === b)) {
\r
208 var d = a.getActionCommand ();
\r
212 var d = new javax.swing.text.SimpleAttributeSet ();
\r
213 javax.swing.text.StyleConstants.setFontFamily (d, c);
\r
214 this.setCharacterAttributes (b, d, false);
\r
216 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);
\r
217 }}}, "java.awt.event.ActionEvent");
\r
219 Clazz.pu$h(self.c$);
\r
220 c$ = Clazz.decorateAsClass (function () {
\r
222 Clazz.instantialize (this, arguments);
\r
223 }, javax.swing.text.StyledEditorKit, "FontSizeAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
224 Clazz.makeConstructor (c$,
\r
226 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.FontSizeAction, [a]);
\r
229 Clazz.overrideMethod (c$, "actionPerformed",
\r
231 var b = this.getEditor (a);
\r
234 if ((a != null) && (a.getSource () === b)) {
\r
235 var d = a.getActionCommand ();
\r
237 c = Integer.parseInt (d, 10);
\r
239 if (Clazz.exceptionOf (nfe, NumberFormatException)) {
\r
245 var d = new javax.swing.text.SimpleAttributeSet ();
\r
246 javax.swing.text.StyleConstants.setFontSize (d, c);
\r
247 this.setCharacterAttributes (b, d, false);
\r
249 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);
\r
250 }}}, "java.awt.event.ActionEvent");
\r
252 Clazz.pu$h(self.c$);
\r
253 c$ = Clazz.decorateAsClass (function () {
\r
255 Clazz.instantialize (this, arguments);
\r
256 }, javax.swing.text.StyledEditorKit, "ForegroundAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
257 Clazz.makeConstructor (c$,
\r
259 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.ForegroundAction, [a]);
\r
261 }, "~S,java.awt.Color");
\r
262 Clazz.overrideMethod (c$, "actionPerformed",
\r
264 var b = this.getEditor (a);
\r
267 if ((a != null) && (a.getSource () === b)) {
\r
268 var d = a.getActionCommand ();
\r
270 c = java.awt.Color.decode (d);
\r
272 if (Clazz.exceptionOf (nfe, NumberFormatException)) {
\r
278 var d = new javax.swing.text.SimpleAttributeSet ();
\r
279 javax.swing.text.StyleConstants.setForeground (d, c);
\r
280 this.setCharacterAttributes (b, d, false);
\r
282 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);
\r
283 }}}, "java.awt.event.ActionEvent");
\r
285 Clazz.pu$h(self.c$);
\r
286 c$ = Clazz.decorateAsClass (function () {
\r
288 Clazz.instantialize (this, arguments);
\r
289 }, javax.swing.text.StyledEditorKit, "AlignmentAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
290 Clazz.makeConstructor (c$,
\r
292 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.AlignmentAction, [a]);
\r
295 Clazz.overrideMethod (c$, "actionPerformed",
\r
297 var b = this.getEditor (a);
\r
300 if ((a != null) && (a.getSource () === b)) {
\r
301 var d = a.getActionCommand ();
\r
303 c = Integer.parseInt (d, 10);
\r
305 if (Clazz.exceptionOf (nfe, NumberFormatException)) {
\r
310 }var d = new javax.swing.text.SimpleAttributeSet ();
\r
311 javax.swing.text.StyleConstants.setAlignment (d, c);
\r
312 this.setParagraphAttributes (b, d, false);
\r
313 }}, "java.awt.event.ActionEvent");
\r
315 Clazz.pu$h(self.c$);
\r
316 c$ = Clazz.declareType (javax.swing.text.StyledEditorKit, "BoldAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
317 Clazz.makeConstructor (c$,
\r
319 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.BoldAction, ["font-bold"]);
\r
321 Clazz.overrideMethod (c$, "actionPerformed",
\r
323 var b = this.getEditor (a);
\r
325 var c = this.getStyledEditorKit (b);
\r
326 var d = c.getInputAttributes ();
\r
327 var e = (javax.swing.text.StyleConstants.isBold (d)) ? false : true;
\r
328 var f = new javax.swing.text.SimpleAttributeSet ();
\r
329 javax.swing.text.StyleConstants.setBold (f, e);
\r
330 this.setCharacterAttributes (b, f, false);
\r
331 }}, "java.awt.event.ActionEvent");
\r
333 Clazz.pu$h(self.c$);
\r
334 c$ = Clazz.declareType (javax.swing.text.StyledEditorKit, "ItalicAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
335 Clazz.makeConstructor (c$,
\r
337 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.ItalicAction, ["font-italic"]);
\r
339 Clazz.overrideMethod (c$, "actionPerformed",
\r
341 var b = this.getEditor (a);
\r
343 var c = this.getStyledEditorKit (b);
\r
344 var d = c.getInputAttributes ();
\r
345 var e = (javax.swing.text.StyleConstants.isItalic (d)) ? false : true;
\r
346 var f = new javax.swing.text.SimpleAttributeSet ();
\r
347 javax.swing.text.StyleConstants.setItalic (f, e);
\r
348 this.setCharacterAttributes (b, f, false);
\r
349 }}, "java.awt.event.ActionEvent");
\r
351 Clazz.pu$h(self.c$);
\r
352 c$ = Clazz.declareType (javax.swing.text.StyledEditorKit, "UnderlineAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
353 Clazz.makeConstructor (c$,
\r
355 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.UnderlineAction, ["font-underline"]);
\r
357 Clazz.overrideMethod (c$, "actionPerformed",
\r
359 var b = this.getEditor (a);
\r
361 var c = this.getStyledEditorKit (b);
\r
362 var d = c.getInputAttributes ();
\r
363 var e = (javax.swing.text.StyleConstants.isUnderline (d)) ? false : true;
\r
364 var f = new javax.swing.text.SimpleAttributeSet ();
\r
365 javax.swing.text.StyleConstants.setUnderline (f, e);
\r
366 this.setCharacterAttributes (b, f, false);
\r
367 }}, "java.awt.event.ActionEvent");
\r
369 Clazz.pu$h(self.c$);
\r
370 c$ = Clazz.decorateAsClass (function () {
\r
371 this.tempSet = null;
\r
372 Clazz.instantialize (this, arguments);
\r
373 }, javax.swing.text.StyledEditorKit, "StyledInsertBreakAction", javax.swing.text.StyledEditorKit.StyledTextAction);
\r
374 Clazz.makeConstructor (c$,
\r
376 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.StyledInsertBreakAction, ["insert-break"]);
\r
378 Clazz.overrideMethod (c$, "actionPerformed",
\r
380 var b = this.getEditor (a);
\r
382 if ((!b.isEditable ()) || (!b.isEnabled ())) {
\r
383 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);
\r
385 }var c = this.getStyledEditorKit (b);
\r
386 if (this.tempSet != null) {
\r
387 this.tempSet.removeAttributes (this.tempSet);
\r
389 this.tempSet = new javax.swing.text.SimpleAttributeSet ();
\r
390 }this.tempSet.addAttributes (c.getInputAttributes ());
\r
391 b.replaceSelection ("\n");
\r
392 var d = c.getInputAttributes ();
\r
393 d.removeAttributes (d);
\r
394 d.addAttributes (this.tempSet);
\r
395 this.tempSet.removeAttributes (this.tempSet);
\r
397 var c = this.getTextComponent (a);
\r
399 if ((!c.isEditable ()) || (!c.isEnabled ())) {
\r
400 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);
\r
402 }c.replaceSelection ("\n");
\r
403 }}}, "java.awt.event.ActionEvent");
\r
405 c$.defaultFactory = c$.prototype.defaultFactory = new javax.swing.text.StyledEditorKit.StyledViewFactory ();
\r
406 c$.$defaultActions = c$.prototype.$defaultActions = Clazz.newArray (-1, [ new javax.swing.text.StyledEditorKit.FontFamilyAction ("font-family-SansSerif", "SansSerif"), new javax.swing.text.StyledEditorKit.FontFamilyAction ("font-family-Monospaced", "Monospaced"), new javax.swing.text.StyledEditorKit.FontFamilyAction ("font-family-Serif", "Serif"), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-8", 8), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-10", 10), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-12", 12), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-14", 14), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-16", 16), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-18", 18), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-24", 24), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-36", 36), new javax.swing.text.StyledEditorKit.FontSizeAction ("font-size-48", 48), new javax.swing.text.StyledEditorKit.AlignmentAction ("left-justify", 0), new javax.swing.text.StyledEditorKit.AlignmentAction ("center-justify", 1), new javax.swing.text.StyledEditorKit.AlignmentAction ("right-justify", 2), new javax.swing.text.StyledEditorKit.BoldAction (), new javax.swing.text.StyledEditorKit.ItalicAction (), new javax.swing.text.StyledEditorKit.StyledInsertBreakAction (), new javax.swing.text.StyledEditorKit.UnderlineAction ()]);
\r