List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:processing.app.Sketch.java
/** * Save all code in the current sketch.//from w w w .j a v a 2s .co m */ public boolean save() throws IOException { // make sure the user didn't hide the sketch folder ensureExistence(); // first get the contents of the editor text area if (current.getCode().isModified()) { current.getCode().setProgram(editor.getText()); } // don't do anything if not actually modified //if (!modified) return false; if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) { Base.showMessage(tr("Sketch is read-only"), tr("Some files are marked \"read-only\", so you'll\n" + "need to re-save this sketch to another location.")); return saveAs(); } // rename .pde files to .ino File mainFile = new File(getMainFilePath()); File mainFolder = mainFile.getParentFile(); File[] pdeFiles = mainFolder.listFiles((dir, name) -> { return name.toLowerCase().endsWith(".pde"); }); if (pdeFiles != null && pdeFiles.length > 0) { if (PreferencesData.get("editor.update_extension") == null) { Object[] options = { tr("OK"), tr("Cancel") }; int result = JOptionPane.showOptionDialog(editor, tr("In Arduino 1.0, the default file extension has changed\n" + "from .pde to .ino. New sketches (including those created\n" + "by \"Save-As\") will use the new extension. The extension\n" + "of existing sketches will be updated on save, but you can\n" + "disable this in the Preferences dialog.\n" + "\n" + "Save sketch and update its extension?"), tr(".pde -> .ino"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (result != JOptionPane.OK_OPTION) return false; // save cancelled PreferencesData.setBoolean("editor.update_extension", true); } if (PreferencesData.getBoolean("editor.update_extension")) { // Do rename of all .pde files to new .ino extension for (File pdeFile : pdeFiles) renameCodeToInoExtension(pdeFile); } } data.save(); calcModified(); return true; }
From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java
/** * associate a dictionnary to the node selected. Each time a value will be * requested for this node, it will be changed for its replacement value in * target list if it exists//from ww w .j a v a 2s. c o m * * @param value * the value */ public void associateDictionnary(XsdNode node) { int dictionnary = dictionaryPanel.getSelectedDictionnary(); if (dictionnary == -1) { // no selection xsdTree.getMessageManager().sendMessage("No dictonnary selected", MessageManagerInt.errorMessage); return; } if (dictionaryPanel.getExampleList().length == 0) { // no selection xsdTree.getMessageManager().sendMessage("This dictionnary does not contain any value," + " maybe the separator has not been set properly.", MessageManagerInt.errorMessage); return; } AssociateDictionnaryListPanel adp = new AssociateDictionnaryListPanel(); int confirm = JOptionPane.showConfirmDialog(null, adp, "[XML maker] load dictionnary", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm != JOptionPane.OK_OPTION) return; if (node == null) { xsdTree.getMessageManager().sendMessage("No node selected", MessageManagerInt.errorMessage); return; } ((XsdTreeStructImpl) xsdTree).associateDictionnary(node, dictionnary, adp.getColumn(), adp.closedAssociation.isSelected()); }
From source file:ro.nextreports.designer.util.MessageUtil.java
public static boolean showReconnect() { Dialect dialect = null;/*from w ww .jav a 2 s . co m*/ try { dialect = Globals.getDialect(); } catch (Exception e1) { e1.printStackTrace(); } // current connection is broken if ((dialect == null) || !ConnectionUtil.isValidConnection(Globals.getConnection(), dialect)) { // try to create a new connection (if a connection pool is used, current connection can expire after some time) try { LOG.warn(".... Connection was lost. Try to recreate the database connection."); Globals.createConnection(DefaultDataSourceManager.getInstance().getConnectedDataSource()); } catch (ConnectionException e) { LOG.warn(".... Connection recreation was not possible."); LOG.error(e.getMessage(), e); // connection is really down int option = JOptionPane.showOptionDialog(Globals.getMainFrame(), I18NSupport.getString("connection.broken"), I18NSupport.getString("error"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] { I18NSupport.getString("save"), I18NSupport.getString("base.dialog.close") }, I18NSupport.getString("base.dialog.close")); if (option != JOptionPane.OK_OPTION) { return true; } else { // forced save (we should be able to save the report anyway to not lost the work) LOG.warn(".... Forced save was called."); new SaveAction(true).actionPerformed(null); } return true; } } return false; }
From source file:se.trixon.jota.client.ui.editor.JobsPanel.java
private void edit(Job job) { String title;/*from w ww .j a v a2 s .co m*/ boolean add = job == null; String type = Dict.JOB.toString().toLowerCase(); if (job == null) { job = new Job(); title = String.format("%s %s", Dict.ADD.toString(), type); } else { title = String.format("%s %s", Dict.EDIT.toString(), type); } JobPanel jobPanel = new JobPanel(); jobPanel.setJob(job); SwingHelper.makeWindowResizable(jobPanel); int retval = JOptionPane.showOptionDialog(getRoot(), jobPanel, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); if (retval == JOptionPane.OK_OPTION) { Job modifiedJob = jobPanel.getJob(); if (modifiedJob.isValid() && !jobExists(modifiedJob)) { if (add) { getModel().addElement(modifiedJob); } else { getModel().set(getModel().indexOf(getSelectedJob()), modifiedJob); } sortModel(); list.setSelectedValue(modifiedJob, true); } else { showInvalidJobDialog(); edit(modifiedJob); } } }
From source file:se.trixon.jota.client.ui.editor.JobsPanel.java
private void removeAllButtonActionPerformed(ActionEvent evt) { if (!getModel().isEmpty()) { int retval = JOptionPane.showConfirmDialog(getRoot(), mBundle.getString("JobsPanel.message.removeAll"), mBundle.getString("JobsPanel.title.removeAll"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (retval == JOptionPane.OK_OPTION) { getModel().removeAllElements(); notifyJobListenersRemoved(); }/*from ww w. j a v a 2 s . co m*/ } }
From source file:se.trixon.jota.client.ui.editor.JobsPanel.java
private void removeButtonActionPerformed(ActionEvent evt) { if (getSelectedJob() != null) { String message = String.format(mBundle.getString("JobsPanel.message.remove"), getSelectedJob().getName()); int retval = JOptionPane.showConfirmDialog(getRoot(), message, mBundle.getString("JobsPanel.title.remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (retval == JOptionPane.OK_OPTION) { getModel().removeElement(getSelectedJob()); notifyJobListenersRemoved(); }//from www.j ava 2 s.c om } }
From source file:se.trixon.jota.client.ui.editor.module.job.CronEditorPanel.java
private void edit(String cronString) { String title;/* w w w.j av a 2 s .c o m*/ boolean add = cronString == null; if (cronString == null) { title = Dict.ADD.toString(); } else { title = Dict.EDIT.toString(); } CronPanel cronPanel = new CronPanel(); cronPanel.setCronString(cronString); SwingHelper.makeWindowResizable(cronPanel); int retval = JOptionPane.showOptionDialog(getRoot(), cronPanel, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); if (retval == JOptionPane.OK_OPTION) { String modifiedCronString = cronPanel.getCronString(); if (cronPanel.isCronValid()) { if (add) { getModel().addElement(modifiedCronString); } else { getModel().set(getModel().indexOf(getSelectedCronString()), modifiedCronString); } sortModel(); list.setSelectedValue(modifiedCronString, true); } else { Message.error(this, "Invalid cron string", modifiedCronString); edit(modifiedCronString); } } }
From source file:se.trixon.jota.client.ui.editor.module.job.CronEditorPanel.java
private void removeAllButtonActionPerformed(ActionEvent evt) { if (!getModel().isEmpty()) { int retval = JOptionPane.showConfirmDialog(getRoot(), mBundle.getString("CronPanel.message.removeAll"), mBundle.getString("CronPanel.title.removeAll"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (retval == JOptionPane.OK_OPTION) { getModel().removeAllElements(); }//ww w . j a v a 2s. co m } }
From source file:se.trixon.jota.client.ui.editor.module.job.CronEditorPanel.java
private void removeButtonActionPerformed(ActionEvent evt) { if (getSelectedCronString() != null) { String message = String.format(mBundle.getString("CronPanel.message.remove"), getSelectedCronString()); int retval = JOptionPane.showConfirmDialog(getRoot(), message, mBundle.getString("CronPanel.title.remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (retval == JOptionPane.OK_OPTION) { getModel().removeElement(getSelectedCronString()); }//from ww w . jav a 2 s . com } }
From source file:se.trixon.jota.client.ui.editor.TasksPanel.java
private void edit(Task task) { String title;/*from www. j a v a 2s . c o m*/ boolean add = task == null; String type = Dict.TASK.toString().toLowerCase(); if (task == null) { task = new Task(); title = String.format("%s %s", Dict.ADD.toString(), type); } else { title = String.format("%s %s", Dict.EDIT.toString(), type); } TaskPanel taskPanel = new TaskPanel(); taskPanel.setTask(task); SwingHelper.makeWindowResizable(taskPanel); int retval = JOptionPane.showOptionDialog(getRoot(), taskPanel, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); if (retval == JOptionPane.OK_OPTION) { Task modifiedTask = taskPanel.getTask(); if (modifiedTask.isValid()) { if (add) { getModel().addElement(modifiedTask); } else { getModel().set(getModel().indexOf(getSelectedTask()), modifiedTask); } sortModel(); list.setSelectedValue(modifiedTask, true); notifyTaskListenersChanged(); } else { showInvalidTaskDialog(); edit(modifiedTask); } } }