Java Code Examples for org.openide.NotifyDescriptor#setOptions()
The following examples show how to use
org.openide.NotifyDescriptor#setOptions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryController.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages({"MSG_Changed=The query was changed and has to be saved before refresh.", "LBL_Save=Save", "LBL_Discard=Discard"}) public void onRefresh() { if(query.isSaved() && isChanged()) { NotifyDescriptor desc = new NotifyDescriptor.Confirmation( Bundle.MSG_Changed(), NotifyDescriptor.YES_NO_CANCEL_OPTION ); Object[] choose = { Bundle.LBL_Save(), Bundle.LBL_Discard(), NotifyDescriptor.CANCEL_OPTION }; desc.setOptions(choose); Object ret = DialogDisplayer.getDefault().notify(desc); if(ret == choose[0]) { saveQuery(); // persist the parameters } else if (ret == choose[1]) { onCancelChanges(); return; } else { return; } } refresh(false, false); }
Example 2
Source File: JavaActions.java From netbeans with Apache License 2.0 | 5 votes |
/** * Display an alert asking the user whether to really generate a target. * @param commandDisplayName the display name of the action to be bound * @param scriptPath the path that to the script that will be generated or written to * @return true if IDE should proceed */ private boolean alert(String commandDisplayName, String scriptPath) { String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName(); String title = NbBundle.getMessage(JavaActions.class, "TITLE_generate_target_dialog", commandDisplayName, projectDisplayName); String body = NbBundle.getMessage(JavaActions.class, "TEXT_generate_target_dialog", commandDisplayName, scriptPath); NotifyDescriptor d = new NotifyDescriptor.Message(body, NotifyDescriptor.QUESTION_MESSAGE); d.setTitle(title); d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); JButton generate = new JButton(NbBundle.getMessage(JavaActions.class, "LBL_generate")); generate.setDefaultCapable(true); d.setOptions(new Object[] {generate, NotifyDescriptor.CANCEL_OPTION}); return DialogDisplayer.getDefault().notify(d) == generate; }
Example 3
Source File: Manager.java From netbeans with Apache License 2.0 | 5 votes |
/** */ private void offerRescanAfterIssuesFound(final ReplaceTask task) { String msg = NbBundle.getMessage(getClass(), "MSG_IssuesFound_Rescan_"); //NOI18N NotifyDescriptor nd = new NotifyDescriptor.Message( msg, NotifyDescriptor.QUESTION_MESSAGE); String rerunOption = NbBundle.getMessage(getClass(), "LBL_Rerun"); //NOI18N nd.setOptions(new Object[] {rerunOption, NotifyDescriptor.CANCEL_OPTION}); Object dlgResult = DialogDisplayer.getDefault().notify(nd); if (rerunOption.equals(dlgResult)) { /* * The rescan method calls 'scheduleSearchTaskRerun()' on this. * But it will wait until 'taskFinished()' returns, which is * exactly what we need to keep consistency of the manager's fields * like 'currentReplaceTask', 'replaceTask' and 'state'. * Using this mechanism also requires that, when sending a method * to the EventQueue thread, we use invokeLater(...) and not * invokeAndWait(...). */ Mutex.EVENT.writeAccess(new Runnable() { @Override public void run() { task.getPanel().rescan(); } }); } }
Example 4
Source File: FeedbackSurvey.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean showDialog(URL whereTo) { String msg = NbBundle.getMessage(FeedbackSurvey.class, "MSG_FeedbackSurvey_Message"); String tit = NbBundle.getMessage(FeedbackSurvey.class, "MSG_FeedbackSurvey_Title"); String yes = NbBundle.getMessage(FeedbackSurvey.class, "MSG_FeedbackSurvey_Yes"); String later = NbBundle.getMessage(FeedbackSurvey.class, "MSG_FeedbackSurvey_Later"); String never = NbBundle.getMessage(FeedbackSurvey.class, "MSG_FeedbackSurvey_Never"); NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.QUESTION_MESSAGE); nd.setTitle(tit); //Object[] buttons = { yes, later, never }; JButton yesButton = new JButton(); yesButton.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(FeedbackSurvey.class, "ACSD_FeedbackSurvey_Yes")); Mnemonics.setLocalizedText(yesButton, yes); JButton laterButton = new JButton(); laterButton.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(FeedbackSurvey.class, "ACSD_FeedbackSurvey_Later")); Mnemonics.setLocalizedText(laterButton, later); JButton neverButton = new JButton(); neverButton.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(FeedbackSurvey.class, "ACSD_FeedbackSurvey_Never")); Mnemonics.setLocalizedText(neverButton, never); Object[] buttons = { yesButton, laterButton, neverButton }; nd.setOptions(buttons); Object res = DialogDisplayer.getDefault().notify(nd); if (res == yesButton) { HtmlBrowser.URLDisplayer.getDefault().showURL(whereTo); return true; } else { if( res == neverButton ) { Preferences prefs = NbPreferences.forModule(FeedbackSurvey.class); prefs.putInt("feedback.survey.show.count", (int)bundledInt("MSG_FeedbackSurvey_AskTimes")); // NOI18N } return false; } }
Example 5
Source File: WebFreeFormActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
/** * Display an alert asking the user whether to really generate a target. * @param commandDisplayName the display name of the action to be bound * @param scriptPath the path that to the script that will be generated or written to * @return true if IDE should proceed */ private boolean alert(String commandDisplayName, String scriptPath) { String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName(); String title = NbBundle.getMessage(WebFreeFormActionProvider.class, "TITLE_generate_target_dialog", commandDisplayName, projectDisplayName); String body = NbBundle.getMessage(WebFreeFormActionProvider.class, "TEXT_generate_target_dialog", commandDisplayName, scriptPath); NotifyDescriptor d = new NotifyDescriptor.Message(body, NotifyDescriptor.QUESTION_MESSAGE); d.setTitle(title); d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); JButton generate = new JButton(NbBundle.getMessage(WebFreeFormActionProvider.class, "LBL_generate")); generate.setDefaultCapable(true); d.setOptions(new Object[] {generate, NotifyDescriptor.CANCEL_OPTION}); return DialogDisplayer.getDefault().notify(d) == generate; }
Example 6
Source File: AppClientProjectProperties.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean showModifiedMessage (String title) { String message = NbBundle.getMessage(AppClientProjectProperties.class,"TXT_Regenerate"); JButton regenerateButton = new JButton (NbBundle.getMessage(AppClientProjectProperties.class,"CTL_RegenerateButton")); regenerateButton.setDefaultCapable(true); regenerateButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage(AppClientProjectProperties.class,"AD_RegenerateButton")); NotifyDescriptor d = new NotifyDescriptor.Message (message, NotifyDescriptor.WARNING_MESSAGE); d.setTitle(title); d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); d.setOptions(new Object[] {regenerateButton, NotifyDescriptor.CANCEL_OPTION}); return DialogDisplayer.getDefault().notify(d) == regenerateButton; }
Example 7
Source File: JavaSEPlatformPanel.java From netbeans with Apache License 2.0 | 3 votes |
/** * Set buttons in user notification descriptor depending on Java SE * platforms. * <p/> * This method is used in constructor so it's better to be static. * <p/> * @param descriptor User notification descriptor. * @param javaPlatforms Java SE JDK selection content. */ private void setDescriptorButtons( NotifyDescriptor descriptor, JavaPlatform[] javaPlatforms) { if (javaPlatforms == null || javaPlatforms.length == 0) { descriptor.setOptions(new Object[] {CANCEL_OPTION}); } else { descriptor.setOptions(new Object[] {OK_OPTION, CANCEL_OPTION}); } }
Example 8
Source File: CommonPasswordPanel.java From netbeans with Apache License 2.0 | 3 votes |
/** * Set buttons in user notification descriptor depending on form validity. * <p/> * This method is used in constructor so it's better to be static. * <p/> * @param descriptor User notification descriptor. * @param javaPlatforms Java SE JDK selection content. */ void setDescriptorButtons( NotifyDescriptor descriptor, boolean valid) { if (valid) descriptor.setOptions(validButtons); else descriptor.setOptions(invalidButtons); }
Example 9
Source File: JavaSEPlatformPanel.java From netbeans with Apache License 2.0 | 3 votes |
/** * Set buttons in user notification descriptor depending on Java SE * platforms. * <p/> * This method is used in constructor so it's better to be static. * <p/> * @param descriptor User notification descriptor. * @param javaPlatforms Java SE JDK selection content. */ private void setDescriptorButtons( NotifyDescriptor descriptor, JavaPlatform[] javaPlatforms) { if (javaPlatforms == null || javaPlatforms.length == 0) { descriptor.setOptions(new Object[] {CANCEL_OPTION}); } else { descriptor.setOptions(new Object[] {OK_OPTION, CANCEL_OPTION}); } }
Example 10
Source File: CommonPasswordPanel.java From netbeans with Apache License 2.0 | 3 votes |
/** * Set buttons in user notification descriptor depending on form validity. * <p/> * This method is used in constructor so it's better to be static. * <p/> * @param descriptor User notification descriptor. * @param javaPlatforms Java SE JDK selection content. */ void setDescriptorButtons( NotifyDescriptor descriptor, boolean valid) { if (valid) descriptor.setOptions(validButtons); else descriptor.setOptions(invalidButtons); }