649f078805199f87d55a27ad168dc3addab0ffe3
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JSplitPane.js
1 Clazz.declarePackage ("javax.swing");\r
2 Clazz.load (["javax.swing.JComponent"], "javax.swing.JSplitPane", ["java.lang.Boolean", "$.IllegalArgumentException", "javax.swing.JButton", "$.UIManager"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.orientation = 0;\r
5 this.continuousLayout = false;\r
6 this.leftComponent = null;\r
7 this.rightComponent = null;\r
8 this.dividerSize = 0;\r
9 this.dividerSizeSet = false;\r
10 this.oneTouchExpandable = false;\r
11 this.oneTouchExpandableSet = false;\r
12 this.lastDividerLocation = 0;\r
13 this.resizeWeight = 0;\r
14 this.dividerLocation = 0;\r
15 Clazz.instantialize (this, arguments);\r
16 }, javax.swing, "JSplitPane", javax.swing.JComponent);\r
17 Clazz.makeConstructor (c$, \r
18 function () {\r
19 this.construct (1, false,  new javax.swing.JButton (javax.swing.UIManager.getString ("SplitPane.leftButtonText")),  new javax.swing.JButton (javax.swing.UIManager.getString ("SplitPane.rightButtonText")));\r
20 });\r
21 Clazz.makeConstructor (c$, \r
22 function (newOrientation) {\r
23 this.construct (newOrientation, false);\r
24 }, "~N");\r
25 Clazz.makeConstructor (c$, \r
26 function (newOrientation, newContinuousLayout) {\r
27 this.construct (newOrientation, newContinuousLayout, null, null);\r
28 }, "~N,~B");\r
29 Clazz.makeConstructor (c$, \r
30 function (newOrientation, newLeftComponent, newRightComponent) {\r
31 this.construct (newOrientation, false, newLeftComponent, newRightComponent);\r
32 }, "~N,java.awt.Component,java.awt.Component");\r
33 Clazz.makeConstructor (c$, \r
34 function (newOrientation, newContinuousLayout, newLeftComponent, newRightComponent) {\r
35 Clazz.superConstructor (this, javax.swing.JSplitPane);\r
36 this.dividerLocation = -1;\r
37 this.setLayout (null);\r
38 this.setUIProperty ("opaque", Boolean.TRUE);\r
39 this.orientation = newOrientation;\r
40 if (this.orientation != 1 && this.orientation != 0) throw  new IllegalArgumentException ("cannot create JSplitPane, orientation must be one of JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT");\r
41 this.continuousLayout = newContinuousLayout;\r
42 if (newLeftComponent != null) this.setLeftComponent (newLeftComponent);\r
43 if (newRightComponent != null) this.setRightComponent (newRightComponent);\r
44 this.updateUI ();\r
45 }, "~N,~B,java.awt.Component,java.awt.Component");\r
46 Clazz.defineMethod (c$, "setUI", \r
47 function (ui) {\r
48 if (this.ui !== ui) {\r
49 Clazz.superCall (this, javax.swing.JSplitPane, "setUI", [ui]);\r
50 this.revalidate ();\r
51 }}, "javax.swing.plaf.SplitPaneUI");\r
52 Clazz.overrideMethod (c$, "getUI", \r
53 function () {\r
54 return this.ui;\r
55 });\r
56 Clazz.overrideMethod (c$, "updateUI", \r
57 function () {\r
58 this.setUI (javax.swing.UIManager.getUI (this));\r
59 this.revalidate ();\r
60 });\r
61 Clazz.overrideMethod (c$, "getUIClassID", \r
62 function () {\r
63 return "SplitPaneUI";\r
64 });\r
65 Clazz.defineMethod (c$, "setDividerSize", \r
66 function (newSize) {\r
67 var oldSize = this.dividerSize;\r
68 this.dividerSizeSet = true;\r
69 if (oldSize != newSize) {\r
70 this.dividerSize = newSize;\r
71 this.firePropertyChangeInt ("dividerSize", oldSize, newSize);\r
72 }}, "~N");\r
73 Clazz.defineMethod (c$, "getDividerSize", \r
74 function () {\r
75 return this.dividerSize;\r
76 });\r
77 Clazz.defineMethod (c$, "setLeftComponent", \r
78 function (comp) {\r
79 if (comp == null) {\r
80 if (this.leftComponent != null) {\r
81 this.remove (this.leftComponent);\r
82 this.leftComponent = null;\r
83 }} else {\r
84 this.add (comp, "left");\r
85 }}, "java.awt.Component");\r
86 Clazz.defineMethod (c$, "getLeftComponent", \r
87 function () {\r
88 return this.leftComponent;\r
89 });\r
90 Clazz.defineMethod (c$, "setTopComponent", \r
91 function (comp) {\r
92 this.setLeftComponent (comp);\r
93 }, "java.awt.Component");\r
94 Clazz.defineMethod (c$, "getTopComponent", \r
95 function () {\r
96 return this.leftComponent;\r
97 });\r
98 Clazz.defineMethod (c$, "setRightComponent", \r
99 function (comp) {\r
100 if (comp == null) {\r
101 if (this.rightComponent != null) {\r
102 this.remove (this.rightComponent);\r
103 this.rightComponent = null;\r
104 }} else {\r
105 this.add (comp, "right");\r
106 }}, "java.awt.Component");\r
107 Clazz.defineMethod (c$, "getRightComponent", \r
108 function () {\r
109 return this.rightComponent;\r
110 });\r
111 Clazz.defineMethod (c$, "setBottomComponent", \r
112 function (comp) {\r
113 this.setRightComponent (comp);\r
114 }, "java.awt.Component");\r
115 Clazz.defineMethod (c$, "getBottomComponent", \r
116 function () {\r
117 return this.rightComponent;\r
118 });\r
119 Clazz.defineMethod (c$, "setOneTouchExpandable", \r
120 function (newValue) {\r
121 var oldValue = this.oneTouchExpandable;\r
122 this.oneTouchExpandable = newValue;\r
123 this.oneTouchExpandableSet = true;\r
124 this.firePropertyChangeBool ("oneTouchExpandable", oldValue, newValue);\r
125 this.repaint ();\r
126 }, "~B");\r
127 Clazz.defineMethod (c$, "isOneTouchExpandable", \r
128 function () {\r
129 return this.oneTouchExpandable;\r
130 });\r
131 Clazz.defineMethod (c$, "setLastDividerLocation", \r
132 function (newLastLocation) {\r
133 var oldLocation = this.lastDividerLocation;\r
134 this.lastDividerLocation = newLastLocation;\r
135 this.firePropertyChangeInt ("lastDividerLocation", oldLocation, newLastLocation);\r
136 }, "~N");\r
137 Clazz.defineMethod (c$, "getLastDividerLocation", \r
138 function () {\r
139 return this.lastDividerLocation;\r
140 });\r
141 Clazz.defineMethod (c$, "setOrientation", \r
142 function (orientation) {\r
143 if ((orientation != 0) && (orientation != 1)) {\r
144 throw  new IllegalArgumentException ("JSplitPane: orientation must be one of JSplitPane.VERTICAL_SPLIT or JSplitPane.HORIZONTAL_SPLIT");\r
145 }var oldOrientation = this.orientation;\r
146 this.orientation = orientation;\r
147 this.firePropertyChangeInt ("orientation", oldOrientation, orientation);\r
148 }, "~N");\r
149 Clazz.defineMethod (c$, "getOrientation", \r
150 function () {\r
151 return this.orientation;\r
152 });\r
153 Clazz.defineMethod (c$, "setContinuousLayout", \r
154 function (newContinuousLayout) {\r
155 var oldCD = this.continuousLayout;\r
156 this.continuousLayout = newContinuousLayout;\r
157 this.firePropertyChangeBool ("continuousLayout", oldCD, newContinuousLayout);\r
158 }, "~B");\r
159 Clazz.defineMethod (c$, "isContinuousLayout", \r
160 function () {\r
161 return this.continuousLayout;\r
162 });\r
163 Clazz.defineMethod (c$, "setResizeWeight", \r
164 function (value) {\r
165 if (value < 0 || value > 1) {\r
166 throw  new IllegalArgumentException ("JSplitPane weight must be between 0 and 1");\r
167 }var oldWeight = this.resizeWeight;\r
168 this.resizeWeight = value;\r
169 this.firePropertyChangeObject ("resizeWeight", new Double (oldWeight), new Double (value));\r
170 }, "~N");\r
171 Clazz.defineMethod (c$, "getResizeWeight", \r
172 function () {\r
173 return this.resizeWeight;\r
174 });\r
175 Clazz.defineMethod (c$, "resetToPreferredSizes", \r
176 function () {\r
177 var ui = this.getUI ();\r
178 if (ui != null) {\r
179 ui.resetToPreferredSizes (this);\r
180 }});\r
181 Clazz.defineMethod (c$, "setDividerLocation", \r
182 function (proportionalLocation) {\r
183 if (proportionalLocation < 0.0 || proportionalLocation > 1.0) {\r
184 throw  new IllegalArgumentException ("proportional location must be between 0.0 and 1.0.");\r
185 }if (this.getOrientation () == 0) {\r
186 this.setDividerLocation (Clazz.doubleToInt ((this.getHeight () - this.getDividerSize ()) * proportionalLocation));\r
187 } else {\r
188 this.setDividerLocation (Clazz.doubleToInt ((this.getWidth () - this.getDividerSize ()) * proportionalLocation));\r
189 }}, "~N");\r
190 Clazz.defineMethod (c$, "setDividerLocation", \r
191 function (location) {\r
192 var oldValue = this.dividerLocation;\r
193 this.dividerLocation = location;\r
194 var ui = this.getUI ();\r
195 if (ui != null) {\r
196 ui.setDividerLocation (this, location);\r
197 }this.firePropertyChangeInt ("dividerLocation", oldValue, location);\r
198 this.setLastDividerLocation (oldValue);\r
199 }, "~N");\r
200 Clazz.defineMethod (c$, "getDividerLocation", \r
201 function () {\r
202 return this.dividerLocation;\r
203 });\r
204 Clazz.defineMethod (c$, "getMinimumDividerLocation", \r
205 function () {\r
206 var ui = this.getUI ();\r
207 if (ui != null) {\r
208 return ui.getMinimumDividerLocation (this);\r
209 }return -1;\r
210 });\r
211 Clazz.defineMethod (c$, "getMaximumDividerLocation", \r
212 function () {\r
213 var ui = this.getUI ();\r
214 if (ui != null) {\r
215 return ui.getMaximumDividerLocation (this);\r
216 }return -1;\r
217 });\r
218 Clazz.defineMethod (c$, "remove", \r
219 function (component) {\r
220 if (component === this.leftComponent) {\r
221 this.leftComponent = null;\r
222 } else if (component === this.rightComponent) {\r
223 this.rightComponent = null;\r
224 }Clazz.superCall (this, javax.swing.JSplitPane, "remove", [component]);\r
225 this.revalidate ();\r
226 this.repaint ();\r
227 }, "java.awt.Component");\r
228 Clazz.defineMethod (c$, "remove", \r
229 function (index) {\r
230 var comp = this.getComponent (index);\r
231 if (comp === this.leftComponent) {\r
232 this.leftComponent = null;\r
233 } else if (comp === this.rightComponent) {\r
234 this.rightComponent = null;\r
235 }Clazz.superCall (this, javax.swing.JSplitPane, "remove", [index]);\r
236 this.revalidate ();\r
237 this.repaint ();\r
238 }, "~N");\r
239 Clazz.defineMethod (c$, "removeAll", \r
240 function () {\r
241 this.leftComponent = this.rightComponent = null;\r
242 Clazz.superCall (this, javax.swing.JSplitPane, "removeAll", []);\r
243 this.revalidate ();\r
244 this.repaint ();\r
245 });\r
246 Clazz.overrideMethod (c$, "isValidateRoot", \r
247 function () {\r
248 return true;\r
249 });\r
250 Clazz.overrideMethod (c$, "addImpl", \r
251 function (comp, constraints, index) {\r
252 var toRemove;\r
253 if (constraints != null && !(Clazz.instanceOf (constraints, String))) {\r
254 throw  new IllegalArgumentException ("cannot add to layout: constraint must be a string (or null)");\r
255 }if (constraints == null) {\r
256 if (this.getLeftComponent () == null) {\r
257 constraints = "left";\r
258 } else if (this.getRightComponent () == null) {\r
259 constraints = "right";\r
260 }}if (constraints != null && (constraints.equals ("left") || constraints.equals ("top"))) {\r
261 toRemove = this.getLeftComponent ();\r
262 if (toRemove != null) {\r
263 this.remove (toRemove);\r
264 }this.leftComponent = comp;\r
265 index = -1;\r
266 } else if (constraints != null && (constraints.equals ("right") || constraints.equals ("bottom"))) {\r
267 toRemove = this.getRightComponent ();\r
268 if (toRemove != null) {\r
269 this.remove (toRemove);\r
270 }this.rightComponent = comp;\r
271 index = -1;\r
272 } else if (constraints != null && constraints.equals ("divider")) {\r
273 index = -1;\r
274 }this.addImplSAEM (comp, constraints, index);\r
275 this.revalidate ();\r
276 this.repaint ();\r
277 return comp;\r
278 }, "java.awt.Component,~O,~N");\r
279 Clazz.defineMethod (c$, "paintChildren", \r
280 function (g) {\r
281 Clazz.superCall (this, javax.swing.JSplitPane, "paintChildren", [g]);\r
282 var ui = this.getUI ();\r
283 if (ui != null) {\r
284 var tempG = g.createSwingJS ();\r
285 ui.finishedPaintingChildren (this, tempG);\r
286 tempG.dispose ();\r
287 }}, "java.awt.Graphics");\r
288 Clazz.defineMethod (c$, "setUIProperty", \r
289 function (propertyName, value) {\r
290 if (propertyName === "dividerSize") {\r
291 if (!this.dividerSizeSet) {\r
292 this.setDividerSize ((value).intValue ());\r
293 this.dividerSizeSet = false;\r
294 }} else if (propertyName === "oneTouchExpandable") {\r
295 if (!this.oneTouchExpandableSet) {\r
296 this.setOneTouchExpandable ((value).booleanValue ());\r
297 this.oneTouchExpandableSet = false;\r
298 }} else {\r
299 Clazz.superCall (this, javax.swing.JSplitPane, "setUIProperty", [propertyName, value]);\r
300 }}, "~S,~O");\r
301 Clazz.defineMethod (c$, "paramString", \r
302 function () {\r
303 var orientationString = (this.orientation == 1 ? "HORIZONTAL_SPLIT" : "VERTICAL_SPLIT");\r
304 var continuousLayoutString = (this.continuousLayout ? "true" : "false");\r
305 var oneTouchExpandableString = (this.oneTouchExpandable ? "true" : "false");\r
306 return Clazz.superCall (this, javax.swing.JSplitPane, "paramString", []) + ",continuousLayout=" + continuousLayoutString + ",dividerSize=" + this.dividerSize + ",lastDividerLocation=" + this.lastDividerLocation + ",oneTouchExpandable=" + oneTouchExpandableString + ",orientation=" + orientationString;\r
307 });\r
308 Clazz.defineStatics (c$,\r
309 "$uiClassID", "SplitPaneUI",\r
310 "VERTICAL_SPLIT", 0,\r
311 "HORIZONTAL_SPLIT", 1,\r
312 "LEFT", "left",\r
313 "RIGHT", "right",\r
314 "TOP", "top",\r
315 "BOTTOM", "bottom",\r
316 "DIVIDER", "divider",\r
317 "ORIENTATION_PROPERTY", "orientation",\r
318 "CONTINUOUS_LAYOUT_PROPERTY", "continuousLayout",\r
319 "DIVIDER_SIZE_PROPERTY", "dividerSize",\r
320 "ONE_TOUCH_EXPANDABLE_PROPERTY", "oneTouchExpandable",\r
321 "LAST_DIVIDER_LOCATION_PROPERTY", "lastDividerLocation",\r
322 "DIVIDER_LOCATION_PROPERTY", "dividerLocation",\r
323 "RESIZE_WEIGHT_PROPERTY", "resizeWeight");\r
324 });\r