Java Code Examples for org.openide.NotifyDescriptor#YES_OPTION
The following examples show how to use
org.openide.NotifyDescriptor#YES_OPTION .
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: DeleteLocalAction.java From netbeans with Apache License 2.0 | 6 votes |
protected void performContextAction(final Node[] nodes) { NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(NbBundle.getMessage(DeleteLocalAction.class, "CTL_DeleteLocal_Prompt")); // NOI18N descriptor.setTitle(NbBundle.getMessage(DeleteLocalAction.class, "CTL_DeleteLocal_Title")); // NOI18N descriptor.setMessageType(JOptionPane.WARNING_MESSAGE); descriptor.setOptionType(NotifyDescriptor.YES_NO_OPTION); Object res = DialogDisplayer.getDefault().notify(descriptor); if (res != NotifyDescriptor.YES_OPTION) { return; } final Context ctx = getContext(nodes); ProgressSupport support = new ContextAction.ProgressSupport(this, nodes, ctx) { public void perform() { performDelete(ctx, this); } }; support.start(createRequestProcessor(ctx)); }
Example 2
Source File: XMLJ2eeEditorSupport.java From netbeans with Apache License 2.0 | 6 votes |
private boolean checkCharsetConversion(final String encoding) { boolean value = true; try { CharsetEncoder coder = Charset.forName(encoding).newEncoder(); if (!coder.canEncode(getDocument().getText(0, getDocument().getLength()))){ NotifyDescriptor nd = new NotifyDescriptor.Confirmation( NbBundle.getMessage(XMLJ2eeEditorSupport.class, "MSG_BadCharConversion", new Object [] { getDataObject().getPrimaryFile().getNameExt(), encoding}), NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE); nd.setValue(NotifyDescriptor.NO_OPTION); DialogDisplayer.getDefault().notify(nd); if(nd.getValue() != NotifyDescriptor.YES_OPTION) { value = false; } } } catch (BadLocationException e){ Logger.getLogger("global").log(Level.INFO, null, e); } return value; }
Example 3
Source File: WebKitPageModel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Checks if the current information that we have about the inspected * page is too large to continue with the page inspection safely. */ @NbBundle.Messages({ "WebKitPageModel.pageSizeWarningTitle=Page Too Large", "WebKitPageModel.pageSizeWarningMessage=" + "The page is too large to inspect it in NetBeans safely. " + "You may run out of memory if you continue with the inspection. " + "Do you want to close this page and stop its inspection?" }) private void showPageSizeWarning() { if (!pageSizeWarningShown) { pageSizeWarningShown = true; NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation( Bundle.WebKitPageModel_pageSizeWarningMessage(), Bundle.WebKitPageModel_pageSizeWarningTitle(), NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE ); DialogDisplayer.getDefault().notify(descriptor); if (descriptor.getValue() == NotifyDescriptor.YES_OPTION) { EnhancedBrowser browser = pageContext.lookup(EnhancedBrowser.class); if (browser != null) { browser.close(true); } } } }
Example 4
Source File: PageFlowController.java From netbeans with Apache License 2.0 | 6 votes |
protected void ifNecessaryShowNoWebFolderDialog() { if (isShowNoWebFolderDialog()) { final NotWebFolder panel = new NotWebFolder(NO_WEB_FOLDER_WARNING); DialogDescriptor descriptor = new DialogDescriptor(panel, NO_WEB_FOLDER_TITLE, true, NotifyDescriptor.PLAIN_MESSAGE, NotifyDescriptor.YES_OPTION, null); JButton okButton = new JButton( NbBundle.getMessage(PageFlowController.class, "MSG_OkButtonText")); //NOI18N descriptor.setOptions(new Object[]{okButton}); descriptor.setMessageType(NotifyDescriptor.PLAIN_MESSAGE); descriptor.setClosingOptions(new Object[]{okButton}); descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN); final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor); d.setSize(400, 200); d.setVisible(true); setShowNoWebFolderDialog(panel.getShowDialog()); } }
Example 5
Source File: CreateDatabasePanel.java From netbeans with Apache License 2.0 | 6 votes |
private static void displayCreateFailure(DatabaseServer server, DatabaseException ex, String dbname, boolean dbCreated) { LOGGER.log(Level.INFO, null, ex); Utils.displayError(NbBundle.getMessage(CreateDatabasePanel.class, "CreateNewDatabasePanel.MSG_CreateFailed"), ex); if ( dbCreated ) { NotifyDescriptor ndesc = new NotifyDescriptor.Confirmation( NbBundle.getMessage(CreateDatabasePanel.class, "CreateNewDatabasePanel.MSG_DeleteCreatedDatabase", dbname), NbBundle.getMessage(CreateDatabasePanel.class, "CreateNewDatabasePanel.STR_DeleteCreatedDatabaseTitle"), NotifyDescriptor.YES_NO_OPTION); Object response = DialogDisplayer.getDefault().notify(ndesc); if ( response == NotifyDescriptor.YES_OPTION ) { server.dropDatabase(dbname); } } }
Example 6
Source File: DashboardViewer.java From netbeans with Apache License 2.0 | 6 votes |
public void clearCategories() { NotifyDescriptor nd = new NotifyDescriptor( NbBundle.getMessage(DashboardViewer.class, "LBL_ClearCatQuestion"), //NOI18N NbBundle.getMessage(DashboardViewer.class, "LBL_ClearCatTitle"), //NOI18N NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.YES_OPTION); if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION) { List<TaskNode> finished = new ArrayList<TaskNode>(); for (CategoryNode categoryNode : categoryNodes) { if (!categoryNode.isOpened() || !categoryNode.getCategory().persist()) { continue; } for (TaskNode taskNode : categoryNode.getTaskNodes()) { if (taskNode.getTask().isFinished()) { finished.add(taskNode); } } } removeTask(finished.toArray(new TaskNode[finished.size()])); } }
Example 7
Source File: CopySupport.java From netbeans with Apache License 2.0 | 6 votes |
/** * @return {@literal true} if copying finished or user wants to continue */ public boolean waitFinished(String message, long timeout, Object... additionalOptions) { try { if (!proxyOperationFactory.isEnabled()) { return true; } if (COPY_TASK.waitFinished(timeout)) { return true; } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); return true; } NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation( message, NotifyDescriptor.YES_NO_OPTION); if (additionalOptions != null) { descriptor.setAdditionalOptions(additionalOptions); } return DialogDisplayer.getDefault().notify(descriptor) == NotifyDescriptor.YES_OPTION; }
Example 8
Source File: FilterTopComponent.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void addFilterSetting() { NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter"); if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) { String name = l.getInputText(); FilterSetting toRemove = null; for (FilterSetting s : filterSettings) { if (s.getName().equals(name)) { NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter"); if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) { toRemove = s; break; } else { return; } } } if (toRemove != null) { filterSettings.remove(toRemove); } FilterSetting setting = createFilterSetting(name); filterSettings.add(setting); // Sort alphabetically Collections.sort(filterSettings, new Comparator<FilterSetting>() { public int compare(FilterSetting o1, FilterSetting o2) { return o1.getName().compareTo(o2.getName()); } }); updateComboBox(); } }
Example 9
Source File: FilterTopComponent.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void addFilterSetting() { NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter"); if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) { String name = l.getInputText(); FilterSetting toRemove = null; for (FilterSetting s : filterSettings) { if (s.getName().equals(name)) { NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter"); if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) { toRemove = s; break; } else { return; } } } if (toRemove != null) { filterSettings.remove(toRemove); } FilterSetting setting = createFilterSetting(name); filterSettings.add(setting); // Sort alphabetically Collections.sort(filterSettings, new Comparator<FilterSetting>() { public int compare(FilterSetting o1, FilterSetting o2) { return o1.getName().compareTo(o2.getName()); } }); updateComboBox(); } }
Example 10
Source File: ProfilerDialogs.java From netbeans with Apache License 2.0 | 5 votes |
private static String ndOptionToString(Object option) { if (option == NotifyDescriptor.CANCEL_OPTION) { return "CANCEL_OPTION"; // NOI18N } else if (option == NotifyDescriptor.CLOSED_OPTION) { return "CLOSED_OPTION"; // NOI18N } else if (option == NotifyDescriptor.NO_OPTION) { return "NO_OPTION"; // NOI18N } else if (option == NotifyDescriptor.OK_OPTION) { return "OK_OPTION"; // NOI18N } else if (option == NotifyDescriptor.YES_OPTION) { return "YES_OPTION"; // NOI18N } return null; }
Example 11
Source File: ProfilerDialogsProviderImpl.java From visualvm with GNU General Public License v2.0 | 5 votes |
@Override public Boolean displayConfirmationDNSA(String message, String caption, String dnsaMessage, boolean cancellable, String key, boolean dnsaDefault) { ProfilerDialogs.DNSAConfirmation dnsa = new ProfilerDialogs.DNSAConfirmation( key, message, cancellable ? NotifyDescriptor.YES_NO_CANCEL_OPTION : NotifyDescriptor.YES_NO_OPTION); if (caption != null) dnsa.setTitle(caption); if (dnsaMessage != null) dnsa.setDNSAMessage(dnsaMessage); dnsa.setDNSADefault(dnsaDefault); Object ret = ProfilerDialogs.notify(dnsa); if (ret == NotifyDescriptor.YES_OPTION) return Boolean.TRUE; if (ret == NotifyDescriptor.NO_OPTION) return Boolean.FALSE; return null; }
Example 12
Source File: ModulesNode.java From netbeans with Apache License 2.0 | 5 votes |
@Messages("MSG_Remove_Module=Do you want to remove the module from the parent POM?") @Override public void actionPerformed(ActionEvent e) { NotifyDescriptor nd = new NotifyDescriptor.Confirmation(MSG_Remove_Module(), NotifyDescriptor.YES_NO_OPTION); Object ret = DialogDisplayer.getDefault().notify(nd); if (ret == NotifyDescriptor.YES_OPTION) { FileObject fo = FileUtil.toFileObject(parent.getPOMFile()); ModelOperation<POMModel> operation = new ModelOperation<POMModel>() { @Override public void performOperation(POMModel model) { List<String> modules = model.getProject().getModules(); if (modules != null) { for (String path : modules) { File rel = new File(parent.getPOMFile().getParent(), path); File norm = FileUtil.normalizeFile(rel); FileObject folder = FileUtil.toFileObject(norm); if (folder != null && folder.equals(project.getProjectDirectory())) { model.getProject().removeModule(path); break; } } } } }; org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(fo, Collections.singletonList(operation)); //TODO is the manual reload necessary if pom.xml file is being saved? NbMavenProject.fireMavenProjectReload(project); } }
Example 13
Source File: SimpleIO.java From netbeans with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { if(process.get() != null) { String message = NbBundle.getMessage(SimpleIO.class, "MSG_QueryCancel", name); // NOI18N NotifyDescriptor nd = new NotifyDescriptor.Confirmation(message, NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE); if(DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION) { Process p = process.getAndSet(null); if(p != null) { p.destroy(); } else { Logger.getLogger("glassfish").log(Level.FINEST, "Process handle unexpectedly null, cancel aborted."); // NOI18N } } } }
Example 14
Source File: ServiceProvidersTablePanel.java From netbeans with Apache License 2.0 | 5 votes |
private boolean confirmDeletion(ServiceProviderElement spe) { NotifyDescriptor.Confirmation notifyDesc = new NotifyDescriptor.Confirmation(NbBundle.getMessage (ServiceProvidersTablePanel.class, "MSG_ServiceProviderConfirmDelete", spe.getEndpoint()), //NOI18N NotifyDescriptor.YES_NO_OPTION); DialogDisplayer.getDefault().notify(notifyDesc); return (notifyDesc.getValue() == NotifyDescriptor.YES_OPTION); }
Example 15
Source File: DashboardUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static boolean confirmDelete(String title, String message) { NotifyDescriptor nd = new NotifyDescriptor( message, title, NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.YES_OPTION); return DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION; }
Example 16
Source File: UiUtils.java From netbeans with Apache License 2.0 | 4 votes |
private static boolean doOpen(FileObject fo, int offset) { try { DataObject od = DataObject.find(fo); EditorCookie ec = od.getLookup().lookup(EditorCookie.class); LineCookie lc = od.getLookup().lookup(LineCookie.class); if (ec != null && lc != null && offset != -1) { StyledDocument doc = null; try { doc = ec.openDocument(); } catch (UserQuestionException uqe) { final Object value = DialogDisplayer.getDefault().notify( new NotifyDescriptor.Confirmation(uqe.getLocalizedMessage(), NbBundle.getMessage(UiUtils.class, "TXT_Question"), NotifyDescriptor.YES_NO_OPTION)); if (value != NotifyDescriptor.YES_OPTION) { return false; } uqe.confirmed(); doc = ec.openDocument(); } if (doc != null) { int line = NbDocument.findLineNumber(doc, offset); int lineOffset = NbDocument.findLineOffset(doc, line); int column = offset - lineOffset; if (line != -1) { Line l = lc.getLineSet().getCurrent(line); if (l != null) { doShow( l, column); return true; } } } } OpenCookie oc = od.getLookup().lookup(OpenCookie.class); if (oc != null) { doOpen(oc); return true; } } catch (IOException e) { if (log.isLoggable(Level.INFO)) log.log(Level.INFO, e.getMessage(), e); } return false; }
Example 17
Source File: OptionsPanel.java From netbeans with Apache License 2.0 | 4 votes |
private boolean confirmDeletion(String option) { NotifyDescriptor.Confirmation notifyDesc = new NotifyDescriptor.Confirmation(NbBundle.getMessage(WsimportOptionsPanel.class, "MSG_CONFIRM_DELETE", option), NbBundle.getMessage(WsimportOptionsPanel.class, "TTL_CONFIRM_DELETE"), NotifyDescriptor.YES_NO_OPTION); DialogDisplayer.getDefault().notify(notifyDesc); return notifyDesc.getValue() == NotifyDescriptor.YES_OPTION; }
Example 18
Source File: ActionProviderImpl.java From netbeans with Apache License 2.0 | 4 votes |
@Messages({ "run_single_method_disabled=Surefire 2.8+ with JUnit 4.8+ or TestNG needed to run a single test method.", "run_single_method_disabled5=Surefire 2.22.0 is required to run a single test method with JUnit5.", "TIT_RequiresUpdateOfPOM=Feature requires update of POM", "TXT_Run_Single_method=<html>Executing single test method requires Surefire 2.8+ and JUnit in version 4.8 and bigger. <br/><br/>Update your pom.xml?</html>", "TXT_Run_Single_method5=<html>Executing single test method with JUnit 5 requires Surefire 2.22.0. <br/><br/>Update your pom.xml?</html>" }) private boolean checkSurefire(final String action) { if (action.equals(SingleMethod.COMMAND_RUN_SINGLE_METHOD) || action.equals(SingleMethod.COMMAND_DEBUG_SINGLE_METHOD)) { if (!runSingleMethodEnabled()) { boolean ju5 = usingJUnit5(); if (NbPreferences.forModule(ActionProviderImpl.class).getBoolean(SHOW_SUREFIRE_WARNING, true)) { WarnPanel pnl = new WarnPanel(ju5 ? TXT_Run_Single_method5() : TXT_Run_Single_method()); Object o = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(pnl, TIT_RequiresUpdateOfPOM(), NotifyDescriptor.YES_NO_OPTION)); if (pnl.disabledWarning()) { NbPreferences.forModule(ActionProviderImpl.class).putBoolean(SHOW_SUREFIRE_WARNING, false); } if (o == NotifyDescriptor.YES_OPTION) { RequestProcessor.getDefault().post(new Runnable() { @Override public void run() { String surefireVersion = null; String junitVersion = null; if (ju5 && !usingSurefire2_22()) { surefireVersion = SUREFIRE_VERSION_SAFE_5; } else if (!usingSurefire28()) { surefireVersion = SUREFIRE_VERSION_SAFE; } if (!ju5) { junitVersion = usingJUnit4() || usingTestNG() ? null : JUNIT_VERSION_SAFE; } Utilities.performPOMModelOperations( proj.getProjectDirectory().getFileObject("pom.xml"), Collections.singletonList(new UpdateSurefireOperation( surefireVersion, junitVersion )) ); //this appears to run too fast, before the resolved model is updated. // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // invokeAction(action, lookup); // } // }); } }); return false; } } StatusDisplayer.getDefault().setStatusText( ju5 ? run_single_method_disabled5() : run_single_method_disabled()); return false; } } return true; }
Example 19
Source File: MultiSizeIssue.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
public static Product maybeResample(Product product) { String title = Dialogs.getDialogTitle("Resampling Required"); final List<Resampler> availableResamplers = getAvailableResamplers(product); int optionType; int messageType; final StringBuilder msgTextBuilder = new StringBuilder("The functionality you have chosen is not supported for products with bands of different sizes.<br/>"); if (availableResamplers.isEmpty()) { optionType = JOptionPane.OK_CANCEL_OPTION; messageType = JOptionPane.INFORMATION_MESSAGE; } else if (availableResamplers.size() == 1) { msgTextBuilder.append("You can use the ").append(availableResamplers.get(0).getName()). append(" to resample this product so that all bands have the same size, <br/>" + "which will enable you to use this feature.<br/>" + "Do you want to resample the product now?"); optionType = JOptionPane.YES_NO_OPTION; messageType = JOptionPane.QUESTION_MESSAGE; } else { msgTextBuilder.append("You can use one of these resamplers to resample this product so that all bands have the same size, <br/>" + "which will enable you to use this feature.<br/>" + "Do you want to resample the product now?"); optionType = JOptionPane.YES_NO_OPTION; messageType = JOptionPane.QUESTION_MESSAGE; } msgTextBuilder.append("<br/>" + "<br/>" + "More info about this issue and its status can be found in the " + "<a href=\"https://senbox.atlassian.net/browse/SNAP-1\">SNAP Issue Tracker</a>." ); JPanel panel = new JPanel(new BorderLayout(4, 4)); final JEditorPane textPane = new JEditorPane("text/html", msgTextBuilder.toString()); setFont(textPane); textPane.setEditable(false); textPane.setOpaque(false); textPane.addHyperlinkListener(e -> { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { Dialogs.showWarning("Could not open URL: " + e.getDescription()); } } }); panel.add(textPane, BorderLayout.CENTER); final JComboBox<Object> resamplerBox = new JComboBox<>(); if (availableResamplers.size() > 1) { String[] resamplerNames = new String[availableResamplers.size()]; for (int i = 0; i < availableResamplers.size(); i++) { resamplerNames[i] = availableResamplers.get(i).getName(); resamplerBox.addItem(resamplerNames[i]); } panel.add(resamplerBox, BorderLayout.SOUTH); } NotifyDescriptor d = new NotifyDescriptor(panel, title, optionType, messageType, null, null); DialogDisplayer.getDefault().notify(d); if (d.getValue() == NotifyDescriptor.YES_OPTION) { Resampler selectedResampler; if (availableResamplers.size() == 1) { selectedResampler = availableResamplers.get(0); } else { selectedResampler = availableResamplers.get(resamplerBox.getSelectedIndex()); } return selectedResampler.resample(product); } return null; }
Example 20
Source File: ProjectDependencyUpgrader.java From netbeans with Apache License 2.0 | 3 votes |
protected final boolean showDependencyUpgradeDialog(Project p, String dep, SpecificationVersion currentDependency, SpecificationVersion spec, boolean newDepenency, boolean canShowUI) { if (!canShowUI) return true; NotifyDescriptor nd = new NotifyDescriptor.Confirmation("New version: " + spec, "Update spec version.", NotifyDescriptor.YES_NO_OPTION); return DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION; }