List of usage examples for javax.swing JOptionPane NO_OPTION
int NO_OPTION
To view the source code for javax.swing JOptionPane NO_OPTION.
Click Source Link
From source file:com.dragoniade.deviantart.deviation.SearchStream.java
public List<Deviation> search(ProgressDialog progress, Collection collection) { if (user == null) { throw new IllegalStateException("You must set the user before searching."); }//w w w.ja v a2 s .c o m if (search == null) { throw new IllegalStateException("You must set the search type before searching."); } String searchQuery = search.getSearch().replace("%username%", user); String queryString = "http://www.deviantart.com/global/difi.php?c=Stream;thumbs;" + searchQuery + "," + offset + "," + OFFSET + "&t=xml"; GetMethod method = new GetMethod(queryString); List<Deviation> results = new ArrayList<Deviation>(OFFSET); try { int sc = -1; do { sc = client.executeMethod(method); if (sc != 200) { int res = DialogHelper.showConfirmDialog(owner, "An error has occured when contacting deviantART : error " + sc + ". Try again?", "Continue?", JOptionPane.YES_NO_OPTION); if (res == JOptionPane.NO_OPTION) { return null; } try { Thread.sleep(500); } catch (InterruptedException e) { } } } while (sc != 200); XmlToolkit toolkit = XmlToolkit.getInstance(); StringBuilder stringBuilder = new StringBuilder(); InputStream inputStream = method.getResponseBodyAsStream(); int b; boolean isOpening = false; while ((b = inputStream.read()) > -1) { if (b > 127) { isOpening = false; continue; } char c = (char) b; if (isOpening && Character.isDigit(c)) { stringBuilder.append('_'); } if (isOpening && c == '/') { stringBuilder.append(c); continue; } isOpening = (c == '<'); stringBuilder.append(c); } Element responses = toolkit.parseDocument(stringBuilder.toString()); method.releaseConnection(); total = toolkit.getNodeAsInt(responses, "response/calls/response/content/total"); List<?> deviations = toolkit.getMultipleNodes(responses, "response/calls/response/content/deviations"); if (total == 0) { return results; } for (Object obj : deviations) { Element deviation = (Element) obj; Deviation da = new Deviation(); da.setId(toolkit.getNodeAsLong(deviation, "id")); da.setArtist(toolkit.getNodeAsString(deviation, "artist")); da.setCategory(toolkit.getNodeAsString(deviation, "category")); da.setTitle(toolkit.getNodeAsString(deviation, "title")); da.setUrl(toolkit.getNodeAsString(deviation, "url")); da.setTimestamp(new Date(toolkit.getNodeAsLong(deviation, "ts") * 1000)); da.setMature("1".equals(toolkit.getNodeAsString(deviation, "is_mature"))); da.setCollection(collection); String filenameStr = toolkit.getNodeAsString(deviation, "filename"); String imageUrl = toolkit.getNodeAsString(deviation, "image/url"); String primaryFilename = Deviation.extractFilename(filenameStr); da.setDocumentDownloadUrl(DOWNLOAD_URL + da.getId() + "/"); da.setDocumentFilename(primaryFilename); if (imageUrl != null) { String secondaryFilename = Deviation.extractFilename(imageUrl); da.setImageDownloadUrl(imageUrl); da.setImageFilename(secondaryFilename); da.setResolution(toolkit.getNodeAsString(deviation, "image/width") + "x" + toolkit.getNodeAsString(deviation, "image/height")); } results.add(da); } offset = offset + deviations.size(); return results; } catch (HttpException e) { DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error", JOptionPane.ERROR_MESSAGE); return null; } catch (IOException e) { DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error", JOptionPane.ERROR_MESSAGE); return null; } }
From source file:serial.ChartFromSerial.java
/** * Creates new form JavaArduinoInterfacingAttempt *///from ww w. j ava 2s.c om public ChartFromSerial() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println(e); } initComponents(); //set autoscroll autoScroll_chkBx.setSelected(true); autoScrollEnabled = true; //create the graph defaultSeries = new XYSeries(graphName); defaultDataset = new XYSeriesCollection(defaultSeries); defaultChart = ChartFactory.createXYLineChart(graphName, xAxisLabel, yAxisLabel, defaultDataset); graph = new ChartPanel(defaultChart); chartPanel.add(graph, BorderLayout.CENTER); graph.setVisible(true); //create the text log text = new JTextArea(); text.setEditable(false); textScrollPane = new JScrollPane(text); textScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); textPanel.add(textScrollPane, BorderLayout.CENTER); textScrollPane.setVisible(true); //Populate the combo box portNames = SerialPort.getCommPorts(); while (portNames.length == 0) { if (JOptionPane.showConfirmDialog(rootPane, "No connected devices found.\nWould you like to refresh?", "Could not connect to any devices.", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) { buttonsOff(); return; } else { portNames = SerialPort.getCommPorts(); } } portList_jCombo.removeAllItems(); for (SerialPort portName : portNames) { portList_jCombo.addItem(portName.getSystemPortName()); } }
From source file:net.sf.jabref.exporter.ExportToClipboardAction.java
@Override public void run() { BasePanel panel = frame.getCurrentBasePanel(); if (panel == null) { return;//from w w w .j a v a2 s . c o m } if (panel.getSelectedEntries().isEmpty()) { message = Localization.lang("This operation requires one or more entries to be selected."); getCallBack().update(); return; } List<IExportFormat> exportFormats = new LinkedList<>(ExportFormats.getExportFormats().values()); Collections.sort(exportFormats, (e1, e2) -> e1.getDisplayName().compareTo(e2.getDisplayName())); String[] exportFormatDisplayNames = new String[exportFormats.size()]; for (int i = 0; i < exportFormats.size(); i++) { IExportFormat exportFormat = exportFormats.get(i); exportFormatDisplayNames[i] = exportFormat.getDisplayName(); } JList<String> list = new JList<>(exportFormatDisplayNames); list.setBorder(BorderFactory.createEtchedBorder()); list.setSelectionInterval(0, 0); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); int answer = JOptionPane.showOptionDialog(frame, list, Localization.lang("Select export format"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { Localization.lang("Export with selected format"), Localization.lang("Return to JabRef") }, Localization.lang("Export with selected format")); if (answer == JOptionPane.NO_OPTION) { return; } IExportFormat format = exportFormats.get(list.getSelectedIndex()); // Set the global variable for this database's file directory before exporting, // so formatters can resolve linked files correctly. // (This is an ugly hack!) Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().getBibDatabaseContext().getFileDirectory(); File tmp = null; try { // To simplify the exporter API we simply do a normal export to a temporary // file, and read the contents afterwards: tmp = File.createTempFile("jabrefCb", ".tmp"); tmp.deleteOnExit(); List<BibEntry> entries = panel.getSelectedEntries(); // Write to file: format.performExport(panel.getBibDatabaseContext(), tmp.getPath(), panel.getEncoding(), entries); // Read the file and put the contents on the clipboard: StringBuilder sb = new StringBuilder(); try (Reader reader = new InputStreamReader(new FileInputStream(tmp), panel.getEncoding())) { int s; while ((s = reader.read()) != -1) { sb.append((char) s); } } ClipboardOwner owner = (clipboard, content) -> { // Do nothing }; RtfSelection rs = new RtfSelection(sb.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(rs, owner); message = Localization.lang("Entries exported to clipboard") + ": " + entries.size(); } catch (Exception e) { LOGGER.error("Error exporting to clipboard", e); //To change body of catch statement use File | Settings | File Templates. message = Localization.lang("Error exporting to clipboard"); } finally { // Clean up: if ((tmp != null) && !tmp.delete()) { LOGGER.info("Cannot delete temporary clipboard file"); } } }
From source file:com.igormaznitsa.zxpspritecorrector.files.AbstractFilePlugin.java
protected boolean saveDataToFile(final File file, final byte[] data) throws IOException { if (file.isFile()) { switch (JOptionPane.showConfirmDialog(this.mainFrame, "Overwrite file '" + file.getAbsolutePath() + "'?", "Overwrite file", JOptionPane.YES_NO_CANCEL_OPTION)) { case JOptionPane.NO_OPTION: return true; case JOptionPane.CANCEL_OPTION: return false; }/* w w w . j av a2 s. c o m*/ } FileUtils.writeByteArrayToFile(file, data); return true; }
From source file:net.sf.jabref.gui.exporter.ExportToClipboardAction.java
@Override public void run() { BasePanel panel = frame.getCurrentBasePanel(); if (panel == null) { return;//from w w w . ja v a2 s . c o m } if (panel.getSelectedEntries().isEmpty()) { message = Localization.lang("This operation requires one or more entries to be selected."); getCallBack().update(); return; } List<IExportFormat> exportFormats = new LinkedList<>(ExportFormats.getExportFormats().values()); Collections.sort(exportFormats, (e1, e2) -> e1.getDisplayName().compareTo(e2.getDisplayName())); String[] exportFormatDisplayNames = new String[exportFormats.size()]; for (int i = 0; i < exportFormats.size(); i++) { IExportFormat exportFormat = exportFormats.get(i); exportFormatDisplayNames[i] = exportFormat.getDisplayName(); } JList<String> list = new JList<>(exportFormatDisplayNames); list.setBorder(BorderFactory.createEtchedBorder()); list.setSelectionInterval(0, 0); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); int answer = JOptionPane.showOptionDialog(frame, list, Localization.lang("Select export format"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { Localization.lang("Export with selected format"), Localization.lang("Return to JabRef") }, Localization.lang("Export with selected format")); if (answer == JOptionPane.NO_OPTION) { return; } IExportFormat format = exportFormats.get(list.getSelectedIndex()); // Set the global variable for this database's file directory before exporting, // so formatters can resolve linked files correctly. // (This is an ugly hack!) Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().getBibDatabaseContext().getFileDirectory(); File tmp = null; try { // To simplify the exporter API we simply do a normal export to a temporary // file, and read the contents afterwards: tmp = File.createTempFile("jabrefCb", ".tmp"); tmp.deleteOnExit(); List<BibEntry> entries = panel.getSelectedEntries(); // Write to file: format.performExport(panel.getBibDatabaseContext(), tmp.getPath(), panel.getBibDatabaseContext().getMetaData().getEncoding(), entries); // Read the file and put the contents on the clipboard: StringBuilder sb = new StringBuilder(); try (Reader reader = new InputStreamReader(new FileInputStream(tmp), panel.getBibDatabaseContext().getMetaData().getEncoding())) { int s; while ((s = reader.read()) != -1) { sb.append((char) s); } } ClipboardOwner owner = (clipboard, content) -> { // Do nothing }; RtfSelection rs = new RtfSelection(sb.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(rs, owner); message = Localization.lang("Entries exported to clipboard") + ": " + entries.size(); } catch (Exception e) { LOGGER.error("Error exporting to clipboard", e); //To change body of catch statement use File | Settings | File Templates. message = Localization.lang("Error exporting to clipboard"); } finally { // Clean up: if ((tmp != null) && !tmp.delete()) { LOGGER.info("Cannot delete temporary clipboard file"); } } }
From source file:eu.ggnet.dwoss.redtape.action.StateTransitionAction.java
@Override public void actionPerformed(ActionEvent e) { //TODO: All the extra checks for hints don't feel like the optimum //Invoice/* www .ja va 2 s .c o m*/ if (((RedTapeStateTransition) transition).getHints() .contains(RedTapeStateTransition.Hint.CREATES_INVOICE)) { int confirmInvoice = JOptionPane.showOptionDialog(parent, "Eine Rechnung wird unwiederruflich erstellt. Mchten Sie fortfahren?", "Rechnungserstellung", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (confirmInvoice == JOptionPane.CANCEL_OPTION) return; } //Cancel if (((RedTapeStateTransition) transition).equals(RedTapeStateTransitions.CANCEL)) { int confirmInvoice = JOptionPane.showOptionDialog(parent, "Der Vorgang wird storniert.\nMchten Sie fortfahren?", "Abbrechen des Vorganges", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (confirmInvoice == JOptionPane.NO_OPTION) return; } if (((RedTapeStateTransition) transition).getHints() .contains(RedTapeStateTransition.Hint.ADDS_SETTLEMENT)) { SettlementViewCask view = new SettlementViewCask(); OkCancelDialog<SettlementViewCask> dialog = new OkCancelDialog<>(parent, "Zahlung hinterlegen", view); dialog.setVisible(true); if (dialog.getCloseType() == CloseType.OK) { for (Document.Settlement settlement : view.getSettlements()) { cdoc.getDocument().add(settlement); } } else { return; } } if (((RedTapeStateTransition) transition).getHints() .contains(RedTapeStateTransition.Hint.UNIT_LEAVES_STOCK)) { for (Position p : cdoc.getDocument().getPositions(PositionType.PRODUCT_BATCH).values()) { //TODO not the best but fastest solution for now, this must be changed later if (StringUtils.isBlank(p.getRefurbishedId())) { if (JOptionPane.showConfirmDialog(parent, "Der Vorgang enthlt Neuware, wurden alle Seriennummern erfasst?", "Bitte verifizieren", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) return; } } } Dossier d = lookup(RedTapeWorker.class).stateChange(cdoc, transition, lookup(Guardian.class).getUsername()) .getDossier(); controller.reloadSelectionOnStateChange(d); }
From source file:com.dragoniade.deviantart.deviation.SearchRss.java
public List<Deviation> search(ProgressDialog progress, Collection collection) { if (user == null) { throw new IllegalStateException("You must set the user before searching."); }/*from www .j a v a2s .co m*/ if (search == null) { throw new IllegalStateException("You must set the search type before searching."); } if (total < 0) { progress.setText("Fetching total (0)"); total = retrieveTotal(progress, collection); progress.setText("Total: " + total); } String searchQuery = search.getSearch().replace("%username%", user); String queryString = "http://backend.deviantart.com/rss.xml?q=" + searchQuery + (collection == null ? "" : "/" + collection.getId()) + "&type=deviation&offset=" + offset; GetMethod method = new GetMethod(queryString); List<Deviation> results = new ArrayList<Deviation>(OFFSET); try { int sc = -1; do { sc = client.executeMethod(method); if (sc != 200) { LoggableException ex = new LoggableException(method.getResponseBodyAsString()); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), ex); int res = DialogHelper.showConfirmDialog(owner, "An error has occured when contacting deviantART : error " + sc + ". Try again?", "Continue?", JOptionPane.YES_NO_OPTION); if (res == JOptionPane.NO_OPTION) { return null; } try { Thread.sleep(500); } catch (InterruptedException e) { } } } while (sc != 200); XmlToolkit toolkit = XmlToolkit.getInstance(); Element responses = toolkit.parseDocument(method.getResponseBodyAsStream()); method.releaseConnection(); HashMap<String, String> prefixes = new HashMap<String, String>(); prefixes.put("media", responses.getOwnerDocument().lookupNamespaceURI("media")); NamespaceContext context = toolkit.getNamespaceContext(prefixes); List<?> deviations = toolkit.getMultipleNodes(responses, "channel/item"); if (deviations.size() == 0) { return results; } for (Object obj : deviations) { Element deviation = (Element) obj; Deviation da = new Deviation(); da.setId(getId(toolkit.getNodeAsString(deviation, "guid"))); da.setArtist(toolkit.getNodeAsString(deviation, "media:credit", context)); da.setCategory(toolkit.getNodeAsString(deviation, "media:category", context)); da.setTitle(toolkit.getNodeAsString(deviation, "media:title", context)); da.setUrl(toolkit.getNodeAsString(deviation, "link")); da.setTimestamp(parseDate(toolkit.getNodeAsString(deviation, "pubDate"))); da.setMature(!"nonadult".equals(toolkit.getNodeAsString(deviation, "media:rating", context))); da.setCollection(collection); Element documentNode = (Element) toolkit.getSingleNode(deviation, "media:content[@medium='document']", context); Element imageNode = (Element) toolkit.getSingleNode(deviation, "media:content[@medium='image']", context); Element videoNode = (Element) toolkit.getSingleNode(deviation, "media:content[@medium='video']", context); if (imageNode != null) { String content = imageNode.getAttribute("url"); String filename = Deviation.extractFilename(content); da.setImageDownloadUrl(content); da.setImageFilename(filename); da.setResolution(imageNode.getAttribute("width") + "x" + imageNode.getAttribute("height")); } if (documentNode != null) { String content = documentNode.getAttribute("url"); String filename = Deviation.extractFilename(content); da.setDocumentDownloadUrl(content); da.setDocumentFilename(filename); } if (videoNode != null) { String content = videoNode.getAttribute("url"); if (!content.endsWith("/")) { content = content + "/"; } String filename = Deviation.extractFilename(content); da.setDocumentDownloadUrl(content); da.setDocumentFilename(filename); } results.add(da); } offset = offset + deviations.size(); return results; } catch (HttpException e) { DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error", JOptionPane.ERROR_MESSAGE); return null; } catch (IOException e) { DialogHelper.showMessageDialog(owner, "Error contacting deviantART : " + e.getMessage() + ".", "Error", JOptionPane.ERROR_MESSAGE); return null; } }
From source file:com.mirth.connect.client.ui.ExportChannelLibrariesDialog.java
private void initComponents(Channel channel) { label1 = new JLabel(" The following code template libraries are linked to this channel:"); label1.setIcon(UIManager.getIcon("OptionPane.questionIcon")); librariesTextPane = new JTextPane(); librariesTextPane.setContentType("text/html"); HTMLEditorKit editorKit = new HTMLEditorKit(); StyleSheet styleSheet = editorKit.getStyleSheet(); styleSheet.addRule(".export-channel-libraries-dialog {font-family:\"Tahoma\";font-size:11;text-align:top}"); librariesTextPane.setEditorKit(editorKit); librariesTextPane.setEditable(false); librariesTextPane.setBackground(getBackground()); librariesTextPane.setBorder(null);//from w w w . ja v a 2s . co m StringBuilder librariesText = new StringBuilder("<html><ul class=\"export-channel-libraries-dialog\">"); for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel.getCachedCodeTemplateLibraries() .values()) { if (library.getEnabledChannelIds().contains(channel.getId()) || (library.isIncludeNewChannels() && !library.getDisabledChannelIds().contains(channel.getId()))) { librariesText.append("<li>").append(StringEscapeUtils.escapeHtml4(library.getName())) .append("</li>"); } } librariesText.append("</ul></html>"); librariesTextPane.setText(librariesText.toString()); librariesTextPane.setCaretPosition(0); librariesScrollPane = new JScrollPane(librariesTextPane); label2 = new JLabel("Do you wish to include these libraries in the channel export?"); alwaysChooseCheckBox = new JCheckBox( "Always choose this option by default in the future (may be changed in the Administrator settings)"); yesButton = new JButton("Yes"); yesButton.setMnemonic('Y'); yesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { result = JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries", true); } dispose(); } }); noButton = new JButton("No"); noButton.setMnemonic('N'); noButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { result = JOptionPane.NO_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class).putBoolean("exportChannelCodeTemplateLibraries", false); } dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.setMnemonic('C'); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { result = JOptionPane.CANCEL_OPTION; dispose(); } }); }
From source file:com.stefanbrenner.droplet.ui.actions.SaveFileAction.java
protected void showFileChooser() { int returnVal = fileChooser.showSaveDialog(getFrame()); if (returnVal == JFileChooser.APPROVE_OPTION) { // Get the selected file File file = fileChooser.getSelectedFile(); // check if file extension fits if (StringUtils.containsIgnoreCase(file.getName(), ".") //$NON-NLS-1$ && !(StringUtils.endsWithIgnoreCase(file.getName(), "." + IDropletContext.DROPLET_FILE_EXTENSION))) { JOptionPane.showMessageDialog(getFrame(), Messages.getString("SaveFileAction.extensionNotAllowed"), //$NON-NLS-1$ Messages.getString("SaveFileAction.wrongExtension"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); showFileChooser();/*from www .ja v a 2 s. c o m*/ return; } else { // automatically add droplet file extension if (!StringUtils.endsWithIgnoreCase(file.getName(), "." + IDropletContext.DROPLET_FILE_EXTENSION)) { String newPath = StringUtils.join(file.getPath(), "." + IDropletContext.DROPLET_FILE_EXTENSION); file = new File(newPath); } } // check if file already exists if (file.exists()) { int retVal = JOptionPane.showConfirmDialog(getFrame(), Messages.getString("SaveFileAction.overwriteFile"), Messages.getString("SaveFileAction.1"), //$NON-NLS-1$ //$NON-NLS-2$ JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (retVal == JOptionPane.NO_OPTION) { showFileChooser(); return; } } saveFile(file); // set file to context getDropletContext().setFile(file); } }
From source file:com.openbravo.pos.customers.CustomersPayment.java
/** * * @return//from w w w .j a v a 2 s . c o m */ @Override public boolean deactivate() { if (dirty.isDirty()) { int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannasave"), AppLocal.getIntString("title.editor"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.YES_OPTION) { save(); return true; } else { return res == JOptionPane.NO_OPTION; } } else { return true; } }