本文整理匯總了Java中org.openide.NotifyDescriptor.setOptions方法的典型用法代碼示例。如果您正苦於以下問題:Java NotifyDescriptor.setOptions方法的具體用法?Java NotifyDescriptor.setOptions怎麽用?Java NotifyDescriptor.setOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.NotifyDescriptor
的用法示例。
在下文中一共展示了NotifyDescriptor.setOptions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onRefresh
import org.openide.NotifyDescriptor; //導入方法依賴的package包/類
@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);
}
示例2: offerRescanAfterIssuesFound
import org.openide.NotifyDescriptor; //導入方法依賴的package包/類
/**
*/
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();
}
});
}
}
示例3: showDialog
import org.openide.NotifyDescriptor; //導入方法依賴的package包/類
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;
}
}
示例4: alert
import org.openide.NotifyDescriptor; //導入方法依賴的package包/類
/**
* 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;
}