List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION
int OK_CANCEL_OPTION
To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:ro.nextreports.designer.util.MessageUtil.java
public static boolean showReconnect() { Dialect dialect = null;//from w ww .j a v a2s . c om 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 w w . j av a2 s . c o 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 w w w . j av a 2s .c o 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(); }// ww w . ja v a 2s . c o m } }
From source file:se.trixon.jota.client.ui.editor.module.job.CronEditorPanel.java
private void edit(String cronString) { String title;/*from www.ja v a2s. 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(); }// www . ja v a 2 s . c o 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 . j a va2 s. c om*/ } }
From source file:se.trixon.jota.client.ui.editor.TasksPanel.java
private void edit(Task task) { String title;//from w w w. j a v a2 s . 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); } } }
From source file:se.trixon.jota.client.ui.editor.TasksPanel.java
private void removeAllButtonActionPerformed(ActionEvent evt) { if (!getModel().isEmpty()) { int retval = JOptionPane.showConfirmDialog(getRoot(), mBundle.getString("TasksPanel.message.removeAll"), mBundle.getString("TasksPanel.title.removeAll"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (retval == JOptionPane.OK_OPTION) { getModel().removeAllElements(); notifyTaskListenersChanged(); }//from w w w. j a v a2s .com } }
From source file:se.trixon.jota.client.ui.editor.TasksPanel.java
private void removeButtonActionPerformed(ActionEvent evt) { int[] indices = list.getSelectedIndices(); if (indices.length > 0) { StringBuilder sb = new StringBuilder(); for (int index : indices) { Task task = (Task) getModel().getElementAt(index); sb.append(task.getName()).append("\n"); }// w w w . ja v a 2 s. c o m String message = String.format(mBundle.getString("TasksPanel.message.remove"), sb.toString()); int retval = JOptionPane.showConfirmDialog(getRoot(), message, mBundle.getString("TasksPanel.title.remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (retval == JOptionPane.OK_OPTION) { for (int i = indices.length - 1; i >= 0; i--) { getModel().removeElement(getModel().getElementAt(indices[i])); } sortModel(); notifyTaskListenersChanged(); } } }