1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["java.awt.event.ComponentListener", "java.beans.PropertyChangeListener", "javax.swing.event.EventListenerList"], "javax.swing.AncestorNotifier", ["java.awt.Window", "javax.swing.JComponent", "javax.swing.event.AncestorEvent", "$.AncestorListener"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.firstInvisibleAncestor = null;
5 this.listenerList = null;
7 Clazz.instantialize (this, arguments);
8 }, javax.swing, "AncestorNotifier", null, [java.awt.event.ComponentListener, java.beans.PropertyChangeListener]);
9 Clazz.prepareFields (c$, function () {
10 this.listenerList = new javax.swing.event.EventListenerList ();
12 Clazz.makeConstructor (c$,
15 this.addListeners (root, true);
16 }, "javax.swing.JComponent");
17 Clazz.defineMethod (c$, "addAncestorListener",
19 this.listenerList.add (javax.swing.event.AncestorListener, l);
20 }, "javax.swing.event.AncestorListener");
21 Clazz.defineMethod (c$, "removeAncestorListener",
23 this.listenerList.remove (javax.swing.event.AncestorListener, l);
24 }, "javax.swing.event.AncestorListener");
25 Clazz.defineMethod (c$, "getAncestorListeners",
27 return this.listenerList.getListeners (javax.swing.event.AncestorListener);
29 Clazz.defineMethod (c$, "fireAncestorAdded",
30 function (source, id, ancestor, ancestorParent) {
31 var listeners = this.listenerList.getListenerList ();
32 for (var i = listeners.length - 2; i >= 0; i -= 2) {
33 if (listeners[i] === javax.swing.event.AncestorListener) {
34 var ancestorEvent = new javax.swing.event.AncestorEvent (source, id, ancestor, ancestorParent);
35 (listeners[i + 1]).ancestorAdded (ancestorEvent);
37 }, "javax.swing.JComponent,~N,java.awt.Container,java.awt.Container");
38 Clazz.defineMethod (c$, "fireAncestorRemoved",
39 function (source, id, ancestor, ancestorParent) {
40 var listeners = this.listenerList.getListenerList ();
41 for (var i = listeners.length - 2; i >= 0; i -= 2) {
42 if (listeners[i] === javax.swing.event.AncestorListener) {
43 var ancestorEvent = new javax.swing.event.AncestorEvent (source, id, ancestor, ancestorParent);
44 (listeners[i + 1]).ancestorRemoved (ancestorEvent);
46 }, "javax.swing.JComponent,~N,java.awt.Container,java.awt.Container");
47 Clazz.defineMethod (c$, "fireAncestorMoved",
48 function (source, id, ancestor, ancestorParent) {
49 var listeners = this.listenerList.getListenerList ();
50 for (var i = listeners.length - 2; i >= 0; i -= 2) {
51 if (listeners[i] === javax.swing.event.AncestorListener) {
52 var ancestorEvent = new javax.swing.event.AncestorEvent (source, id, ancestor, ancestorParent);
53 (listeners[i + 1]).ancestorMoved (ancestorEvent);
55 }, "javax.swing.JComponent,~N,java.awt.Container,java.awt.Container");
56 Clazz.defineMethod (c$, "removeAllListeners",
58 this.removeListeners (this.root);
60 Clazz.defineMethod (c$, "addListeners",
61 function (ancestor, addToFirst) {
63 this.firstInvisibleAncestor = null;
64 for (a = ancestor; this.firstInvisibleAncestor == null; a = a.getParent ()) {
65 if (addToFirst || a !== ancestor) {
66 a.addComponentListener (this);
67 if (Clazz.instanceOf (a, javax.swing.JComponent)) {
69 jAncestor.addPropertyChangeListener (this);
70 }}if (!a.isVisible () || a.getParent () == null || Clazz.instanceOf (a, java.awt.Window)) {
71 this.firstInvisibleAncestor = a;
73 if (Clazz.instanceOf (this.firstInvisibleAncestor, java.awt.Window) && this.firstInvisibleAncestor.isVisible ()) {
74 this.firstInvisibleAncestor = null;
75 }}, "java.awt.Component,~B");
76 Clazz.defineMethod (c$, "removeListeners",
79 for (a = ancestor; a != null; a = a.getParent ()) {
80 a.removeComponentListener (this);
81 if (Clazz.instanceOf (a, javax.swing.JComponent)) {
83 jAncestor.removePropertyChangeListener (this);
84 }if (a === this.firstInvisibleAncestor || Clazz.instanceOf (a, java.awt.Window)) {
87 }, "java.awt.Component");
88 Clazz.overrideMethod (c$, "componentResized",
90 }, "java.awt.event.ComponentEvent");
91 Clazz.overrideMethod (c$, "componentMoved",
93 var source = e.getComponent ();
94 this.fireAncestorMoved (this.root, 3, source, source.getParent ());
95 }, "java.awt.event.ComponentEvent");
96 Clazz.overrideMethod (c$, "componentShown",
98 var ancestor = e.getComponent ();
99 if (ancestor === this.firstInvisibleAncestor) {
100 this.addListeners (ancestor, false);
101 if (this.firstInvisibleAncestor == null) {
102 this.fireAncestorAdded (this.root, 1, ancestor, ancestor.getParent ());
103 }}}, "java.awt.event.ComponentEvent");
104 Clazz.overrideMethod (c$, "componentHidden",
106 var ancestor = e.getComponent ();
107 var needsNotify = this.firstInvisibleAncestor == null;
108 if (!(Clazz.instanceOf (ancestor, java.awt.Window))) {
109 this.removeListeners (ancestor.getParent ());
110 }this.firstInvisibleAncestor = ancestor;
112 this.fireAncestorRemoved (this.root, 2, ancestor, ancestor.getParent ());
113 }}, "java.awt.event.ComponentEvent");
114 Clazz.overrideMethod (c$, "propertyChange",
116 var s = evt.getPropertyName ();
117 if (s != null && (s.equals ("parent") || s.equals ("ancestor"))) {
118 var component = evt.getSource ();
119 if (evt.getNewValue () != null) {
120 if (component === this.firstInvisibleAncestor) {
121 this.addListeners (component, false);
122 if (this.firstInvisibleAncestor == null) {
123 this.fireAncestorAdded (this.root, 1, component, component.getParent ());
125 var needsNotify = this.firstInvisibleAncestor == null;
126 var oldParent = evt.getOldValue ();
127 this.removeListeners (oldParent);
128 this.firstInvisibleAncestor = component;
130 this.fireAncestorRemoved (this.root, 2, component, oldParent);
131 }}}}, "java.beans.PropertyChangeEvent");