Java Code Examples for org.openide.NotifyDescriptor#getValue()
The following examples show how to use
org.openide.NotifyDescriptor#getValue() .
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: 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 2
Source File: CordovaPerformer.java From netbeans with Apache License 2.0 | 6 votes |
private boolean hasOtherBuildTool(Project project, String toolfile, String toolName, Runnable r) { if(project.getProjectDirectory().getFileObject(toolfile) != null) { ProjectInformation info = ProjectUtils.getInformation(project); String name = info != null ? info.getDisplayName() : project.getProjectDirectory().getNameExt(); JButton tool = new JButton(toolName); NotifyDescriptor desc = new NotifyDescriptor( Bundle.MSG_SelectBuildTool(name, toolfile, toolName), Bundle.CTL_SelectBuildTool(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE, new Object[] {tool, new JButton("Ant"), NotifyDescriptor.CANCEL_OPTION}, NotifyDescriptor.OK_OPTION); DialogDisplayer.getDefault().notify(desc); if(desc.getValue() == tool) { r.run(); return true; } else if (desc.getValue() == NotifyDescriptor.CANCEL_OPTION) { return true; } } return false; }
Example 3
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 4
Source File: XmlMultiViewEditorSupport.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(XmlMultiViewEditorSupport.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){ ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } return value; }
Example 5
Source File: ContextView.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages({ "TTL_ContextView_showBigFile=Show Big File?", "# {0} - file name", "# {1} - file size in kilobytes", "MSG_ContextView_showBigFile=File {0} is quite big ({1} kB).\n" + "Showing it can cause memory and performance problems.\n" + "Do you want to show content of this file?", "LBL_ContextView_Show=Show", "LBL_ContextView_Skip=Do Not Show", "LBL_ContextView_ApplyAll=Apply to all big files" }) private void approveFetchingOfBigFile(final MatchingObject mo, final int partIndex) { FileObject fo = mo.getFileObject(); long fileSize = fo.getSize() / 1024; JButton showButton = new JButton(Bundle.LBL_ContextView_Show()); JButton skipButton = new JButton(Bundle.LBL_ContextView_Skip()); JCheckBox all = new JCheckBox(Bundle.LBL_ContextView_ApplyAll()); all.setSelected(approveApplyToAllSelected); JPanel allPanel = new JPanel(); allPanel.add(all); //Add to panel not to be handled as standard button. NotifyDescriptor nd = new NotifyDescriptor( Bundle.MSG_ContextView_showBigFile( fo.getNameExt(), fileSize), Bundle.TTL_ContextView_showBigFile(), NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE, new Object[]{skipButton, showButton}, lastApproveOption ? showButton : skipButton); nd.setAdditionalOptions(new Object[]{allPanel}); DialogDisplayer.getDefault().notify(nd); boolean app = nd.getValue() == showButton; APPROVED_FILES.put(fo, app); if (all.isSelected()) { allApproved = app; } approveApplyToAllSelected = all.isSelected(); lastApproveOption = app; displayFile(mo, partIndex); }
Example 6
Source File: UI.java From netbeans with Apache License 2.0 | 4 votes |
public static boolean printWarning(String message) { NotifyDescriptor confirm = new NotifyDescriptor.Confirmation(message, NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(confirm); return confirm.getValue() == NotifyDescriptor.YES_OPTION; }
Example 7
Source File: DependenciesPanel.java From netbeans with Apache License 2.0 | 4 votes |
/** * Checks whether there is already dependency of the same name but * of a different type. If so then a dialog is displayed to determine * what should happen. * * @param libraryName name of the dependency to check. * @return {@code true} when the new dependency should be added, * returns {@code false} when the user decided to cancel addition * of the dependency. */ @NbBundle.Messages({ "DependenciesPanel.otherDependencyTitle=Another Dependency Type", "# {0} - library name", "# {1} - other dependencies message", "DependenciesPanel.otherDependencyWarning=There is another type " + "of dependency for \"{0}\" package. " + "{1}Do you want to remove these existing dependencies?", "DependenciesPanel.otherRegularDependency=a regular", "DependenciesPanel.otherDevelopmentDependency=a development", "DependenciesPanel.otherOptionalDependency=an optional", "# {0} - type of dependency", "DependenciesPanel.alsoDependency=It is also {0} dependency. ", "DependenciesPanel.addAndKeep=Add and Keep Existing", "DependenciesPanel.addAndRemove=Add and Remove Existing", "DependenciesPanel.cancel=Cancel" }) private boolean checkOtherDependencyTypes(String libraryName) { List<Dependency.Type> types = allDependencies.otherDependencyTypes(libraryName, dependencyType); if (!types.isEmpty()) { StringBuilder dependencyTypesMessage = new StringBuilder(); for (Dependency.Type type : types) { String dependencyTypeMessage; switch(type) { case REGULAR: dependencyTypeMessage = Bundle.DependenciesPanel_otherRegularDependency(); break; case DEVELOPMENT: dependencyTypeMessage = Bundle.DependenciesPanel_otherDevelopmentDependency(); break; case OPTIONAL: dependencyTypeMessage = Bundle.DependenciesPanel_otherOptionalDependency(); break; default: throw new InternalError(); } dependencyTypesMessage.append(Bundle.DependenciesPanel_alsoDependency(dependencyTypeMessage)); } String message = Bundle.DependenciesPanel_otherDependencyWarning(libraryName, dependencyTypesMessage); NotifyDescriptor descriptor = new NotifyDescriptor( message, Bundle.DependenciesPanel_otherDependencyTitle(), -1, NotifyDescriptor.INFORMATION_MESSAGE, new Object[] { Bundle.DependenciesPanel_addAndRemove(), Bundle.DependenciesPanel_addAndKeep(), Bundle.DependenciesPanel_cancel() }, Bundle.DependenciesPanel_addAndRemove() ); DialogDisplayer.getDefault().notify(descriptor); Object retVal = descriptor.getValue(); if (Bundle.DependenciesPanel_addAndKeep().equals(retVal)) { return true; } else if (Bundle.DependenciesPanel_addAndRemove().equals(retVal)) { allDependencies.removeOtherDependencies(libraryName, dependencyType); return true; } return false; } return true; }
Example 8
Source File: DependenciesPanel.java From netbeans with Apache License 2.0 | 4 votes |
/** * Checks whether there is already dependency of the same name but * of a different type. If so then a dialog is displayed to determine * what should happen. * * @param libraryName name of the dependency to check. * @return {@code true} when the new dependency should be added, * returns {@code false} when the user decided to cancel addition * of the dependency. */ @NbBundle.Messages({ "DependenciesPanel.otherDependencyTitle=Another Dependency Type", "# {0} - library name", "# {1} - other dependencies message", "DependenciesPanel.otherDependencyWarning=There is another type " + "of dependency for \"{0}\" package. " + "{1}Do you want to remove these existing dependencies?", "DependenciesPanel.otherRegularDependency=a regular", "DependenciesPanel.otherDevelopmentDependency=a development", "# {0} - type of dependency", "DependenciesPanel.alsoDependency=It is also {0} dependency. ", "DependenciesPanel.addAndKeep=Add and Keep Existing", "DependenciesPanel.addAndRemove=Add and Remove Existing", "DependenciesPanel.cancel=Cancel" }) private boolean checkOtherDependencyTypes(String libraryName) { List<Dependency.Type> types = allDependencies.otherDependencyTypes(libraryName, dependencyType); if (!types.isEmpty()) { StringBuilder dependencyTypesMessage = new StringBuilder(); for (Dependency.Type type : types) { String dependencyTypeMessage; switch(type) { case REGULAR: dependencyTypeMessage = Bundle.DependenciesPanel_otherRegularDependency(); break; case DEVELOPMENT: dependencyTypeMessage = Bundle.DependenciesPanel_otherDevelopmentDependency(); break; default: throw new InternalError(); } dependencyTypesMessage.append(Bundle.DependenciesPanel_alsoDependency(dependencyTypeMessage)); } String message = Bundle.DependenciesPanel_otherDependencyWarning(libraryName, dependencyTypesMessage); NotifyDescriptor descriptor = new NotifyDescriptor( message, Bundle.DependenciesPanel_otherDependencyTitle(), -1, NotifyDescriptor.INFORMATION_MESSAGE, new Object[] { Bundle.DependenciesPanel_addAndRemove(), Bundle.DependenciesPanel_addAndKeep(), Bundle.DependenciesPanel_cancel() }, Bundle.DependenciesPanel_addAndRemove() ); DialogDisplayer.getDefault().notify(descriptor); Object retVal = descriptor.getValue(); if (Bundle.DependenciesPanel_addAndKeep().equals(retVal)){ return true; } else if (Bundle.DependenciesPanel_addAndRemove().equals(retVal)) { allDependencies.removeOtherDependencies(libraryName, dependencyType); return true; } return false; } return true; }
Example 9
Source File: TplEditorSupport.java From netbeans with Apache License 2.0 | 4 votes |
@NbBundle.Messages({ "warning=Warning", "# {0} document name", "# {1} encoding", "# {2} original encoding of the file when loaded", "MSG_unsupportedEncodingSave=<html>The encoding {1} specified in meta tag of the document {0} is invalid<br> or the document contains characters which cannot be saved using this encoding.<br> Do you want to save the file using <b>{2}</b> encoding?</html>" }) void updateEncoding() throws UserCancelException { //try to find encoding specification in the editor content String documentContent = getDocumentText(); String encoding = TplDataObject.findEncoding(documentContent); String feqEncoding = FileEncodingQuery.getEncoding(getDataObject().getPrimaryFile()).name(); String finalEncoding = null; if (encoding != null) { //found encoding specified in the file content by meta tag if (!isSupportedEncoding(encoding) || !canEncode(documentContent, encoding)) { //test if the file can be saved by the original encoding or if it needs to be saved using utf-8 finalEncoding = canEncode(documentContent, feqEncoding) ? feqEncoding : UTF_8_ENCODING; Integer showEncodingWarnings = getTplDO().getShowEncodingWarnings(); if (showEncodingWarnings == null) { String message = MSG_unsupportedEncodingSave(getDataObject().getPrimaryFile().getNameExt(), encoding, finalEncoding); SaveConfirmationPanel panel = new SaveConfirmationPanel(message); DialogDescriptor dd = new DialogDescriptor(panel, Bundle.warning(), true, DialogDescriptor.YES_NO_OPTION, DialogDescriptor.YES_OPTION, null); DialogDisplayer.getDefault().notify(dd); showEncodingWarnings = (Integer) dd.getValue(); if (panel.isDoNotShowAgainCheckBox() && showEncodingWarnings == NotifyDescriptor.YES_OPTION) { getTplDO().setShowEncodingWarnings(showEncodingWarnings); } } if (!showEncodingWarnings.equals(NotifyDescriptor.YES_OPTION)) { throw new UserCancelException(); } } else { finalEncoding = encoding; } } else { //no encoding specified in the file, use FEQ value if (!canEncode(documentContent, feqEncoding)) { NotifyDescriptor nd = new NotifyDescriptor.Confirmation(NbBundle.getMessage(TplEditorSupport.class, "MSG_badCharConversionSave", new Object[]{getDataObject().getPrimaryFile().getNameExt(), feqEncoding}), NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE); nd.setValue(NotifyDescriptor.NO_OPTION); DialogDisplayer.getDefault().notify(nd); if (nd.getValue() != NotifyDescriptor.YES_OPTION) { throw new UserCancelException(); } else { finalEncoding = UTF_8_ENCODING; } } else { finalEncoding = feqEncoding; } } //FEQ cannot be run in saveFromKitToStream since document is locked for writing, //so setting the FEQ result to document property Document document = getDocument(); if (document != null) { document.putProperty(DOCUMENT_SAVE_ENCODING, finalEncoding); } }
Example 10
Source File: UserXMLCatalog.java From netbeans with Apache License 2.0 | 4 votes |
private boolean requestUpdate(String id) { NotifyDescriptor desc = new NotifyDescriptor.Confirmation( NbBundle.getMessage(UserXMLCatalog.class,"TXT_updateEntry",id),NotifyDescriptor.YES_NO_OPTION); DialogDisplayer.getDefault().notify(desc); return (NotifyDescriptor.YES_OPTION==desc.getValue()); }
Example 11
Source File: DataViewActionHandler.java From netbeans with Apache License 2.0 | 4 votes |
private static Object showYesAllDialog(Object msg, String title) { NotifyDescriptor nd = new NotifyDescriptor(msg, title, NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); DialogDisplayer.getDefault().notify(nd); return nd.getValue(); }
Example 12
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; }