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.orbisgis.mapeditorapi.MapElement.java
@Override public void save() throws UnsupportedOperationException { // If a layer hold a not well known source then alert the user boolean doSave = true; if (hasTemporaryTables()) { int response = JOptionPane.showConfirmDialog(UIFactory.getMainFrame(), I18N.tr("Some layers use temporary" + " table, are you sure to save this map and loose layers with temporary tables ?"), I18N.tr("Temporary layers data source"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.NO_OPTION) { doSave = false;/* w ww . ja va 2 s .co m*/ } } if (doSave) { // Save MapContext try { //Create folders if needed File parentFolder = mapContextFile.getParentFile(); if (!parentFolder.exists()) { parentFolder.mkdirs(); } mapContext.write(new FileOutputStream(mapContextFile)); } catch (FileNotFoundException ex) { throw new UnsupportedOperationException(ex); } if (doSave) { setModified(false); } } }
From source file:org.orbisgis.r.RConsolePanel.java
/** * Open a dialog that let the user select a file and add or replace the * content of the R editor./*from ww w . j ava 2 s . co m*/ */ public void onOpenFile() { final OpenFilePanel inFilePanel = new OpenFilePanel("rConsoleInFile", I18N.tr("Open script")); inFilePanel.addFilter("R", I18N.tr("R Script (*.R)")); inFilePanel.loadState(); if (UIFactory.showDialog(inFilePanel)) { int answer = JOptionPane.NO_OPTION; if (scriptPanel.getDocument().getLength() > 0) { answer = JOptionPane.showConfirmDialog(this, I18N.tr("Do you want to clear all before loading the file ?"), I18N.tr("Open file"), JOptionPane.YES_NO_CANCEL_OPTION); } String text; try { text = FileUtils.readFileToString(inFilePanel.getSelectedFile()); } catch (IOException e1) { LOGGER.error(I18N.tr("Cannot write the script."), e1); return; } if (answer == JOptionPane.YES_OPTION) { scriptPanel.setText(text); } else if (answer == JOptionPane.NO_OPTION) { scriptPanel.append(text); } } }
From source file:org.orbisgis.sqlconsole.ui.SQLConsolePanel.java
/** * Open a dialog that let the user to select a file * and add or replace the content of the sql editor. *///from ww w . ja v a 2s . c o m public void onOpenFile() { final OpenFilePanel inFilePanel = new OpenFilePanel("sqlConsoleInFile", I18N.tr("Open script")); inFilePanel.addFilter("sql", I18N.tr("SQL script (*.sql)")); if (sqlElement.getDocumentPathString().isEmpty()) { inFilePanel.loadState(); } else { inFilePanel.setCurrentDirectory(sqlElement.getDocumentPath()); } if (UIFactory.showDialog(inFilePanel)) { int answer = JOptionPane.YES_OPTION; if (scriptPanel.getDocument().getLength() > 0) { answer = JOptionPane.showConfirmDialog(this, I18N.tr("Do you want to clear all before loading the file ?"), I18N.tr("Open file"), JOptionPane.YES_NO_CANCEL_OPTION); } String text; try { text = FileUtils.readFileToString(inFilePanel.getSelectedFile()); } catch (IOException e1) { LOGGER.error(I18N.tr("IO error."), e1); return; } if (answer == JOptionPane.YES_OPTION) { scriptPanel.setText(text); sqlElement.setDocumentPath(inFilePanel.getSelectedFile()); sqlElement.setModified(false); } else if (answer == JOptionPane.NO_OPTION) { scriptPanel.append(text); } } }
From source file:org.orbisgis.view.beanshell.BshConsolePanel.java
/** * Open a dialog that let the user select a file * and add or replace the content of the sql editor. *//*from w w w.jav a2 s.c om*/ public void onOpenFile() { final OpenFilePanel inFilePanel = new OpenFilePanel("bshConsoleInFile", I18N.tr("Open script")); inFilePanel.addFilter("bsh", I18N.tr("BeanShell Script (*.bsh)")); inFilePanel.loadState(); if (UIFactory.showDialog(inFilePanel)) { int answer = JOptionPane.NO_OPTION; if (scriptPanel.getDocument().getLength() > 0) { answer = JOptionPane.showConfirmDialog(this, I18N.tr("Do you want to clear all before loading the file ?"), I18N.tr("Open file"), JOptionPane.YES_NO_CANCEL_OPTION); } String text; try { text = FileUtils.readFileToString(inFilePanel.getSelectedFile()); } catch (IOException e1) { LOGGER.error(I18N.tr("IO error."), e1); return; } if (answer == JOptionPane.YES_OPTION) { scriptPanel.setText(text); } else if (answer == JOptionPane.NO_OPTION) { scriptPanel.append(text); } } }
From source file:org.orbisgis.view.map.MapElement.java
@Override public void save() throws UnsupportedOperationException { // If a layer hold a not well known source then alert the user boolean doSave = true; if (hasNotWellKnownDataSources()) { int response = JOptionPane.showConfirmDialog(UIFactory.getMainFrame(), I18N.tr( "Some layers use temporary data source, are you sure to save this map and loose layers with temporary data sources ?"), I18N.tr("Temporary layers data source"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.NO_OPTION) { doSave = false;/* w w w . ja va 2 s . co m*/ } } if (hasModifiedDataSources()) { int response = JOptionPane.showConfirmDialog(UIFactory.getMainFrame(), I18N.tr("Some layers use modified data source, do you want to save also these modifications ?"), I18N.tr("Save geometry edits"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.CANCEL_OPTION) { doSave = false; } else if (response == JOptionPane.YES_OPTION) { // Save DataSources if (!saveModifiedDataSources()) { response = JOptionPane.showConfirmDialog(UIFactory.getMainFrame(), I18N.tr( "Some layers data source modifications can not be saved, are you sure you want to continue ?"), I18N.tr("Errors on data source save process"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.NO_OPTION) { doSave = false; } } } } if (doSave) { // Save MapContext try { //Create folders if needed File parentFolder = mapContextFile.getParentFile(); if (!parentFolder.exists()) { parentFolder.mkdirs(); } mapContext.write(new FileOutputStream(mapContextFile)); } catch (FileNotFoundException ex) { throw new UnsupportedOperationException(ex); } if (doSave) { setModified(false); } } }
From source file:org.orbisgis.view.sqlconsole.ui.SQLConsolePanel.java
/** * Open a dialog that let the user to select a file * and add or replace the content of the sql editor. *//* w w w. ja v a 2 s . com*/ public void onOpenFile() { final OpenFilePanel inFilePanel = new OpenFilePanel("sqlConsoleInFile", I18N.tr("Open script")); inFilePanel.addFilter("sql", I18N.tr("SQL script (*.sql)")); inFilePanel.loadState(); if (UIFactory.showDialog(inFilePanel)) { int answer = JOptionPane.NO_OPTION; if (scriptPanel.getDocument().getLength() > 0) { answer = JOptionPane.showConfirmDialog(this, I18N.tr("Do you want to clear all before loading the file ?"), I18N.tr("Open file"), JOptionPane.YES_NO_CANCEL_OPTION); } String text; try { text = FileUtils.readFileToString(inFilePanel.getSelectedFile()); } catch (IOException e1) { LOGGER.error(I18N.tr("IO error."), e1); return; } if (answer == JOptionPane.YES_OPTION) { scriptPanel.setText(text); } else if (answer == JOptionPane.NO_OPTION) { scriptPanel.append(text); } } }
From source file:org.owasp.jbrofuzz.fuzz.io.Save.java
/** * <p>Method for obtaining a file location, through a * JFileChooser for the user to save a .jbrofuzz file.</p> * /*w w w . j a v a 2 s . c o m*/ * <p>In the event of an error or an exception, this * method returns null.</p> * * @param mWindow * @return */ public static File showSaveDialog(JBroFuzzWindow mWindow) { final String dirString = JBroFuzz.PREFS.get(JBroFuzzPrefs.DIRS[2].getId(), System.getProperty("user.dir")); final File dirLocation = new File(dirString); JFileChooser fChooser; try { if (dirLocation.exists() && dirLocation.isDirectory()) { fChooser = new JFileChooser(dirString); } else { fChooser = new JFileChooser(); } } catch (final SecurityException sException) { fChooser = new JFileChooser(); Logger.log("A security exception occured, while attempting to save as to a directory", 4); } // Set the filter for the file extension fChooser.setFileFilter(new JBroFuzzFileFilter()); // Talk to the user final int retValue = fChooser.showSaveDialog(mWindow); // If there is an approval or selection if (retValue == JFileChooser.APPROVE_OPTION) { File returnFile = fChooser.getSelectedFile(); Logger.log("Saving: " + returnFile.getName(), 1); // final String filePath = returnFile.getAbsolutePath().toLowerCase(); if (!filePath.endsWith(".jbrofuzz")) { returnFile = new File(filePath + ".jbrofuzz"); } if (returnFile.exists()) { final int overwrite = JOptionPane.showConfirmDialog(fChooser, "File already exists. Do you \nwant to replace it?", " JBroFuzz - Save ", JOptionPane.YES_NO_OPTION); // If the user does not want to overwrite, return null if (overwrite == JOptionPane.NO_OPTION) { return null; } } // Before returning the file, set the preference // for the parent directory final String parentDir = returnFile.getParent(); if (parentDir != null) { JBroFuzz.PREFS.put(JBroFuzzPrefs.DIRS[2].getId(), parentDir); } return returnFile; } // If the user cancelled, return nulls return null; }
From source file:org.panbox.desktop.common.gui.AddContactToShareWizard.java
private boolean handleContactSelection() { List<PanboxGUIContact> contacts = contactList.getSelectedValuesList(); // reallyAdded.clear(); if (contacts.isEmpty()) { return false; }/*www . j a v a 2s .c om*/ char[] password = PasswordEnterDialog.invoke(PermissionType.USER); try { client.showTrayMessage(bundle.getString("PleaseWait"), bundle.getString("tray.addContactToShare.waitMessage"), MessageType.INFO); PanboxShare sharenew = null; for (int i = 0; i < contacts.size(); i++) { // add permission for user ContactShareParticipant cp = new ContactShareParticipant(contacts.get(i)); if (!cp.getContact().isVerified()) { int res = JOptionPane.showConfirmDialog(this, MessageFormat.format( bundle.getString("PanboxClientGUI.addUnverifiedContactWarning.text"), cp.getName()), bundle.getString("PanboxClientGUI.addUnverifiedContactWarning.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (res == JOptionPane.YES_OPTION) { sharenew = client.addPermissionToShare(share, cp, password); logger.info("Added unverified contact " + cp.getName() + " to share."); reallyAdded.add(contacts.get(i)); // TODO: update users list } else if (res == JOptionPane.NO_OPTION) { logger.info("Skipped adding unverified contact " + cp.getName() + " to share."); continue; } } else { sharenew = client.addPermissionToShare(share, cp, password); reallyAdded.add(contacts.get(i)); // TODO: update users list } } this.share = (sharenew != null) ? sharenew : this.share; if (reallyAdded.size() > 0) { return true; } client.showTrayMessage(bundle.getString("tray.addContactToShare.finishTitle"), bundle.getString("tray.addContactToShare.finishMessage"), MessageType.INFO); } catch (ShareDoesNotExistException e1) { logger.error("Share not found!", e1); JOptionPane.showMessageDialog(this, bundle.getString("PanboxClient.shareNotFound"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (ShareManagerException e1) { logger.error("Could not add contact to share!", e1); JOptionPane.showMessageDialog(this, bundle.getString("PanboxClientGUI.errorWhileAddingContactToShare"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (UnrecoverableKeyException e1) { logger.error("Unable to recover key!", e1); JOptionPane.showMessageDialog(this, bundle.getString("PanboxClient.unableToRecoverKeys"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (ShareMetaDataException e1) { logger.error("Error in share metadata", e1); JOptionPane.showMessageDialog(this, bundle.getString("PanboxClientGUI.errorWhileAccessingShareMetadata"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } finally { Utils.eraseChars(password); } return false; }
From source file:org.panbox.desktop.common.gui.PanboxClientGUI.java
private void contactVerificationStatusCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_contactVerificationStatusCheckBoxActionPerformed if (contactVerificationStatusCheckBox.isSelected()) { String message = bundle.getString("PanboxClientGUI.really.verifiy.contact") + "\nFingerprint Enc: " + contact.getCertEncFingerprint() + "\nFingerprint Sign: " + contact.getCertSignFingerprint(); int reallyTrust = JOptionPane.showConfirmDialog(null, message, bundle.getString("PanboxClientGUI.panboxMessage"), JOptionPane.YES_NO_OPTION); if (reallyTrust == JOptionPane.NO_OPTION) { contactVerificationStatusCheckBox.setSelected(false); contactVerificationStatusCheckBox.setText(bundle.getString("PanboxClientGUI.contact.verified")); } else {/*from ww w . j a v a 2 s . com*/ contactVerificationStatusCheckBox.setText(bundle.getString("PanboxClientGUI.contact.verified")); } } else { contactVerificationStatusCheckBox.setText(bundle.getString("PanboxClientGUI.contact.verified")); } setContactChangesDetected(); }
From source file:org.panbox.desktop.common.gui.PanboxClientGUI.java
private void addDeviceContactShareButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_addDeviceContactShareButtonMousePressed final JFrame thisFrame = this; JPopupMenu menu = new JPopupMenu(); JMenuItem addDevice = new JMenuItem(bundle.getString("shareUserList.device")); addDevice.addActionListener(new ActionListener() { @Override// w w w. ja v a2 s . c o m public void actionPerformed(ActionEvent e) { try { int selected = shareList.getSelectedIndex(); PanboxShare share = shareModel.getElementAt(selected); if (share instanceof DropboxPanboxShare) { DropboxAdapterFactory dbxFac = (DropboxAdapterFactory) CSPAdapterFactory .getInstance(StorageBackendType.DROPBOX); DropboxAPIIntegration api = (DropboxAPIIntegration) dbxFac.getAPIAdapter(); DropboxClientIntegration c = (DropboxClientIntegration) dbxFac.getClientAdapter(); if (!c.isClientRunning()) { int ret = JOptionPane.showConfirmDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.dropboxNotRunningError"), bundle.getString("client.warn"), JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return; } } if (!api.isOnline()) { int ret = JOptionPane.showConfirmDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.offlineError"), bundle.getString("client.warn"), JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return; } } } if (share != null) { AddDeviceToShareDialog dialog = new AddDeviceToShareDialog(thisFrame, deviceModel, share.getDevices()); dialog.setVisible(true); List<PanboxDevice> result = dialog.getResult(); if (result.isEmpty()) { logger.debug("PanboxClientGUI : addDevice.addActionListener : Operation aborted!"); return; } char[] password = PasswordEnterDialog.invoke(PermissionType.DEVICE); PanboxShare sharenew = null; try { client.showTrayMessage(bundle.getString("PleaseWait"), bundle.getString("tray.addDeviceToShare.waitMessage"), MessageType.INFO); client.getShareWatchService().removeShare(share); for (PanboxDevice dev : result) { DeviceShareParticipant dp = new DeviceShareParticipant(dev); sharenew = client.addPermissionToShare(share, dp, password); ((ShareParticipantListModel) usersList.getModel()).addElement(dp); } if (sharenew != null) { shareModel.setElementAt(sharenew, selected); } client.showTrayMessage(bundle.getString("tray.addDeviceToShare.finishTitle"), bundle.getString("tray.addDeviceToShare.finishMessage"), MessageType.INFO); } catch (ShareDoesNotExistException e1) { logger.error("Share not found!", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClient.shareNotFound"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (ShareManagerException e1) { logger.error("Could not add device to share!", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.errorWhileAddingDeviceToShare"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (UnrecoverableKeyException e1) { logger.error("Unable to recover key!", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClient.unableToRecoverKeys"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (ShareMetaDataException e1) { logger.error("Error in share metadata", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.errorWhileAccessingShareMetadata"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } finally { Utils.eraseChars(password); PanboxShare tmp = (sharenew != null) ? sharenew : share; client.getShareWatchService().registerShare(tmp); // Also update share list for selected device if (device != null) { deviceShareList.setModel(client.getDeviceShares(device)); } } } } catch (OperationAbortedException ex) { System.out.println("Operation aborted!"); } } }); JMenuItem addContact = new JMenuItem(bundle.getString("shareUserList.contact")); addContact.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // check if user is share owner int selected = shareList.getSelectedIndex(); if ((selected != -1) && shareModel.getElementAt(selected).isOwner()) { boolean hasParticipants = (share.getContacts().size() != 0); PanboxShare share = shareModel.getElementAt(selected); if (share instanceof DropboxPanboxShare) { DropboxAdapterFactory dbxFac = (DropboxAdapterFactory) CSPAdapterFactory .getInstance(StorageBackendType.DROPBOX); DropboxAPIIntegration api = (DropboxAPIIntegration) dbxFac.getAPIAdapter(); DropboxClientIntegration c = (DropboxClientIntegration) dbxFac.getClientAdapter(); if (!c.isClientRunning()) { int ret = JOptionPane.showConfirmDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.dropboxNotRunningError"), bundle.getString("client.warn"), JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return; } } if (!api.isOnline()) { int ret = JOptionPane.showConfirmDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.offlineError"), bundle.getString("client.warn"), JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return; } } } // AddContactToShareWizard contactWizard; // try { // contactWizard = new AddContactToShareWizard(thisFrame, // client, share, contactModel); // } catch (Exception e2) { // e2.printStackTrace(); // return; // } // // contactWizard.setVisible(true); AddContactToShareDialog dialog = new AddContactToShareDialog(thisFrame, contactModel, share.getContacts()); dialog.setVisible(true); List<PanboxGUIContact> result; try { result = dialog.getResult(); } catch (OperationAbortedException e2) { logger.debug("PanboxClientGUI : addContact.addActionListener : Operation aborted!"); return; } if (result.isEmpty()) { logger.debug("PanboxClientGUI : addContact.addActionListener : Operation aborted!"); return; } char[] password = PasswordEnterDialog.invoke(PermissionType.USER); PanboxShare sharenew = null; try { client.showTrayMessage(bundle.getString("PleaseWait"), bundle.getString("tray.addContactToShare.waitMessage"), MessageType.INFO); ArrayList<PanboxGUIContact> reallyAdded = new ArrayList<PanboxGUIContact>(); client.getShareWatchService().removeShare(share); for (int i = 0; i < result.size(); i++) { // add permission for user ContactShareParticipant cp = new ContactShareParticipant(result.get(i)); if (Settings.getInstance().getExpertMode() && !cp.getContact().isVerified()) { int res = JOptionPane.showConfirmDialog(client.getMainWindow(), MessageFormat.format(bundle.getString( "PanboxClientGUI.addUnverifiedContactWarning.text"), cp.getName()), bundle.getString("PanboxClientGUI.addUnverifiedContactWarning.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (res == JOptionPane.YES_OPTION) { sharenew = client.addPermissionToShare(share, cp, password); logger.info("Added unverified contact " + cp.getName() + " to share."); reallyAdded.add(result.get(i)); ((ShareParticipantListModel) usersList.getModel()).addElement(cp); } else if (res == JOptionPane.NO_OPTION) { logger.info("Skipped adding unverified contact " + cp.getName() + " to share."); continue; } } else { sharenew = client.addPermissionToShare(share, cp, password); reallyAdded.add(result.get(i)); ((ShareParticipantListModel) usersList.getModel()).addElement(cp); } } if (reallyAdded.size() > 0) { shareModel.setElementAt(sharenew, selected); handleCSPShareParticipantConfiguration(sharenew, hasParticipants, reallyAdded); } client.showTrayMessage(bundle.getString("tray.addContactToShare.finishTitle"), bundle.getString("tray.addContactToShare.finishMessage"), MessageType.INFO); } catch (ShareDoesNotExistException e1) { logger.error("Share not found!", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClient.shareNotFound"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (ShareManagerException e1) { logger.error("Could not add contact to share!", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.errorWhileAddingContactToShare"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (UnrecoverableKeyException e1) { logger.error("Unable to recover key!", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClient.unableToRecoverKeys"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } catch (ShareMetaDataException e1) { logger.error("Error in share metadata", e1); JOptionPane.showMessageDialog(client.getMainWindow(), bundle.getString("PanboxClientGUI.errorWhileAccessingShareMetadata"), bundle.getString("client.error"), JOptionPane.ERROR_MESSAGE); } finally { Utils.eraseChars(password); PanboxShare tmp = (sharenew != null) ? sharenew : share; client.getShareWatchService().registerShare(tmp); } } } }); menu.add(addDevice); menu.add(addContact); menu.show(addDeviceContactShareButton, evt.getX(), evt.getY()); }