List of usage examples for javax.swing JOptionPane YES_NO_OPTION
int YES_NO_OPTION
To view the source code for javax.swing JOptionPane YES_NO_OPTION.
Click Source Link
showConfirmDialog
. From source file:gdt.jgui.entity.JEntityFacetPanel.java
private void removeFacets() { try {//from ww w . j a v a 2 s. co m // System.out.println("EntityFacetPanel:removeFacets:BEGIN"); JItemPanel[] ipa = getItems(); if (ipa == null) return; ArrayList<JFacetOpenItem> foil = new ArrayList<JFacetOpenItem>(); for (JItemPanel aIpa : ipa) { if (aIpa.isChecked()) { if (((JFacetOpenItem) aIpa).isRemovable()) foil.add((JFacetOpenItem) aIpa); else aIpa.setChecked(false); } } JFacetOpenItem[] foia = foil.toArray(new JFacetOpenItem[0]); if (foia.length < 1) return; int response = JOptionPane.showConfirmDialog(this, "Delete selected facets ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response != JOptionPane.YES_OPTION) return; for (JFacetOpenItem foi : foia) foi.removeFacet(); console.putContext(instantiate(console, this.locator$), this.locator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } }
From source file:gdt.jgui.base.JPropertyPanel.java
public void deleteProperty(JMainConsole console, String locator$) { try {/*from w w w .ja v a2s . com*/ Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); Entigrator entigrator = console.getEntigrator(entihome$); String propertyName$ = locator.getProperty(JDesignPanel.PROPERTY_NAME); int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete property ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { entigrator.prp_deletePropertyName(propertyName$); JDesignPanel dp = new JDesignPanel(); String dpLocator$ = dp.getLocator(); dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$); JConsoleHandler.execute(console, dpLocator$); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:com.xmage.launcher.XMageLauncher.java
private void handleUpdate() { disableButtons();// w w w. j a va2 s. c o m if (!newJava && !newXMage) { int response = JOptionPane.showConfirmDialog(frame, messages.getString("force.update.message"), messages.getString("force.update.title"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { UpdateTask update = new UpdateTask(progressBar, true); update.execute(); } else { enableButtons(); } } else { UpdateTask update = new UpdateTask(progressBar, false); update.execute(); } }
From source file:de.juwimm.cms.util.Communication.java
public boolean exitPerformed(ExitEvent e) { log.info("Exit-event started"); int result = JOptionPane.showConfirmDialog(UIConstants.getMainFrame(), rb.getString("dialog.exit.text"), rb.getString("dialog.exit"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { if (!checkOutPages.isEmpty()) { ArrayList<ContentValue> pageList = new ArrayList<ContentValue>(); Iterator it = checkOutPages.iterator(); while (it.hasNext()) { try { ContentValue current = getClientService().getContent(((Integer) it.next())); pageList.add(current); } catch (Exception ex) { String msg = Messages.getString("exception.checkingInAllRemainingPages", Integer.toString(checkOutPages.size())); log.info(msg);/*w w w .j ava 2s .c om*/ JOptionPane.showMessageDialog(UIConstants.getMainFrame(), msg, rb.getString("dialog.title"), JOptionPane.INFORMATION_MESSAGE); UIConstants.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); while (it.hasNext()) { Integer contentId = (Integer) it.next(); try { msg = Messages.getString("exception.checkingInAllRemainingPagesStatusbar", contentId.toString()); UIConstants.setActionStatus(msg); getClientService().checkIn4ContentId(contentId); } catch (Exception exe) { log.error("Exit event error", exe); } } checkOutPages = new ArrayList<Integer>(); UIConstants.getMainFrame().setCursor(Cursor.getDefaultCursor()); try { if (log.isDebugEnabled()) { log.debug("Calling logout on server"); } getClientService().logout(); } catch (Exception exe) { } log.info("Goodbye!"); loggedIn = false; return true; } } PanCheckInPages pan = new PanCheckInPages(pageList); if (rb == null) rb = Constants.rb; DlgModal dlg = new DlgModal(pan, 300, 500, rb.getString("DlgModal.checkin")); dlg.addOkListener(new OkListener(pan, dlg)); dlg.setVisible(true); } try { if (log.isDebugEnabled()) { log.debug("Calling logout on server"); } getClientService().logout(); } catch (Exception exe) { } log.info("Goodbye!"); loggedIn = false; return true; } return false; }
From source file:com.orthancserver.SelectImageDialog.java
public SelectImageDialog() { tree_ = new JTree(); tree_.addTreeWillExpandListener(new TreeWillExpandListener() { @Override// ww w. ja v a2 s. c o m public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { TreePath path = event.getPath(); if (path.getLastPathComponent() instanceof MyTreeNode) { MyTreeNode node = (MyTreeNode) path.getLastPathComponent(); node.LoadChildren((DefaultTreeModel) tree_.getModel()); } } @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { } }); tree_.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path != null) { MyTreeNode node = (MyTreeNode) path.getLastPathComponent(); if (node.UpdatePreview(preview_)) { selectedType_ = node.GetResourceType(); selectedUuid_ = node.GetUuid(); selectedConnection_ = node.GetConnection(); okButton_.setEnabled(true); } removeServer_.setEnabled(node.GetResourceType() == ResourceType.SERVER); } } }); tree_.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { TreePath path = tree_.getPathForLocation(e.getX(), e.getY()); if (path != null) { MyTreeNode node = (MyTreeNode) path.getLastPathComponent(); if (e.getClickCount() == 2 && node.GetResourceType() == ResourceType.INSTANCE) { // Double click on an instance, close the dialog isSuccess_ = true; setVisible(false); } } } }); final JPanel contentPanel = new JPanel(); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.6); contentPanel.add(splitPane); splitPane.setLeftComponent(new JScrollPane(tree_)); splitPane.setRightComponent(preview_); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton btnAddServer = new JButton("Add server"); btnAddServer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { OrthancConfigurationDialog dd = new OrthancConfigurationDialog(); dd.setLocationRelativeTo(null); // Center dialog on screen OrthancConnection orthanc = dd.ShowModal(); if (orthanc != null) { AddOrthancServer(orthanc); ((DefaultTreeModel) tree_.getModel()).reload(); } } }); buttonPane.add(btnAddServer); } { buttonPane.add(removeServer_); removeServer_.setEnabled(false); removeServer_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { MyTreeNode selected = (MyTreeNode) tree_.getLastSelectedPathComponent(); if (selected.GetResourceType() == ResourceType.SERVER && JOptionPane.showConfirmDialog(null, "Remove server \"" + selected.getUserObject() + "\"?", "WARNING", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { ((DefaultTreeModel) tree_.getModel()).removeNodeFromParent(selected); } } }); } { okButton_.setEnabled(false); okButton_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { isSuccess_ = true; setVisible(false); } }); buttonPane.add(okButton_); getRootPane().setDefaultButton(okButton_); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg) { setVisible(false); } }); buttonPane.add(cancelButton); } } setUndecorated(false); setSize(500, 500); setTitle("Select some series or some instance in Orthanc"); setModal(true); }
From source file:com.floreantpos.ui.views.SwitchboardView.java
protected void doAssignDriver() { try {//from w w w.j a va 2s. c om Ticket ticket = getFirstSelectedTicket(); if (ticket == null) { return; } if (!ticket.getOrderType().isDelivery()) { POSMessageDialog.showError(this, Messages.getString("SwitchboardView.8")); //$NON-NLS-1$ return; } User assignedDriver = ticket.getAssignedDriver(); if (assignedDriver != null) { int option = JOptionPane.showOptionDialog(Application.getPosWindow(), Messages.getString("SwitchboardView.9"), POSConstants.CONFIRM, //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (option != JOptionPane.YES_OPTION) { return; } } orderServiceExtension.assignDriver(ticket.getId()); } catch (Exception e) { PosLog.error(getClass(), e); POSMessageDialog.showError(this, e.getMessage()); LogFactory.getLog(SwitchboardView.class).error(e); } }
From source file:com.edduarte.protbox.Protbox.java
private static void changeProtPath(PReg reg, File serializedDirectory) throws ProtboxException { if (JOptionPane.showConfirmDialog(null, "The prot folder from one of your registries\n" + "was deleted while Protbox wasn't running!\n" + "Do you wish to set a new folder to place the decoded files from the shared folder?\n" + "CHOOSING \"NO\" WILL DELETE THE REGISTRY AND YOU WILL LOSE ACCESS TO THE FILES " + "IN THE SHARED FOLDER!", "Prot Folder was deleted!", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { final DirectoryChooser chooser = new DirectoryChooser("Choose Output folder..."); String newOutputPath = chooser.getDirectory(); if (newOutputPath != null) { reg.changeProtPath(newOutputPath); } else {/*from w w w .j ava 2s .com*/ changeProtPath(reg, serializedDirectory); } } else { reg.stop(); serializedDirectory.deleteOnExit(); } }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * Export data //from w w w. j a v a2 s .c om */ protected void exportSingleLocale() { statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTING")); //$NON-NLS-1$ statusBar.paintImmediately(statusBar.getBounds()); schemaLocPanel.getAllDataFromUI(); if (localizableIO.hasChanged()) { if (UIRegistry.askYesNoLocalized("SAVE", "CANCEL", UIRegistry.getResourceString("SchemaLocalizerFrame.NEEDS_SAVING"), "SAVE") == JOptionPane.YES_NO_OPTION) { localizableIO.save(); } else { return; } } Vector<Locale> stdLocales = SchemaI18NService.getInstance().getStdLocaleList(false); final JList list = new JList(stdLocales); list.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { setText(((Locale) value).getDisplayName()); } return this; } }); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); pb.add(UIHelper.createScrollPane(list), (new CellConstraints()).xy(1, 1)); pb.setDefaultDialogBorder(); final CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), getResourceString("SchemaLocalizerFrame.CHOOSE_LOCALE"), true, pb.getPanel()); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { dlg.getOkBtn().setEnabled(list.getSelectedValue() != null); } } }); dlg.createUI(); dlg.getOkBtn().setEnabled(false); UIHelper.centerAndShow(dlg); if (!dlg.isCancelled()) { Locale locale = (Locale) list.getSelectedValue(); if (locale != null) { FileDialog fileDlg = new FileDialog((Frame) UIRegistry.getTopWindow(), getResourceString("SchemaLocalizerFrame.SVFILENAME"), FileDialog.SAVE); fileDlg.setVisible(true); String fileName = fileDlg.getFile(); if (StringUtils.isNotEmpty(fileName)) { File outFile = new File(fileDlg.getDirectory() + File.separator + fileName); boolean savedOK = localizableIO.exportSingleLanguageToDirectory(outFile, locale); if (savedOK) { String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTEDTO", locale.getDisplayName(), outFile.getAbsolutePath()); UIRegistry.displayInfoMsgDlg(msg); } else { String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTING_ERR", outFile.getAbsolutePath()); UIRegistry.showError(msg); } } } } }
From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java
private void jchkCompletedActionPerformed(ActionEvent evt) { String todoName = (String) jcbTodos.getSelectedItem(); boolean isCompletedTodo = StringUtils.containsIgnoreCase(todoName, CoreObject.getConfig().getString(Constants.CONFIG_COMPLETED_ITEM_TAG)); if (jchkCompleted.isSelected() && !isCompletedTodo) { String message = "This to-do item will be marked as completed. Are you sure to continue?"; String title = "Complete To-Do Item"; int optionType = JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null, null, null);/*from w w w . ja v a2 s.c o m*/ if (selectedOption == JOptionPane.YES_OPTION) { String todoDescription = (String) jcbTodos.getSelectedItem(); BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription); Integer todoItemId = todoItem.getId(); String statusCode = BasecampBusiness.completeTodoItem(todoItemId.toString()); if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) { jtfHours.setText("0"); jDateChooser_IL.setDate(new Date()); jchkCompleted.setSelected(false); jtfDescription.setText(""); CoreObject.reloadTodoMap(); lblMessages.setText("ToDo has been completed!"); } else { lblMessages.setText("Failed! Status: " + statusCode); } } else { jchkCompleted.setSelected(false); } } else { if (isCompletedTodo) { String message = "This to-do item will be marked as uncompleted. Are you sure to activate the item?"; String title = "Activate To-Do Item"; int optionType = JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null, null, null); if (selectedOption == JOptionPane.YES_OPTION) { String todoDescription = (String) jcbTodos.getSelectedItem(); BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription); Integer todoItemId = todoItem.getId(); String statusCode = BasecampBusiness.uncompleteTodoItem(todoItemId.toString()); if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) { jtfHours.setText("0"); jDateChooser_IL.setDate(new Date()); jchkCompleted.setSelected(false); jtfDescription.setText(""); CoreObject.reloadTodoMap(); lblMessages.setText("ToDo is now active!"); } else { lblMessages.setText("Failed! Status: " + statusCode); } } else { jchkCompleted.setSelected(true); } } } }
From source file:com.dragoniade.deviantart.deviation.SearchRss.java
public List<Collection> getCollections() { List<Collection> collections = new ArrayList<Collection>(); if (search.getCollection() == null) { collections.add(null);//from w ww . j av a 2 s . c om return collections; } String queryString = "http://" + user + ".deviantart.com/" + search.getCollection() + "/"; GetMethod method = new GetMethod(queryString); try { int sc = -1; do { sc = client.executeMethod(method); if (sc != 200) { LoggableException ex = new LoggableException(method.getResponseBodyAsString()); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), ex); int res = DialogHelper.showConfirmDialog(owner, "An error has occured when contacting deviantART : error " + sc + ". Try again?", "Continue?", JOptionPane.YES_NO_OPTION); if (res == JOptionPane.NO_OPTION) { return null; } } } while (sc != 200); InputStream is = method.getResponseBodyAsStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int read = -1; while ((read = is.read(buffer)) > -1) { baos.write(buffer, 0, read); if (baos.size() > 2097152) { int res = DialogHelper.showConfirmDialog(owner, "An error has occured: The document is too big (over 2 megabytes) and look suspicious. Abort?", "Continue?", JOptionPane.YES_NO_OPTION); if (res == JOptionPane.YES_NO_OPTION) { return null; } } } String charsetName = method.getResponseCharSet(); String body = baos.toString(charsetName); String regex = user + ".deviantart.com/" + search.getCollection() + "/([0-9]+)\"[^>]*>([^<]+)<"; Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(body); while (matcher.find()) { String id = matcher.group(1); String name = matcher.group(2); Collection c = new Collection(Long.parseLong(id), name); collections.add(c); } } catch (IOException e) { } finally { method.releaseConnection(); } collections.add(null); return collections; }