Lines 124-131
Link Here
|
124 |
* @author Ian Formanek, Jaroslav Tulach |
124 |
* @author Ian Formanek, Jaroslav Tulach |
125 |
*/ |
125 |
*/ |
126 |
class NbPresenter extends JDialog |
126 |
class NbPresenter extends JDialog |
127 |
implements PropertyChangeListener, WindowListener, Mutex.Action<Void>, Comparator<Object> { |
127 |
implements PropertyChangeListener, WindowListener, Mutex.Action<Void>, Comparator<Object> { |
128 |
|
128 |
|
129 |
/** variable holding current modal dialog in the system */ |
129 |
/** variable holding current modal dialog in the system */ |
130 |
public static NbPresenter currentModalDialog; |
130 |
public static NbPresenter currentModalDialog; |
131 |
private static final ChangeSupport cs = new ChangeSupport(NbPresenter.class); |
131 |
private static final ChangeSupport cs = new ChangeSupport(NbPresenter.class); |
Lines 150-156
Link Here
|
150 |
stdHelpButton.setDefaultCapable(false); |
150 |
stdHelpButton.setDefaultCapable(false); |
151 |
stdDetailButton.setDefaultCapable(false); |
151 |
stdDetailButton.setDefaultCapable(false); |
152 |
Mnemonics.setLocalizedText (stdHelpButton, NbBundle.getBundle(NbPresenter.class).getString("HELP_OPTION_CAPTION")); // NOI18N |
152 |
Mnemonics.setLocalizedText (stdHelpButton, NbBundle.getBundle(NbPresenter.class).getString("HELP_OPTION_CAPTION")); // NOI18N |
153 |
|
153 |
|
154 |
/** Initilizes accessible contexts */ |
154 |
/** Initilizes accessible contexts */ |
155 |
initAccessibility(); |
155 |
initAccessibility(); |
156 |
} |
156 |
} |
Lines 181-187
Link Here
|
181 |
private transient boolean haveCalledInitializeButtons = false; |
181 |
private transient boolean haveCalledInitializeButtons = false; |
182 |
|
182 |
|
183 |
static final Logger LOG = Logger.getLogger(NbPresenter.class.getName()); |
183 |
static final Logger LOG = Logger.getLogger(NbPresenter.class.getName()); |
184 |
|
184 |
|
185 |
static final long serialVersionUID =-4508637164126678997L; |
185 |
static final long serialVersionUID =-4508637164126678997L; |
186 |
|
186 |
|
187 |
/** Creates a new Dialog from specified NotifyDescriptor, |
187 |
/** Creates a new Dialog from specified NotifyDescriptor, |
Lines 192-198
Link Here
|
192 |
super(owner, d.getTitle(), modal); // modal |
192 |
super(owner, d.getTitle(), modal); // modal |
193 |
initialize(d); |
193 |
initialize(d); |
194 |
} |
194 |
} |
195 |
|
195 |
|
196 |
/** Creates a new Dialog from specified NotifyDescriptor, |
196 |
/** Creates a new Dialog from specified NotifyDescriptor, |
197 |
* with given dialog owner. |
197 |
* with given dialog owner. |
198 |
* @param d The NotifyDescriptor to create the dialog from |
198 |
* @param d The NotifyDescriptor to create the dialog from |
Lines 201-245
Link Here
|
201 |
super(owner, d.getTitle(), modal); // modal |
201 |
super(owner, d.getTitle(), modal); // modal |
202 |
initialize(d); |
202 |
initialize(d); |
203 |
} |
203 |
} |
204 |
|
204 |
|
205 |
boolean isLeaf () { |
205 |
boolean isLeaf () { |
206 |
return leaf; |
206 |
return leaf; |
207 |
} |
207 |
} |
208 |
|
208 |
|
209 |
private void initAccessibility(){ |
209 |
private void initAccessibility(){ |
210 |
|
210 |
|
211 |
ResourceBundle bundle; |
211 |
ResourceBundle bundle; |
212 |
bundle = NbBundle.getBundle(NbPresenter.class); |
212 |
bundle = NbBundle.getBundle(NbPresenter.class); |
213 |
|
213 |
|
214 |
stdYesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_YES_OPTION_NAME")); // NOI18N |
214 |
stdYesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_YES_OPTION_NAME")); // NOI18N |
215 |
stdYesButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_YES_OPTION_DESC")); // NOI18N |
215 |
stdYesButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_YES_OPTION_DESC")); // NOI18N |
216 |
|
216 |
|
217 |
stdNoButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_NO_OPTION_NAME")); // NOI18N |
217 |
stdNoButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_NO_OPTION_NAME")); // NOI18N |
218 |
stdNoButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_NO_OPTION_DESC")); // NOI18N |
218 |
stdNoButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_NO_OPTION_DESC")); // NOI18N |
219 |
|
219 |
|
220 |
stdOKButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_OK_OPTION_NAME")); // NOI18N |
220 |
stdOKButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_OK_OPTION_NAME")); // NOI18N |
221 |
stdOKButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_OK_OPTION_DESC")); // NOI18N |
221 |
stdOKButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_OK_OPTION_DESC")); // NOI18N |
222 |
|
222 |
|
223 |
stdCancelButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_CANCEL_OPTION_NAME")); // NOI18N |
223 |
stdCancelButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_CANCEL_OPTION_NAME")); // NOI18N |
224 |
stdCancelButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CANCEL_OPTION_DESC")); // NOI18N |
224 |
stdCancelButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CANCEL_OPTION_DESC")); // NOI18N |
225 |
|
225 |
|
226 |
stdClosedButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_CLOSED_OPTION_NAME")); // NOI18N |
226 |
stdClosedButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_CLOSED_OPTION_NAME")); // NOI18N |
227 |
stdClosedButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CLOSED_OPTION_DESC")); // NOI18N |
227 |
stdClosedButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CLOSED_OPTION_DESC")); // NOI18N |
228 |
|
228 |
|
229 |
stdHelpButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_HELP_OPTION_NAME")); // NOI18N |
229 |
stdHelpButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_HELP_OPTION_NAME")); // NOI18N |
230 |
stdHelpButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_HELP_OPTION_DESC")); // NOI18N |
230 |
stdHelpButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_HELP_OPTION_DESC")); // NOI18N |
231 |
|
231 |
|
232 |
stdDetailButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_HELP_OPTION_NAME")); // NOI18N |
232 |
stdDetailButton.getAccessibleContext().setAccessibleName(bundle.getString("ACS_HELP_OPTION_NAME")); // NOI18N |
233 |
stdDetailButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_HELP_OPTION_DESC")); // NOI18N |
233 |
stdDetailButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_HELP_OPTION_DESC")); // NOI18N |
234 |
} |
234 |
} |
235 |
|
235 |
|
236 |
private void initialize(NotifyDescriptor d) { |
236 |
private void initialize(NotifyDescriptor d) { |
237 |
//Optimization related to jdk bug 4393857 - on pre 1.5 jdk's an |
237 |
//Optimization related to jdk bug 4393857 - on pre 1.5 jdk's an |
238 |
//extra repaint is caused by the search for an opaque component up |
238 |
//extra repaint is caused by the search for an opaque component up |
239 |
//to the component root. Post 1.5, root pane will automatically be |
239 |
//to the component root. Post 1.5, root pane will automatically be |
240 |
//opaque. |
240 |
//opaque. |
241 |
getRootPane().setOpaque(true); |
241 |
getRootPane().setOpaque(true); |
242 |
|
242 |
|
243 |
if (d instanceof WizardDescriptor) { |
243 |
if (d instanceof WizardDescriptor) { |
244 |
// #81938: wizard close button shouln't work during finish progress |
244 |
// #81938: wizard close button shouln't work during finish progress |
245 |
setDefaultCloseOperation (WindowConstants.DO_NOTHING_ON_CLOSE); |
245 |
setDefaultCloseOperation (WindowConstants.DO_NOTHING_ON_CLOSE); |
Lines 247-259
Link Here
|
247 |
// #55273: Dialogs created by DialogDisplayer are not disposed after close |
247 |
// #55273: Dialogs created by DialogDisplayer are not disposed after close |
248 |
setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE); |
248 |
setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE); |
249 |
} |
249 |
} |
250 |
|
250 |
|
251 |
descriptor = d; |
251 |
descriptor = d; |
252 |
|
252 |
|
253 |
buttonListener = new ButtonListener(); |
253 |
buttonListener = new ButtonListener(); |
254 |
// set leaf by DialogDescriptor, NotifyDescriptor is leaf as default |
254 |
// set leaf by DialogDescriptor, NotifyDescriptor is leaf as default |
255 |
leaf = d instanceof DialogDescriptor ? ((DialogDescriptor)d).isLeaf () : true; |
255 |
leaf = d instanceof DialogDescriptor ? ((DialogDescriptor)d).isLeaf () : true; |
256 |
|
256 |
|
257 |
getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( |
257 |
getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( |
258 |
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESCAPE_COMMAND); |
258 |
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESCAPE_COMMAND); |
259 |
getRootPane().getActionMap().put(ESCAPE_COMMAND, new EscapeAction()); |
259 |
getRootPane().getActionMap().put(ESCAPE_COMMAND, new EscapeAction()); |
Lines 273-290
Link Here
|
273 |
* request first. */ |
273 |
* request first. */ |
274 |
private void requestFocusForMessage() { |
274 |
private void requestFocusForMessage() { |
275 |
Component comp = currentMessage; |
275 |
Component comp = currentMessage; |
276 |
|
276 |
|
277 |
if(comp == null) { |
277 |
if(comp == null) { |
278 |
return; |
278 |
return; |
279 |
} |
279 |
} |
280 |
|
280 |
|
281 |
if(!(comp instanceof JComponent) |
281 |
if(!(comp instanceof JComponent) |
282 |
|| !((JComponent)comp).requestDefaultFocus()) { |
282 |
|| !((JComponent)comp).requestDefaultFocus()) { |
283 |
|
283 |
|
284 |
comp.requestFocus(); |
284 |
comp.requestFocus(); |
285 |
} |
285 |
} |
286 |
} |
286 |
} |
287 |
|
287 |
|
288 |
private void initializeMessage() { |
288 |
private void initializeMessage() { |
289 |
Object newMessage = descriptor.getMessage(); |
289 |
Object newMessage = descriptor.getMessage(); |
290 |
// replace only if old and new messages are different |
290 |
// replace only if old and new messages are different |
Lines 302-308
Link Here
|
302 |
} |
302 |
} |
303 |
Dimension prefSize = currentMessage.getPreferredSize(); |
303 |
Dimension prefSize = currentMessage.getPreferredSize(); |
304 |
final Rectangle screenBounds = Utilities.getUsableScreenBounds(); |
304 |
final Rectangle screenBounds = Utilities.getUsableScreenBounds(); |
305 |
|
305 |
|
306 |
if (prefSize.width > screenBounds.width - 100 |
306 |
if (prefSize.width > screenBounds.width - 100 |
307 |
|| prefSize.height > screenBounds.height- 100 |
307 |
|| prefSize.height > screenBounds.height- 100 |
308 |
) { |
308 |
) { |
Lines 323-329
Link Here
|
323 |
} else { |
323 |
} else { |
324 |
toAdd = currentMessage; |
324 |
toAdd = currentMessage; |
325 |
} |
325 |
} |
326 |
|
326 |
|
327 |
if (! (descriptor instanceof WizardDescriptor) && descriptor.getNotificationLineSupport () != null) { |
327 |
if (! (descriptor instanceof WizardDescriptor) && descriptor.getNotificationLineSupport () != null) { |
328 |
JPanel enlargedToAdd = new JPanel (new BorderLayout ()); |
328 |
JPanel enlargedToAdd = new JPanel (new BorderLayout ()); |
329 |
enlargedToAdd.add (toAdd, BorderLayout.CENTER); |
329 |
enlargedToAdd.add (toAdd, BorderLayout.CENTER); |
Lines 389-395
Link Here
|
389 |
isJava17 = javaVersion.startsWith("1.7") || javaRuntimeName.startsWith("OpenJDK"); // NOI18N |
389 |
isJava17 = javaVersion.startsWith("1.7") || javaRuntimeName.startsWith("OpenJDK"); // NOI18N |
390 |
return isJava17; |
390 |
return isJava17; |
391 |
} |
391 |
} |
392 |
|
392 |
|
393 |
private static final class FixedHeightLabel extends JLabel { |
393 |
private static final class FixedHeightLabel extends JLabel { |
394 |
|
394 |
|
395 |
private static final int ESTIMATED_HEIGHT = 16; |
395 |
private static final int ESTIMATED_HEIGHT = 16; |
Lines 423-442
Link Here
|
423 |
private void initializePresenter() { |
423 |
private void initializePresenter() { |
424 |
if (currentMessage != null) |
424 |
if (currentMessage != null) |
425 |
return; |
425 |
return; |
426 |
|
426 |
|
427 |
initializeMessage(); |
427 |
initializeMessage(); |
428 |
|
428 |
|
429 |
updateHelp(); |
429 |
updateHelp(); |
430 |
|
430 |
|
431 |
initializeButtons(); |
431 |
initializeButtons(); |
432 |
haveCalledInitializeButtons = true; |
432 |
haveCalledInitializeButtons = true; |
433 |
|
433 |
|
434 |
descriptor.addPropertyChangeListener(this); |
434 |
descriptor.addPropertyChangeListener(this); |
435 |
addWindowListener(this); |
435 |
addWindowListener(this); |
436 |
|
436 |
|
437 |
initializeClosingOptions (); |
437 |
initializeClosingOptions (); |
438 |
} |
438 |
} |
439 |
|
439 |
|
440 |
/** Descriptor can be cached and reused. We need to remove listeners |
440 |
/** Descriptor can be cached and reused. We need to remove listeners |
441 |
* from descriptor, buttons and disconnect componets from container hierarchy. |
441 |
* from descriptor, buttons and disconnect componets from container hierarchy. |
442 |
*/ |
442 |
*/ |
Lines 452-458
Link Here
|
452 |
public void addNotify() { |
452 |
public void addNotify() { |
453 |
super.addNotify(); |
453 |
super.addNotify(); |
454 |
initializePresenter(); |
454 |
initializePresenter(); |
455 |
|
455 |
|
456 |
hack.activate(); |
456 |
hack.activate(); |
457 |
} |
457 |
} |
458 |
|
458 |
|
Lines 460-466
Link Here
|
460 |
public void removeNotify() { |
460 |
public void removeNotify() { |
461 |
super.removeNotify(); |
461 |
super.removeNotify(); |
462 |
uninitializePresenter(); |
462 |
uninitializePresenter(); |
463 |
|
463 |
|
464 |
} |
464 |
} |
465 |
|
465 |
|
466 |
/** Creates option pane message. |
466 |
/** Creates option pane message. |
Lines 469-475
Link Here
|
469 |
Object msg = descriptor.getMessage(); |
469 |
Object msg = descriptor.getMessage(); |
470 |
boolean override = true; |
470 |
boolean override = true; |
471 |
String strMsg = null, strMsgLower; |
471 |
String strMsg = null, strMsgLower; |
472 |
|
472 |
|
473 |
if (msg instanceof String) { |
473 |
if (msg instanceof String) { |
474 |
msg = ((String) msg).replace("\t", " "); // NOI18N |
474 |
msg = ((String) msg).replace("\t", " "); // NOI18N |
475 |
msg = ((String) msg).replace("\r", ""); // NOI18N |
475 |
msg = ((String) msg).replace("\r", ""); // NOI18N |
Lines 488-500
Link Here
|
488 |
if (override) { |
488 |
if (override) { |
489 |
// initialize component (override max char count per line in a message) |
489 |
// initialize component (override max char count per line in a message) |
490 |
optionPane = new JOptionPane( |
490 |
optionPane = new JOptionPane( |
491 |
msg, |
491 |
msg, |
492 |
descriptor.getMessageType(), |
492 |
descriptor.getMessageType(), |
493 |
0, // options type |
493 |
0, // options type |
494 |
null, // icon |
494 |
null, // icon |
495 |
new Object[0], // options |
495 |
new Object[0], // options |
496 |
null // value |
496 |
null // value |
497 |
) { |
497 |
) { |
498 |
@Override |
498 |
@Override |
499 |
public int getMaxCharactersPerLineCount() { |
499 |
public int getMaxCharactersPerLineCount() { |
500 |
return 100; |
500 |
return 100; |
Lines 503-517
Link Here
|
503 |
} else { |
503 |
} else { |
504 |
//Do not override JOptionPane.getMaxCharactersPerLineCount for html text |
504 |
//Do not override JOptionPane.getMaxCharactersPerLineCount for html text |
505 |
optionPane = new JOptionPane( |
505 |
optionPane = new JOptionPane( |
506 |
msg, |
506 |
msg, |
507 |
descriptor.getMessageType(), |
507 |
descriptor.getMessageType(), |
508 |
0, // options type |
508 |
0, // options type |
509 |
null, // icon |
509 |
null, // icon |
510 |
new Object[0], // options |
510 |
new Object[0], // options |
511 |
null // value |
511 |
null // value |
512 |
); |
512 |
); |
513 |
} |
513 |
} |
514 |
|
514 |
|
515 |
if (UIManager.getLookAndFeel().getClass() == MetalLookAndFeel.class || |
515 |
if (UIManager.getLookAndFeel().getClass() == MetalLookAndFeel.class || |
516 |
UIManager.getLookAndFeel().getClass() == BasicLookAndFeel.class) { |
516 |
UIManager.getLookAndFeel().getClass() == BasicLookAndFeel.class) { |
517 |
optionPane.setUI(new javax.swing.plaf.basic.BasicOptionPaneUI() { |
517 |
optionPane.setUI(new javax.swing.plaf.basic.BasicOptionPaneUI() { |
Lines 571-599
Link Here
|
571 |
modifyListener(currentSecondaryButtons[i], buttonListener, false); |
571 |
modifyListener(currentSecondaryButtons[i], buttonListener, false); |
572 |
} |
572 |
} |
573 |
} |
573 |
} |
574 |
|
574 |
|
575 |
getContentPane().remove(currentButtonsPanel); |
575 |
getContentPane().remove(currentButtonsPanel); |
576 |
currentButtonsPanel = null; |
576 |
currentButtonsPanel = null; |
577 |
} |
577 |
} |
578 |
} |
578 |
} |
579 |
|
579 |
|
580 |
private void initializeClosingOptions (boolean init) { |
580 |
private void initializeClosingOptions (boolean init) { |
581 |
Object[] options = getClosingOptions (); |
581 |
Object[] options = getClosingOptions (); |
582 |
|
582 |
|
583 |
if (options == null) return ; |
583 |
if (options == null) return ; |
|
|
584 |
if (options.length == 0) { |
585 |
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
586 |
} |
584 |
for (int i = 0; i < options.length; i++) { |
587 |
for (int i = 0; i < options.length; i++) { |
585 |
modifyListener (options[i], buttonListener, init); |
588 |
modifyListener (options[i], buttonListener, init); |
586 |
} |
589 |
} |
587 |
} |
590 |
} |
588 |
|
591 |
|
589 |
private void initializeClosingOptions () { |
592 |
private void initializeClosingOptions () { |
590 |
initializeClosingOptions (true); |
593 |
initializeClosingOptions (true); |
591 |
} |
594 |
} |
592 |
|
595 |
|
593 |
private void uninitializeClosingOptions () { |
596 |
private void uninitializeClosingOptions () { |
594 |
initializeClosingOptions (false); |
597 |
initializeClosingOptions (false); |
595 |
} |
598 |
} |
596 |
|
599 |
|
597 |
/** |
600 |
/** |
598 |
* On Aqua look and feel, options should be sorted such that the default |
601 |
* On Aqua look and feel, options should be sorted such that the default |
599 |
* button is always rightmost, and 'yes' options appear to thr right of |
602 |
* button is always rightmost, and 'yes' options appear to thr right of |
Lines 607-640
Link Here
|
607 |
} else { |
610 |
} else { |
608 |
result = 0; |
611 |
result = 0; |
609 |
} |
612 |
} |
610 |
|
613 |
|
611 |
if (isDefaultButton) { |
614 |
if (isDefaultButton) { |
612 |
result++; |
615 |
result++; |
613 |
} |
616 |
} |
614 |
return result; |
617 |
return result; |
615 |
} |
618 |
} |
616 |
|
619 |
|
617 |
protected final void initializeButtons() { |
620 |
protected final void initializeButtons() { |
618 |
// ----------------------------------------------------------------------------- |
621 |
// ----------------------------------------------------------------------------- |
619 |
// If there were any buttons previously, remove them and removeActionListener from them |
622 |
// If there were any buttons previously, remove them and removeActionListener from them |
620 |
|
623 |
|
621 |
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager ().getFocusOwner (); |
624 |
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager ().getFocusOwner (); |
622 |
|
625 |
|
623 |
boolean dontShowHelp = Constants.DO_NOT_SHOW_HELP_IN_DIALOGS || |
626 |
boolean dontShowHelp = Constants.DO_NOT_SHOW_HELP_IN_DIALOGS || |
624 |
( descriptor instanceof WizardDescriptor && ( Boolean.FALSE.equals (((WizardDescriptor)descriptor).getProperty (WizardDescriptor.PROP_HELP_DISPLAYED)) )); // NOI18N |
627 |
( descriptor instanceof WizardDescriptor && ( Boolean.FALSE.equals (((WizardDescriptor)descriptor).getProperty (WizardDescriptor.PROP_HELP_DISPLAYED)) )); // NOI18N |
625 |
boolean helpButtonShown = |
628 |
boolean helpButtonShown = |
626 |
stdHelpButton.isShowing() || ( descriptor instanceof WizardDescriptor && !dontShowHelp ); |
629 |
stdHelpButton.isShowing() || ( descriptor instanceof WizardDescriptor && !dontShowHelp ); |
627 |
|
630 |
|
628 |
|
631 |
|
629 |
uninitializeButtons(); |
632 |
uninitializeButtons(); |
630 |
|
633 |
|
631 |
Object[] primaryOptions = descriptor.getOptions(); |
634 |
Object[] primaryOptions = descriptor.getOptions(); |
632 |
Object[] secondaryOptions = descriptor.getAdditionalOptions(); |
635 |
Object[] secondaryOptions = descriptor.getAdditionalOptions(); |
633 |
currentAlign = getOptionsAlign(); |
636 |
currentAlign = getOptionsAlign(); |
634 |
|
637 |
|
635 |
// ----------------------------------------------------------------------------- |
638 |
// ----------------------------------------------------------------------------- |
636 |
// Obtain main (primary) and additional (secondary) buttons |
639 |
// Obtain main (primary) and additional (secondary) buttons |
637 |
|
640 |
|
638 |
currentPrimaryButtons = null; |
641 |
currentPrimaryButtons = null; |
639 |
currentSecondaryButtons = null; |
642 |
currentSecondaryButtons = null; |
640 |
|
643 |
|
Lines 644-650
Link Here
|
644 |
//No mac dialogs with buttons on side |
647 |
//No mac dialogs with buttons on side |
645 |
currentAlign = DialogDescriptor.BOTTOM_ALIGN; |
648 |
currentAlign = DialogDescriptor.BOTTOM_ALIGN; |
646 |
} |
649 |
} |
647 |
|
650 |
|
648 |
// explicitly provided options (AKA buttons) |
651 |
// explicitly provided options (AKA buttons) |
649 |
// JST: The following line causes only problems, |
652 |
// JST: The following line causes only problems, |
650 |
// I hope that my change will not cause additional ones ;-) |
653 |
// I hope that my change will not cause additional ones ;-) |
Lines 720-728
Link Here
|
720 |
break; |
723 |
break; |
721 |
} |
724 |
} |
722 |
} |
725 |
} |
723 |
|
726 |
|
724 |
// Automatically add a help button if needed. |
727 |
// Automatically add a help button if needed. |
725 |
|
728 |
|
726 |
if (!dontShowHelp && (currentHelp != null || helpButtonShown)) { |
729 |
if (!dontShowHelp && (currentHelp != null || helpButtonShown)) { |
727 |
if (currentPrimaryButtons == null) currentPrimaryButtons = new Component[] { }; |
730 |
if (currentPrimaryButtons == null) currentPrimaryButtons = new Component[] { }; |
728 |
Component[] cPB2 = new Component[currentPrimaryButtons.length + 1]; |
731 |
Component[] cPB2 = new Component[currentPrimaryButtons.length + 1]; |
Lines 738-744
Link Here
|
738 |
|
741 |
|
739 |
stdHelpButton.setEnabled(currentHelp != null); |
742 |
stdHelpButton.setEnabled(currentHelp != null); |
740 |
} |
743 |
} |
741 |
|
744 |
|
742 |
if ((secondaryOptions != null) && (secondaryOptions.length != 0)) { |
745 |
if ((secondaryOptions != null) && (secondaryOptions.length != 0)) { |
743 |
currentSecondaryButtons = new Component [secondaryOptions.length]; |
746 |
currentSecondaryButtons = new Component [secondaryOptions.length]; |
744 |
Arrays.sort (secondaryOptions, this); |
747 |
Arrays.sort (secondaryOptions, this); |
Lines 766-784
Link Here
|
766 |
} |
769 |
} |
767 |
} |
770 |
} |
768 |
} |
771 |
} |
769 |
|
772 |
|
770 |
// ----------------------------------------------------------------------------- |
773 |
// ----------------------------------------------------------------------------- |
771 |
// Create panels for main (primary) and additional (secondary) buttons and add to content pane |
774 |
// Create panels for main (primary) and additional (secondary) buttons and add to content pane |
772 |
|
775 |
|
773 |
if (currentAlign == DialogDescriptor.BOTTOM_ALIGN || currentAlign == -1) { |
776 |
if (currentAlign == DialogDescriptor.BOTTOM_ALIGN || currentAlign == -1) { |
774 |
|
777 |
|
775 |
JPanel panelForPrimary = null; |
778 |
JPanel panelForPrimary = null; |
776 |
JPanel panelForSecondary = null; |
779 |
JPanel panelForSecondary = null; |
777 |
|
780 |
|
778 |
|
781 |
|
779 |
if (currentPrimaryButtons != null) { |
782 |
if (currentPrimaryButtons != null) { |
780 |
panelForPrimary = new JPanel(); |
783 |
panelForPrimary = new JPanel(); |
781 |
|
784 |
|
782 |
if (currentAlign == -1) { |
785 |
if (currentAlign == -1) { |
783 |
panelForPrimary.setLayout(new org.openide.awt.EqualFlowLayout()); |
786 |
panelForPrimary.setLayout(new org.openide.awt.EqualFlowLayout()); |
784 |
} else { |
787 |
} else { |
Lines 789-795
Link Here
|
789 |
panelForPrimary.add(currentPrimaryButtons[i]); |
792 |
panelForPrimary.add(currentPrimaryButtons[i]); |
790 |
} |
793 |
} |
791 |
} |
794 |
} |
792 |
|
795 |
|
793 |
if (currentSecondaryButtons != null) { |
796 |
if (currentSecondaryButtons != null) { |
794 |
panelForSecondary = new JPanel(); |
797 |
panelForSecondary = new JPanel(); |
795 |
panelForSecondary.setLayout(new org.openide.awt.EqualFlowLayout(FlowLayout.LEFT)); |
798 |
panelForSecondary.setLayout(new org.openide.awt.EqualFlowLayout(FlowLayout.LEFT)); |
Lines 798-804
Link Here
|
798 |
panelForSecondary.add(currentSecondaryButtons[i]); |
801 |
panelForSecondary.add(currentSecondaryButtons[i]); |
799 |
} |
802 |
} |
800 |
} |
803 |
} |
801 |
|
804 |
|
802 |
// both primary and secondary buttons are used |
805 |
// both primary and secondary buttons are used |
803 |
if ((panelForPrimary != null) && (panelForSecondary != null)) { |
806 |
if ((panelForPrimary != null) && (panelForSecondary != null)) { |
804 |
currentButtonsPanel = new JPanel(); |
807 |
currentButtonsPanel = new JPanel(); |
Lines 810-816
Link Here
|
810 |
} else { |
813 |
} else { |
811 |
currentButtonsPanel = panelForSecondary; |
814 |
currentButtonsPanel = panelForSecondary; |
812 |
} |
815 |
} |
813 |
|
816 |
|
814 |
// add final button panel to the dialog |
817 |
// add final button panel to the dialog |
815 |
if ((currentButtonsPanel != null)&&(currentButtonsPanel.getComponentCount() != 0)) { |
818 |
if ((currentButtonsPanel != null)&&(currentButtonsPanel.getComponentCount() != 0)) { |
816 |
if (currentButtonsPanel.getBorder() == null) { |
819 |
if (currentButtonsPanel.getBorder() == null) { |
Lines 818-824
Link Here
|
818 |
} |
821 |
} |
819 |
getContentPane().add(currentButtonsPanel, BorderLayout.SOUTH); |
822 |
getContentPane().add(currentButtonsPanel, BorderLayout.SOUTH); |
820 |
} |
823 |
} |
821 |
|
824 |
|
822 |
} else if (currentAlign == DialogDescriptor.RIGHT_ALIGN) { |
825 |
} else if (currentAlign == DialogDescriptor.RIGHT_ALIGN) { |
823 |
currentButtonsPanel = new JPanel(); |
826 |
currentButtonsPanel = new JPanel(); |
824 |
currentButtonsPanel.setLayout(new GridBagLayout()); |
827 |
currentButtonsPanel.setLayout(new GridBagLayout()); |
Lines 827-847
Link Here
|
827 |
gbc.weightx = 1.0f; |
830 |
gbc.weightx = 1.0f; |
828 |
gbc.insets = new Insets(5, 4, 2, 5); |
831 |
gbc.insets = new Insets(5, 4, 2, 5); |
829 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
832 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
830 |
|
833 |
|
831 |
if (currentPrimaryButtons != null) { |
834 |
if (currentPrimaryButtons != null) { |
832 |
for (int i = 0; i < currentPrimaryButtons.length; i++) { |
835 |
for (int i = 0; i < currentPrimaryButtons.length; i++) { |
833 |
modifyListener(currentPrimaryButtons[i], buttonListener, true); // add button listener |
836 |
modifyListener(currentPrimaryButtons[i], buttonListener, true); // add button listener |
834 |
currentButtonsPanel.add(currentPrimaryButtons[i], gbc); |
837 |
currentButtonsPanel.add(currentPrimaryButtons[i], gbc); |
835 |
} |
838 |
} |
836 |
} |
839 |
} |
837 |
|
840 |
|
838 |
GridBagConstraints padding = new GridBagConstraints(); |
841 |
GridBagConstraints padding = new GridBagConstraints(); |
839 |
padding.gridwidth = GridBagConstraints.REMAINDER; |
842 |
padding.gridwidth = GridBagConstraints.REMAINDER; |
840 |
padding.weightx = 1.0f; |
843 |
padding.weightx = 1.0f; |
841 |
padding.weighty = 1.0f; |
844 |
padding.weighty = 1.0f; |
842 |
padding.fill = GridBagConstraints.BOTH; |
845 |
padding.fill = GridBagConstraints.BOTH; |
843 |
currentButtonsPanel.add(new JPanel(), padding); |
846 |
currentButtonsPanel.add(new JPanel(), padding); |
844 |
|
847 |
|
845 |
gbc.insets = new Insets(2, 4, 5, 5); |
848 |
gbc.insets = new Insets(2, 4, 5, 5); |
846 |
if (currentSecondaryButtons != null) { |
849 |
if (currentSecondaryButtons != null) { |
847 |
for (int i = 0; i < currentSecondaryButtons.length; i++) { |
850 |
for (int i = 0; i < currentSecondaryButtons.length; i++) { |
Lines 849-855
Link Here
|
849 |
currentButtonsPanel.add(currentSecondaryButtons[i], gbc); |
852 |
currentButtonsPanel.add(currentSecondaryButtons[i], gbc); |
850 |
} |
853 |
} |
851 |
} |
854 |
} |
852 |
|
855 |
|
853 |
// add final button panel to the dialog |
856 |
// add final button panel to the dialog |
854 |
if (currentButtonsPanel != null) { |
857 |
if (currentButtonsPanel != null) { |
855 |
if (currentButtonsPanel.getBorder() == null) { |
858 |
if (currentButtonsPanel.getBorder() == null) { |
Lines 857-874
Link Here
|
857 |
} |
860 |
} |
858 |
getContentPane().add(currentButtonsPanel, BorderLayout.EAST); |
861 |
getContentPane().add(currentButtonsPanel, BorderLayout.EAST); |
859 |
} |
862 |
} |
860 |
|
863 |
|
861 |
} |
864 |
} |
862 |
updateDefaultButton(); |
865 |
updateDefaultButton(); |
863 |
|
866 |
|
864 |
|
867 |
|
865 |
Component fo = KeyboardFocusManager.getCurrentKeyboardFocusManager ().getFocusOwner (); |
868 |
Component fo = KeyboardFocusManager.getCurrentKeyboardFocusManager ().getFocusOwner (); |
866 |
|
869 |
|
867 |
if (fo != focusOwner && focusOwner != null) { |
870 |
if (fo != focusOwner && focusOwner != null) { |
868 |
focusOwner.requestFocus(); |
871 |
focusOwner.requestFocus(); |
869 |
} |
872 |
} |
870 |
} |
873 |
} |
871 |
|
874 |
|
872 |
/** Checks default button and updates it |
875 |
/** Checks default button and updates it |
873 |
*/ |
876 |
*/ |
874 |
private void updateDefaultButton() { |
877 |
private void updateDefaultButton() { |
Lines 924-945
Link Here
|
924 |
// no default capable button found |
927 |
// no default capable button found |
925 |
getRootPane().setDefaultButton(null); |
928 |
getRootPane().setDefaultButton(null); |
926 |
} |
929 |
} |
927 |
|
930 |
|
928 |
private void updateNotificationLine (int msgType, Object o) { |
931 |
private void updateNotificationLine (int msgType, Object o) { |
929 |
String msg = o == null ? null : o.toString (); |
932 |
String msg = o == null ? null : o.toString (); |
930 |
if (msg != null && msg.trim().length() > 0) { |
933 |
if (msg != null && msg.trim().length() > 0) { |
931 |
switch (msgType) { |
934 |
switch (msgType) { |
932 |
case MSG_TYPE_ERROR: |
935 |
case MSG_TYPE_ERROR: |
933 |
prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/core/windows/resources/error.png", false), |
936 |
prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/core/windows/resources/error.png", false), |
934 |
nbErrorForeground); |
937 |
nbErrorForeground); |
935 |
break; |
938 |
break; |
936 |
case MSG_TYPE_WARNING: |
939 |
case MSG_TYPE_WARNING: |
937 |
prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/core/windows/resources/warning.png", false), |
940 |
prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/core/windows/resources/warning.png", false), |
938 |
nbWarningForeground); |
941 |
nbWarningForeground); |
939 |
break; |
942 |
break; |
940 |
case MSG_TYPE_INFO: |
943 |
case MSG_TYPE_INFO: |
941 |
prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/core/windows/resources/info.png", false), |
944 |
prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/core/windows/resources/info.png", false), |
942 |
nbInfoForeground); |
945 |
nbInfoForeground); |
943 |
break; |
946 |
break; |
944 |
default: |
947 |
default: |
945 |
} |
948 |
} |
Lines 980-991
Link Here
|
980 |
} |
983 |
} |
981 |
} |
984 |
} |
982 |
} |
985 |
} |
983 |
|
986 |
|
984 |
private void modifyListener(Object comp, ButtonListener l, boolean add) { |
987 |
private void modifyListener(Object comp, ButtonListener l, boolean add) { |
985 |
// on JButtons attach simply by method call |
988 |
// on JButtons attach simply by method call |
986 |
if (comp instanceof JButton) { |
989 |
if (comp instanceof JButton) { |
987 |
JButton b = (JButton)comp; |
990 |
JButton b = (JButton)comp; |
988 |
if (add) { |
991 |
if (add) { |
989 |
List listeners; |
992 |
List listeners; |
990 |
listeners = Arrays.asList (b.getActionListeners ()); |
993 |
listeners = Arrays.asList (b.getActionListeners ()); |
991 |
if (!listeners.contains (l)) { |
994 |
if (!listeners.contains (l)) { |
Lines 1030-1043
Link Here
|
1030 |
} |
1033 |
} |
1031 |
} |
1034 |
} |
1032 |
} |
1035 |
} |
1033 |
|
1036 |
|
1034 |
/** Shows the dialog, used in method show so no inner class is needed. |
1037 |
/** Shows the dialog, used in method show so no inner class is needed. |
1035 |
*/ |
1038 |
*/ |
1036 |
private void superShow() { |
1039 |
private void superShow() { |
1037 |
assert SwingUtilities.isEventDispatchThread () : "Invoked super.show() in AWT event thread."; // NOI18N |
1040 |
assert SwingUtilities.isEventDispatchThread () : "Invoked super.show() in AWT event thread."; // NOI18N |
1038 |
super.show(); |
1041 |
super.show(); |
1039 |
} |
1042 |
} |
1040 |
|
1043 |
|
1041 |
@Override @Deprecated |
1044 |
@Override @Deprecated |
1042 |
public void show() { |
1045 |
public void show() { |
1043 |
//Bugfix #29993: Call show() asynchronously for non modal dialogs. |
1046 |
//Bugfix #29993: Call show() asynchronously for non modal dialogs. |
Lines 1055-1066
Link Here
|
1055 |
} |
1058 |
} |
1056 |
} |
1059 |
} |
1057 |
} |
1060 |
} |
1058 |
|
1061 |
|
1059 |
public Void run() { |
1062 |
public Void run() { |
1060 |
doShow(); |
1063 |
doShow(); |
1061 |
return null; |
1064 |
return null; |
1062 |
} |
1065 |
} |
1063 |
|
1066 |
|
1064 |
private void doShow () { |
1067 |
private void doShow () { |
1065 |
NbPresenter prev = null; |
1068 |
NbPresenter prev = null; |
1066 |
if (isModal()) { |
1069 |
if (isModal()) { |
Lines 1068-1082
Link Here
|
1068 |
currentModalDialog = this; |
1071 |
currentModalDialog = this; |
1069 |
fireChangeEvent(); |
1072 |
fireChangeEvent(); |
1070 |
} |
1073 |
} |
1071 |
|
1074 |
|
1072 |
superShow(); |
1075 |
superShow(); |
1073 |
|
1076 |
|
1074 |
if (currentModalDialog != prev) { |
1077 |
if (currentModalDialog != prev) { |
1075 |
currentModalDialog = prev; |
1078 |
currentModalDialog = prev; |
1076 |
fireChangeEvent(); |
1079 |
fireChangeEvent(); |
1077 |
} |
1080 |
} |
1078 |
} |
1081 |
} |
1079 |
|
1082 |
|
1080 |
public void propertyChange(final java.beans.PropertyChangeEvent evt) { |
1083 |
public void propertyChange(final java.beans.PropertyChangeEvent evt) { |
1081 |
if( !SwingUtilities.isEventDispatchThread() ) { |
1084 |
if( !SwingUtilities.isEventDispatchThread() ) { |
1082 |
SwingUtilities.invokeLater(new Runnable() { |
1085 |
SwingUtilities.invokeLater(new Runnable() { |
Lines 1087-1093
Link Here
|
1087 |
return; |
1090 |
return; |
1088 |
} |
1091 |
} |
1089 |
boolean update = false; |
1092 |
boolean update = false; |
1090 |
|
1093 |
|
1091 |
if (DialogDescriptor.PROP_OPTIONS.equals(evt.getPropertyName())) { |
1094 |
if (DialogDescriptor.PROP_OPTIONS.equals(evt.getPropertyName())) { |
1092 |
initializeButtons(); |
1095 |
initializeButtons(); |
1093 |
update = true; |
1096 |
update = true; |
Lines 1134-1140
Link Here
|
1134 |
// XXX: need set update on true? |
1137 |
// XXX: need set update on true? |
1135 |
updateNotificationLine (MSG_TYPE_ERROR, evt.getNewValue ()); |
1138 |
updateNotificationLine (MSG_TYPE_ERROR, evt.getNewValue ()); |
1136 |
} |
1139 |
} |
1137 |
|
1140 |
|
1138 |
if (update) { |
1141 |
if (update) { |
1139 |
Dimension sz = getSize(); |
1142 |
Dimension sz = getSize(); |
1140 |
Dimension prefSize = getPreferredSize(); |
1143 |
Dimension prefSize = getPreferredSize(); |
Lines 1147-1153
Link Here
|
1147 |
repaint(); |
1150 |
repaint(); |
1148 |
} |
1151 |
} |
1149 |
} |
1152 |
} |
1150 |
|
1153 |
|
1151 |
private void updateHelp() { |
1154 |
private void updateHelp() { |
1152 |
//System.err.println ("Updating help for NbDialog..."); |
1155 |
//System.err.println ("Updating help for NbDialog..."); |
1153 |
HelpCtx help = getHelpCtx(); |
1156 |
HelpCtx help = getHelpCtx(); |
Lines 1159-1165
Link Here
|
1159 |
help = HelpCtx.findHelp((Component) msg); |
1162 |
help = HelpCtx.findHelp((Component) msg); |
1160 |
} |
1163 |
} |
1161 |
if (HelpCtx.DEFAULT_HELP.equals(help)) help = null; |
1164 |
if (HelpCtx.DEFAULT_HELP.equals(help)) help = null; |
1162 |
} |
1165 |
} |
1163 |
if (! Utilities.compareObjects(currentHelp, help)) { |
1166 |
if (! Utilities.compareObjects(currentHelp, help)) { |
1164 |
currentHelp = help; |
1167 |
currentHelp = help; |
1165 |
if (help != null && help.getHelpID() != null) { |
1168 |
if (help != null && help.getHelpID() != null) { |
Lines 1168-1200
Link Here
|
1168 |
} |
1171 |
} |
1169 |
// Refresh button list if it had already been created. |
1172 |
// Refresh button list if it had already been created. |
1170 |
if (haveCalledInitializeButtons) initializeButtons(); |
1173 |
if (haveCalledInitializeButtons) initializeButtons(); |
|
|
1174 |
} |
1171 |
} |
1175 |
} |
1172 |
} |
1176 |
|
1173 |
|
|
|
1174 |
/** Options align. |
1177 |
/** Options align. |
1175 |
*/ |
1178 |
*/ |
1176 |
protected int getOptionsAlign() { |
1179 |
protected int getOptionsAlign() { |
1177 |
return -1; |
1180 |
return -1; |
1178 |
} |
1181 |
} |
1179 |
|
1182 |
|
1180 |
/** Getter for button listener or null |
1183 |
/** Getter for button listener or null |
1181 |
*/ |
1184 |
*/ |
1182 |
protected ActionListener getButtonListener() { |
1185 |
protected ActionListener getButtonListener() { |
1183 |
return null; |
1186 |
return null; |
1184 |
} |
1187 |
} |
1185 |
|
1188 |
|
1186 |
/** Closing options. |
1189 |
/** Closing options. |
1187 |
*/ |
1190 |
*/ |
1188 |
protected Object[] getClosingOptions() { |
1191 |
protected Object[] getClosingOptions() { |
1189 |
return null; |
1192 |
return null; |
1190 |
} |
1193 |
} |
1191 |
|
1194 |
|
1192 |
/** Updates help. |
1195 |
/** Updates help. |
1193 |
*/ |
1196 |
*/ |
1194 |
protected HelpCtx getHelpCtx() { |
1197 |
protected HelpCtx getHelpCtx() { |
1195 |
return null; |
1198 |
return null; |
1196 |
} |
1199 |
} |
1197 |
|
1200 |
|
1198 |
|
1201 |
|
1199 |
public void windowDeactivated(final java.awt.event.WindowEvent p1) { |
1202 |
public void windowDeactivated(final java.awt.event.WindowEvent p1) { |
1200 |
} |
1203 |
} |
Lines 1214-1220
Link Here
|
1214 |
} |
1217 |
} |
1215 |
public void windowActivated(final java.awt.event.WindowEvent p1) { |
1218 |
public void windowActivated(final java.awt.event.WindowEvent p1) { |
1216 |
} |
1219 |
} |
1217 |
|
1220 |
|
1218 |
// Used by JavaHelp: |
1221 |
// Used by JavaHelp: |
1219 |
public static void addChangeListener(ChangeListener l) { |
1222 |
public static void addChangeListener(ChangeListener l) { |
1220 |
cs.addChangeListener(l); |
1223 |
cs.addChangeListener(l); |
Lines 1229-1235
Link Here
|
1229 |
} |
1232 |
} |
1230 |
}); |
1233 |
}); |
1231 |
} |
1234 |
} |
1232 |
|
1235 |
|
1233 |
private final class EscapeAction extends AbstractAction { |
1236 |
private final class EscapeAction extends AbstractAction { |
1234 |
|
1237 |
|
1235 |
public EscapeAction () { |
1238 |
public EscapeAction () { |
Lines 1241-1247
Link Here
|
1241 |
} |
1244 |
} |
1242 |
|
1245 |
|
1243 |
} |
1246 |
} |
1244 |
|
1247 |
|
1245 |
/** Button listener |
1248 |
/** Button listener |
1246 |
*/ |
1249 |
*/ |
1247 |
private class ButtonListener implements ActionListener, ComponentListener, PropertyChangeListener { |
1250 |
private class ButtonListener implements ActionListener, ComponentListener, PropertyChangeListener { |
Lines 1249-1262
Link Here
|
1249 |
public void actionPerformed(ActionEvent evt) { |
1252 |
public void actionPerformed(ActionEvent evt) { |
1250 |
boolean isAqua = "Aqua".equals (UIManager.getLookAndFeel().getID()) || //NOI18N |
1253 |
boolean isAqua = "Aqua".equals (UIManager.getLookAndFeel().getID()) || //NOI18N |
1251 |
"true".equalsIgnoreCase (System.getProperty ("xtest.looks_as_mac")); |
1254 |
"true".equalsIgnoreCase (System.getProperty ("xtest.looks_as_mac")); |
1252 |
|
1255 |
|
1253 |
Object pressedOption = evt.getSource(); |
1256 |
Object pressedOption = evt.getSource(); |
1254 |
// handle ESCAPE |
1257 |
// handle ESCAPE |
1255 |
if (ESCAPE_COMMAND.equals (evt.getActionCommand ())) { |
1258 |
if (ESCAPE_COMMAND.equals (evt.getActionCommand ())) { |
1256 |
MenuElement[] selPath = MenuSelectionManager.defaultManager().getSelectedPath(); |
1259 |
MenuElement[] selPath = MenuSelectionManager.defaultManager().getSelectedPath(); |
1257 |
// part of #130919 fix - handle ESC key well in dialogs with menus |
1260 |
// part of #130919 fix - handle ESC key well in dialogs with menus |
1258 |
if (selPath == null || selPath.length == 0) { |
1261 |
if (selPath == null || selPath.length == 0) { |
1259 |
pressedOption = NotifyDescriptor.CLOSED_OPTION; |
1262 |
//check if closingOptions is != null && 0 |
|
|
1263 |
if (getClosingOptions() != null && getClosingOptions().length == 0) { |
1264 |
pressedOption = WindowConstants.DO_NOTHING_ON_CLOSE; |
1265 |
} else { |
1266 |
pressedOption = NotifyDescriptor.CLOSED_OPTION; |
1267 |
} |
1260 |
} else { |
1268 |
} else { |
1261 |
MenuSelectionManager.defaultManager().clearSelectedPath(); |
1269 |
MenuSelectionManager.defaultManager().clearSelectedPath(); |
1262 |
return ; |
1270 |
return ; |
Lines 1267-1278
Link Here
|
1267 |
showHelp(currentHelp); |
1275 |
showHelp(currentHelp); |
1268 |
return; |
1276 |
return; |
1269 |
} |
1277 |
} |
1270 |
|
1278 |
|
1271 |
Object[] options = descriptor.getOptions(); |
1279 |
Object[] options = descriptor.getOptions(); |
1272 |
if (isAqua && options != null) { |
1280 |
if (isAqua && options != null) { |
1273 |
Arrays.sort (options, NbPresenter.this); |
1281 |
Arrays.sort (options, NbPresenter.this); |
1274 |
} |
1282 |
} |
1275 |
|
1283 |
|
1276 |
if ( |
1284 |
if ( |
1277 |
options != null && |
1285 |
options != null && |
1278 |
currentPrimaryButtons != null && |
1286 |
currentPrimaryButtons != null && |
Lines 1287-1298
Link Here
|
1287 |
} |
1295 |
} |
1288 |
} |
1296 |
} |
1289 |
} |
1297 |
} |
1290 |
|
1298 |
|
1291 |
options = descriptor.getAdditionalOptions(); |
1299 |
options = descriptor.getAdditionalOptions(); |
1292 |
if (isAqua && options != null) { |
1300 |
if (isAqua && options != null) { |
1293 |
Arrays.sort (options, NbPresenter.this); |
1301 |
Arrays.sort (options, NbPresenter.this); |
1294 |
} |
1302 |
} |
1295 |
|
1303 |
|
1296 |
if ( |
1304 |
if ( |
1297 |
options != null && |
1305 |
options != null && |
1298 |
currentSecondaryButtons != null && |
1306 |
currentSecondaryButtons != null && |
Lines 1304-1310
Link Here
|
1304 |
} |
1312 |
} |
1305 |
} |
1313 |
} |
1306 |
} |
1314 |
} |
1307 |
|
1315 |
|
1308 |
if (evt.getSource() == stdYesButton) { |
1316 |
if (evt.getSource() == stdYesButton) { |
1309 |
pressedOption = NotifyDescriptor.YES_OPTION; |
1317 |
pressedOption = NotifyDescriptor.YES_OPTION; |
1310 |
} else if (evt.getSource() == stdNoButton) { |
1318 |
} else if (evt.getSource() == stdNoButton) { |
Lines 1319-1328
Link Here
|
1319 |
} |
1327 |
} |
1320 |
|
1328 |
|
1321 |
descriptor.setValue(pressedOption); |
1329 |
descriptor.setValue(pressedOption); |
1322 |
|
1330 |
|
1323 |
ActionListener al = getButtonListener(); |
1331 |
ActionListener al = getButtonListener(); |
1324 |
if (al != null) { |
1332 |
if (al != null) { |
1325 |
|
1333 |
|
1326 |
if (pressedOption == evt.getSource()) { |
1334 |
if (pressedOption == evt.getSource()) { |
1327 |
al.actionPerformed(evt); |
1335 |
al.actionPerformed(evt); |
1328 |
} else { |
1336 |
} else { |
Lines 1331-1344
Link Here
|
1331 |
)); |
1339 |
)); |
1332 |
} |
1340 |
} |
1333 |
} |
1341 |
} |
1334 |
|
1342 |
|
1335 |
Object[] arr = getClosingOptions(); |
1343 |
Object[] arr = getClosingOptions(); |
1336 |
if (arr == null || pressedOption == NotifyDescriptor.CLOSED_OPTION) { |
1344 |
if (arr == null || pressedOption == NotifyDescriptor.CLOSED_OPTION) { |
1337 |
// all options should close |
1345 |
// all options should close |
1338 |
dispose(); |
1346 |
dispose(); |
1339 |
} else { |
1347 |
} else { |
1340 |
java.util.List l = java.util.Arrays.asList(arr); |
1348 |
java.util.List l = java.util.Arrays.asList(arr); |
1341 |
|
1349 |
|
1342 |
if (l.contains(pressedOption)) { |
1350 |
if (l.contains(pressedOption)) { |
1343 |
dispose(); |
1351 |
dispose(); |
1344 |
} |
1352 |
} |
Lines 1349-1369
Link Here
|
1349 |
} |
1357 |
} |
1350 |
public void componentResized(final java.awt.event.ComponentEvent p1) { |
1358 |
public void componentResized(final java.awt.event.ComponentEvent p1) { |
1351 |
} |
1359 |
} |
1352 |
|
1360 |
|
1353 |
public void componentHidden(final java.awt.event.ComponentEvent p1) { |
1361 |
public void componentHidden(final java.awt.event.ComponentEvent p1) { |
1354 |
updateDefaultButton(); |
1362 |
updateDefaultButton(); |
1355 |
} |
1363 |
} |
1356 |
|
1364 |
|
1357 |
public void componentMoved(final java.awt.event.ComponentEvent p1) { |
1365 |
public void componentMoved(final java.awt.event.ComponentEvent p1) { |
1358 |
} |
1366 |
} |
1359 |
|
1367 |
|
1360 |
public void propertyChange(final java.beans.PropertyChangeEvent p1) { |
1368 |
public void propertyChange(final java.beans.PropertyChangeEvent p1) { |
1361 |
if ("enabled".equals(p1.getPropertyName())) { |
1369 |
if ("enabled".equals(p1.getPropertyName())) { |
1362 |
updateDefaultButton(); |
1370 |
updateDefaultButton(); |
1363 |
} |
1371 |
} |
1364 |
} |
1372 |
} |
1365 |
} |
1373 |
} |
1366 |
|
1374 |
|
1367 |
@Override |
1375 |
@Override |
1368 |
public javax.accessibility.AccessibleContext getAccessibleContext() { |
1376 |
public javax.accessibility.AccessibleContext getAccessibleContext() { |
1369 |
if (accessibleContext == null) { |
1377 |
if (accessibleContext == null) { |
Lines 1371-1389
Link Here
|
1371 |
} |
1379 |
} |
1372 |
return accessibleContext; |
1380 |
return accessibleContext; |
1373 |
} |
1381 |
} |
1374 |
|
1382 |
|
1375 |
private static String getMessageTypeDescription(int messageType) { |
1383 |
private static String getMessageTypeDescription(int messageType) { |
1376 |
switch(messageType) { |
1384 |
switch(messageType) { |
1377 |
case NotifyDescriptor.ERROR_MESSAGE: |
1385 |
case NotifyDescriptor.ERROR_MESSAGE: |
1378 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_ErrorMessage"); // NOI18N |
1386 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_ErrorMessage"); // NOI18N |
1379 |
case NotifyDescriptor.WARNING_MESSAGE: |
1387 |
case NotifyDescriptor.WARNING_MESSAGE: |
1380 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_WarningMessage"); // NOI18N |
1388 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_WarningMessage"); // NOI18N |
1381 |
case NotifyDescriptor.QUESTION_MESSAGE: |
1389 |
case NotifyDescriptor.QUESTION_MESSAGE: |
1382 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_QuestionMessage"); // NOI18N |
1390 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_QuestionMessage"); // NOI18N |
1383 |
case NotifyDescriptor.INFORMATION_MESSAGE: |
1391 |
case NotifyDescriptor.INFORMATION_MESSAGE: |
1384 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_InformationMessage"); // NOI18N |
1392 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_InformationMessage"); // NOI18N |
1385 |
case NotifyDescriptor.PLAIN_MESSAGE: |
1393 |
case NotifyDescriptor.PLAIN_MESSAGE: |
1386 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_PlainMessage"); // NOI18N |
1394 |
return NbBundle.getBundle(NbPresenter.class).getString("ACSD_PlainMessage"); // NOI18N |
1387 |
} |
1395 |
} |
1388 |
return ""; // NOI18N |
1396 |
return ""; // NOI18N |
1389 |
} |
1397 |
} |
Lines 1396-1402
Link Here
|
1396 |
return accessibleName; |
1404 |
return accessibleName; |
1397 |
} else { |
1405 |
} else { |
1398 |
if (currentMessage instanceof javax.accessibility.Accessible |
1406 |
if (currentMessage instanceof javax.accessibility.Accessible |
1399 |
&& currentMessage.getAccessibleContext().getAccessibleName() != null) { |
1407 |
&& currentMessage.getAccessibleContext().getAccessibleName() != null) { |
1400 |
return currentMessage.getAccessibleContext().getAccessibleName(); |
1408 |
return currentMessage.getAccessibleContext().getAccessibleName(); |
1401 |
} else { |
1409 |
} else { |
1402 |
return super.getAccessibleName(); |
1410 |
return super.getAccessibleName(); |
Lines 1409-1419
Link Here
|
1409 |
return accessibleDescription; |
1417 |
return accessibleDescription; |
1410 |
} else { |
1418 |
} else { |
1411 |
if (currentMessage instanceof javax.accessibility.Accessible |
1419 |
if (currentMessage instanceof javax.accessibility.Accessible |
1412 |
&& currentMessage.getAccessibleContext().getAccessibleDescription() != null) { |
1420 |
&& currentMessage.getAccessibleContext().getAccessibleDescription() != null) { |
1413 |
return java.text.MessageFormat.format( |
1421 |
return java.text.MessageFormat.format( |
1414 |
getMessageTypeDescription(descriptor.getMessageType()), |
1422 |
getMessageTypeDescription(descriptor.getMessageType()), |
1415 |
new Object[] { |
1423 |
new Object[] { |
1416 |
currentMessage.getAccessibleContext().getAccessibleDescription() |
1424 |
currentMessage.getAccessibleContext().getAccessibleDescription() |
1417 |
} |
1425 |
} |
1418 |
); |
1426 |
); |
1419 |
} else { |
1427 |
} else { |
Lines 1422-1428
Link Here
|
1422 |
} |
1430 |
} |
1423 |
} |
1431 |
} |
1424 |
} |
1432 |
} |
1425 |
|
|
|
1426 |
static Field markers; |
1433 |
static Field markers; |
1427 |
static Method dequeue; |
1434 |
static Method dequeue; |
1428 |
static { |
1435 |
static { |
Lines 1437-1456
Link Here
|
1437 |
} |
1444 |
} |
1438 |
} |
1445 |
} |
1439 |
} |
1446 |
} |
1440 |
|
1447 |
|
1441 |
private final class HackTypeAhead implements Runnable { |
1448 |
private final class HackTypeAhead implements Runnable { |
1442 |
private RequestProcessor.Task task = RequestProcessor.getDefault().create(this); |
1449 |
private RequestProcessor.Task task = RequestProcessor.getDefault().create(this); |
1443 |
|
1450 |
|
1444 |
|
1451 |
|
1445 |
public HackTypeAhead() { |
1452 |
public HackTypeAhead() { |
1446 |
} |
1453 |
} |
1447 |
|
1454 |
|
1448 |
public void activate() { |
1455 |
public void activate() { |
1449 |
if (markers != null) { |
1456 |
if (markers != null) { |
1450 |
task.schedule(1000); |
1457 |
task.schedule(1000); |
1451 |
} |
1458 |
} |
1452 |
} |
1459 |
} |
1453 |
|
1460 |
|
1454 |
public void run() { |
1461 |
public void run() { |
1455 |
if (!SwingUtilities.isEventDispatchThread()) { |
1462 |
if (!SwingUtilities.isEventDispatchThread()) { |
1456 |
SwingUtilities.invokeLater(this); |
1463 |
SwingUtilities.invokeLater(this); |
Lines 1480-1487
Link Here
|
1480 |
|
1487 |
|
1481 |
/** Shows a specified HelpCtx in IDE's help window. |
1488 |
/** Shows a specified HelpCtx in IDE's help window. |
1482 |
* XXX would be better to directly depend on org.netbeans.api.javahelp.Help |
1489 |
* XXX would be better to directly depend on org.netbeans.api.javahelp.Help |
1483 |
* @param helpCtx thehelp to be shown |
1490 |
* @param helpCtx thehelp to be shown |
1484 |
*/ |
1491 |
*/ |
1485 |
private static void showHelp(HelpCtx helpCtx) { |
1492 |
private static void showHelp(HelpCtx helpCtx) { |
1486 |
// Awkward but should work. |
1493 |
// Awkward but should work. |
1487 |
try { |
1494 |
try { |