94cd632b4d48633eae712f8f040cfbe7af50164d
[jalviewjs.git] / site / j2s / javax / swing / text / StyledEditorKit.js
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
10 }\r
11 Clazz.instantialize (this, arguments);\r
12 }, javax.swing.text, "StyledEditorKit", javax.swing.text.DefaultEditorKit);\r
13 Clazz.makeConstructor (c$, \r
14 function () {\r
15 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit, []);\r
16 this.createInputAttributeUpdated ();\r
17 this.createInputAttributes ();\r
18 });\r
19 Clazz.overrideMethod (c$, "getInputAttributes", \r
20 function () {\r
21 return this.inputAttributes;\r
22 });\r
23 Clazz.defineMethod (c$, "getCharacterAttributeRun", \r
24 function () {\r
25 return this.currentRun;\r
26 });\r
27 Clazz.defineMethod (c$, "getActions", \r
28 function () {\r
29 return javax.swing.text.TextAction.augmentList (Clazz.superCall (this, javax.swing.text.StyledEditorKit, "getActions", []), javax.swing.text.StyledEditorKit.$defaultActions);\r
30 });\r
31 Clazz.overrideMethod (c$, "createDefaultDocument", \r
32 function () {\r
33 return null;\r
34 });\r
35 Clazz.overrideMethod (c$, "install", \r
36 function (c) {\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
44 function (c) {\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
51 function () {\r
52 return javax.swing.text.StyledEditorKit.defaultFactory;\r
53 });\r
54 Clazz.defineMethod (c$, "clone", \r
55 function () {\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
60 return o;\r
61 });\r
62 Clazz.defineMethod (c$, "createInputAttributes", \r
63  function () {\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
65 });\r
66 Clazz.defineMethod (c$, "createInputAttributeUpdated", \r
67  function () {\r
68 this.inputAttributeUpdater = Clazz.innerTypeInstance (javax.swing.text.StyledEditorKit.AttributeTracker, this, null);\r
69 });\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
90 return;\r
91 }var e = Math.min (a, b);\r
92 var f = d;\r
93 var g;\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
97 } else {\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
104 function (a) {\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
111 function (a) {\r
112 this.updateInputAttributes (a.getDot (), a.getMark (), a.getSource ());\r
113 }, "javax.swing.event.CaretEvent");\r
114 c$ = Clazz.p0p ();\r
115 };\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
120 function () {\r
121 return (this.b$["javax.swing.text.StyledEditorKit"].currentParagraph != null) ? this.b$["javax.swing.text.StyledEditorKit"].currentParagraph.getAttributes () : null;\r
122 });\r
123 Clazz.overrideMethod (c$, "clone", \r
124 function () {\r
125 return  new javax.swing.text.SimpleAttributeSet (this);\r
126 });\r
127 c$ = Clazz.p0p ();\r
128 };\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
132 function (a) {\r
133 var b = a.getName ();\r
134 if (b != null) {\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
147 c$ = Clazz.p0p ();\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
151 function (a) {\r
152 var b = this.getTextComponent (a);\r
153 if (Clazz.instanceOf (b, javax.swing.JEditorPane)) {\r
154 return b;\r
155 }return null;\r
156 }, "java.awt.event.ActionEvent");\r
157 Clazz.defineMethod (c$, "getStyledDocument", \r
158 function (a) {\r
159 var b = a.getDocument ();\r
160 if (Clazz.instanceOf (b, javax.swing.text.StyledDocument)) {\r
161 return b;\r
162 }throw  new IllegalArgumentException ("document must be StyledDocument");\r
163 }, "javax.swing.JEditorPane");\r
164 Clazz.defineMethod (c$, "getStyledEditorKit", \r
165 function (a) {\r
166 var b = a.getEditorKit ();\r
167 if (Clazz.instanceOf (b, javax.swing.text.StyledEditorKit)) {\r
168 return b;\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
175 if (d != e) {\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
180 if (c) {\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
191 c$ = Clazz.p0p ();\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
198 function (a, b) {\r
199 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.FontFamilyAction, [a]);\r
200 this.family = b;\r
201 }, "~S,~S");\r
202 Clazz.overrideMethod (c$, "actionPerformed", \r
203 function (a) {\r
204 var b = this.getEditor (a);\r
205 if (b != null) {\r
206 var c = this.family;\r
207 if ((a != null) && (a.getSource () === b)) {\r
208 var d = a.getActionCommand ();\r
209 if (d != null) {\r
210 c = d;\r
211 }}if (c != null) {\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
215 } else {\r
216 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);\r
217 }}}, "java.awt.event.ActionEvent");\r
218 c$ = Clazz.p0p ();\r
219 Clazz.pu$h(self.c$);\r
220 c$ = Clazz.decorateAsClass (function () {\r
221 this.size = 0;\r
222 Clazz.instantialize (this, arguments);\r
223 }, javax.swing.text.StyledEditorKit, "FontSizeAction", javax.swing.text.StyledEditorKit.StyledTextAction);\r
224 Clazz.makeConstructor (c$, \r
225 function (a, b) {\r
226 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.FontSizeAction, [a]);\r
227 this.size = b;\r
228 }, "~S,~N");\r
229 Clazz.overrideMethod (c$, "actionPerformed", \r
230 function (a) {\r
231 var b = this.getEditor (a);\r
232 if (b != null) {\r
233 var c = this.size;\r
234 if ((a != null) && (a.getSource () === b)) {\r
235 var d = a.getActionCommand ();\r
236 try {\r
237 c = Integer.parseInt (d, 10);\r
238 } catch (nfe) {\r
239 if (Clazz.exceptionOf (nfe, NumberFormatException)) {\r
240 } else {\r
241 throw nfe;\r
242 }\r
243 }\r
244 }if (c != 0) {\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
248 } else {\r
249 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);\r
250 }}}, "java.awt.event.ActionEvent");\r
251 c$ = Clazz.p0p ();\r
252 Clazz.pu$h(self.c$);\r
253 c$ = Clazz.decorateAsClass (function () {\r
254 this.fg = null;\r
255 Clazz.instantialize (this, arguments);\r
256 }, javax.swing.text.StyledEditorKit, "ForegroundAction", javax.swing.text.StyledEditorKit.StyledTextAction);\r
257 Clazz.makeConstructor (c$, \r
258 function (a, b) {\r
259 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.ForegroundAction, [a]);\r
260 this.fg = b;\r
261 }, "~S,java.awt.Color");\r
262 Clazz.overrideMethod (c$, "actionPerformed", \r
263 function (a) {\r
264 var b = this.getEditor (a);\r
265 if (b != null) {\r
266 var c = this.fg;\r
267 if ((a != null) && (a.getSource () === b)) {\r
268 var d = a.getActionCommand ();\r
269 try {\r
270 c = java.awt.Color.decode (d);\r
271 } catch (nfe) {\r
272 if (Clazz.exceptionOf (nfe, NumberFormatException)) {\r
273 } else {\r
274 throw nfe;\r
275 }\r
276 }\r
277 }if (c != null) {\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
281 } else {\r
282 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);\r
283 }}}, "java.awt.event.ActionEvent");\r
284 c$ = Clazz.p0p ();\r
285 Clazz.pu$h(self.c$);\r
286 c$ = Clazz.decorateAsClass (function () {\r
287 this.a = 0;\r
288 Clazz.instantialize (this, arguments);\r
289 }, javax.swing.text.StyledEditorKit, "AlignmentAction", javax.swing.text.StyledEditorKit.StyledTextAction);\r
290 Clazz.makeConstructor (c$, \r
291 function (a, b) {\r
292 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.AlignmentAction, [a]);\r
293 this.a = b;\r
294 }, "~S,~N");\r
295 Clazz.overrideMethod (c$, "actionPerformed", \r
296 function (a) {\r
297 var b = this.getEditor (a);\r
298 if (b != null) {\r
299 var c = this.a;\r
300 if ((a != null) && (a.getSource () === b)) {\r
301 var d = a.getActionCommand ();\r
302 try {\r
303 c = Integer.parseInt (d, 10);\r
304 } catch (nfe) {\r
305 if (Clazz.exceptionOf (nfe, NumberFormatException)) {\r
306 } else {\r
307 throw nfe;\r
308 }\r
309 }\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
314 c$ = Clazz.p0p ();\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
318 function () {\r
319 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.BoldAction, ["font-bold"]);\r
320 });\r
321 Clazz.overrideMethod (c$, "actionPerformed", \r
322 function (a) {\r
323 var b = this.getEditor (a);\r
324 if (b != null) {\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
332 c$ = Clazz.p0p ();\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
336 function () {\r
337 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.ItalicAction, ["font-italic"]);\r
338 });\r
339 Clazz.overrideMethod (c$, "actionPerformed", \r
340 function (a) {\r
341 var b = this.getEditor (a);\r
342 if (b != null) {\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
350 c$ = Clazz.p0p ();\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
354 function () {\r
355 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.UnderlineAction, ["font-underline"]);\r
356 });\r
357 Clazz.overrideMethod (c$, "actionPerformed", \r
358 function (a) {\r
359 var b = this.getEditor (a);\r
360 if (b != null) {\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
368 c$ = Clazz.p0p ();\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
375 function () {\r
376 Clazz.superConstructor (this, javax.swing.text.StyledEditorKit.StyledInsertBreakAction, ["insert-break"]);\r
377 });\r
378 Clazz.overrideMethod (c$, "actionPerformed", \r
379 function (a) {\r
380 var b = this.getEditor (a);\r
381 if (b != null) {\r
382 if ((!b.isEditable ()) || (!b.isEnabled ())) {\r
383 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);\r
384 return;\r
385 }var c = this.getStyledEditorKit (b);\r
386 if (this.tempSet != null) {\r
387 this.tempSet.removeAttributes (this.tempSet);\r
388 } else {\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
396 } else {\r
397 var c = this.getTextComponent (a);\r
398 if (c != null) {\r
399 if ((!c.isEditable ()) || (!c.isEnabled ())) {\r
400 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (b);\r
401 return;\r
402 }c.replaceSelection ("\n");\r
403 }}}, "java.awt.event.ActionEvent");\r
404 c$ = Clazz.p0p ();\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
407 });\r