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:contactsdirectory.frontend.MainJFrame.java
private void removePerson() { if (jListPerson.getSelectedIndex() < 0) { JOptionPane.showMessageDialog(this, localizedTexts.getString("noPersonSelected"), "", JOptionPane.INFORMATION_MESSAGE); return;//from w ww . j av a2s .c o m } if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(rootPane, localizedTexts.getString("deletePersonMsg"), "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { try { Person person = getSelectedPerson(); jProgressBar.setIndeterminate(true); jProgressBar.setVisible(true); RemovePersonSwingWorker worker = new RemovePersonSwingWorker(person); worker.execute(); ((DefaultListModel<Contact>) jListPerson.getModel()).removeElement(person); jProgressBar.setVisible(false); jProgressBar.setIndeterminate(false); } catch (RuntimeException e) { JOptionPane.showMessageDialog(this, localizedTexts.getString("noPersonRemoved"), localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE); } } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_link.java
private List<JComponent> getExtraOptions(final int row, final Object itemId) { List<JComponent> options = new LinkedList<JComponent>(); final List<Link> rowVisibleLinks = getVisibleElementsInTable(); final NetPlan netPlan = callback.getDesign(); if (itemId != null) { final long linkId = (long) itemId; JMenuItem lengthToEuclidean_thisLink = new JMenuItem("Set link length to node-pair Euclidean distance"); lengthToEuclidean_thisLink.addActionListener(new ActionListener() { @Override//from w w w. j a va 2 s .c om public void actionPerformed(ActionEvent e) { Link link = netPlan.getLinkFromId(linkId); Node originNode = link.getOriginNode(); Node destinationNode = link.getDestinationNode(); double euclideanDistance = netPlan.getNodePairEuclideanDistance(originNode, destinationNode); link.setLengthInKm(euclideanDistance); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(lengthToEuclidean_thisLink); JMenuItem lengthToHaversine_allNodes = new JMenuItem( "Set link length to node-pair Haversine distance (longitude-latitude) in km"); lengthToHaversine_allNodes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Link link = netPlan.getLinkFromId(linkId); Node originNode = link.getOriginNode(); Node destinationNode = link.getDestinationNode(); double haversineDistanceInKm = netPlan.getNodePairHaversineDistanceInKm(originNode, destinationNode); link.setLengthInKm(haversineDistanceInKm); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(lengthToHaversine_allNodes); JMenuItem scaleLinkLength_thisLink = new JMenuItem("Scale link length"); scaleLinkLength_thisLink.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double scaleFactor; while (true) { String str = JOptionPane.showInputDialog(null, "(Multiplicative) Scale factor", "Scale link length", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { scaleFactor = Double.parseDouble(str); if (scaleFactor < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Non-valid scale value. Please, introduce a non-negative number", "Error setting scale factor"); } } netPlan.getLinkFromId(linkId) .setLengthInKm(netPlan.getLinkFromId(linkId).getLengthInKm() * scaleFactor); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(scaleLinkLength_thisLink); if (netPlan.isMultilayer()) { Link link = netPlan.getLinkFromId(linkId); if (link.getCoupledDemand() != null) { JMenuItem decoupleLinkItem = new JMenuItem("Decouple link (if coupled to unicast demand)"); decoupleLinkItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { netPlan.getLinkFromId(linkId).getCoupledDemand().decouple(); model.setValueAt("", row, 20); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(decoupleLinkItem); } else { JMenuItem createLowerLayerDemandFromLinkItem = new JMenuItem( "Create lower layer demand from link"); createLowerLayerDemandFromLinkItem.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 lower layer to create the demand", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); Link link = netPlan.getLinkFromId(linkId); netPlan.addDemand(link.getOriginNode(), link.getDestinationNode(), link.getCapacity(), link.getAttributes(), netPlan.getNetworkLayerFromId(layerId)); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating lower layer demand from link"); } } } }); options.add(createLowerLayerDemandFromLinkItem); JMenuItem coupleLinkToDemand = new JMenuItem("Couple link to lower layer demand"); coupleLinkToDemand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); final JComboBox demandSelector = 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(); demandSelector.removeAllItems(); for (Demand demand : netPlan .getDemands(netPlan.getNetworkLayerFromId(selectedLayerId))) { if (demand.isCoupled()) continue; long ingressNodeId = demand.getIngressNode().getId(); long egressNodeId = demand.getEgressNode().getId(); String ingressNodeName = demand.getIngressNode().getName(); String egressNodeName = demand.getEgressNode().getName(); demandSelector.addItem(StringLabeller.unmodifiableOf(demand.getId(), "d" + demand.getId() + " [n" + ingressNodeId + " (" + ingressNodeName + ") -> n" + egressNodeId + " (" + egressNodeName + ")]")); } } if (demandSelector.getItemCount() == 0) { demandSelector.setEnabled(false); } else { demandSelector.setSelectedIndex(0); demandSelector.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 demand: ")); pane.add(demandSelector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the lower layer demand", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long demandId; try { demandId = (long) ((StringLabeller) demandSelector.getSelectedItem()) .getObject(); } catch (Throwable ex) { throw new RuntimeException("No demand was selected"); } netPlan.getDemandFromId(demandId) .coupleToUpperLayerLink(netPlan.getLinkFromId(linkId)); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error coupling lower layer demand to link"); } } } }); options.add(coupleLinkToDemand); } } } if (rowVisibleLinks.size() > 1) { if (!options.isEmpty()) options.add(new JPopupMenu.Separator()); JMenuItem caFixValue = new JMenuItem("Set capacity to all"); caFixValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double u_e; while (true) { String str = JOptionPane.showInputDialog(null, "Capacity value", "Set capacity to all table links", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { u_e = Double.parseDouble(str); if (u_e < 0) throw new NumberFormatException(); break; } catch (NumberFormatException ex) { ErrorHandling.showErrorDialog( "Non-valid capacity value. Please, introduce a non-negative number", "Error setting capacity value"); } } try { for (Link link : rowVisibleLinks) link.setCapacity(u_e); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set capacity to all links"); } } }); options.add(caFixValue); JMenuItem caFixValueUtilization = new JMenuItem("Set capacity to match a given utilization"); caFixValueUtilization.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double utilization; while (true) { String str = JOptionPane.showInputDialog(null, "Link utilization value", "Set capacity to all table links to match a given utilization", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { utilization = Double.parseDouble(str); if (utilization <= 0) throw new NumberFormatException(); break; } catch (NumberFormatException ex) { ErrorHandling.showErrorDialog( "Non-valid link utilization value. Please, introduce a strictly positive number", "Error setting link utilization value"); } } try { for (Link link : rowVisibleLinks) link.setCapacity(link.getOccupiedCapacity() / utilization); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set capacity to all links according to a given link utilization"); } } }); options.add(caFixValueUtilization); JMenuItem lengthToAll = new JMenuItem("Set link length to all"); lengthToAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double l_e; while (true) { String str = JOptionPane.showInputDialog(null, "Link length value (in km)", "Set link length to all table links", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { l_e = Double.parseDouble(str); if (l_e < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Non-valid link length value. Please, introduce a non-negative number", "Error setting link length"); } } NetPlan netPlan = callback.getDesign(); try { for (Link link : rowVisibleLinks) link.setLengthInKm(l_e); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set link length to all links"); } } }); options.add(lengthToAll); JMenuItem lengthToEuclidean_allLinks = new JMenuItem( "Set all table link lengths to node-pair Euclidean distance"); lengthToEuclidean_allLinks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { for (Link link : rowVisibleLinks) link.setLengthInKm(netPlan.getNodePairEuclideanDistance(link.getOriginNode(), link.getDestinationNode())); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set link length value to all links"); } } }); options.add(lengthToEuclidean_allLinks); JMenuItem lengthToHaversine_allLinks = new JMenuItem( "Set all table link lengths to node-pair Haversine distance (longitude-latitude) in km"); lengthToHaversine_allLinks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { for (Link link : rowVisibleLinks) { link.setLengthInKm(netPlan.getNodePairHaversineDistanceInKm(link.getOriginNode(), link.getDestinationNode())); } callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set link length value to all links"); } } }); options.add(lengthToHaversine_allLinks); JMenuItem scaleLinkLength_allLinks = new JMenuItem("Scale all table link lengths"); scaleLinkLength_allLinks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double scaleFactor; while (true) { String str = JOptionPane.showInputDialog(null, "(Multiplicative) Scale factor", "Scale (all) link length", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { scaleFactor = Double.parseDouble(str); if (scaleFactor < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Non-valid scale value. Please, introduce a non-negative number", "Error setting scale factor"); } } NetPlan netPlan = callback.getDesign(); try { for (Link link : rowVisibleLinks) link.setLengthInKm(link.getLengthInKm() * scaleFactor); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to scale link length"); } } }); options.add(scaleLinkLength_allLinks); if (netPlan.isMultilayer()) { final Set<Link> coupledLinks = rowVisibleLinks.stream().filter(e -> e.isCoupled()) .collect(Collectors.toSet()); if (!coupledLinks.isEmpty()) { JMenuItem decoupleAllLinksItem = new JMenuItem("Decouple all table links"); decoupleAllLinksItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Link link : coupledLinks) if (link.getCoupledDemand() == null) link.getCoupledMulticastDemand().decouple(); else link.getCoupledDemand().decouple(); int numRows = model.getRowCount(); for (int i = 0; i < numRows; i++) model.setValueAt("", i, 20); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(decoupleAllLinksItem); } if (coupledLinks.size() < rowVisibleLinks.size()) { JMenuItem createLowerLayerDemandsFromLinksItem = new JMenuItem( "Create lower layer unicast demands from uncoupled links"); createLowerLayerDemandsFromLinksItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JComboBox layerSelector = new WiderJComboBox(); for (NetworkLayer layer : netPlan.getNetworkLayers()) { if (layer.getId() == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = layer.getName(); String layerLabel = "Layer " + layer.getId(); if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layer.getId(), 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 lower layer to create demands", 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 (Link link : rowVisibleLinks) if (!link.isCoupled()) link.coupleToNewDemandCreated(layer); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating lower layer demands"); } } } }); options.add(createLowerLayerDemandsFromLinksItem); } } } return options; }
From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java
@Override public void windowClosing(WindowEvent arg0) { // save window location and bounds Point myLocation = getLocation(); Dimension mySize = getSize(); guiProps.setProperty(EditorConfiguration.PROPERTY_MAIN_WINDOW_LOCATION_X, myLocation.x + ""); guiProps.setProperty(EditorConfiguration.PROPERTY_MAIN_WINDOW_LOCATION_Y, myLocation.y + ""); guiProps.setProperty(EditorConfiguration.PROPERTY_MAIN_WINDOW_SIZE_X, mySize.width + ""); guiProps.setProperty(EditorConfiguration.PROPERTY_MAIN_WINDOW_SIZE_Y, mySize.height + ""); guiProps.save();/*from w w w . j a v a 2 s . co m*/ // cycle through open internal frames(documents) // and see if any of them need to be saved JInternalFrame[] openFrames = desktopPane.getAllFrames(); if (openFrames != null && openFrames.length > 0) { for (int x = 0; x < openFrames.length; x++) { JInternalFrame internalWin = openFrames[x]; if (internalWin instanceof EditorForm) { EditorForm ef = (EditorForm) internalWin; if (ef.getDocument() == null) { continue; } String filename = ef.getDocument().getFilename(); if (filename == null) { continue; } if (ef.isDirty()) { Object[] options = { EditorMessages.FILE_CHOOSER_BUTTON_TEXT_SAVE, "Discard" }; String message = filename + " has unsaved changes. Do you want to save or discard changes?"; String dTitle = "Unsaved changes"; int n = JOptionPane.showOptionDialog(this, message, dTitle, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.DEFAULT_OPTION || n == JOptionPane.YES_OPTION) { final GenericProgressDialog progress = new GenericProgressDialog( EditorMainWindow.getInstance(), true); progress.setMessage("Saving changes to " + ef.getDocument().getFilename()); try { final SCAPDocument sdoc = (SCAPDocument) ef.getDocument(); Runnable r = new Runnable() { @Override public void run() { try { sdoc.save(); } catch (Exception e) { progress.setException(e); } } }; progress.setRunnable(r); progress.pack(); progress.setLocationRelativeTo(this); progress.setVisible(true); if (progress.getException() != null) { throw (progress.getException()); } ef.setDirty(false); } catch (Exception e) { LOG.error("Error saving file " + filename, e); String errMessage = filename + " couldn't be saved. An error occured: " + e.getMessage(); dTitle = "File save error"; EditorUtil.showMessageDialog(this, errMessage, dTitle, JOptionPane.ERROR_MESSAGE); } } } } } } }
From source file:com._17od.upm.gui.DatabaseActions.java
public void importAccounts() throws TransportException, ProblemReadingDatabaseFile, IOException, CryptoException, PasswordDatabaseException { if (getLatestVersionOfDatabase()) { // Prompt for the file to import JFileChooser fc = new JFileChooser(); fc.setDialogTitle(Translator.translate("import")); int returnVal = fc.showOpenDialog(mainWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { File csvFile = fc.getSelectedFile(); // Unmarshall the accounts from the CSV file try { AccountsCSVMarshaller marshaller = new AccountsCSVMarshaller(); ArrayList accountsInCSVFile = marshaller.unmarshal(csvFile); ArrayList accountsToImport = new ArrayList(); boolean importCancelled = false; // Add each account to the open database. If the account // already exits the prompt to overwrite for (int i = 0; i < accountsInCSVFile.size(); i++) { AccountInformation importedAccount = (AccountInformation) accountsInCSVFile.get(i); if (database.getAccount(importedAccount.getAccountName()) != null) { Object[] options = { "Overwrite Existing", "Keep Existing", "Cancel" }; int answer = JOptionPane.showOptionDialog(mainWindow, Translator.translate("importExistingQuestion", importedAccount.getAccountName()), Translator.translate("importExistingTitle"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (answer == 1) { continue; // If keep existing then continue to the next iteration } else if (answer == 2) { importCancelled = true; break; // Cancel the import }/* w w w .ja v a2 s . c o m*/ } accountsToImport.add(importedAccount); } if (!importCancelled && accountsToImport.size() > 0) { for (int i = 0; i < accountsToImport.size(); i++) { AccountInformation accountToImport = (AccountInformation) accountsToImport.get(i); database.deleteAccount(accountToImport.getAccountName()); database.addAccount(accountToImport); } saveDatabase(); accountNames = getAccountNames(); filter(); } } catch (ImportException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } catch (CryptoException e) { JOptionPane.showMessageDialog(mainWindow, e.getMessage(), Translator.translate("problemImporting"), JOptionPane.ERROR_MESSAGE); } } } }
From source file:corelyzer.ui.CorelyzerApp.java
private void onDeleteSelectedSections(final int[] rows) { String mesg = "Are you sure you want to remove all\n" + "selected sections?"; Object[] options = { "Cancel", "Yes" }; int ans = JOptionPane.showOptionDialog(app.getMainFrame(), mesg, "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (ans == 1) { CoreGraph cg = CoreGraph.getInstance(); TrackSceneNode t = cg.getCurrentTrack(); if (t != null) { int tid = t.getId(); // delete in reverse order for (int i = rows.length - 1; i >= 0; i--) { int row = rows[i]; CoreSection cs = t.getCoreSection(row); if (cs != null) { int csid = cs.getId(); controller.deleteSection(tid, csid); }// www . ja v a 2 s . co m } } } }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * Launches dialog for Importing and Exporting Forms and Resources. *///from w w w . j a v a2 s. c o m public static boolean askBeforeStartingTool() { if (SubPaneMgr.getInstance().aboutToShutdown()) { Object[] options = { getResourceString("CONTINUE"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ }; return JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(getTopWindow(), getLocalizedMessage(getI18NKey("REI_MSG")), //$NON-NLS-1$ getResourceString(getI18NKey("REI_TITLE")), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } return false; }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
public boolean canClose() { if (session != null) { setFullScreenMode(false);/*from w w w . j a v a 2 s . c o m*/ if (JOptionPane.showConfirmDialog(this, "Close the current session and exit?", "Exit Application", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { return false; } /*if (browserFrame != null) { if (! ( (SessionProviderFrame) browserFrame).canExit()) { return false; } }*/ } return true; }
From source file:gdt.data.entity.ArchiveHandler.java
/** * Insert entities from the archive file into the database. * @param console main console instance * @param entihome$ the root directory of the database * @param file$ the path of the archive file. * @return the key of 'undo' entity.//from w ww. ja v a 2 s .c o m */ public static String insertEntities(JMainConsole console, String entihome$, String file$) { try { if (!ARCHIVE_CONTENT_ENTITIES.equals(detectContentOfArchive(file$))) { System.out.println("ArchiveHandler:insertEntites:wrong archive=" + file$); return null; } File cache = new File(System.getProperty("user.home") + "/.entigrator/cache"); if (!cache.exists()) cache.mkdirs(); FileExpert.clear(cache.getPath()); ArchiveHandler.extractEntities(cache.getPath(), file$); Entigrator entigrator = console.getEntigrator(entihome$); Sack undo = ArchiveHandler.prepareUndo(entigrator, cache.getPath()); String undoLocator$ = EntityHandler.getEntityLocator(entigrator, undo); JEntityPrimaryMenu.reindexEntity(console, undoLocator$); ArchiveHandler.fillUndo(entigrator, undo); int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Keep existing entities ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) ArchiveHandler.insertCache(entigrator, cache.getPath(), true); else ArchiveHandler.insertCache(entigrator, cache.getPath(), false); String[] sa = undo.elementList("entity"); if (sa != null) { String entityLocator$; for (String s : sa) { entityLocator$ = EntityHandler.getEntityLocatorAtKey(entigrator, s); JEntityPrimaryMenu.reindexEntity(console, entityLocator$); } } return undo.getKey(); } catch (Exception ee) { Logger.getLogger(ArchiveHandler.class.getName()).severe(ee.toString()); return null; } }
From source file:edu.ku.brc.af.tasks.BaseTask.java
/** * Asks where the source of the COs should come from. * (This needs to be moved to the BaseTask in specify package) * @return the source enum/*from w w w .ja v a 2 s.c o m*/ */ public ASK_TYPE askSourceOfObjects(final Class<? extends FormDataObjIFace> classForSrc) { Object[] options = { getResourceString("NEW_BT_USE_RS"), getResourceString("NEW_BT_ENTER_" + classForSrc.getSimpleName()) }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getResourceString("NEW_BT_CHOOSE_RS_" + classForSrc.getSimpleName()), getResourceString("NEW_BT_CHOOSE_RSOPT_TITLE"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.NO_OPTION) { return ASK_TYPE.EnterDataObjs; } else if (userChoice == JOptionPane.YES_OPTION) { return ASK_TYPE.ChooseRS; } return ASK_TYPE.Cancel; }
From source file:gdt.jgui.entity.JEntityPrimaryMenu.java
public void deleteEntity(JMainConsole console, String locator$) { try {//from www . j a v a 2s. c o m Properties locator = Locator.toProperties(locator$); entihome$ = locator.getProperty(Entigrator.ENTIHOME); Entigrator entigrator = console.getEntigrator(entihome$); entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Sack entity = entigrator.getEntityAtKey(entityKey$); int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete entity ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { entigrator.deleteEntity(entity); if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } else { console.back(); console.back(); } } } catch (Exception e) { LOGGER.severe(e.toString()); } }