List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE
int QUESTION_MESSAGE
To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.
Click Source Link
From source file:com.sshtools.powervnc.PowerVNCPanel.java
public boolean canClose() { if (isConnected()) { if (JOptionPane.showConfirmDialog(this, "Close the current session and exit?", "Exit Application", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { return false; }//from w w w.ja v a 2 s. co m } return true; }
From source file:contactsdirectory.frontend.MainJFrame.java
private void removeContact() { if (jListContact.getSelectedIndex() < 0) { JOptionPane.showMessageDialog(rootPane, localizedTexts.getString("noContactSelected"), "", JOptionPane.INFORMATION_MESSAGE); return;/*from www . j a v a 2 s . co m*/ } if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(rootPane, localizedTexts.getString("deleteContactMsg"), "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { try { Contact contact = (Contact) jListContact.getSelectedValue(); jProgressBar.setIndeterminate(true); jProgressBar.setVisible(true); RemoveContactSwingWorker worker = new RemoveContactSwingWorker(contact); worker.execute(); ((DefaultListModel<Contact>) jListContact.getModel()).removeElement(contact); jProgressBar.setVisible(false); jProgressBar.setIndeterminate(false); } catch (RuntimeException e) { JOptionPane.showMessageDialog(this, localizedTexts.getString("removeContactErrMsg"), localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE); } } }
From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java
private int showPromptToSaveMessageBeforeClosingIt(Hl7V2MessageCollection theMsg, boolean theShowCancelButton) { Component parentComponent = myView.getFrame(); Object message = "<html>The following file is unsaved, do you want to save before closing?<br>" + theMsg.getBestDescription() + "</html>"; String title = DIALOG_TITLE;/* ww w.j av a 2s . c o m*/ int optionType = theShowCancelButton ? JOptionPane.YES_NO_CANCEL_OPTION : JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; return JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageType); }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * @param objWrapper/*from w w w. j a va 2 s.com*/ * @param groupObjWrapper * @param selectedObjTitle */ /*private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper userObjWrapperArg, final DataModelObjBaseWrapper groupObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout)(infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = groupObjWrapperArg != null ? groupObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal)dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] {getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL")}; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, userObjWrapperArg, groupObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; groupObjWrapper = groupObjWrapperArg; collectionObjWrapper = collectionWrapperArg; }*/ private void showInfoPanel(final DataModelObjBaseWrapper objWrapperArg, final DataModelObjBaseWrapper secondObjWrapperArg, final DataModelObjBaseWrapper collectionWrapperArg, final String selectedObjTitle) { String className = objWrapperArg.getType(); CardLayout cardLayout = (CardLayout) (infoCards.getLayout()); // This displays the panel that says they have all permissions DataModelObjBaseWrapper wrpr = secondObjWrapperArg != null ? secondObjWrapperArg : objWrapperArg; if (wrpr != null) { Object dataObj = wrpr.getDataObj(); if (dataObj instanceof SpPrincipal && ((SpPrincipal) dataObj).getGroupSubClass().equals(AdminPrincipal.class.getName())) { cardLayout.show(infoCards, AdminPrincipal.class.getCanonicalName()); return; } } if (currentEditorPanel != null && currentEditorPanel.hasChanged()) { String[] optionLabels = new String[] { getResourceString("SaveChangesBtn"), getResourceString("DiscardChangesBtn"), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("SaveChanges", currentTitle), getResourceString("SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionLabels, optionLabels[0]); if (rv == JOptionPane.YES_OPTION) { doSave(true); } } currentTitle = selectedObjTitle; // show info panel that corresponds to the type of object selected AdminInfoSubPanelWrapper panelWrapper = infoSubPanels.get(className); currentEditorPanel = editorPanels.get(className); if (currentEditorPanel != null) { currentEditorPanel.setHasChanged(false); } // fill form with object data if (panelWrapper != null) { currentDisplayPanel = panelWrapper; if (currentDisplayPanel.setData(objWrapperArg, secondObjWrapperArg, collectionWrapperArg, nodesDivision) && currentEditorPanel != null) { currentEditorPanel.setHasChanged(true); } cardLayout.show(infoCards, className); } objWrapper = objWrapperArg; secondObjWrapper = secondObjWrapperArg; collectionWrapper = collectionWrapperArg; }
From source file:AppSpringLayout.java
protected void saveFileChooser(String fileUrl) { fc.setDialogTitle("Specify name of the file to save"); File output = new File(fc.getSelectedFile().toString()); // check if file already exists, ask user if they wish to overwrite it if (output.exists()) { int response = JOptionPane.showConfirmDialog(null, // "Do you want to replace the existing file?", // "Confirm", JOptionPane.YES_NO_OPTION, // JOptionPane.QUESTION_MESSAGE); if (response != JOptionPane.YES_OPTION) { return; }// w w w. ja v a2 s .c o m } fc.setSelectedFile(output); try { URL fileNameAsUrl = new URL(fileUrl); originalImage = ImageIO.read(fileNameAsUrl); ImageIO.write(toBufferedImage(originalImage), "jpeg", output); System.out.println("image saved, in the folder: " + output.getAbsolutePath()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java
private List<JComponent> getExtraOptions(final int row, final Object itemId) { List<JComponent> options = new LinkedList<JComponent>(); final int numRows = model.getRowCount(); final NetPlan netPlan = callback.getDesign(); final List<Demand> tableVisibleDemands = getVisibleElementsInTable(); JMenuItem offeredTrafficToAll = new JMenuItem("Set offered traffic to all"); offeredTrafficToAll.addActionListener(new ActionListener() { @Override// w w w . j a va 2 s .co m public void actionPerformed(ActionEvent e) { double h_d; while (true) { String str = JOptionPane.showInputDialog(null, "Offered traffic volume", "Set traffic value to all demands in the table", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { h_d = Double.parseDouble(str); if (h_d < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog("Please, introduce a non-negative number", "Error setting offered traffic"); } } NetPlan netPlan = callback.getDesign(); try { for (Demand d : tableVisibleDemands) d.setOfferedTraffic(h_d); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set offered traffic to all demands in the table"); } } }); options.add(offeredTrafficToAll); JMenuItem scaleOfferedTrafficToAll = new JMenuItem("Scale offered traffic all demands in the table"); scaleOfferedTrafficToAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double scalingFactor; while (true) { String str = JOptionPane.showInputDialog(null, "Scaling factor to multiply to all offered traffics", "Scale offered traffic", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { scalingFactor = Double.parseDouble(str); if (scalingFactor < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog("Please, introduce a non-negative number", "Error setting offered traffic"); } } try { for (Demand d : tableVisibleDemands) d.setOfferedTraffic(d.getOfferedTraffic() * scalingFactor); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to scale demand offered traffics"); } } }); options.add(scaleOfferedTrafficToAll); JMenuItem setServiceTypes = new JMenuItem( "Set traversed resource types (to one or all demands in the table)"); setServiceTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { Demand d = netPlan.getDemandFromId((Long) itemId); String[] headers = StringUtils.arrayOf("Order", "Type"); Object[][] data = { null, null }; DefaultTableModel model = new ClassAwareTableModelImpl(data, headers); AdvancedJTable table = new AdvancedJTable(model); JButton addRow = new JButton("Add new traversed resource type"); addRow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object[] newRow = { table.getRowCount(), "" }; ((DefaultTableModel) table.getModel()).addRow(newRow); } }); JButton removeRow = new JButton("Remove selected"); removeRow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((DefaultTableModel) table.getModel()).removeRow(table.getSelectedRow()); for (int t = 0; t < table.getRowCount(); t++) table.getModel().setValueAt(t, t, 0); } }); JButton removeAllRows = new JButton("Remove all"); removeAllRows.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { while (table.getRowCount() > 0) ((DefaultTableModel) table.getModel()).removeRow(0); } }); List<String> oldTraversedResourceTypes = d.getServiceChainSequenceOfTraversedResourceTypes(); Object[][] newData = new Object[oldTraversedResourceTypes.size()][headers.length]; for (int i = 0; i < oldTraversedResourceTypes.size(); i++) { newData[i][0] = i; newData[i][1] = oldTraversedResourceTypes.get(i); } ((DefaultTableModel) table.getModel()).setDataVector(newData, headers); JPanel pane = new JPanel(); JPanel pane2 = new JPanel(); pane.setLayout(new BorderLayout()); pane2.setLayout(new BorderLayout()); pane.add(new JScrollPane(table), BorderLayout.CENTER); pane2.add(addRow, BorderLayout.WEST); pane2.add(removeRow, BorderLayout.EAST); pane2.add(removeAllRows, BorderLayout.SOUTH); pane.add(pane2, BorderLayout.SOUTH); final String[] optionsArray = new String[] { "Set to selected demand", "Set to all demands", "Cancel" }; int result = JOptionPane.showOptionDialog(null, pane, "Set traversed resource types", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, optionsArray, optionsArray[0]); if ((result != 0) && (result != 1)) return; final boolean setToAllDemands = (result == 1); List<String> newTraversedResourcesTypes = new LinkedList<>(); for (int j = 0; j < table.getRowCount(); j++) { String travResourceType = table.getModel().getValueAt(j, 1).toString(); newTraversedResourcesTypes.add(travResourceType); } if (setToAllDemands) { for (Demand dd : tableVisibleDemands) if (!dd.getRoutes().isEmpty()) throw new Net2PlanException( "It is not possible to set the resource types traversed to demands with routes"); for (Demand dd : tableVisibleDemands) dd.setServiceChainSequenceOfTraversedResourceTypes(newTraversedResourcesTypes); } else { if (!d.getRoutes().isEmpty()) throw new Net2PlanException( "It is not possible to set the resource types traversed to demands with routes"); d.setServiceChainSequenceOfTraversedResourceTypes(newTraversedResourcesTypes); } callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set traversed resource types"); } } }); options.add(setServiceTypes); if (itemId != null && netPlan.isMultilayer()) { final long demandId = (long) itemId; if (netPlan.getDemandFromId(demandId).isCoupled()) { JMenuItem decoupleDemandItem = new JMenuItem("Decouple demand"); decoupleDemandItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { netPlan.getDemandFromId(demandId).decouple(); model.setValueAt("", row, 3); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(decoupleDemandItem); } else { JMenuItem createUpperLayerLinkFromDemandItem = new JMenuItem("Create upper layer link from demand"); createUpperLayerLinkFromDemandItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the upper layer to create the link", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); netPlan.getDemandFromId(demandId) .coupleToNewLinkCreated(netPlan.getNetworkLayerFromId(layerId)); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND, NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating upper layer link from demand"); } } } }); options.add(createUpperLayerLinkFromDemandItem); JMenuItem coupleDemandToLink = new JMenuItem("Couple demand to upper layer link"); coupleDemandToLink.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); final JComboBox linkSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (layerSelector.getSelectedIndex() >= 0) { long selectedLayerId = (Long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); NetworkLayer selectedLayer = netPlan.getNetworkLayerFromId(selectedLayerId); linkSelector.removeAllItems(); Collection<Link> links_thisLayer = netPlan.getLinks(selectedLayer); for (Link link : links_thisLayer) { if (link.isCoupled()) continue; String originNodeName = link.getOriginNode().getName(); String destinationNodeName = link.getDestinationNode().getName(); linkSelector.addItem(StringLabeller.unmodifiableOf(link.getId(), "e" + link.getIndex() + " [n" + link.getOriginNode().getIndex() + " (" + originNodeName + ") -> n" + link.getDestinationNode().getIndex() + " (" + destinationNodeName + ")]")); } } if (linkSelector.getItemCount() == 0) { linkSelector.setEnabled(false); } else { linkSelector.setSelectedIndex(0); linkSelector.setEnabled(true); } } }); layerSelector.setSelectedIndex(-1); layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[][]")); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector, "growx, wrap"); pane.add(new JLabel("Select link: ")); pane.add(linkSelector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the upper layer link", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); long linkId; try { linkId = (long) ((StringLabeller) linkSelector.getSelectedItem()).getObject(); } catch (Throwable ex) { throw new RuntimeException("No link was selected"); } netPlan.getDemandFromId(demandId) .coupleToUpperLayerLink(netPlan.getLinkFromId(linkId)); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND, NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error coupling upper layer link to demand"); } } } }); options.add(coupleDemandToLink); } if (numRows > 1) { JMenuItem decoupleAllDemandsItem = null; JMenuItem createUpperLayerLinksFromDemandsItem = null; final Set<Demand> coupledDemands = tableVisibleDemands.stream().filter(d -> d.isCoupled()) .collect(Collectors.toSet()); if (!coupledDemands.isEmpty()) { decoupleAllDemandsItem = new JMenuItem("Decouple all demands"); decoupleAllDemandsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Demand d : new LinkedHashSet<Demand>(coupledDemands)) d.decouple(); int numRows = model.getRowCount(); for (int i = 0; i < numRows; i++) model.setValueAt("", i, 3); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); } if (coupledDemands.size() < tableVisibleDemands.size()) { createUpperLayerLinksFromDemandsItem = new JMenuItem( "Create upper layer links from uncoupled demands"); createUpperLayerLinksFromDemandsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the upper layer to create links", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); for (Demand demand : tableVisibleDemands) if (!demand.isCoupled()) demand.coupleToNewLinkCreated(layer); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND, NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating upper layer links"); } } } }); } if (!options.isEmpty() && (decoupleAllDemandsItem != null || createUpperLayerLinksFromDemandsItem != null)) { options.add(new JPopupMenu.Separator()); if (decoupleAllDemandsItem != null) options.add(decoupleAllDemandsItem); if (createUpperLayerLinksFromDemandsItem != null) options.add(createUpperLayerLinksFromDemandsItem); } } } return options; }
From source file:edu.ku.brc.specify.config.init.DatabasePanel.java
/** * Check the engine and charset./*from w w w . j a v a 2s . c o m*/ * @param props the props * @return true if it exists */ protected boolean checkEngineCharSet(final Properties props) { final String databaseName = props.getProperty(DBNAME); DBMSUserMgr mgr = null; try { String itUsername = props.getProperty(DBUSERNAME); String itPassword = props.getProperty(DBPWD); String hostName = props.getProperty(HOSTNAME); if (!DBConnection.getInstance().isEmbedded()) { mgr = DBMSUserMgr.getInstance(); if (mgr.connectToDBMS(itUsername, itPassword, hostName)) { if (!mgr.verifyEngineAndCharSet(databaseName)) { String errMsg = mgr.getErrorMsg(); if (errMsg != null) { Object[] options = { getResourceString("CLOSE") }; JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), errMsg, getResourceString("DEL_CUR_DB_TITLE"), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } return false; } return true; } } else { return true; } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, ex); } finally { if (mgr != null) { mgr.close(); } } return false; }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @return true if no unsaved changes are present * else return results of prompt to save *//* w w w . ja v a 2 s . co m*/ protected boolean checkForChanges() { // if (termList != null) // { // int s = termList.getSelectedIndex(); // if (s != -1) // { // L10NItem entry = srcFile.getKey(s); // entry.setDstStr(textField.getText()); // } // if (srcFile.isEdited()) // { // int response = JOptionPane.showOptionDialog((Frame )getTopWindow(), // String.format(getResourceString("StrLocalizerApp.SaveChangesMsg"), destFile.getPath()), // getResourceString("StrLocalizerApp.SaveChangesTitle"), // JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION); // if (response == JOptionPane.CANCEL_OPTION) // { // return false; // } // if (response == JOptionPane.YES_OPTION) // { // doSave(); // return true; //what if it fails? // } // } // return true; // } boolean hasChanges = false; for (L10NFile f : srcFiles) { if (f.isChanged()) { hasChanges = true; break; } } if (hasChanges) { int response = JOptionPane.showOptionDialog((Frame) getTopWindow(), "Changes have not been saved.\n\nDo you wish to save them?", getResourceString("StrLocalizerApp.SaveChangesTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION); if (response == JOptionPane.CANCEL_OPTION) { return false; } if (response == JOptionPane.YES_OPTION) { doSave(); return true; //what if it fails? } } return true; }
From source file:com.iucosoft.eavertizare.gui.MainJFrame.java
private void sendAvertizare(String tipAvertizare) { int selectedRowIndex = jTableClients.getSelectedRow(); Client client = null;/* w w w . j a v a2s. c o m*/ int contor = 0; String mesaj = ""; Icon icon = new ImageIcon(getClass().getResource("/images/help_and_support.png")); if (selectedRowIndex != -1) { int rez = JOptionPane.showConfirmDialog(this, "Doriti sa modificati mesajul ?", "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon); switch (rez) { case JOptionPane.YES_OPTION: client = cientForIndex(selectedRowIndex); sendAvertizareJFrame(client.getFirma(), client, tipAvertizare); break; case JOptionPane.NO_OPTION: client = cientForIndex(selectedRowIndex); SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); String mesajClient = client.getFirma().getMesajPentruClienti() .replaceFirst("nume", client.getNume()).replaceFirst("prenume", client.getPrenume()) .replaceFirst("data", sdf.format(client.getDateExpirare()).toString()) .replaceFirst("compania", client.getFirma().getNumeFirma()); switch (tipAvertizare) { case "SMS AND E-MAIL": mesaj = "Sms si e-mail"; { try { client.setTrimis(true); clientsDao.update(client.getFirma(), client); smsSender.sendSms(client.getNrTelefon(), mesajClient); mailSender.sendMail(client.getEmail(), "E-avetizare", mesajClient); } catch (Exception ex) { //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); contor = 1; } } clientiTableModel.refreshModel(); break; case "SMS": mesaj = "Sms"; try { smsSender.sendSms(client.getNrTelefon(), mesajClient); } catch (Exception ex) { //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); contor = 1; } break; case "E-MAIL": mesaj = "E-mail"; try { mailSender.sendMail(client.getEmail(), "E-avetizare", mesajClient); } catch (Exception ex) { //Logger.getLogger(MainJFrame.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(new JFrame(), "Verificai conexiunea la internet!\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); contor = 1; } break; } if (contor != 1) { JOptionPane.showMessageDialog(MainJFrame.this, mesaj + " transmis cu succes!", "Info", JOptionPane.INFORMATION_MESSAGE); } break; case JOptionPane.CLOSED_OPTION: break; } } else { JOptionPane.showMessageDialog(this, "Selectati clientul!", "Info", JOptionPane.INFORMATION_MESSAGE); } }
From source file:brainflow.app.toplevel.BrainFlow.java
private void register(IImageSource dataSource) { DataSourceManager manager = DataSourceManager.get(); boolean alreadyRegistered = manager.isRegistered(dataSource); try {//from w w w. ja va 2s . co m if (alreadyRegistered) { long lastModified = dataSource.getDataFile().getContent().getLastModifiedTime(); long lastRead = dataSource.whenRead(); if (lastModified > lastRead) { StringBuffer sb = new StringBuffer(); sb.append("Image " + dataSource.getDataFile().getName().getBaseName()); sb.append( "has already been loaded in BrainFlow, but has changed on disk. Would you like to reload?"); Integer ret = JOptionPane.showConfirmDialog(brainFrame, sb.toString(), "Image has been modified", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.YES_OPTION) { dataSource.releaseData(); } } else { log.info(dataSource.getStem() + " is already registered ..."); } } else { manager.register(dataSource); } } catch (FileSystemException e) { JOptionPane.showMessageDialog(brainFrame, "Error accessing file information: " + e.getMessage()); } }