e20b014100bfea95abd4d09f5a6a9e9bc40e6c4a
[jalviewjs.git] / site / swingjs / j2s / javax / swing / JToolBar.js
1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.awt.LayoutManager2", "java.beans.PropertyChangeListener", "javax.swing.JComponent", "$.JSeparator", "$.SwingConstants", "javax.swing.plaf.UIResource"], "javax.swing.JToolBar", ["java.lang.Boolean", "$.IllegalArgumentException", "java.awt.Insets", "javax.swing.BoxLayout", "$.JButton", "$.UIManager"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.$paintBorder = true;
5 this.margin = null;
6 this.floatable = true;
7 this.orientation = 0;
8 if (!Clazz.isClassDefined ("javax.swing.JToolBar.DefaultToolBarLayout")) {
9 javax.swing.JToolBar.$JToolBar$DefaultToolBarLayout$ ();
10 }
11 Clazz.instantialize (this, arguments);
12 }, javax.swing, "JToolBar", javax.swing.JComponent, javax.swing.SwingConstants);
13 Clazz.makeConstructor (c$, 
14 function () {
15 this.construct (0);
16 });
17 Clazz.makeConstructor (c$, 
18 function (orientation) {
19 this.construct (null, orientation);
20 }, "~N");
21 Clazz.makeConstructor (c$, 
22 function (name) {
23 this.construct (name, 0);
24 }, "~S");
25 Clazz.makeConstructor (c$, 
26 function (name, orientation) {
27 Clazz.superConstructor (this, javax.swing.JToolBar, []);
28 this.setName (name);
29 this.checkOrientation (orientation);
30 this.orientation = orientation;
31 var layout = Clazz.innerTypeInstance (javax.swing.JToolBar.DefaultToolBarLayout, this, null, orientation);
32 this.setLayout (layout);
33 this.addPropertyChangeListener (layout);
34 this.updateUI ();
35 }, "~S,~N");
36 Clazz.overrideMethod (c$, "getUI", 
37 function () {
38 return this.ui;
39 });
40 Clazz.overrideMethod (c$, "updateUI", 
41 function () {
42 this.setUI (javax.swing.UIManager.getUI (this));
43 if (this.getLayout () == null) {
44 this.setLayout (Clazz.innerTypeInstance (javax.swing.JToolBar.DefaultToolBarLayout, this, null, this.getOrientation ()));
45 }this.invalidate ();
46 });
47 Clazz.overrideMethod (c$, "getUIClassID", 
48 function () {
49 return "ToolBarUI";
50 });
51 Clazz.defineMethod (c$, "getComponentIndex", 
52 function (c) {
53 var ncomponents = this.getComponentCount ();
54 var component = this.getComponents ();
55 for (var i = 0; i < ncomponents; i++) {
56 var comp = component[i];
57 if (comp === c) return i;
58 }
59 return -1;
60 }, "java.awt.Component");
61 Clazz.defineMethod (c$, "getComponentAtIndex", 
62 function (i) {
63 var ncomponents = this.getComponentCount ();
64 if (i >= 0 && i < ncomponents) {
65 var component = this.getComponents ();
66 return component[i];
67 }return null;
68 }, "~N");
69 Clazz.defineMethod (c$, "setMargin", 
70 function (m) {
71 var old = this.margin;
72 this.margin = m;
73 this.firePropertyChangeObject ("margin", old, m);
74 this.revalidate ();
75 this.repaint ();
76 }, "java.awt.Insets");
77 Clazz.defineMethod (c$, "getMargin", 
78 function () {
79 if (this.margin == null) {
80 return  new java.awt.Insets (0, 0, 0, 0);
81 } else {
82 return this.margin;
83 }});
84 Clazz.defineMethod (c$, "isBorderPainted", 
85 function () {
86 return this.$paintBorder;
87 });
88 Clazz.defineMethod (c$, "setBorderPainted", 
89 function (b) {
90 if (this.$paintBorder != b) {
91 var old = this.$paintBorder;
92 this.$paintBorder = b;
93 this.firePropertyChangeBool ("borderPainted", old, b);
94 this.revalidate ();
95 this.repaint ();
96 }}, "~B");
97 Clazz.defineMethod (c$, "paintBorder", 
98 function (g) {
99 if (this.isBorderPainted ()) {
100 Clazz.superCall (this, javax.swing.JToolBar, "paintBorder", [g]);
101 }}, "java.awt.Graphics");
102 Clazz.defineMethod (c$, "isFloatable", 
103 function () {
104 return this.floatable;
105 });
106 Clazz.defineMethod (c$, "setFloatable", 
107 function (b) {
108 if (this.floatable != b) {
109 var old = this.floatable;
110 this.floatable = b;
111 this.firePropertyChangeBool ("floatable", old, b);
112 this.revalidate ();
113 this.repaint ();
114 }}, "~B");
115 Clazz.defineMethod (c$, "getOrientation", 
116 function () {
117 return this.orientation;
118 });
119 Clazz.defineMethod (c$, "setOrientation", 
120 function (o) {
121 this.checkOrientation (o);
122 if (this.orientation != o) {
123 var old = this.orientation;
124 this.orientation = o;
125 this.firePropertyChangeInt ("orientation", old, o);
126 this.revalidate ();
127 this.repaint ();
128 }}, "~N");
129 Clazz.defineMethod (c$, "setRollover", 
130 function (rollover) {
131 this.putClientProperty ("JToolBar.isRollover", rollover ? Boolean.TRUE : Boolean.FALSE);
132 }, "~B");
133 Clazz.defineMethod (c$, "isRollover", 
134 function () {
135 var rollover = this.getClientProperty ("JToolBar.isRollover");
136 if (rollover != null) {
137 return rollover.booleanValue ();
138 }return false;
139 });
140 Clazz.defineMethod (c$, "checkOrientation", 
141  function (orientation) {
142 switch (orientation) {
143 case 1:
144 case 0:
145 break;
146 default:
147 throw  new IllegalArgumentException ("orientation must be one of: VERTICAL, HORIZONTAL");
148 }
149 }, "~N");
150 Clazz.defineMethod (c$, "addSeparator", 
151 function () {
152 this.addSeparator (null);
153 });
154 Clazz.defineMethod (c$, "addSeparator", 
155 function (size) {
156 var s =  new javax.swing.JToolBar.Separator (size);
157 this.add (s);
158 }, "java.awt.Dimension");
159 Clazz.defineMethod (c$, "add", 
160 function (a) {
161 var b = this.createActionComponent (a);
162 b.setAction (a);
163 this.add (b);
164 return b;
165 }, "javax.swing.Action");
166 Clazz.defineMethod (c$, "createActionComponent", 
167 function (a) {
168 var b = ((Clazz.isClassDefined ("javax.swing.JToolBar$1") ? 0 : javax.swing.JToolBar.$JToolBar$1$ ()), Clazz.innerTypeInstance (javax.swing.JToolBar$1, this, null));
169 if (a != null && (a.getValue ("SmallIcon") != null || a.getValue ("SwingLargeIconKey") != null)) {
170 b.setHideActionText (true);
171 }b.setHorizontalTextPosition (0);
172 b.setVerticalTextPosition (3);
173 return b;
174 }, "javax.swing.Action");
175 Clazz.defineMethod (c$, "createActionChangeListener", 
176 function (b) {
177 return null;
178 }, "javax.swing.JButton");
179 Clazz.overrideMethod (c$, "addImpl", 
180 function (comp, constraints, index) {
181 if (Clazz.instanceOf (comp, javax.swing.JToolBar.Separator)) {
182 if (this.getOrientation () == 1) {
183 (comp).setOrientation (0);
184 } else {
185 (comp).setOrientation (1);
186 }}this.addImplSAEM (comp, constraints, index);
187 if (Clazz.instanceOf (comp, javax.swing.JButton)) {
188 (comp).setDefaultCapable (false);
189 }return comp;
190 }, "java.awt.Component,~O,~N");
191 Clazz.defineMethod (c$, "paramString", 
192 function () {
193 var paintBorderString = (this.$paintBorder ? "true" : "false");
194 var marginString = (this.margin != null ? this.margin.toString () : "");
195 var floatableString = (this.floatable ? "true" : "false");
196 var orientationString = (this.orientation == 0 ? "HORIZONTAL" : "VERTICAL");
197 return Clazz.superCall (this, javax.swing.JToolBar, "paramString", []) + ",floatable=" + floatableString + ",margin=" + marginString + ",orientation=" + orientationString + ",paintBorder=" + paintBorderString;
198 });
199 Clazz.defineMethod (c$, "setLayout", 
200 function (mgr) {
201 var oldMgr = this.getLayout ();
202 if (Clazz.instanceOf (oldMgr, java.beans.PropertyChangeListener)) {
203 this.removePropertyChangeListener (oldMgr);
204 }Clazz.superCall (this, javax.swing.JToolBar, "setLayout", [mgr]);
205 }, "java.awt.LayoutManager");
206 c$.$JToolBar$DefaultToolBarLayout$ = function () {
207 Clazz.pu$h(self.c$);
208 c$ = Clazz.decorateAsClass (function () {
209 Clazz.prepareCallback (this, arguments);
210 this.lm = null;
211 Clazz.instantialize (this, arguments);
212 }, javax.swing.JToolBar, "DefaultToolBarLayout", null, [java.awt.LayoutManager2, java.beans.PropertyChangeListener, javax.swing.plaf.UIResource]);
213 Clazz.makeConstructor (c$, 
214 function (a) {
215 if (a == 1) {
216 this.lm =  new javax.swing.BoxLayout (this.b$["javax.swing.JToolBar"], 3);
217 } else {
218 this.lm =  new javax.swing.BoxLayout (this.b$["javax.swing.JToolBar"], 2);
219 }}, "~N");
220 Clazz.defineMethod (c$, "addLayoutComponent", 
221 function (a, b) {
222 this.lm.addLayoutComponent (a, b);
223 }, "~S,java.awt.Component");
224 Clazz.defineMethod (c$, "addLayoutComponent", 
225 function (a, b) {
226 this.lm.addLayoutComponent (a, b);
227 }, "java.awt.Component,~O");
228 Clazz.overrideMethod (c$, "removeLayoutComponent", 
229 function (a) {
230 this.lm.removeLayoutComponent (a);
231 }, "java.awt.Component");
232 Clazz.overrideMethod (c$, "preferredLayoutSize", 
233 function (a) {
234 return this.lm.preferredLayoutSize (a);
235 }, "java.awt.Container");
236 Clazz.overrideMethod (c$, "minimumLayoutSize", 
237 function (a) {
238 return this.lm.minimumLayoutSize (a);
239 }, "java.awt.Container");
240 Clazz.overrideMethod (c$, "maximumLayoutSize", 
241 function (a) {
242 return this.lm.maximumLayoutSize (a);
243 }, "java.awt.Container");
244 Clazz.overrideMethod (c$, "layoutContainer", 
245 function (a) {
246 this.lm.layoutContainer (a);
247 }, "java.awt.Container");
248 Clazz.overrideMethod (c$, "getLayoutAlignmentX", 
249 function (a) {
250 return this.lm.getLayoutAlignmentX (a);
251 }, "java.awt.Container");
252 Clazz.overrideMethod (c$, "getLayoutAlignmentY", 
253 function (a) {
254 return this.lm.getLayoutAlignmentY (a);
255 }, "java.awt.Container");
256 Clazz.overrideMethod (c$, "invalidateLayout", 
257 function (a) {
258 this.lm.invalidateLayout (a);
259 }, "java.awt.Container");
260 Clazz.overrideMethod (c$, "propertyChange", 
261 function (a) {
262 var b = a.getPropertyName ();
263 if (b.equals ("orientation")) {
264 var c = (a.getNewValue ()).intValue ();
265 if (c == 1) this.lm =  new javax.swing.BoxLayout (this.b$["javax.swing.JToolBar"], 3);
266  else {
267 this.lm =  new javax.swing.BoxLayout (this.b$["javax.swing.JToolBar"], 2);
268 }}}, "java.beans.PropertyChangeEvent");
269 c$ = Clazz.p0p ();
270 };
271 c$.$JToolBar$1$ = function () {
272 Clazz.pu$h(self.c$);
273 c$ = Clazz.declareAnonymous (javax.swing, "JToolBar$1", javax.swing.JButton);
274 Clazz.defineMethod (c$, "createActionPropertyChangeListener", 
275 function (a) {
276 var pcl = this.b$["javax.swing.JToolBar"].createActionChangeListener (this);
277 if (pcl == null) {
278 pcl = Clazz.superCall (this, javax.swing.JToolBar$1, "createActionPropertyChangeListener", [a]);
279 }return pcl;
280 }, "javax.swing.Action");
281 c$ = Clazz.p0p ();
282 };
283 Clazz.pu$h(self.c$);
284 c$ = Clazz.decorateAsClass (function () {
285 this.separatorSize = null;
286 Clazz.instantialize (this, arguments);
287 }, javax.swing.JToolBar, "Separator", javax.swing.JSeparator);
288 Clazz.makeConstructor (c$, 
289 function () {
290 this.construct (null);
291 });
292 Clazz.makeConstructor (c$, 
293 function (a) {
294 Clazz.superConstructor (this, javax.swing.JToolBar.Separator, [0]);
295 this.setSeparatorSize (a);
296 }, "java.awt.Dimension");
297 Clazz.overrideMethod (c$, "getUIClassID", 
298 function () {
299 return "ToolBarSeparatorUI";
300 });
301 Clazz.defineMethod (c$, "setSeparatorSize", 
302 function (a) {
303 if (a != null) {
304 this.separatorSize = a;
305 } else {
306 Clazz.superCall (this, javax.swing.JToolBar.Separator, "updateUI", []);
307 }this.invalidate ();
308 }, "java.awt.Dimension");
309 Clazz.defineMethod (c$, "getSeparatorSize", 
310 function () {
311 return this.separatorSize;
312 });
313 Clazz.defineMethod (c$, "getMinimumSize", 
314 function () {
315 if (this.separatorSize != null) {
316 return this.separatorSize.getSize ();
317 } else {
318 return Clazz.superCall (this, javax.swing.JToolBar.Separator, "getMinimumSize", []);
319 }});
320 Clazz.defineMethod (c$, "getMaximumSize", 
321 function () {
322 if (this.separatorSize != null) {
323 return this.separatorSize.getSize ();
324 } else {
325 return Clazz.superCall (this, javax.swing.JToolBar.Separator, "getMaximumSize", []);
326 }});
327 Clazz.overrideMethod (c$, "getPreferredSize", 
328 function () {
329 if (this.separatorSize != null) {
330 return this.separatorSize.getSize ();
331 } else {
332 return this.getPrefSizeJComp ();
333 }});
334 c$ = Clazz.p0p ();
335 Clazz.defineStatics (c$,
336 "$uiClassID", "ToolBarUI");
337 });