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:org.pdfsam.plugin.unpack.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent arg0) { if (WorkExecutor.getInstance().getRunningThreads() > 0 || panel.getSelectionPanel().isAdding()) { DialogUtility.showWarningAddingDocument(panel); return;//from w ww .j a va 2 s . c o m } PdfSelectionTableItem[] items = panel.getSelectionPanel().getTableRows(); if (ArrayUtils.isEmpty(items)) { DialogUtility.showWarningNoDocsSelected(panel, DialogUtility.AT_LEAST_ONE_DOC); return; } LinkedList<String> args = new LinkedList<String>(); // validation and permission check are demanded to the CmdParser object try { // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } args.addAll(getInputFilesArguments(items)); args.add("-" + UnpackParsedCommand.O_ARG); if (StringUtils.isEmpty(panel.getDestinationTextField().getText())) { String suggestedDir = getSuggestedDestinationDirectory(items[items.length - 1]); int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationTextField().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add(panel.getDestinationTextField().getText()); if (panel.getOverwriteCheckbox().isSelected()) { args.add("-" + UnpackParsedCommand.OVERWRITE_ARG); } args.add(UnpackParsedCommand.COMMAND_UNPACK); String[] myStringArray = (String[]) args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception e) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), e); SoundPlayer.getInstance().playErrorSound(); } }
From source file:org.pdfsam.plugin.vcomposer.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent e) { if (!panel.getComposerPanel().hasValidElements()) { JOptionPane.showMessageDialog(panel, GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Please select a pdf document or undelete some pages"), GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Warning"), JOptionPane.WARNING_MESSAGE); return;/*from www.jav a 2 s .co m*/ } if (StringUtils.isEmpty(panel.getDestinationFileText().getText())) { DialogUtility.showWarningNoDestinationSelected(panel, DialogUtility.FILE_DESTINATION); return; } // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } LinkedList<String> args = new LinkedList<String>(); try { args.addAll(panel.getComposerPanel().getValidConsoleParameters()); // rotation String rotation = panel.getComposerPanel().getRotatedElementsString(); if (rotation != null && rotation.length() > 0) { args.add("-" + ConcatParsedCommand.R_ARG); args.add(rotation); } String destination = ""; // if no extension given ensurePdfExtensionOnTextField(panel.getDestinationFileText()); File destinationDir = new File(panel.getDestinationFileText().getText()); File parent = destinationDir.getParentFile(); if (!(parent != null && parent.exists())) { String suggestedDir = null; if (Configuration.getInstance().getDefaultWorkingDirectory() != null && Configuration.getInstance().getDefaultWorkingDirectory().length() > 0) { suggestedDir = new File(Configuration.getInstance().getDefaultWorkingDirectory(), destinationDir.getName()).getAbsolutePath(); } if (suggestedDir != null) { int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationFileText().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } } destination = panel.getDestinationFileText().getText(); // check if the file already exists and the user didn't select to overwrite File destFile = (destination != null) ? new File(destination) : null; if (destFile != null && destFile.exists() && !panel.getOverwriteCheckbox().isSelected()) { int chosenOpt = DialogUtility.askForOverwriteOutputFileDialog(panel, destFile.getName()); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getOverwriteCheckbox().setSelected(true); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add("-" + ConcatParsedCommand.O_ARG); args.add(destination); if (panel.getOverwriteCheckbox().isSelected()) args.add("-" + ConcatParsedCommand.OVERWRITE_ARG); if (panel.getOutputCompressedCheck().isSelected()) args.add("-" + ConcatParsedCommand.COMPRESSED_ARG); args.add("-" + ConcatParsedCommand.PDFVERSION_ARG); args.add(((StringItem) panel.getVersionCombo().getSelectedItem()).getId()); args.add(AbstractParsedCommand.COMMAND_CONCAT); String[] myStringArray = args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception ex) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), ex); SoundPlayer.getInstance().playErrorSound(); } }
From source file:org.pdfsam.plugin.vpagereorder.listeners.RunButtonActionListener.java
public void actionPerformed(ActionEvent e) { File inputFile = panel.getSelectionPanel().getSelectedPdfDocument(); if (inputFile == null || !panel.getSelectionPanel().hasValidElements()) { JOptionPane.showMessageDialog(panel, GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Please select a pdf document or undelete some page"), GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Warning"), JOptionPane.WARNING_MESSAGE); return;/*from w ww . ja v a 2 s .c o m*/ } if (!panel.getSameAsSourceRadio().isSelected() && StringUtils.isEmpty(panel.getDestinationFileText().getText())) { DialogUtility.showWarningNoDestinationSelected(panel, DialogUtility.FILE_DESTINATION); return; } // overwrite confirmation if (panel.getOverwriteCheckbox().isSelected() && Configuration.getInstance().isAskOverwriteConfirmation()) { int dialogRet = DialogUtility.askForOverwriteConfirmation(panel); if (JOptionPane.NO_OPTION == dialogRet) { panel.getOverwriteCheckbox().setSelected(false); } else if (JOptionPane.CANCEL_OPTION == dialogRet) { return; } } LinkedList<String> args = new LinkedList<String>(); try { args.addAll(panel.getSelectionPanel().getValidConsoleParameters()); // rotation String rotation = panel.getSelectionPanel().getRotatedElementsString(); if (rotation != null && rotation.length() > 0) { args.add("-" + ConcatParsedCommand.R_ARG); args.add(rotation); } String destination = ""; // check radio for output options if (panel.getSameAsSourceRadio().isSelected()) { if (inputFile != null) { destination = inputFile.getAbsolutePath(); } } else { // if no extension given ensurePdfExtensionOnTextField(panel.getDestinationFileText()); File destinationDir = new File(panel.getDestinationFileText().getText()); File parent = destinationDir.getParentFile(); if (!(parent != null && parent.exists())) { String suggestedDir = null; if (Configuration.getInstance().getDefaultWorkingDirectory() != null && Configuration.getInstance().getDefaultWorkingDirectory().length() > 0) { suggestedDir = new File(Configuration.getInstance().getDefaultWorkingDirectory(), destinationDir.getName()).getAbsolutePath(); } else { suggestedDir = new File(inputFile.getParent(), destinationDir.getName()).getAbsolutePath(); } if (suggestedDir != null) { int chosenOpt = DialogUtility.showConfirmOuputLocationDialog(panel, suggestedDir); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getDestinationFileText().setText(suggestedDir); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } } destination = panel.getDestinationFileText().getText(); } // check if the file already exists and the user didn't select to overwrite File destFile = (destination != null) ? new File(destination) : null; if (destFile != null && destFile.exists() && !panel.getOverwriteCheckbox().isSelected()) { int chosenOpt = DialogUtility.askForOverwriteOutputFileDialog(panel, destFile.getName()); if (JOptionPane.YES_OPTION == chosenOpt) { panel.getOverwriteCheckbox().setSelected(true); } else if (JOptionPane.CANCEL_OPTION == chosenOpt) { return; } } args.add("-" + ConcatParsedCommand.O_ARG); args.add(destination); if (panel.getOverwriteCheckbox().isSelected()) args.add("-" + ConcatParsedCommand.OVERWRITE_ARG); if (panel.getOutputCompressedCheck().isSelected()) args.add("-" + ConcatParsedCommand.COMPRESSED_ARG); args.add("-" + ConcatParsedCommand.PDFVERSION_ARG); args.add(((StringItem) panel.getVersionCombo().getSelectedItem()).getId()); args.add(AbstractParsedCommand.COMMAND_CONCAT); String[] myStringArray = args.toArray(new String[args.size()]); WorkExecutor.getInstance().execute(new WorkThread(myStringArray)); } catch (Exception ex) { log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Error: "), ex); SoundPlayer.getInstance().playErrorSound(); } }
From source file:org.pentaho.reporting.designer.core.actions.report.SaveReportUtilities.java
/** * Prompts the user for the name of the report file which should be created * * @param parent the parent component of which the file chooser dialog will be a child * @param defaultFile the initially selected file. * @return The <code>File</code> which the report should be saved into, or <code>null</code> if the user does not want * to continue with the save operation// w ww . j av a2 s . c o m */ public static File promptReportFilename(final Component parent, final File defaultFile) { final FileFilter filter = new FilesystemFilter(new String[] { DEFAULT_EXTENSION }, ActionMessages.getString("ReportBundleFileExtension.Description"), true); final CommonFileChooser fileChooser = FileChooserService.getInstance().getFileChooser("report"); fileChooser.setSelectedFile(defaultFile); fileChooser.setFilters(new FileFilter[] { filter }); logger.debug("Prompting for save filename"); // NON-NLS if (fileChooser.showDialog(parent, JFileChooser.SAVE_DIALOG) == false) { logger.debug("Save filename - cancel option selected");// NON-NLS return null; } final File selectedFile = validateFileExtension(fileChooser.getSelectedFile(), parent); if (selectedFile == null) { // Cancel on another dialog return null; } // Once the filename has stabelized, check for overwrite if (selectedFile.exists()) { logger.debug("Selected file exists [" + selectedFile.getName() + "] - prompting for overwrite...");// NON-NLS final int overwrite = JOptionPane.showConfirmDialog(parent, ActionMessages.getString("SaveReportUtilities.OverwriteDialog.Message", selectedFile.getAbsolutePath()), ActionMessages.getString("SaveReportUtilities.OverwriteDialog.Title"), JOptionPane.YES_NO_OPTION); if (overwrite == JOptionPane.NO_OPTION) { return null; } } return selectedFile; }
From source file:org.pentaho.reporting.designer.core.actions.report.SaveReportUtilities.java
/** * Validates that the extension of the filename is prpt, and prompts the user if it is not. * * @param proposedFile the target file to validate * @param parent the parent component in case we need to display a dialog * @return the filename based on the validation and optional prompting, or <code>null</code> if the user decided to * cancel the operaion/* ww w.ja v a 2s. c om*/ */ public static File validateFileExtension(final File proposedFile, final Component parent) { if (proposedFile == null) { return null; } // See if we need to change the file extension final String s = proposedFile.getName(); if (s.endsWith(DEFAULT_EXTENSION) || s.endsWith(".prpti")) { return proposedFile; } final String extension = IOUtils.getInstance().getFileExtension(s); if ("".equals(extension)) { final File parentFile = proposedFile.getParentFile(); if (parentFile == null) { return new File(IOUtils.getInstance().stripFileExtension(s) + DEFAULT_EXTENSION); } else { return new File(parentFile, IOUtils.getInstance().stripFileExtension(s) + DEFAULT_EXTENSION); } } logger.debug("The selected filename does not have the standard extension - " + // NON-NLS "prompting the user to see if they want to change the extension");// NON-NLS final int result = JOptionPane.showConfirmDialog(parent, ActionMessages.getString("SaveReportUtilities.VerifyFileExtension.Message", proposedFile.getAbsolutePath()), ActionMessages.getString("SaveReportUtilities.VerifyFileExtension.Title"), JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { return null; } if (result == JOptionPane.NO_OPTION) { return proposedFile; } final File validatedFile = new File(proposedFile.getParent(), IOUtils.getInstance().stripFileExtension(s) + DEFAULT_EXTENSION); logger.debug("User has selected YES - the filename has been changed to [" + validatedFile.getName() + "]");// NON-NLS return validatedFile; }
From source file:org.pentaho.reporting.designer.core.editor.styles.styleeditor.StyleDefinitionUtilities.java
/** * Prompts the user for the name of the report file which should be created * * @param parent the parent component of which the file chooser dialog will be a child * @param defaultFile the initially selected file. * @return The <code>File</code> which the report should be saved into, or <code>null</code> if the user does not want * to continue with the save operation//from w ww . j av a 2s .co m */ public static File promptReportFilename(final Component parent, final File defaultFile) { final FileFilter filter = new FilesystemFilter(new String[] { DEFAULT_EXTENSION }, Messages.getString("StyleDefinitionUtilities.FileDescription"), true); final CommonFileChooser fileChooser = FileChooserService.getInstance().getFileChooser(FILE_CHOOSER_TYPE); fileChooser.setSelectedFile(defaultFile); fileChooser.setFilters(new FileFilter[] { filter }); logger.debug("Prompting for save filename"); // NON-NLS if (fileChooser.showDialog(parent, JFileChooser.SAVE_DIALOG) == false) { logger.debug("Save filename - cancel option selected");// NON-NLS return null; } final File selectedFile = validateFileExtension(fileChooser.getSelectedFile(), parent); if (selectedFile == null) { // Cancel on another dialog return null; } // Once the filename has stabelized, check for overwrite if (selectedFile.exists()) { logger.debug("Selected file exists [" + selectedFile.getName() + "] - prompting for overwrite...");// NON-NLS final int overwrite = JOptionPane.showConfirmDialog(parent, Messages.getString("StyleDefinitionUtilities.OverwriteDialog.Message", selectedFile.getAbsolutePath()), Messages.getString("StyleDefinitionUtilities.OverwriteDialog.Title"), JOptionPane.YES_NO_OPTION); if (overwrite == JOptionPane.NO_OPTION) { return null; } } return selectedFile; }
From source file:org.pentaho.reporting.designer.core.editor.styles.styleeditor.StyleDefinitionUtilities.java
/** * Validates that the extension of the filename is prpt, and prompts the user if it is not. * * @param proposedFile the target file to validate * @param parent the parent component in case we need to display a dialog * @return the filename based on the validation and optional prompting, or <code>null</code> if the user decided to * cancel the operaion/*from w ww . j ava 2s . co m*/ */ public static File validateFileExtension(final File proposedFile, final Component parent) { if (proposedFile == null) { return null; } // See if we need to change the file extension final String s = proposedFile.getName(); if (s.endsWith(DEFAULT_EXTENSION)) { return proposedFile; } final String extension = IOUtils.getInstance().getFileExtension(s); if ("".equals(extension)) { final File parentFile = proposedFile.getParentFile(); if (parentFile == null) { return new File(IOUtils.getInstance().stripFileExtension(s) + DEFAULT_EXTENSION); } else { return new File(parentFile, IOUtils.getInstance().stripFileExtension(s) + DEFAULT_EXTENSION); } } logger.debug("The selected filename does not have the standard extension - " + // NON-NLS "prompting the user to see if they want to change the extension");// NON-NLS final int result = JOptionPane.showConfirmDialog(parent, Messages.getString("StyleDefinitionUtilities.VerifyFileExtension.Message", proposedFile.getAbsolutePath()), Messages.getString("StyleDefinitionUtilities.VerifyFileExtension.Title"), JOptionPane.YES_NO_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { return null; } if (result == JOptionPane.NO_OPTION) { return proposedFile; } final File validatedFile = new File(proposedFile.getParent(), IOUtils.getInstance().stripFileExtension(s) + DEFAULT_EXTENSION); logger.debug("User has selected YES - the filename has been changed to [" + validatedFile.getName() + "]");// NON-NLS return validatedFile; }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.pdf.PdfExportDialog.java
protected boolean performConfirm() { final String filename = txFilename.getText(); final File f = new File(filename); if (f.exists()) { final String key1 = "pdfsavedialog.targetOverwriteConfirmation"; //$NON-NLS-1$ final String key2 = "pdfsavedialog.targetOverwriteTitle"; //$NON-NLS-1$ if (JOptionPane.showConfirmDialog(this, MessageFormat.format(getResources().getString(key1), new Object[] { txFilename.getText() }), getResources().getString(key2), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { return false; }/* w w w .j a v a 2 s .c om*/ } if (getEncryptionValue().equals(PdfExportGUIModule.SECURITY_ENCRYPTION_128BIT) || getEncryptionValue().equals(PdfExportGUIModule.SECURITY_ENCRYPTION_40BIT)) { if (txOwnerPassword.getText().trim().length() == 0) { if (JOptionPane.showConfirmDialog(this, getResources().getString("pdfsavedialog.ownerpasswordEmpty"), //$NON-NLS-1$ getResources().getString("pdfsavedialog.warningTitle"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) { return false; } } } return true; }
From source file:org.planetcrypto.bitcoin.PlanetCryptoBitcoinUI.java
@SuppressWarnings("unchecked") private void ConfigurationRemoveMinerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfigurationRemoveMinerButtonActionPerformed PlanetCryptoBitcoinUserConfiguration cfg = new PlanetCryptoBitcoinUserConfiguration(); String miner = ConfigurationRemoveMinerNameTextField.getText(); String ip = ConfigurationRemoveMinerIPTextField.getText(); int response; if (miner.isEmpty() & ip.isEmpty()) { JOptionPane.showMessageDialog(null, "Enter Miner Name or Miner IP!", "ERROR: NO PARAMETERS", JOptionPane.WARNING_MESSAGE); } else if (!miner.isEmpty()) { response = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + miner + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { return; //System.out.println("User opted out of deleting " + miner + "."); } else if (response == JOptionPane.CLOSED_OPTION) { return; //System.out.println("Dialog box was closed"); } else if (response == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, cfg.removeMiner(miner, "name")); ConfigurationCurrentMinersTextPane.setText(cfg.currentMiners()); ConfigurationRemoveMinerNameTextField.setText(""); cfg.closeAll();//from w ww . j a va 2 s .c o m } } else if (!ip.isEmpty()) { response = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + ip + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { return; //System.out.println("User opted out of deleting " + ip + "."); } else if (response == JOptionPane.CLOSED_OPTION) { return; //System.out.println("Dialog box was closed"); } else if (response == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, cfg.removeMiner(ip, "ip"), "SUCCESS!", JOptionPane.INFORMATION_MESSAGE); ConfigurationCurrentMinersTextPane.setText(cfg.currentMiners()); ConfigurationRemoveMinerIPTextField.setText(""); cfg.closeAll(); } } existing_miners = currentMiners(); ArrayList<String> miners = new ArrayList<>(); Map<Integer, HashMap<String, String>> current_miners = cfg.getMiners(); //jComboBox1. if (current_miners.get(0) == null) { miners.add("No Miners"); } else { for (int i = 0; i < current_miners.size(); i++) { miners.add(current_miners.get(i).get("name")); } } MinerSelectionBox.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox1.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox2.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox3.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); CustomCommandMinerSelectionBox.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionBox5.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerSelectionForAlarmsBox.setModel(new javax.swing.DefaultComboBoxModel(miners.toArray())); MinerVitalStatsTextPanePropertyChange(null); }
From source file:org.planetcrypto.bitcoin.PlanetCryptoBitcoinUI.java
private void RemoveCoinbaseUsernameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoveCoinbaseUsernameButtonActionPerformed // TODO add your handling code here: PlanetCryptoBitcoinUserConfiguration cfg = new PlanetCryptoBitcoinUserConfiguration(); existing_coinbase = cfg.getCoinbase(); if (existing_coinbase == null) { JOptionPane.showInternalMessageDialog(null, "No Users to delete", "ERROR!", JOptionPane.WARNING_MESSAGE); return;/*from ww w . jav a 2s . c o m*/ } String email = CoinbaseAPIUsernameTextField.getText(); int response; if (email.isEmpty()) { JOptionPane.showMessageDialog(null, "Please enter Coinbase Username", "ERROR: NO PARAMETERS", JOptionPane.WARNING_MESSAGE); } else if (!existing_coinbase.toString().contains(email)) { JOptionPane.showMessageDialog(null, "No such Coinbase Username: " + email + ".", "ERROR: NO SUCH USERNAME", JOptionPane.WARNING_MESSAGE); } else if (!email.isEmpty()) { response = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + email + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { return; //System.out.println("User opted out of deleting " + miner + "."); } else if (response == JOptionPane.CLOSED_OPTION) { return; //System.out.println("Dialog box was closed"); } else if (response == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, cfg.removeCoinbase(email)); CoinbaseAPIUsernameTextField.setText(""); GenericInformationCoinbaseUserSelectionBox .setModel(new DefaultComboBoxModel(existingCoinbase().toArray())); CurrentCoinbaseConfigurationTextPanePropertyChange(null); cfg.closeAll(); } } }