List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE
int PLAIN_MESSAGE
To view the source code for javax.swing JOptionPane PLAIN_MESSAGE.
Click Source Link
From source file:com.freedomotic.jfrontend.MainWindow.java
private void mnuRenameRoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuRenameRoomActionPerformed ZoneLogic zone = drawer.getSelectedZone(); if (zone == null) { JOptionPane.showMessageDialog(this, i18n.msg("select_room_first"), i18n.msg("room_rename_popup_title"), JOptionPane.ERROR_MESSAGE); } else {// w ww. j a va 2s . c o m String input = JOptionPane.showInputDialog(this, i18n.msg("enter_new_name_for_zone") + zone.getPojo().getName(), i18n.msg("room_rename_popup_title"), JOptionPane.PLAIN_MESSAGE); if (input != null && !input.isEmpty()) { zone.getPojo().setName(input.trim()); } else { JOptionPane.showMessageDialog(this, i18n.msg("room_name_cannot_be_empty"), i18n.msg("room_rename_popup_title"), JOptionPane.ERROR_MESSAGE); } drawer.setNeedRepaint(true); } }
From source file:edu.harvard.i2b2.previousquery.ui.QueryPreviousRunsPanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Rename ...")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1)); if (inputValue != null) { String newQueryName = (String) inputValue; String requestXml = ndata.writeRenameQueryXML(newQueryName); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); }// w w w . j a v a2 s .c o m if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { ndata.name(newQueryName + " [" + ndata.userId() + "]"); node.setUserObject(ndata); // DefaultMutableTreeNode parent = // (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?", "Delete Query Dialog", JOptionPane.YES_NO_OPTION); if (selectedValue.equals(JOptionPane.YES_OPTION)) { System.out.println("delete " + ndata.name()); String requestXml = ndata.writeDeleteQueryXML(); // System.out.println(requestXml); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { // TO DO // response = // QueryListNamesClient.sendQueryRequestSOAP(requestXml); } else { response = QueryListNamesClient.sendQueryRequestREST(requestXml); } if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { treeModel.removeNodeFromParent(node); // jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) { String status = loadPreviousQueries(false); if (status.equalsIgnoreCase("")) { reset(200, false); } else if (status.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } } }
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//from ww 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:ca.osmcanada.osvuploadr.JPMain.java
private void jbUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbUploadActionPerformed String path = ca.osmcanada.osvuploadr.JFMain.class.getProtectionDomain().getCodeSource().getLocation() .getPath();//www. j a va 2s .co m String decodedPath = ""; try { decodedPath = new File(URLDecoder.decode(path, "UTF-8")).getParentFile().getPath(); } catch (Exception ex) { Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "decodePath", ex); } File id = new File(decodedPath + "/access_token.txt"); String accessToken = ""; System.out.println("id_file exists:" + id.exists()); if (!id.exists()) { try { String[] buttons = { new String(r.getString("automatically").getBytes(), "UTF-8"), new String(r.getString("manually").getBytes(), "UTF-8"), new String(r.getString("cancel").getBytes(), "UTF-8") }; int rc = JOptionPane.showOptionDialog(null, new String(r.getString("login_to_osm").getBytes(), "UTF-8"), new String(r.getString("confirmation").getBytes(), "UTF-8"), JOptionPane.INFORMATION_MESSAGE, 0, null, buttons, buttons[0]); String token = ""; System.out.println("GetOSMUser"); switch (rc) { case 0: String usr = ""; String psw = ""; JTextField tf = new JTextField(); JPasswordField pf = new JPasswordField(); rc = JOptionPane.showConfirmDialog(null, tf, new String(r.getString("email_osm_usr").getBytes(), "UTF-8"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (rc == JOptionPane.OK_OPTION) { usr = tf.getText(); } else { return; } rc = JOptionPane.showConfirmDialog(null, pf, new String(r.getString("enter_password").getBytes(), "UTF-8"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (rc == JOptionPane.OK_OPTION) { psw = new String(pf.getPassword()); } else { return; } token = GetOSMUser(usr, psw); break; case 1: token = GetOSMUser(); break; case 2: return; } Path targetPath = Paths.get("./access_token.txt"); byte[] bytes = token.split("\\|")[0].getBytes(StandardCharsets.UTF_8); Files.write(targetPath, bytes, StandardOpenOption.CREATE); accessToken = token.split("\\|")[0]; String accessSecret = token.split("\\|")[1]; SendAuthTokens(accessToken, accessSecret); } catch (Exception ex) { Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "GetOSMUser", ex); } } else { try { List<String> token = Files.readAllLines(Paths.get(id.getPath())); if (token.size() > 0) { accessToken = token.get(0); //read first line } } catch (Exception ex) { Logger.getLogger(JPMain.class.getName()).log(Level.SEVERE, "readAllLines", ex); } } System.out.println("Access Token obtained from file or OSM:" + accessToken); //Start processing list for (String item : listDir.getItems()) { System.out.println("Processing folder:" + item); Process(item, accessToken); } //um = new UploadManager(listDir.getItems()); //um.start(); }
From source file:com.freedomotic.jfrontend.MainWindow.java
private void mnuChangeRendererActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuChangeRendererActionPerformed Object[] possibilities = { "list", "plain", "image", "photo" }; String input = (String) JOptionPane.showInputDialog(this, i18n.msg("select_renderer"), i18n.msg("select_renderer_title"), JOptionPane.PLAIN_MESSAGE, null, possibilities, drawer.getCurrEnv().getPojo().getRenderer()); //If a string was returned if ((input != null) && (!input.isEmpty())) { changeRenderer(input);//from www . j a va 2s .co m } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Displays a dialog that allows the user to edit the properties for the * current chart.//w w w . j av a 2 s .c o m */ private void attemptEditChartProperties() { ChartPropertyEditPanel panel = new ChartPropertyEditPanel(chart); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { panel.updateChartProperties(chart); } }
From source file:dataviewer.DataViewer.java
private void view(String _sql) { final String sql = _sql; // check pivot t[THREAD.view.ordinal()].stop();// ww w. ja v a 2 s . c o m t[THREAD.view.ordinal()] = new Thread(new Runnable() { @Override public void run() { try { Timing timer = new Timing(); boolean alive = t[THREAD.read.ordinal()].isAlive(); if (!alive) { txt_count.setText("Running query ... "); } DB db = new DB("./db/" + table + ".db"); db.open(); ResultSet results = db.execute(sql); String csv = ""; CSVWriter out = null; boolean asked = false; if (export && ck_export.isEnabled()) { csv = JOptionPane.showInputDialog(new JFrame(""), "Please enter the name of the file without extension.", "Export File Name", JOptionPane.PLAIN_MESSAGE); if (csv == null) { csv = ""; } if (!csv.equals("")) { out = new CSVWriter(new FileWriter("./output/" + csv + ".txt"), '\n', CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.NO_ESCAPE_CHARACTER); } } String _delimiter = StringEscapeUtils.unescapeJava(delimiter); StringBuilder sb = new StringBuilder(); List<String> cols = new ArrayList(); for (int i = 0; i < results.getMetaData().getColumnCount(); ++i) { String name = results.getMetaData().getColumnName(i + 1); cols.add(name); sb.append(name).append(_delimiter); } sb.setLength(sb.length() - 1); DefaultTableModel model = new DefaultTableModel(); for (int i = 0; i < cols.size(); ++i) { model.addColumn(cols.get(i)); } if (!csv.equals("")) { out.writeNext(sb.toString()); } String[] vals; long count = 0; boolean is_model_render = false; while (results.next()) { count++; vals = new String[cols.size()]; sb = new StringBuilder(); for (int i = 0; i < cols.size(); ++i) { vals[i] = results.getString(cols.get(i)); sb.append(vals[i]).append(_delimiter); } sb.setLength(sb.length() - 1); if (!csv.equals("")) { out.writeNext(sb.toString()); } if (asked == false && is_model_render == false && count > N) { if (JOptionPane.showConfirmDialog(null, "Number of rows are more than " + N + ". Stop?", "", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { renderData(model); is_model_render = true; } asked = true; } if (is_model_render == false) { model.addRow(vals); } } db.close(); if (is_model_render == false) { if (transpose) { tb_data.setModel(model); transpose((DefaultTableModel) tb_data.getModel()); } else { renderData(model); } } if (!csv.equals("")) { out.close(); txt_count.setText(count + " records are queried from " + table + " and exported to /output/" + csv + ".txt. Took " + timer.getSec() + "s."); } else if (!alive) { if (is_model_render) { txt_count.setText(count + " records are queried from " + table + " but stopped at " + N + ". Took " + timer.getSec() + "s."); } else { txt_count.setText(count + " records are queried from " + table + ". Took " + timer.getSec() + "s."); } } } catch (Exception e) { txt_count.setText(e.getMessage()); } } }); t[THREAD.view.ordinal()].start(); }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed int idd = (int) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 0); ChoixStat1 chStat = new ChoixStat1(); ChoixStat2 chStat2 = new ChoixStat2(); Object[] options = { "BACK", "NEXT" }; int a = JOptionPane.showOptionDialog(null, chStat, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); int b = 0;// w ww.j av a 2 s . c o m if (chStat.jRadiosexe.isSelected() && chStat.jRadioconsult.isSelected()) { b = 0; } if (chStat.jRadiosexe.isSelected() && chStat.jRadiores.isSelected()) { b = 1; } if (chStat.jRadiooperation.isSelected() && chStat.jRadioconsult.isSelected()) { b = 2; } if (chStat.jRadiooperation.isSelected() && chStat.jRadiores.isSelected()) { b = 3; } if (a == 1 && b == 2) { chStat.setVisible(false); Object[] options2 = { "Annuler", "Afficher la Statistique" }; int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options2, options[0]); if (c == 1) { java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime(); java.sql.Date sqlDate = new java.sql.Date(d1.getTime()); java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime(); java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime()); Charts charts = new Charts(); XYSeriesCollection dataxy = charts.createDataset(sqlDate.toString(), sqlDate2.toString(), idd); final JFreeChart chart = ChartFactory.createXYLineChart( "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Consultations", // dataxy, // Dataset PlotOrientation.VERTICAL, // true, true, false); XYItemRenderer rend = chart.getXYPlot().getRenderer(); ChartPanel crepart = new ChartPanel(chart); Plot plot = chart.getPlot(); JPanel jpan = new JPanel(); JButton button = new JButton("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "Chart d'volution des consultations", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } } if (a == 1 && (b == 3)) { Object[] options2 = { "Annuler", "Afficher la Statistique" }; int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options2, options[0]); if (c == 1) { java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime(); java.sql.Date sqlDate = new java.sql.Date(d1.getTime()); java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime(); java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime()); Charts charts = new Charts(); // JFreeChart chrt = ChartFactory.createXYStepAreaChart(null, null, null, null, PlotOrientation.HORIZONTAL, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled) XYSeriesCollection dataxy = charts.createDatasetRes(sqlDate.toString(), sqlDate2.toString(), idd); final JFreeChart chart = ChartFactory.createXYLineChart( "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Reservations", dataxy, PlotOrientation.VERTICAL, true, true, false); XYItemRenderer rend = chart.getXYPlot().getRenderer(); ChartPanel crepart = new ChartPanel(chart); Plot plot = chart.getPlot(); JPanel jpan = new JPanel(); jpan.setLayout(new FlowLayout(FlowLayout.LEADING)); JButton button = new JButton(); button.setText("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "Test", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } } if (a == 1 && b == 0) { ConsultationDAO cdao = ConsultationDAO.getInstance(); DefaultPieDataset union = new DefaultPieDataset(); union.setValue("Homme", cdao.consultationCounterByGender(false, idd)); union.setValue("Femme", cdao.consultationCounterByGender(true, idd)); final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); Plot plot = repart.getPlot(); JPanel jpan = new JPanel(); JButton button = new JButton("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } if (a == 1 && b == 1) { DefaultPieDataset union = new DefaultPieDataset(); ReservationDAO dAO = ReservationDAO.getInstance(); union.setValue("Homme", dAO.reservationCounterByGender(false, idd)); union.setValue("Femme", dAO.reservationCounterByGender(true, idd)); final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); Plot plot = repart.getPlot(); JPanel jpan = new JPanel(); JButton button = new JButton("Sauvegarder"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser(); chooser.showSaveDialog(jPanel3); String path = chooser.getSelectedFile().getPath(); if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) { path = path + ".png"; } File f = new File(path); ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600); if (f.exists() && !f.isDirectory()) { JOptionPane.showMessageDialog(null, "Sauvegarde Effectue"); Desktop.getDesktop().open(f); } } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }); jpan.add(crepart); jpan.add(button); JOptionPane.showConfirmDialog(null, jpan, "Chart de la rpartition des achat par sexe", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); } }
From source file:game.Clue.ClueGameUI.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: String s = (String) JOptionPane.showInputDialog(this, "Who do you think is the murderer?", "Solved It???", JOptionPane.PLAIN_MESSAGE); }
From source file:net.rptools.maptool.client.functions.InputFunction.java
@Override public Object childEvaluate(Parser parser, String functionName, List<Object> parameters) throws EvaluationException, ParserException { // Extract the list of specifier strings from the parameters // "name | value | prompt | inputType | options" List<String> varStrings = new ArrayList<String>(); for (Object param : parameters) { String paramStr = (String) param; if (StringUtils.isEmpty(paramStr)) { continue; }/* w w w. j av a2 s . c om*/ // Multiple vars can be packed into a string, separated by "##" List<String> substrings = new ArrayList<String>(); StrListFunctions.parse(paramStr, substrings, "##"); for (String varString : substrings) { if (StringUtils.isEmpty(paramStr)) { continue; } varStrings.add(varString); } } // Create VarSpec objects from each variable's specifier string List<VarSpec> varSpecs = new ArrayList<VarSpec>(); for (String specifier : varStrings) { VarSpec vs; try { vs = new VarSpec(specifier); } catch (VarSpec.SpecifierException se) { throw new ParameterException(se.msg); } catch (InputType.OptionException oe) { throw new ParameterException(I18N.getText("macro.function.input.invalidOptionType", oe.key, oe.value, oe.type, specifier)); } varSpecs.add(vs); } // Check if any variables were defined if (varSpecs.isEmpty()) return BigDecimal.ONE; // No work to do, so treat it as a successful invocation. // UI step 1 - First, see if a token is in context. VariableResolver varRes = parser.getVariableResolver(); Token tokenInContext = null; if (varRes instanceof MapToolVariableResolver) { tokenInContext = ((MapToolVariableResolver) varRes).getTokenInContext(); } String dialogTitle = "Input Values"; if (tokenInContext != null) { String name = tokenInContext.getName(), gm_name = tokenInContext.getGMName(); boolean isGM = MapTool.getPlayer().isGM(); String extra = ""; if (isGM && gm_name != null && gm_name.compareTo("") != 0) extra = " for " + gm_name; else if (name != null && name.compareTo("") != 0) extra = " for " + name; dialogTitle = dialogTitle + extra; } // UI step 2 - build the panel with the input fields InputPanel ip = new InputPanel(varSpecs); // Calculate the height // TODO: remove this workaround int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height; int maxHeight = screenHeight * 3 / 4; Dimension ipPreferredDim = ip.getPreferredSize(); if (maxHeight < ipPreferredDim.height) { ip.modifyMaxHeightBy(maxHeight - ipPreferredDim.height); } // UI step 3 - show the dialog JOptionPane jop = new JOptionPane(ip, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dlg = jop.createDialog(MapTool.getFrame(), dialogTitle); // Set up callbacks needed for desired runtime behavior dlg.addComponentListener(new FixupComponentAdapter(ip)); dlg.setVisible(true); int dlgResult = JOptionPane.CLOSED_OPTION; try { dlgResult = (Integer) jop.getValue(); } catch (NullPointerException npe) { } dlg.dispose(); if (dlgResult == JOptionPane.CANCEL_OPTION || dlgResult == JOptionPane.CLOSED_OPTION) return BigDecimal.ZERO; // Finally, assign values from the dialog box to the variables for (ColumnPanel cp : ip.columnPanels) { List<VarSpec> panelVars = cp.varSpecs; List<JComponent> panelControls = cp.inputFields; int numPanelVars = panelVars.size(); StringBuilder allAssignments = new StringBuilder(); // holds all values assigned in this tab for (int varCount = 0; varCount < numPanelVars; varCount++) { VarSpec vs = panelVars.get(varCount); JComponent comp = panelControls.get(varCount); String newValue = null; switch (vs.inputType) { case TEXT: { newValue = ((JTextField) comp).getText(); break; } case LIST: { Integer index = ((JComboBox) comp).getSelectedIndex(); if (vs.optionValues.optionEquals("VALUE", "STRING")) { newValue = vs.valueList.get(index); } else { // default is "NUMBER" newValue = index.toString(); } break; } case CHECK: { Integer value = ((JCheckBox) comp).isSelected() ? 1 : 0; newValue = value.toString(); break; } case RADIO: { // This code assumes that the Box container returns components // in the same order that they were added. Component[] comps = ((Box) comp).getComponents(); int componentCount = 0; Integer index = 0; for (Component c : comps) { if (c instanceof JRadioButton) { JRadioButton radio = (JRadioButton) c; if (radio.isSelected()) index = componentCount; } componentCount++; } if (vs.optionValues.optionEquals("VALUE", "STRING")) { newValue = vs.valueList.get(index); } else { // default is "NUMBER" newValue = index.toString(); } break; } case LABEL: { newValue = null; // The variable name is ignored and not set. break; } case PROPS: { // Read out and assign all the subvariables. // The overall return value is a property string (as in StrPropFunctions.java) with all the new settings. Component[] comps = ((JPanel) comp).getComponents(); StringBuilder sb = new StringBuilder(); int setVars = 0; // "NONE", no assignments made if (vs.optionValues.optionEquals("SETVARS", "SUFFIXED")) setVars = 1; if (vs.optionValues.optionEquals("SETVARS", "UNSUFFIXED")) setVars = 2; if (vs.optionValues.optionEquals("SETVARS", "TRUE")) setVars = 2; // for backward compatibility for (int compCount = 0; compCount < comps.length; compCount += 2) { String key = ((JLabel) comps[compCount]).getText().split("\\:")[0]; // strip trailing colon String value = ((JTextField) comps[compCount + 1]).getText(); sb.append(key); sb.append("="); sb.append(value); sb.append(" ; "); switch (setVars) { case 0: // Do nothing break; case 1: parser.setVariable(key + "_", value); break; case 2: parser.setVariable(key, value); break; } } newValue = sb.toString(); break; } default: // should never happen newValue = null; break; } // Set the variable to the value we got from the dialog box. if (newValue != null) { parser.setVariable(vs.name, newValue.trim()); allAssignments.append(vs.name + "=" + newValue.trim() + " ## "); } } if (cp.tabVarSpec != null) { parser.setVariable(cp.tabVarSpec.name, allAssignments.toString()); } } return BigDecimal.ONE; // success // for debugging: //return debugOutput(varSpecs); }