Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / ModalEventFilter.js
1 Clazz.declarePackage ("java.awt");
2 Clazz.load (["java.awt.EventFilter"], "java.awt.ModalEventFilter", ["java.awt.Component", "$.Dialog", "$.Window", "jssun.awt.ModalExclude"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.modalDialog = null;
5 this.disabled = false;
6 Clazz.instantialize (this, arguments);
7 }, java.awt, "ModalEventFilter", null, java.awt.EventFilter);
8 Clazz.makeConstructor (c$, 
9 function (modalDialog) {
10 this.modalDialog = modalDialog;
11 this.disabled = false;
12 }, "java.awt.Dialog");
13 Clazz.defineMethod (c$, "getModalDialog", 
14 function () {
15 return this.modalDialog;
16 });
17 Clazz.overrideMethod (c$, "acceptEvent", 
18 function (event) {
19 if (this.disabled || !this.modalDialog.isVisible ()) {
20 return java.awt.EventFilter.FilterAction.ACCEPT;
21 }var eventID = event.getID ();
22 if ((eventID >= 500 && eventID <= 507) || (eventID >= 1001 && eventID <= 1001) || eventID == 201) {
23 var o = event.getSource ();
24 if (Clazz.instanceOf (o, jssun.awt.ModalExclude)) {
25 } else if (Clazz.instanceOf (o, java.awt.Component)) {
26 var c = o;
27 while ((c != null) && !(Clazz.instanceOf (c, java.awt.Window))) {
28 c = c.getParent_NoClientCode ();
29 }
30 if (c != null) {
31 return this.acceptWindow (c);
32 }}}return java.awt.EventFilter.FilterAction.ACCEPT;
33 }, "java.awt.AWTEvent");
34 Clazz.defineMethod (c$, "disable", 
35 function () {
36 this.disabled = true;
37 });
38 Clazz.defineMethod (c$, "compareTo", 
39 function (another) {
40 var anotherDialog = another.getModalDialog ();
41 var c = this.modalDialog;
42 while (c != null) {
43 if (c === anotherDialog) {
44 return 1;
45 }c = c.getParent_NoClientCode ();
46 }
47 c = anotherDialog;
48 while (c != null) {
49 if (c === this.modalDialog) {
50 return -1;
51 }c = c.getParent_NoClientCode ();
52 }
53 var blocker = this.modalDialog.getModalBlocker ();
54 while (blocker != null) {
55 if (blocker === anotherDialog) {
56 return -1;
57 }blocker = blocker.getModalBlocker ();
58 }
59 blocker = anotherDialog.getModalBlocker ();
60 while (blocker != null) {
61 if (blocker === this.modalDialog) {
62 return 1;
63 }blocker = blocker.getModalBlocker ();
64 }
65 return this.modalDialog.getModalityType ().compareTo (anotherDialog.getModalityType ());
66 }, "java.awt.ModalEventFilter");
67 c$.createFilterForDialog = Clazz.defineMethod (c$, "createFilterForDialog", 
68 function (modalDialog) {
69 switch (modalDialog.getModalityType ()) {
70 case java.awt.Dialog.ModalityType.DOCUMENT_MODAL:
71 return  new java.awt.ModalEventFilter.DocumentModalEventFilter (modalDialog);
72 case java.awt.Dialog.ModalityType.APPLICATION_MODAL:
73 return  new java.awt.ModalEventFilter.ApplicationModalEventFilter (modalDialog);
74 case java.awt.Dialog.ModalityType.TOOLKIT_MODAL:
75 return  new java.awt.ModalEventFilter.ToolkitModalEventFilter (modalDialog);
76 }
77 return null;
78 }, "java.awt.Dialog");
79 Clazz.pu$h(self.c$);
80 c$ = Clazz.decorateAsClass (function () {
81 this.appContext = null;
82 Clazz.instantialize (this, arguments);
83 }, java.awt.ModalEventFilter, "ToolkitModalEventFilter", java.awt.ModalEventFilter);
84 Clazz.makeConstructor (c$, 
85 function (a) {
86 Clazz.superConstructor (this, java.awt.ModalEventFilter.ToolkitModalEventFilter, [a]);
87 this.appContext = a.appContext;
88 }, "java.awt.Dialog");
89 Clazz.overrideMethod (c$, "acceptWindow", 
90 function (a) {
91 if (a.isModalExcluded (java.awt.Dialog.ModalExclusionType.TOOLKIT_EXCLUDE)) {
92 return java.awt.EventFilter.FilterAction.ACCEPT;
93 }if (a.appContext !== this.appContext) {
94 return java.awt.EventFilter.FilterAction.REJECT;
95 }while (a != null) {
96 if (a === this.modalDialog) {
97 return java.awt.EventFilter.FilterAction.ACCEPT_IMMEDIATELY;
98 }a = a.getOwner ();
99 }
100 return java.awt.EventFilter.FilterAction.REJECT;
101 }, "java.awt.Window");
102 c$ = Clazz.p0p ();
103 Clazz.pu$h(self.c$);
104 c$ = Clazz.decorateAsClass (function () {
105 this.appContext = null;
106 Clazz.instantialize (this, arguments);
107 }, java.awt.ModalEventFilter, "ApplicationModalEventFilter", java.awt.ModalEventFilter);
108 Clazz.makeConstructor (c$, 
109 function (a) {
110 Clazz.superConstructor (this, java.awt.ModalEventFilter.ApplicationModalEventFilter, [a]);
111 this.appContext = a.appContext;
112 }, "java.awt.Dialog");
113 Clazz.overrideMethod (c$, "acceptWindow", 
114 function (a) {
115 if (a.isModalExcluded (java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE)) {
116 return java.awt.EventFilter.FilterAction.ACCEPT;
117 }if (a.appContext === this.appContext) {
118 while (a != null) {
119 if (a === this.modalDialog) {
120 return java.awt.EventFilter.FilterAction.ACCEPT_IMMEDIATELY;
121 }a = a.getOwner ();
122 }
123 return java.awt.EventFilter.FilterAction.REJECT;
124 }return java.awt.EventFilter.FilterAction.ACCEPT;
125 }, "java.awt.Window");
126 c$ = Clazz.p0p ();
127 Clazz.pu$h(self.c$);
128 c$ = Clazz.decorateAsClass (function () {
129 this.documentRoot = null;
130 Clazz.instantialize (this, arguments);
131 }, java.awt.ModalEventFilter, "DocumentModalEventFilter", java.awt.ModalEventFilter);
132 Clazz.makeConstructor (c$, 
133 function (a) {
134 Clazz.superConstructor (this, java.awt.ModalEventFilter.DocumentModalEventFilter, [a]);
135 this.documentRoot = a.getDocumentRoot ();
136 }, "java.awt.Dialog");
137 Clazz.overrideMethod (c$, "acceptWindow", 
138 function (a) {
139 if (a.isModalExcluded (java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE)) {
140 var b = this.modalDialog.getOwner ();
141 while (b != null) {
142 if (b === a) {
143 return java.awt.EventFilter.FilterAction.REJECT;
144 }b = b.getOwner ();
145 }
146 return java.awt.EventFilter.FilterAction.ACCEPT;
147 }while (a != null) {
148 if (a === this.modalDialog) {
149 return java.awt.EventFilter.FilterAction.ACCEPT_IMMEDIATELY;
150 }if (a === this.documentRoot) {
151 return java.awt.EventFilter.FilterAction.REJECT;
152 }a = a.getOwner ();
153 }
154 return java.awt.EventFilter.FilterAction.ACCEPT;
155 }, "java.awt.Window");
156 c$ = Clazz.p0p ();
157 });