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