1 Clazz.declarePackage ("javax.swing");
\r
2 Clazz.load (["javax.swing.JComponent", "$.JSeparator", "$.MenuElement"], "javax.swing.JPopupMenu", ["java.lang.Boolean", "$.IllegalArgumentException", "java.util.Vector", "java.awt.Dimension", "$.Frame", "$.GraphicsEnvironment", "$.Insets", "$.Point", "javax.swing.DefaultSingleSelectionModel", "$.JMenu", "$.JMenuItem", "$.MenuSelectionManager", "$.PopupFactory", "$.SwingUtilities", "$.UIManager", "javax.swing.event.MenuKeyEvent", "$.MenuKeyListener", "$.PopupMenuEvent", "$.PopupMenuListener"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
7 this.desiredLocationX = 0;
\r
8 this.desiredLocationY = 0;
\r
10 this.$paintBorder = true;
\r
12 this.lightWeightPopup = true;
\r
13 this.selectionModel = null;
\r
14 Clazz.instantialize (this, arguments);
\r
15 }, javax.swing, "JPopupMenu", javax.swing.JComponent, javax.swing.MenuElement);
\r
16 c$.setDefaultLightWeightPopupEnabled = Clazz.defineMethod (c$, "setDefaultLightWeightPopupEnabled",
\r
18 javax.swing.SwingUtilities.appContextPut (javax.swing.JPopupMenu.defaultLWPopupEnabledKey, Boolean.$valueOf (aFlag));
\r
20 c$.getDefaultLightWeightPopupEnabled = Clazz.defineMethod (c$, "getDefaultLightWeightPopupEnabled",
\r
22 var b = javax.swing.SwingUtilities.appContextGet (javax.swing.JPopupMenu.defaultLWPopupEnabledKey);
\r
24 javax.swing.SwingUtilities.appContextPut (javax.swing.JPopupMenu.defaultLWPopupEnabledKey, Boolean.TRUE);
\r
26 }return b.booleanValue ();
\r
28 Clazz.makeConstructor (c$,
\r
30 this.construct (null);
\r
32 Clazz.makeConstructor (c$,
\r
34 Clazz.superConstructor (this, javax.swing.JPopupMenu, []);
\r
36 this.lightWeightPopup = javax.swing.JPopupMenu.getDefaultLightWeightPopupEnabled ();
\r
37 this.setSelectionModel ( new javax.swing.DefaultSingleSelectionModel ());
\r
38 this.enableEvents (16);
\r
41 Clazz.overrideMethod (c$, "getUI",
\r
45 Clazz.overrideMethod (c$, "updateUI",
\r
47 this.setUI (javax.swing.UIManager.getUI (this));
\r
49 Clazz.overrideMethod (c$, "getUIClassID",
\r
51 return "PopupMenuUI";
\r
53 Clazz.defineMethod (c$, "processKeyEvent",
\r
55 javax.swing.MenuSelectionManager.defaultManager ().processKeyEvent (evt);
\r
56 if (evt.isConsumed ()) {
\r
58 }Clazz.superCall (this, javax.swing.JPopupMenu, "processKeyEvent", [evt]);
\r
59 }, "java.awt.event.KeyEvent");
\r
60 Clazz.defineMethod (c$, "getSelectionModel",
\r
62 return this.selectionModel;
\r
64 Clazz.defineMethod (c$, "setSelectionModel",
\r
66 this.selectionModel = model;
\r
67 }, "javax.swing.SingleSelectionModel");
\r
68 Clazz.defineMethod (c$, "add",
\r
69 function (menuItem) {
\r
70 Clazz.superCall (this, javax.swing.JPopupMenu, "add", [menuItem]);
\r
72 }, "javax.swing.JMenuItem");
\r
73 Clazz.defineMethod (c$, "add",
\r
75 return this.add ( new javax.swing.JMenuItem (s));
\r
77 Clazz.defineMethod (c$, "add",
\r
79 var mi = this.createActionComponent (a);
\r
83 }, "javax.swing.Action");
\r
84 Clazz.defineMethod (c$, "adjustPopupLocationToFitScreen",
\r
85 function (xposition, yposition) {
\r
86 var p = new java.awt.Point (xposition, yposition);
\r
87 if (javax.swing.JPopupMenu.popupPostionFixDisabled == true || java.awt.GraphicsEnvironment.isHeadless ()) return p;
\r
90 Clazz.defineMethod (c$, "createActionComponent",
\r
92 var mi = ((Clazz.isClassDefined ("javax.swing.JPopupMenu$1") ? 0 : javax.swing.JPopupMenu.$JPopupMenu$1$ ()), Clazz.innerTypeInstance (javax.swing.JPopupMenu$1, this, null));
\r
93 mi.setHorizontalTextPosition (11);
\r
94 mi.setVerticalTextPosition (0);
\r
96 }, "javax.swing.Action");
\r
97 Clazz.defineMethod (c$, "createActionChangeListener",
\r
99 return b.createActionPropertyChangeListener0 (b.getAction ());
\r
100 }, "javax.swing.JMenuItem");
\r
101 Clazz.defineMethod (c$, "remove",
\r
104 throw new IllegalArgumentException ("index less than zero.");
\r
105 }if (pos > this.getComponentCount () - 1) {
\r
106 throw new IllegalArgumentException ("index greater than the number of items.");
\r
107 }Clazz.superCall (this, javax.swing.JPopupMenu, "remove", [pos]);
\r
109 Clazz.defineMethod (c$, "setLightWeightPopupEnabled",
\r
111 this.lightWeightPopup = aFlag;
\r
113 Clazz.defineMethod (c$, "isLightWeightPopupEnabled",
\r
115 return this.lightWeightPopup;
\r
117 Clazz.defineMethod (c$, "getLabel",
\r
121 Clazz.defineMethod (c$, "setLabel",
\r
123 var oldValue = this.label;
\r
124 this.label = label;
\r
125 this.firePropertyChangeObject ("label", oldValue, label);
\r
126 this.invalidate ();
\r
129 Clazz.defineMethod (c$, "addSeparator",
\r
131 this.add ( new javax.swing.JPopupMenu.Separator ());
\r
133 Clazz.defineMethod (c$, "insert",
\r
134 function (a, index) {
\r
135 var mi = this.createActionComponent (a);
\r
137 this.insert (mi, index);
\r
138 }, "javax.swing.Action,~N");
\r
139 Clazz.defineMethod (c$, "insert",
\r
140 function (component, index) {
\r
142 throw new IllegalArgumentException ("index less than zero.");
\r
143 }var nitems = this.getComponentCount ();
\r
144 var tempItems = new java.util.Vector ();
\r
145 for (var i = index; i < nitems; i++) {
\r
146 tempItems.addElement (this.getComponent (index));
\r
147 this.remove (index);
\r
149 this.add (component);
\r
150 for (var i = 0; i < tempItems.size (); i++) {
\r
151 this.add (tempItems.elementAt (i));
\r
153 }, "java.awt.Component,~N");
\r
154 Clazz.defineMethod (c$, "addPopupMenuListener",
\r
156 this.listenerList.add (javax.swing.event.PopupMenuListener, l);
\r
157 }, "javax.swing.event.PopupMenuListener");
\r
158 Clazz.defineMethod (c$, "removePopupMenuListener",
\r
160 this.listenerList.remove (javax.swing.event.PopupMenuListener, l);
\r
161 }, "javax.swing.event.PopupMenuListener");
\r
162 Clazz.defineMethod (c$, "getPopupMenuListeners",
\r
164 return this.listenerList.getListeners (javax.swing.event.PopupMenuListener);
\r
166 Clazz.defineMethod (c$, "addMenuKeyListener",
\r
168 this.listenerList.add (javax.swing.event.MenuKeyListener, l);
\r
169 }, "javax.swing.event.MenuKeyListener");
\r
170 Clazz.defineMethod (c$, "removeMenuKeyListener",
\r
172 this.listenerList.remove (javax.swing.event.MenuKeyListener, l);
\r
173 }, "javax.swing.event.MenuKeyListener");
\r
174 Clazz.defineMethod (c$, "getMenuKeyListeners",
\r
176 return this.listenerList.getListeners (javax.swing.event.MenuKeyListener);
\r
178 Clazz.defineMethod (c$, "firePopupMenuWillBecomeVisible",
\r
180 var listeners = this.listenerList.getListenerList ();
\r
182 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
183 if (listeners[i] === javax.swing.event.PopupMenuListener) {
\r
184 if (e == null) e = new javax.swing.event.PopupMenuEvent (this);
\r
185 (listeners[i + 1]).popupMenuWillBecomeVisible (e);
\r
188 Clazz.defineMethod (c$, "firePopupMenuWillBecomeInvisible",
\r
190 var listeners = this.listenerList.getListenerList ();
\r
192 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
193 if (listeners[i] === javax.swing.event.PopupMenuListener) {
\r
194 if (e == null) e = new javax.swing.event.PopupMenuEvent (this);
\r
195 (listeners[i + 1]).popupMenuWillBecomeInvisible (e);
\r
198 Clazz.defineMethod (c$, "firePopupMenuCanceled",
\r
200 var listeners = this.listenerList.getListenerList ();
\r
202 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
203 if (listeners[i] === javax.swing.event.PopupMenuListener) {
\r
204 if (e == null) e = new javax.swing.event.PopupMenuEvent (this);
\r
205 (listeners[i + 1]).popupMenuCanceled (e);
\r
208 Clazz.overrideMethod (c$, "alwaysOnTop",
\r
212 Clazz.defineMethod (c$, "pack",
\r
214 if (this.popup != null) {
\r
215 var pref = this.getPreferredSize ();
\r
216 if (pref == null || pref.width != this.getWidth () || pref.height != this.getHeight ()) {
\r
217 this.popup = this.getPopup ();
\r
221 Clazz.overrideMethod (c$, "setVisible",
\r
223 if (b == this.isVisible ()) return;
\r
225 var doCanceled = this.getClientProperty ("JPopupMenu.firePopupMenuCanceled");
\r
226 if (doCanceled != null && doCanceled === Boolean.TRUE) {
\r
227 this.putClientProperty ("JPopupMenu.firePopupMenuCanceled", Boolean.FALSE);
\r
228 this.firePopupMenuCanceled ();
\r
229 }this.getSelectionModel ().clearSelection ();
\r
231 if (this.isPopupMenu ()) {
\r
232 var me = new Array (1);
\r
234 javax.swing.MenuSelectionManager.defaultManager ().setSelectedPath (me);
\r
236 this.firePopupMenuWillBecomeVisible ();
\r
237 this.popup = this.getPopup ();
\r
238 this.firePropertyChangeObject ("visible", Boolean.FALSE, Boolean.TRUE);
\r
239 } else if (this.popup != null) {
\r
240 this.firePopupMenuWillBecomeInvisible ();
\r
241 this.popup.hide ();
\r
243 this.firePropertyChangeObject ("visible", Boolean.TRUE, Boolean.FALSE);
\r
244 if (this.isPopupMenu ()) {
\r
245 javax.swing.MenuSelectionManager.defaultManager ().clearSelectedPath ();
\r
247 Clazz.defineMethod (c$, "getPopup",
\r
249 var oldPopup = this.popup;
\r
250 if (oldPopup != null) {
\r
252 }var popupFactory = javax.swing.PopupFactory.getSharedInstance ();
\r
253 if (this.isLightWeightPopupEnabled ()) {
\r
254 popupFactory.setPopupType (0);
\r
256 popupFactory.setPopupType (1);
\r
257 }var p = this.adjustPopupLocationToFitScreen (this.desiredLocationX, this.desiredLocationY);
\r
258 this.desiredLocationX = p.x;
\r
259 this.desiredLocationY = p.y;
\r
260 var newPopup = this.getUI ().getPopup (this, this.desiredLocationX, this.desiredLocationY);
\r
261 popupFactory.setPopupType (0);
\r
265 Clazz.overrideMethod (c$, "isVisible",
\r
267 if (this.popup != null) return true;
\r
270 Clazz.defineMethod (c$, "setLocation",
\r
272 var oldX = this.desiredLocationX;
\r
273 var oldY = this.desiredLocationY;
\r
274 this.desiredLocationX = x;
\r
275 this.desiredLocationY = y;
\r
276 if (this.popup != null && (x != oldX || y != oldY)) {
\r
277 this.popup = this.getPopup ();
\r
279 Clazz.defineMethod (c$, "isPopupMenu",
\r
281 return ((this.invoker != null) && !(Clazz.instanceOf (this.invoker, javax.swing.JMenu)));
\r
283 Clazz.defineMethod (c$, "getInvoker",
\r
285 return this.invoker;
\r
287 Clazz.defineMethod (c$, "setInvoker",
\r
288 function (invoker) {
\r
289 var oldInvoker = this.invoker;
\r
290 this.invoker = invoker;
\r
291 if ((oldInvoker !== this.invoker) && (this.ui != null)) {
\r
292 this.ui.uninstallUI (this);
\r
293 this.ui.installUI (this);
\r
294 }this.invalidate ();
\r
295 }, "java.awt.Component");
\r
296 Clazz.defineMethod (c$, "show",
\r
297 function (invoker, x, y) {
\r
298 this.setInvoker (invoker);
\r
299 var newFrame = javax.swing.JPopupMenu.getFrame (invoker);
\r
300 if (newFrame !== this.frame) {
\r
301 if (newFrame != null) {
\r
302 this.frame = newFrame;
\r
303 if (this.popup != null) {
\r
304 this.setVisible (false);
\r
305 }}}var invokerOrigin;
\r
306 if (invoker != null) {
\r
307 invokerOrigin = invoker.getLocationOnScreen ();
\r
310 lx = (invokerOrigin.x) + (x);
\r
311 ly = (invokerOrigin.y) + (y);
\r
312 if (lx > 2147483647) lx = 2147483647;
\r
313 if (lx < -2147483648) lx = -2147483648;
\r
314 if (ly > 2147483647) ly = 2147483647;
\r
315 if (ly < -2147483648) ly = -2147483648;
\r
316 this.setLocation (lx, ly);
\r
318 this.setLocation (x, y);
\r
319 }this.setVisible (true);
\r
320 }, "java.awt.Component,~N,~N");
\r
321 Clazz.defineMethod (c$, "getRootPopupMenu",
\r
324 while ((mp != null) && (mp.isPopupMenu () != true) && (mp.getInvoker () != null) && (mp.getInvoker ().getParent () != null) && (Clazz.instanceOf (mp.getInvoker ().getParent (), javax.swing.JPopupMenu))) {
\r
325 mp = mp.getInvoker ().getParent ();
\r
329 Clazz.defineMethod (c$, "getComponentAtIndex",
\r
331 return this.getComponent (i);
\r
333 Clazz.defineMethod (c$, "getComponentIndex",
\r
335 var ncomponents = this.getComponentCount ();
\r
336 var component = this.getComponents ();
\r
337 for (var i = 0; i < ncomponents; i++) {
\r
338 var comp = component[i];
\r
339 if (comp === c) return i;
\r
342 }, "java.awt.Component");
\r
343 Clazz.defineMethod (c$, "setPopupSize",
\r
345 var oldSize = this.getPreferredSize ();
\r
346 this.setPreferredSize (d);
\r
347 if (this.popup != null) {
\r
348 var newSize = this.getPreferredSize ();
\r
349 if (!oldSize.equals (newSize)) {
\r
350 this.popup = this.getPopup ();
\r
351 }}}, "java.awt.Dimension");
\r
352 Clazz.defineMethod (c$, "setPopupSize",
\r
353 function (width, height) {
\r
354 this.setPopupSize ( new java.awt.Dimension (width, height));
\r
356 Clazz.defineMethod (c$, "setSelected",
\r
358 var model = this.getSelectionModel ();
\r
359 var index = this.getComponentIndex (sel);
\r
360 model.setSelectedIndex (index);
\r
361 }, "java.awt.Component");
\r
362 Clazz.defineMethod (c$, "isBorderPainted",
\r
364 return this.$paintBorder;
\r
366 Clazz.defineMethod (c$, "setBorderPainted",
\r
368 this.$paintBorder = b;
\r
371 Clazz.defineMethod (c$, "paintBorder",
\r
373 if (this.isBorderPainted ()) {
\r
374 Clazz.superCall (this, javax.swing.JPopupMenu, "paintBorder", [g]);
\r
375 }}, "java.awt.Graphics");
\r
376 Clazz.defineMethod (c$, "getMargin",
\r
378 if (this.margin == null) {
\r
379 return new java.awt.Insets (0, 0, 0, 0);
\r
381 return this.margin;
\r
383 Clazz.defineMethod (c$, "isSubPopupMenu",
\r
385 var ncomponents = this.getComponentCount ();
\r
386 var component = this.getComponents ();
\r
387 for (var i = 0; i < ncomponents; i++) {
\r
388 var comp = component[i];
\r
389 if (Clazz.instanceOf (comp, javax.swing.JMenu)) {
\r
391 var subPopup = menu.getPopupMenu ();
\r
392 if (subPopup === popup) return true;
\r
393 if (subPopup.isSubPopupMenu (popup)) return true;
\r
396 }, "javax.swing.JPopupMenu");
\r
397 c$.getFrame = Clazz.defineMethod (c$, "getFrame",
\r
400 while (!(Clazz.instanceOf (w, java.awt.Frame)) && (w != null)) {
\r
401 w = w.getParent ();
\r
404 }, "java.awt.Component");
\r
405 Clazz.defineMethod (c$, "paramString",
\r
407 var labelString = (this.label != null ? this.label : "");
\r
408 var paintBorderString = (this.$paintBorder ? "true" : "false");
\r
409 var marginString = (this.margin != null ? this.margin.toString () : "");
\r
410 var lightWeightPopupEnabledString = (this.isLightWeightPopupEnabled () ? "true" : "false");
\r
411 return Clazz.superCall (this, javax.swing.JPopupMenu, "paramString", []) + ",desiredLocationX=" + this.desiredLocationX + ",desiredLocationY=" + this.desiredLocationY + ",label=" + labelString + ",lightWeightPopupEnabled=" + lightWeightPopupEnabledString + ",margin=" + marginString + ",paintBorder=" + paintBorderString;
\r
413 Clazz.defineMethod (c$, "processMouseEvent",
\r
414 function (event, path, manager) {
\r
415 }, "java.awt.event.MouseEvent,~A,javax.swing.MenuSelectionManager");
\r
416 Clazz.defineMethod (c$, "processKeyEvent",
\r
417 function (e, path, manager) {
\r
418 var mke = new javax.swing.event.MenuKeyEvent (e.getComponent (), e.getID (), e.getWhen (), e.getModifiers (), e.getKeyCode (), e.getKeyChar (), path, manager);
\r
419 this.processMenuKeyEvent (mke);
\r
420 if (mke.isConsumed ()) {
\r
422 }}, "java.awt.event.KeyEvent,~A,javax.swing.MenuSelectionManager");
\r
423 Clazz.defineMethod (c$, "processMenuKeyEvent",
\r
425 switch (e.getID ()) {
\r
427 this.fireMenuKeyPressed (e);
\r
430 this.fireMenuKeyReleased (e);
\r
433 this.fireMenuKeyTyped (e);
\r
438 }, "javax.swing.event.MenuKeyEvent");
\r
439 Clazz.defineMethod (c$, "fireMenuKeyPressed",
\r
441 var listeners = this.listenerList.getListenerList ();
\r
442 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
443 if (listeners[i] === javax.swing.event.MenuKeyListener) {
\r
444 (listeners[i + 1]).menuKeyPressed (event);
\r
446 }, "javax.swing.event.MenuKeyEvent");
\r
447 Clazz.defineMethod (c$, "fireMenuKeyReleased",
\r
449 var listeners = this.listenerList.getListenerList ();
\r
450 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
451 if (listeners[i] === javax.swing.event.MenuKeyListener) {
\r
452 (listeners[i + 1]).menuKeyReleased (event);
\r
454 }, "javax.swing.event.MenuKeyEvent");
\r
455 Clazz.defineMethod (c$, "fireMenuKeyTyped",
\r
457 var listeners = this.listenerList.getListenerList ();
\r
458 for (var i = listeners.length - 2; i >= 0; i -= 2) {
\r
459 if (listeners[i] === javax.swing.event.MenuKeyListener) {
\r
460 (listeners[i + 1]).menuKeyTyped (event);
\r
462 }, "javax.swing.event.MenuKeyEvent");
\r
463 Clazz.overrideMethod (c$, "menuSelectionChanged",
\r
464 function (isIncluded) {
\r
465 if (Clazz.instanceOf (this.invoker, javax.swing.JMenu)) {
\r
466 var m = this.invoker;
\r
467 if (isIncluded) m.setPopupMenuVisible (true);
\r
468 else m.setPopupMenuVisible (false);
\r
469 }if (this.isPopupMenu () && !isIncluded) this.setVisible (false);
\r
471 Clazz.overrideMethod (c$, "getSubElements",
\r
474 var tmp = new java.util.Vector ();
\r
475 var c = this.getComponentCount ();
\r
478 for (i = 0; i < c; i++) {
\r
479 m = this.getComponent (i);
\r
480 if (Clazz.instanceOf (m, javax.swing.MenuElement)) tmp.addElement (m);
\r
482 result = new Array (tmp.size ());
\r
483 for (i = 0, c = tmp.size (); i < c; i++) result[i] = tmp.elementAt (i);
\r
487 Clazz.defineMethod (c$, "getComponent",
\r
491 Clazz.defineMethod (c$, "isPopupTrigger",
\r
493 return this.getUI ().isPopupTrigger (e);
\r
494 }, "java.awt.event.MouseEvent");
\r
495 c$.$JPopupMenu$1$ = function () {
\r
496 Clazz.pu$h(self.c$);
\r
497 c$ = Clazz.declareAnonymous (javax.swing, "JPopupMenu$1", javax.swing.JMenuItem);
\r
498 Clazz.defineMethod (c$, "createActionPropertyChangeListener",
\r
500 var pcl = this.b$["javax.swing.JPopupMenu"].createActionChangeListener (this);
\r
502 pcl = Clazz.superCall (this, javax.swing.JPopupMenu$1, "createActionPropertyChangeListener", [a]);
\r
504 }, "javax.swing.Action");
\r
507 Clazz.pu$h(self.c$);
\r
508 c$ = Clazz.declareType (javax.swing.JPopupMenu, "Separator", javax.swing.JSeparator);
\r
509 Clazz.makeConstructor (c$,
\r
511 Clazz.superConstructor (this, javax.swing.JPopupMenu.Separator, [0]);
\r
513 Clazz.overrideMethod (c$, "getUIClassID",
\r
515 return "PopupMenuSeparatorUI";
\r
518 Clazz.defineStatics (c$,
\r
519 "$uiClassID", "PopupMenuUI");
\r
520 c$.defaultLWPopupEnabledKey = c$.prototype.defaultLWPopupEnabledKey = new Clazz._O ();
\r
521 Clazz.defineStatics (c$,
\r
522 "popupPostionFixDisabled", false);
\r