Lines 21-36
Link Here
|
21 |
package org.netbeans.core.windows.services; |
21 |
package org.netbeans.core.windows.services; |
22 |
|
22 |
|
23 |
|
23 |
|
24 |
import java.awt.event.FocusEvent; |
24 |
import java.awt.Component; |
25 |
import java.awt.event.FocusListener; |
25 |
import java.awt.Dialog; |
26 |
import javax.swing.JDialog; |
26 |
import java.awt.EventQueue; |
|
|
27 |
import java.awt.Frame; |
28 |
import java.awt.KeyboardFocusManager; |
29 |
import java.awt.Window; |
27 |
import org.openide.DialogDescriptor; |
30 |
import org.openide.DialogDescriptor; |
28 |
import org.openide.DialogDisplayer; |
31 |
import org.openide.DialogDisplayer; |
29 |
import org.openide.NotifyDescriptor; |
32 |
import org.openide.NotifyDescriptor; |
30 |
import org.openide.util.Mutex; |
33 |
import org.openide.util.Mutex; |
31 |
import org.openide.windows.WindowManager; |
34 |
import org.openide.windows.WindowManager; |
32 |
|
35 |
import java.util.ArrayList; |
33 |
import java.awt.*; |
36 |
import java.util.Collections; |
|
|
37 |
import java.util.List; |
34 |
|
38 |
|
35 |
|
39 |
|
36 |
// Extracted from core/NbTopManager. |
40 |
// Extracted from core/NbTopManager. |
Lines 40-45
Link Here
|
40 |
* @author Jesse Glick |
44 |
* @author Jesse Glick |
41 |
*/ |
45 |
*/ |
42 |
public class DialogDisplayerImpl extends DialogDisplayer { |
46 |
public class DialogDisplayerImpl extends DialogDisplayer { |
|
|
47 |
/** delayed runnables */ |
48 |
private static List<Runnable> run = Collections.synchronizedList(new ArrayList<Runnable>()); |
49 |
|
43 |
/** non-null if we are running in unit test and should no show any dialogs */ |
50 |
/** non-null if we are running in unit test and should no show any dialogs */ |
44 |
private Object testResult; |
51 |
private Object testResult; |
45 |
|
52 |
|
Lines 51-56
Link Here
|
51 |
DialogDisplayerImpl (Object testResult) { |
58 |
DialogDisplayerImpl (Object testResult) { |
52 |
this.testResult = testResult; |
59 |
this.testResult = testResult; |
53 |
} |
60 |
} |
|
|
61 |
|
62 |
public static void runDelayed() { |
63 |
List<Runnable> local = run; |
64 |
run = null; |
65 |
if (local == null) { |
66 |
return; |
67 |
} |
68 |
|
69 |
assert EventQueue.isDispatchThread(); |
70 |
for (Runnable r : local) { |
71 |
r.run(); |
72 |
} |
73 |
} |
74 |
|
54 |
|
75 |
|
55 |
/** Creates new dialog. */ |
76 |
/** Creates new dialog. */ |
56 |
public Dialog createDialog (final DialogDescriptor d) { |
77 |
public Dialog createDialog (final DialogDescriptor d) { |
Lines 91-97
Link Here
|
91 |
/** Notifies user by a dialog. |
112 |
/** Notifies user by a dialog. |
92 |
* @param descriptor description that contains needed informations |
113 |
* @param descriptor description that contains needed informations |
93 |
* @return the option that has been choosen in the notification. */ |
114 |
* @return the option that has been choosen in the notification. */ |
94 |
public Object notify (final NotifyDescriptor descriptor) { |
115 |
public Object notify (NotifyDescriptor descriptor) { |
|
|
116 |
return notify(descriptor, false); |
117 |
} |
118 |
|
119 |
private Object notify (final NotifyDescriptor descriptor, final boolean noParent) { |
95 |
class AWTQuery implements Runnable { |
120 |
class AWTQuery implements Runnable { |
96 |
public Object result; |
121 |
public Object result; |
97 |
public boolean running; |
122 |
public boolean running; |
Lines 150-155
Link Here
|
150 |
instanceof Frame ? |
175 |
instanceof Frame ? |
151 |
(Frame) KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow() |
176 |
(Frame) KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow() |
152 |
: WindowManager.getDefault().getMainWindow(); |
177 |
: WindowManager.getDefault().getMainWindow(); |
|
|
178 |
|
179 |
if (noParent) { |
180 |
f = null; |
181 |
} |
153 |
presenter = new NbPresenter(descriptor, f, true); |
182 |
presenter = new NbPresenter(descriptor, f, true); |
154 |
} |
183 |
} |
155 |
} |
184 |
} |
Lines 204-207
Link Here
|
204 |
} |
233 |
} |
205 |
} |
234 |
} |
206 |
|
235 |
|
|
|
236 |
public void notifyLater(final NotifyDescriptor descriptor) { |
237 |
class R implements Runnable { |
238 |
public boolean noParent; |
239 |
|
240 |
public void run() { |
241 |
DialogDisplayerImpl.this.notify(descriptor, noParent); |
242 |
} |
243 |
} |
244 |
R r = new R(); |
245 |
|
246 |
List<Runnable> local = run; |
247 |
if (local != null) { |
248 |
r.noParent = true; |
249 |
local.add(r); |
250 |
} else { |
251 |
EventQueue.invokeLater(r); |
252 |
} |
253 |
} |
207 |
} |
254 |
} |