1 Clazz.declarePackage ("javax.swing");
\r
2 Clazz.load (["javax.swing.JEditorPane"], "javax.swing.JTextPane", ["java.lang.IllegalArgumentException", "javax.swing.UIManager", "javax.swing.text.JSMinimalAbstractDocument", "$.StyleConstants", "$.StyledDocument", "$.StyledEditorKit"], function () {
\r
3 c$ = Clazz.declareType (javax.swing, "JTextPane", javax.swing.JEditorPane);
\r
4 Clazz.makeConstructor (c$,
\r
6 Clazz.superConstructor (this, javax.swing.JTextPane);
\r
7 var editorKit = this.createDefaultEditorKit ();
\r
8 var contentType = editorKit.getContentType ();
\r
9 if (contentType != null && javax.swing.JEditorPane.getEditorKitClassNameForContentType (contentType) === javax.swing.JEditorPane.defaultEditorKitMap.get (contentType)) {
\r
10 this.setEditorKitForContentType (contentType, editorKit);
\r
11 }this.setEditorKit (editorKit);
\r
13 Clazz.makeConstructor (c$,
\r
16 this.setStyledDocument (doc);
\r
17 }, "javax.swing.text.StyledDocument");
\r
18 Clazz.overrideMethod (c$, "getUIClassID",
\r
20 return "TextPaneUI";
\r
22 Clazz.defineMethod (c$, "setDocument",
\r
24 if (Clazz.instanceOf (doc, javax.swing.text.StyledDocument)) {
\r
25 Clazz.superCall (this, javax.swing.JTextPane, "setDocument", [doc]);
\r
27 throw new IllegalArgumentException ("Model must be StyledDocument");
\r
28 }}, "javax.swing.text.Document");
\r
29 Clazz.defineMethod (c$, "setStyledDocument",
\r
31 Clazz.superCall (this, javax.swing.JTextPane, "setDocument", [doc]);
\r
32 }, "javax.swing.text.StyledDocument");
\r
33 Clazz.defineMethod (c$, "getStyledDocument",
\r
35 return this.getDocument ();
\r
37 Clazz.defineMethod (c$, "replaceSelection",
\r
38 function (content) {
\r
39 this.replaceSelection (content, true);
\r
41 Clazz.defineMethod (c$, "replaceSelection",
\r
42 function (content, checkEditable) {
\r
43 if (checkEditable && !this.isEditable ()) {
\r
44 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this);
\r
46 }var doc = this.getStyledDocument ();
\r
49 var caret = this.getCaret ();
\r
50 var p0 = Math.min (caret.getDot (), caret.getMark ());
\r
51 var p1 = Math.max (caret.getDot (), caret.getMark ());
\r
52 var attr = this.getInputAttributes ().copyAttributes ();
\r
53 if (Clazz.instanceOf (doc, javax.swing.text.JSMinimalAbstractDocument)) {
\r
54 (doc).replace (p0, p1 - p0, content, attr);
\r
57 doc.remove (p0, p1 - p0);
\r
58 }if (content != null && content.length > 0) {
\r
59 doc.insertString (p0, content, attr);
\r
61 if (Clazz.exceptionOf (e, javax.swing.text.BadLocationException)) {
\r
62 javax.swing.UIManager.getLookAndFeel ().provideErrorFeedback (this);
\r
68 Clazz.defineMethod (c$, "insertComponent",
\r
70 var inputAttributes = this.getInputAttributes ();
\r
71 inputAttributes.removeAttributes (inputAttributes);
\r
72 javax.swing.text.StyleConstants.setComponent (inputAttributes, c);
\r
73 this.replaceSelection (" ", false);
\r
74 inputAttributes.removeAttributes (inputAttributes);
\r
75 }, "java.awt.Component");
\r
76 Clazz.defineMethod (c$, "insertIcon",
\r
78 var inputAttributes = this.getInputAttributes ();
\r
79 inputAttributes.removeAttributes (inputAttributes);
\r
80 javax.swing.text.StyleConstants.setIcon (inputAttributes, g);
\r
81 this.replaceSelection (" ", false);
\r
82 inputAttributes.removeAttributes (inputAttributes);
\r
83 }, "javax.swing.Icon");
\r
84 Clazz.defineMethod (c$, "addStyle",
\r
85 function (nm, parent) {
\r
86 var doc = this.getStyledDocument ();
\r
87 return doc.addStyle (nm, parent);
\r
88 }, "~S,javax.swing.text.Style");
\r
89 Clazz.defineMethod (c$, "removeStyle",
\r
91 var doc = this.getStyledDocument ();
\r
92 doc.removeStyle (nm);
\r
94 Clazz.defineMethod (c$, "getStyle",
\r
96 var doc = this.getStyledDocument ();
\r
97 return doc.getStyle (nm);
\r
99 Clazz.defineMethod (c$, "setLogicalStyle",
\r
101 var doc = this.getStyledDocument ();
\r
102 doc.setLogicalStyle (this.getCaretPosition (), s);
\r
103 }, "javax.swing.text.Style");
\r
104 Clazz.defineMethod (c$, "getLogicalStyle",
\r
106 var doc = this.getStyledDocument ();
\r
107 return doc.getLogicalStyle (this.getCaretPosition ());
\r
109 Clazz.defineMethod (c$, "getCharacterAttributes",
\r
111 var doc = this.getStyledDocument ();
\r
112 var run = doc.getCharacterElement (this.getCaretPosition ());
\r
114 return run.getAttributes ();
\r
117 Clazz.defineMethod (c$, "setCharacterAttributes",
\r
118 function (attr, replace) {
\r
119 var p0 = this.getSelectionStart ();
\r
120 var p1 = this.getSelectionEnd ();
\r
122 var doc = this.getStyledDocument ();
\r
123 doc.setCharacterAttributes (p0, p1 - p0, attr, replace);
\r
125 var inputAttributes = this.getInputAttributes ();
\r
127 inputAttributes.removeAttributes (inputAttributes);
\r
128 }inputAttributes.addAttributes (attr);
\r
129 }}, "javax.swing.text.AttributeSet,~B");
\r
130 Clazz.defineMethod (c$, "getParagraphAttributes",
\r
132 var doc = this.getStyledDocument ();
\r
133 var paragraph = doc.getParagraphElement (this.getCaretPosition ());
\r
134 if (paragraph != null) {
\r
135 return paragraph.getAttributes ();
\r
138 Clazz.defineMethod (c$, "setParagraphAttributes",
\r
139 function (attr, replace) {
\r
140 var p0 = this.getSelectionStart ();
\r
141 var p1 = this.getSelectionEnd ();
\r
142 var doc = this.getStyledDocument ();
\r
143 doc.setParagraphAttributes (p0, p1 - p0, attr, replace);
\r
144 }, "javax.swing.text.AttributeSet,~B");
\r
145 Clazz.defineMethod (c$, "getInputAttributes",
\r
147 return this.getStyledEditorKit ().getInputAttributes ();
\r
149 Clazz.defineMethod (c$, "getStyledEditorKit",
\r
151 return this.getEditorKit ();
\r
153 Clazz.overrideMethod (c$, "createDefaultEditorKit",
\r
155 return new javax.swing.text.StyledEditorKit ();
\r
157 Clazz.defineMethod (c$, "setEditorKit",
\r
159 if (Clazz.instanceOf (kit, javax.swing.text.StyledEditorKit)) {
\r
160 Clazz.superCall (this, javax.swing.JTextPane, "setEditorKit", [kit]);
\r
162 throw new IllegalArgumentException ("Must be StyledEditorKit");
\r
163 }}, "javax.swing.text.EditorKit");
\r
164 Clazz.defineStatics (c$,
\r
165 "$$uiClassID", "TextPaneUI");
\r