List of usage examples for javax.swing JOptionPane YES_NO_CANCEL_OPTION
int YES_NO_CANCEL_OPTION
To view the source code for javax.swing JOptionPane YES_NO_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. 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/*w ww. j av a2 s.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) || 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
/** * 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 ww w . ja va2 s. c o 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.rimudb.editor.RimuDBEditor.java
/** * DataObjectEditor//from ww w . ja va 2s . com */ public RimuDBEditor() { super(TITLE); log.debug(System.getProperties()); logMemory(); // Create a preferences object preferences = new RimuDBPreferences(this.getClass().getName()); // Use the system l&f try { String plaf = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(plaf); } catch (Exception e) { } setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (getDescriptorEditor().hasChanged()) { log.debug("windowClosing() Save changes to table descriptor?"); int option = JOptionPane.showConfirmDialog(RimuDBEditor.this, "Save changes to Table Descriptor?", "RimuDB Editor", JOptionPane.YES_NO_CANCEL_OPTION); // Cancel the close operation if (option == JOptionPane.CANCEL_OPTION) { // setVisible(true); return; } // Save the file if (option == JOptionPane.YES_OPTION) { log.debug("windowClosing() saving data"); getDescriptorFileContoller().save(); } } log.debug("System.exit(0)"); System.exit(0); } }); setIconImage(loadIcon("/images/rimudb_logo.gif").getImage()); descriptorFileController = new DescriptorFileController(this); setJMenuBar(buildJMenuBar()); JToolBar toolbar = createToolbar(); editor = new DescriptorEditor(this); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(toolbar, BorderLayout.NORTH); panel.add(new JSeparator()); panel.add(editor, BorderLayout.CENTER); setContentPane(panel); pack(); editor.requestPackageFocus(); // Center in the screen setLocationRelativeTo(null); startDriverCheck(); }
From source file:org.roche.antibody.services.graphsynchronizer.GraphSynchronizer.java
/** * Validates in order to decide, if we can sync our model back or not! * /*from w ww. j ava 2 s.c om*/ * @param code * @return JOptionPane.YES_NO_CANCEL_OPTION */ private int validate(HELMCode code) { int blockersInCode = 0; boolean activeDomainDetected = false; boolean activeDomainChanged = false; String domainChangesMsg = ""; for (HELMElement elem : code.getAllElements()) { if (blocksToRemove.contains(elem.getSequenceRepresentation())) { blockersInCode++; } if (elem instanceof HELMPeptide) { HELMPeptide pep = (HELMPeptide) elem; if (pep.getSimpleSequence().startsWith(activeDomain.getSequence()) || pep.getSimpleSequence().endsWith(activeDomain.getSequence())) { activeDomainDetected = true; } else { domainChangesMsg = checkForSequenceChanges(activeDomain.getSequence(), pep.getSimpleSequence()); activeDomainChanged = true; } } } if (blockersInCode != blockerCount) { JOptionPane.showMessageDialog(me.getFrame(), "Blockers were mainpulated! Model cannot be sync back!", "Sync Error", JOptionPane.ERROR_MESSAGE); return JOptionPane.CANCEL_OPTION; } else if (!activeDomainDetected && activeDomainChanged) { FontUIResource defaultFont = (FontUIResource) UIManager.get("OptionPane.messageFont"); UIManager.put("OptionPane.messageFont", new FontUIResource("Courier New", FontUIResource.PLAIN, 13)); int isConfirmed = JOptionPane.showConfirmDialog(me.getFrame(), domainChangesMsg, "Sequence has changed", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); UIManager.put("OptionPane.messageFont", defaultFont); return isConfirmed; } return JOptionPane.YES_OPTION; }
From source file:org.signserver.admin.gui.AddWorkerDialog.java
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed if (configurationEdited) { final int confirm = JOptionPane.showConfirmDialog(this, "Configuration has been edited, going back to the initial setup will discard changes.\n Proceed?", "Changes have been made", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (confirm == JOptionPane.YES_OPTION) { goBackToInitialConfig();/* ww w. j av a2 s. c o m*/ } } else { // no changes made goBackToInitialConfig(); } }
From source file:org.signserver.admin.gui.MainView.java
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed try {//w w w .j av a 2 s. c o m final int row = configurationTable.getSelectedRow(); if (row != -1) { final int res = JOptionPane.showConfirmDialog(getFrame(), "Are you sure you want to remove the property?", "Remove property", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.YES_OPTION) { int workerId = selectedWorker.getWorkerId(); SignServerAdminGUIApplication.getAdminWS().removeWorkerProperty(workerId, (String) configurationTable.getValueAt(row, 0)); SignServerAdminGUIApplication.getAdminWS().reloadConfiguration(workerId); refreshButton.doClick(); } } } catch (AdminNotAuthorizedException_Exception ex) { showAdminNotAuthorized(ex); } catch (SOAPFaultException ex) { showServerSideException(ex); } catch (EJBException ex) { showServerSideException(ex); } }
From source file:org.signserver.admin.gui.MainView.java
private void authRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authRemoveButtonActionPerformed final int row = authTable.getSelectedRow(); if (row != -1) { final String serialNumberBefore = (String) authTable.getValueAt(row, 0); final String issuerDNBefore = (String) authTable.getValueAt(row, 1); editSerialNumberTextfield.setText(serialNumberBefore); editSerialNumberTextfield.setEditable(false); editIssuerDNTextfield.setText(issuerDNBefore); editIssuerDNTextfield.setEditable(false); editUpdateAllCheckbox.setSelected(false); final int res = JOptionPane.showConfirmDialog(getFrame(), authEditPanel, "Remove authorized client", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.YES_OPTION) { List<Worker> workers; if (editUpdateAllCheckbox.isSelected()) { workers = selectedWorkers; } else { workers = Collections.singletonList(selectedWorker); }//from w ww.jav a 2 s . co m if (LOG.isDebugEnabled()) { LOG.debug("Selected workers: " + workers); } final AuthorizedClient oldAuthorizedClient = new AuthorizedClient(); oldAuthorizedClient.setCertSN(serialNumberBefore); oldAuthorizedClient.setIssuerDN(issuerDNBefore); final AuthorizedClient client = new AuthorizedClient(); client.setCertSN(editSerialNumberTextfield.getText()); client.setIssuerDN(editIssuerDNTextfield.getText()); for (Worker worker : workers) { try { SignServerAdminGUIApplication.getAdminWS().removeAuthorizedClient(worker.getWorkerId(), oldAuthorizedClient); SignServerAdminGUIApplication.getAdminWS().reloadConfiguration(worker.getWorkerId()); } catch (AdminNotAuthorizedException_Exception ex) { showAdminNotAuthorized(ex); } catch (SOAPFaultException ex) { showServerSideException(ex); } catch (EJBException ex) { showServerSideException(ex); } } refreshButton.doClick(); } } }
From source file:org.sleeksnap.ScreenSnapper.java
/** * Prompt the user for a configuration reset *//*from w w w.j av a 2s.co m*/ public void promptConfigurationReset() { final int option = JOptionPane.showConfirmDialog(null, Language.getString("settingsCorrupted"), Language.getString("errorLoadingSettings"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (option == JOptionPane.YES_OPTION) { try { loadSettings(true); } catch (final Exception e) { logger.log(Level.SEVERE, "Unable to load default settings!", e); } } else if (option == JOptionPane.NO_OPTION) { // If no, let them set the configuration themselves.. openSettings(); } else if (option == JOptionPane.CANCEL_OPTION) { // Exit, they don't want anything to do with it. System.exit(0); } }
From source file:org.tellervo.desktop.bulkdataentry.command.ImportSelectedElementsCommand.java
/** * @see com.dmurph.mvc.control.ICommand#execute(com.dmurph.mvc.MVCEvent) *//* w w w . ja v a 2 s . co m*/ @Override public void execute(MVCEvent argEvent) { BulkImportModel model = BulkImportModel.getInstance(); ElementModel emodel = model.getElementModel(); ElementTableModel tmodel = emodel.getTableModel(); ArrayList<IBulkImportSingleRowModel> selected = new ArrayList<IBulkImportSingleRowModel>(); tmodel.getSelected(selected); // here is where we verify they contain required info HashSet<String> requiredMessages = new HashSet<String>(); ArrayList<IBulkImportSingleRowModel> incompleteModels = new ArrayList<IBulkImportSingleRowModel>(); HashSet<String> definedProps = new HashSet<String>(); for (IBulkImportSingleRowModel som : selected) { definedProps.clear(); for (String s : SingleElementModel.TABLE_PROPERTIES) { if (som.getProperty(s) != null) { definedProps.add(s); } } boolean incomplete = false; // object if (!definedProps.contains(SingleElementModel.OBJECT)) { requiredMessages.add("Cannot import without a parent object."); incomplete = true; } else if (fixTempObjectCode(som)) { // There was a temp code but it is fixed now } else { requiredMessages.add("Cannot import as parent object has not been created yet"); incomplete = true; } // type if (!definedProps.contains(SingleElementModel.TYPE)) { requiredMessages.add("Element must contain a type."); incomplete = true; } // taxon if (!definedProps.contains(SingleElementModel.TAXON)) { requiredMessages.add("Element must contain a taxon."); incomplete = true; } // title if (!definedProps.contains(SingleElementModel.TITLE)) { requiredMessages.add("Element must have a title"); incomplete = true; } // lat/long if (definedProps.contains(SingleElementModel.LATITUDE) || definedProps.contains(SingleElementModel.LONGITUDE)) { if (!definedProps.contains(SingleElementModel.LATITUDE) || !definedProps.contains(SingleElementModel.LONGITUDE)) { requiredMessages .add("If coordinates are specified then both latitude and longitude are required"); incomplete = true; } else { String attempt = som.getProperty(SingleElementModel.LATITUDE).toString().trim(); try { Double lat = Double.parseDouble(attempt); if (lat > -90 || lat < 90) { requiredMessages.add("Latitude must be between -90 and 90"); incomplete = true; } } catch (NumberFormatException e) { requiredMessages.add("Cannot parse '" + attempt + "' into a number."); incomplete = true; } attempt = som.getProperty(SingleElementModel.LONGITUDE).toString().trim(); try { Double lng = Double.parseDouble(attempt); if (lng > -180 || lng < 180) { requiredMessages.add("Longitude must be between -180 and 180"); incomplete = true; } } catch (NumberFormatException e) { requiredMessages.add("Cannot parse '" + attempt + "' into a number."); incomplete = true; } } } if (definedProps.contains(SingleElementModel.HEIGHT) || definedProps.contains(SingleElementModel.WIDTH) || definedProps.contains(SingleElementModel.DEPTH) || definedProps.contains(SingleElementModel.DIAMETER)) { if (!definedProps.contains(SingleElementModel.UNIT)) { requiredMessages.add("Units must be specified when dimensions are included"); incomplete = true; } if ((definedProps.contains(SingleElementModel.HEIGHT) && definedProps.contains(SingleElementModel.DIAMETER) && !definedProps.contains(SingleElementModel.WIDTH) && !definedProps.contains(SingleElementModel.DEPTH))) { // h+diam but not width or depth } else if ((definedProps.contains(SingleElementModel.HEIGHT) && definedProps.contains(SingleElementModel.WIDTH) && definedProps.contains(SingleElementModel.DEPTH) && !definedProps.contains(SingleElementModel.DIAMETER))) { // h+w+d but not diam } else { requiredMessages.add( "When dimensions are included they must be: height/width/depth or height/diameter."); incomplete = true; } } if (incomplete) { incompleteModels.add(som); } } if (!incompleteModels.isEmpty()) { StringBuilder message = new StringBuilder(); message.append("Please correct the following errors:\n"); message.append(StringUtils.join(requiredMessages.toArray(), "\n")); Alert.message(model.getMainView(), "Importing Errors", message.toString()); return; } // now we actually create the models int i = -1; boolean hideErrorMessage = false; for (IBulkImportSingleRowModel srm : selected) { i++; SingleElementModel som = (SingleElementModel) srm; TridasElement origElement = new TridasElement(); if (!som.isDirty()) { System.out.println("Element isn't dirty, not saving/updating: " + som.getProperty(SingleElementModel.TITLE).toString()); } som.populateToTridasElement(origElement); Object o = som.getProperty(SingleElementModel.OBJECT); TridasObject parentObject = null; if (o instanceof TridasObjectOrPlaceholder) { parentObject = ((TridasObjectOrPlaceholder) o).getTridasObject(); } else if (o instanceof TridasObject) { parentObject = (TridasObject) o; } EntityResource<TridasElement> resource; if (origElement.getIdentifier() != null) { resource = new EntityResource<TridasElement>(origElement, TellervoRequestType.UPDATE, TridasElement.class); } else { resource = new EntityResource<TridasElement>(origElement, parentObject, TridasElement.class); } // set up a dialog... Window parentWindow = SwingUtilities.getWindowAncestor(model.getMainView()); TellervoResourceAccessDialog dialog = new TellervoResourceAccessDialog(parentWindow, resource, i, selected.size()); resource.query(); dialog.setVisible(true); if (!dialog.isSuccessful()) { if (hideErrorMessage) { continue; } else if (i < selected.size() - 1) { // More records remain Object[] options = { "Yes", "Yes, but hide further messages", "No" }; int result = JOptionPane.showOptionDialog(BulkImportModel.getInstance().getMainView(), //parent I18n.getText("error.savingChanges") + ":" + System.lineSeparator() + // message dialog.getFailException().getLocalizedMessage() + System.lineSeparator() + System.lineSeparator() + "Would you like to continue importing the remaining records?", I18n.getText("error"), // title JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); if (result == JOptionPane.NO_OPTION) { hideErrorMessage = true; continue; } else if (result == JOptionPane.YES_OPTION) { continue; } else { break; } } else { JOptionPane.showMessageDialog(BulkImportModel.getInstance().getMainView(), //parent I18n.getText("error.savingChanges") + ":" + System.lineSeparator() + // message dialog.getFailException().getLocalizedMessage(), I18n.getText("error"), // title JOptionPane.ERROR_MESSAGE); //option break; } } som.populateFromTridasElement(resource.getAssociatedResult()); som.setDirty(false); tmodel.setSelected(som, false); // add to imported list or update existing if (origElement.getIdentifier() != null) { TridasElement found = null; for (TridasElement tox : model.getElementModel().getImportedList()) { if (tox.getIdentifier().getValue().equals(origElement.getIdentifier().getValue())) { found = tox; break; } } if (found == null) { log.warn( "Error updating model. Couldn't find the object in the model to update so adding to imported list."); model.getElementModel().getImportedList().add(resource.getAssociatedResult()); } else { resource.getAssociatedResult().copyTo(found); } } else { model.getElementModel().getImportedList().add(resource.getAssociatedResult()); } } // // // finally, update the combo boxes in the table to the new options // DynamicJComboBoxEvent event = new DynamicJComboBoxEvent(emodel.getImportedDynamicComboBoxKey(), emodel.getImportedListStrings()); // event.dispatch(); tmodel.fireTableDataChanged(); }
From source file:org.tridas.io.gui.control.TricycleController.java
public void startup(MVCEvent argEvent) { if (view == null) { view = new MainWindow(TricycleModelLocator.getInstance().getTricycleModel()); TricycleModelLocator.getInstance().setMainWindow(view); if (argEvent instanceof StartupEvent) { if (((StartupEvent) argEvent).exitOnClose) { view.setDefaultCloseOperation(3); } else { view.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); }// w w w .j av a2 s .co m } view.setVisible(true); ToolTipManager.sharedInstance().setDismissDelay(10000); } else { view.setVisible(true); } TricycleModel model = TricycleModelLocator.getInstance().getTricycleModel(); // Check to see if we should auto update if (TricycleModelLocator.getInstance().isAutoUpdate()) { model.setAutoUpdate(true); CheckForUpdateEvent event = new CheckForUpdateEvent(false); event.dispatch(); } // Check to see if tracking should be set if (TricycleModelLocator.getInstance().isTracking()) { model.setTracking(true); } // Check to see if we need to ask permission about tracking if (!model.isTracking() && !TricycleModelLocator.getInstance().isDontAskTracking()) { String[] options = new String[] { I18n.getText("view.popup.tracking.askLater"), I18n.getText("view.popup.tracking.no"), I18n.getText("view.popup.tracking.yes") }; ImageIcon aicon = new ImageIcon(IOUtils.getFileInJarURL("icons/128x128/application.png")); int response = JOptionPane.showOptionDialog(view, WordUtils.wrap(I18n.getText("view.popup.tracking.question"), 50), I18n.getText("view.popup.tracking.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, aicon, options, options[0]); if (response == 2) { model.setTracking(true); TricycleModelLocator.getInstance().setDontAskTracking(true); } else if (response == 1) { model.setTracking(false); TricycleModelLocator.getInstance().setDontAskTracking(true); } else if (response == 0) { model.setTracking(false); TricycleModelLocator.getInstance().setDontAskTracking(false); } } }