List of usage examples for javax.swing JOptionPane ERROR_MESSAGE
int ERROR_MESSAGE
To view the source code for javax.swing JOptionPane ERROR_MESSAGE.
Click Source Link
From source file:com.sshtools.tunnel.PortForwardingPane.java
protected void editPortForward() { ForwardingConfiguration config = model.getForwardingConfigurationAt(table.getSelectedRow()); if (config.getName().equals("x11")) { JOptionPane.showMessageDialog(this, "You cannot edit X11 forwarding.", "Error", JOptionPane.ERROR_MESSAGE); return;/* w ww .java2 s . c o m*/ } PortForwardEditorPane editor = new PortForwardEditorPane(config); int option = JOptionPane.showConfirmDialog(this, editor, "Edit Tunnel", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (option != JOptionPane.CANCEL_OPTION && option != JOptionPane.CLOSED_OPTION) { try { ForwardingClient forwardingClient = client; String id = editor.getForwardName(); if (id.equals("x11")) { throw new Exception("The id of x11 is reserved."); } if (editor.getHost().equals("")) { throw new Exception("Please specify a destination host."); } int i = model.getRowCount(); if (editor.isLocal()) { forwardingClient.removeLocalForwarding(config.getName()); forwardingClient.addLocalForwarding(id, editor.getBindAddress(), editor.getLocalPort(), editor.getHost(), editor.getRemotePort()); forwardingClient.startLocalForwarding(id); } else { forwardingClient.removeRemoteForwarding(config.getName()); forwardingClient.addRemoteForwarding(id, editor.getBindAddress(), editor.getLocalPort(), editor.getHost(), editor.getRemotePort()); forwardingClient.startRemoteForwarding(id); } if (i < model.getRowCount()) { table.getSelectionModel().addSelectionInterval(i, i); } } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } finally { model.refresh(); sessionPanel.setAvailableActions(); } } }
From source file:com.bwc.ora.OraUtils.java
/** * Create the anchor LRP. Does this by creating the LRP model and then adds * it to the LRP collections used by the application for storing LRPs for * analysis and display/* w ww.j av a 2 s . c o m*/ * * @param assisted use fovea finding algorithm or manual click to identify * fovea */ public static void generateAnchorLrp(boolean assisted, JButton buttonToEnable) { OCTDisplayPanel octDisplayPanel = OCTDisplayPanel.getInstance(); LrpSettings lrpSettings = ModelsCollection.getInstance().getLrpSettings(); DisplaySettings displaySettings = ModelsCollection.getInstance().getDisplaySettings(); if (assisted) { JOptionPane.showMessageDialog(null, "Click and drag a window on the OCT which\n" + "contains the foveal pit, some of the vitrious,\n" + "and some of the Bruch's membrane and choroid.\n" + "ORA will the place a LRP at what it believes is\n" + "the center of the foveal pit.\n" + "\n" + "Use the arrow keys to move the LRP if desired after placement.\n" + "If any setting are adjusted while in this mode\n" + "you'll have to click the mouse on the OCT to regain\n" + "the ability to move the LRP with the arrow keys.", "Draw foveal pit window", JOptionPane.INFORMATION_MESSAGE); //allow the user to select region on screen where fovea should be found OctWindowSelector octWindowSelector = ModelsCollection.getInstance().getOctWindowSelector(); MouseInputAdapter selectorMouseListener = new MouseInputAdapter() { Point firstPoint = null; Point secondPoint = null; Point lastWindowPoint = null; @Override public void mousePressed(MouseEvent e) { Collections.getInstance().getOctDrawnLineCollection().clear(); Collections.getInstance().getLrpCollection().clearLrps(); if ((firstPoint = octDisplayPanel.convertPanelPointToOctPoint(e.getPoint())) != null) { octWindowSelector.setDisplay(true); displaySettings.setDisplaySelectorWindow(true); } } @Override public void mouseReleased(MouseEvent e) { secondPoint = octDisplayPanel.convertPanelPointToOctPoint(e.getPoint()); octWindowSelector.setDisplay(false); displaySettings.setDisplaySelectorWindow(false); octDisplayPanel.removeMouseListener(this); octDisplayPanel.removeMouseMotionListener(this); OctPolyLine ilm = ILMsegmenter.segmentILM(firstPoint, secondPoint == null ? lastWindowPoint : secondPoint); Collections.getInstance().getOctDrawnLineCollection().add(ilm); //use ILM segmented line to find local minima and place LRP Point maxYPoint = ilm.stream().max(Comparator.comparingInt(p -> p.y)).orElse(ilm.get(0)); int fovealCenterX = (int) Math.round(ilm.stream().filter(p -> p.y == maxYPoint.y) .mapToInt(p -> p.x).average().getAsDouble()); Lrp newLrp; try { newLrp = new Lrp("Fovea", fovealCenterX, Oct.getInstance().getImageHeight() / 2, lrpSettings.getLrpWidth(), lrpSettings.getLrpHeight(), LrpType.FOVEAL); lrpCollection.setLrps(Arrays.asList(newLrp)); octDisplayPanel.removeMouseListener(this); if (buttonToEnable != null) { buttonToEnable.setEnabled(true); } } catch (LRPBoundaryViolationException e1) { JOptionPane.showMessageDialog(null, e1.getMessage() + " Try again.", "LRP generation error", JOptionPane.ERROR_MESSAGE); return; } } @Override public void mouseDragged(MouseEvent e) { Point dragPoint; if ((dragPoint = octDisplayPanel.convertPanelPointToOctPoint(e.getPoint())) != null) { lastWindowPoint = dragPoint; int minX = Math.min(firstPoint.x, dragPoint.x); int minY = Math.min(firstPoint.y, dragPoint.y); int width = Math.max(firstPoint.x, dragPoint.x) - minX; int height = Math.max(firstPoint.y, dragPoint.y) - minY; octWindowSelector.setRect(minX, minY, width, height); displaySettings.setDisplaySelectorWindow(false); displaySettings.setDisplaySelectorWindow(true); } } }; octDisplayPanel.addMouseListener(selectorMouseListener); octDisplayPanel.addMouseMotionListener(selectorMouseListener); } else { JOptionPane.showMessageDialog(null, "Click on the OCT where the anchor LRP should go.\n" + "Use the arrow keys to move the LRP.\n" + "If any setting are adjusted while in this mode\n" + "you'll have to click the mouse on the OCT to regain\n" + "the ability to move the LRP with the arrow keys.", "Click anchor point", JOptionPane.INFORMATION_MESSAGE); //listen for the location on the screen where the user clicks, create LRP at location octDisplayPanel.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { Point clickPoint; if ((clickPoint = octDisplayPanel.convertPanelPointToOctPoint(e.getPoint())) != null) { Lrp newLrp; try { newLrp = new Lrp("Fovea", clickPoint.x, clickPoint.y, lrpSettings.getLrpWidth(), lrpSettings.getLrpHeight(), LrpType.FOVEAL); lrpCollection.setLrps(Arrays.asList(newLrp)); octDisplayPanel.removeMouseListener(this); if (buttonToEnable != null) { buttonToEnable.setEnabled(true); } } catch (LRPBoundaryViolationException e1) { JOptionPane.showMessageDialog(null, e1.getMessage() + " Try again.", "LRP generation error", JOptionPane.ERROR_MESSAGE); return; } } } }); } }
From source file:com.dnsoft.inmobiliaria.controllers.ConsultaCCPropietariosController.java
void verPropietarioSeleccionado() { try {/* w w w. jav a 2 s . c om*/ propietarioSeleccionado = propietarioDAO .findByPropietarioEager(listPropietarios.get(view.tblPropietario.getSelectedRow()).getId()); PropietariosDetalleDlg propietario = new PropietariosDetalleDlg(null, true, propietarioSeleccionado); propietario.setVisible(true); propietario.toFront(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex, "Error", JOptionPane.ERROR_MESSAGE); ex.printStackTrace(); } }
From source file:com.googlecode.onevre.utils.ServerClassLoader.java
/** * * @see java.security.SecureClassLoader#getPermissions( * java.security.CodeSource)/*from www . ja v a2 s . c om*/ */ protected PermissionCollection getPermissions(CodeSource codesource) { boolean isAcceptable = false; if (!CHECKED.containsKey(codesource.getLocation())) { Certificate[] certs = codesource.getCertificates(); if (certs == null || certs.length == 0) { JOptionPane.showMessageDialog(null, "The jar at " + codesource.getLocation() + " is not signed!", "Security Error", JOptionPane.ERROR_MESSAGE); isAcceptable = false; } else { isAcceptable = true; for (int i = 0; (i < certs.length) && isAcceptable; i++) { if (!verifyCertificate((X509Certificate) certs[i])) { isAcceptable = false; } } } CHECKED.put(codesource.getLocation(), isAcceptable); } else { isAcceptable = CHECKED.get(codesource.getLocation()); } Permissions permissions = new Permissions(); if (isAcceptable) { permissions.add(new AllPermission()); return permissions; } throw new SecurityException("Access denied to " + codesource.getLocation()); }
From source file:com.diversityarrays.kdxplore.exportdata.CurationDataExporter.java
public void exportCurationData(ExportOptions options) { RowDataEmitter rowDataEmitter = null; boolean success = false; File tmpfile = null;// w w w .j a v a 2 s. c om File outputFile = options.file; List<PlotAttribute> plotAttributes = helper.getPlotAttributes(options.allPlotAttributes); List<TraitInstance> traitInstances = helper.getTraitInstances(options.whichTraitInstances); try { String loname = outputFile.getName().toLowerCase(); tmpfile = File.createTempFile(TEMPDIR_KDX, SUFFIX_TMP, outputFile.getParentFile()); if (loname.endsWith(SUFFIX_XLS)) { rowDataEmitter = new OldExcelRowDataEmitter(options, tmpfile, trial); } else if (loname.endsWith(SUFFIX_XLSX)) { // NOTE: BMS not supported for XLSX rowDataEmitter = new NewExcelRowDataEmitter(options, tmpfile, trial); } else { rowDataEmitter = new CsvRowDataEmitter(options, tmpfile); if (!loname.endsWith(SUFFIX_CSV)) { outputFile = new File(outputFile.getParentFile(), outputFile.getName() + SUFFIX_CSV); } } rowDataEmitter.emitTrialDetails(trialAttributes, plotAttributes, traitInstances); rowDataEmitter.emitSampleData(plotAttributes, traitInstances); success = true; } catch (IOException e) { JOptionPane.showMessageDialog(messageComponent, e.getMessage(), "I/O Error", JOptionPane.ERROR_MESSAGE); } finally { if (rowDataEmitter != null) { try { rowDataEmitter.close(); } catch (IOException ignore) { } } if (success) { if (outputFile.exists()) { outputFile.delete(); } if (tmpfile.renameTo(outputFile)) { messagePrinter.println("Exported data to " + outputFile.getPath()); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(messageComponent, "Saved " + outputFile.getName(), "Open the saved file?", JOptionPane.YES_NO_OPTION)) { try { Util.openFile(outputFile); } catch (IOException e) { messagePrinter.println("Failed to open " + outputFile.getPath()); messagePrinter.println(e.getMessage()); } } } else { } } else { if (tmpfile != null) { tmpfile.delete(); } } } }
From source file:net.sf.jabref.openoffice.OpenOfficePanel.java
private void initPanel() { useDefaultAuthoryearStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE); useDefaultNumericalStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE); connect.addActionListener(e -> connect(true)); manualConnect.addActionListener(e -> connect(false)); selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on")); selectDocument.addActionListener(e -> { try {/*from w w w . j a v a 2 s .c o m*/ ooBase.selectDocument(); frame.output(Localization.lang("Connected to document") + ": " + ooBase.getCurrentDocumentTitle().orElse("")); } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException | NoSuchElementException | NoDocumentException ex) { JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem connecting", ex); } }); setStyleFile.addActionListener(e -> { if (styleDialog == null) { styleDialog = new StyleSelectDialog(frame, styleFile); } styleDialog.setVisible(true); if (styleDialog.isOkPressed()) { useDefaultAuthoryearStyle = Globals.prefs .getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE); useDefaultNumericalStyle = Globals.prefs .getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE); styleFile = Globals.prefs.get(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE); try { readStyleFile(); } catch (IOException ex) { LOGGER.warn("Could not read style file", ex); } } }); pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis")); pushEntries.addActionListener(e -> pushEntries(true, true, false)); pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation")); pushEntriesInt.addActionListener(e -> pushEntries(false, true, false)); pushEntriesEmpty.setToolTipText( Localization.lang("Insert a citation without text (the entry will appear in the reference list)")); pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false)); pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information")); pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true)); update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date")); Action updateAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { if (style == null) { readStyleFile(); } else { style.ensureUpToDate(); } ooBase.updateSortedReferenceMarks(); List<BibDatabase> databases = getBaseList(); List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style); ooBase.rebuildBibTextSection(databases, style); if (!unresolvedKeys.isEmpty()) { JOptionPane.showMessageDialog(frame, Localization.lang( "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.", unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE); } } catch (UndefinedCharacterFormatException ex) { reportUndefinedCharacterFormat(ex); } catch (UndefinedParagraphFormatException ex) { reportUndefinedParagraphFormat(ex); } catch (ConnectionLostException ex) { showConnectionLostErrorMessage(); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang( "You must select either a valid style file, or use one of the default styles."), Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Problem with style file", ex); return; } catch (BibEntryNotFoundException ex) { JOptionPane.showMessageDialog(frame, Localization.lang( "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.", ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"), JOptionPane.ERROR_MESSAGE); LOGGER.debug("BibEntry not found", ex); } catch (Exception ex) { LOGGER.warn("Could not update bibliography", ex); } } }; update.addActionListener(updateAction); merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only")); merge.addActionListener(e -> { try { ooBase.combineCiteMarkers(getBaseList(), style); } catch (UndefinedCharacterFormatException ex) { reportUndefinedCharacterFormat(ex); } catch (Exception ex) { LOGGER.warn("Problem combining cite markers", ex); } }); settingsB.addActionListener(e -> showSettingsPopup()); manageCitations.addActionListener(e -> { try { CitationManager cm = new CitationManager(frame, ooBase); cm.showDialog(); } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) { LOGGER.warn("Problem showing citation manager", ex); } }); selectDocument.setEnabled(false); pushEntries.setEnabled(false); pushEntriesInt.setEnabled(false); pushEntriesEmpty.setEnabled(false); pushEntriesAdvanced.setEnabled(false); update.setEnabled(false); merge.setEnabled(false); manageCitations.setEnabled(false); diag = new JDialog((JFrame) null, "OpenOffice panel", false); DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow", //"p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu")); "p,p,p,p,p,p,p,p,p,p")); //ButtonBarBuilder bb = new ButtonBarBuilder(); DefaultFormBuilder bb = new DefaultFormBuilder( new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, " + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", "")); bb.append(connect); bb.append(manualConnect); bb.append(selectDocument); bb.append(update); bb.append(help); b.append(bb.getPanel()); b.append(setStyleFile); b.append(pushEntries); b.append(pushEntriesInt); b.append(pushEntriesAdvanced); b.append(pushEntriesEmpty); b.append(merge); b.append(manageCitations); b.append(settingsB); JPanel content = new JPanel(); comp.setContentContainer(content); content.setLayout(new BorderLayout()); content.add(b.getPanel(), BorderLayout.CENTER); frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO"); frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction); }
From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java
public FileListEditor(JabRefFrame frame, BibDatabaseContext databaseContext, String fieldName, String content, EntryEditor entryEditor) {// w w w.j a v a 2s.com this.frame = frame; this.databaseContext = databaseContext; this.fieldName = fieldName; this.entryEditor = entryEditor; label = new FieldNameLabel(fieldName); tableModel = new FileListTableModel(); setText(content); setModel(tableModel); JScrollPane sPane = new JScrollPane(this); setTableHeader(null); addMouseListener(new TableClickListener()); JButton add = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon()); add.setToolTipText(Localization.lang("New file link (INSERT)")); JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon()); remove.setToolTipText(Localization.lang("Remove file link (DELETE)")); JButton up = new JButton(IconTheme.JabRefIcon.UP.getSmallIcon()); JButton down = new JButton(IconTheme.JabRefIcon.DOWN.getSmallIcon()); auto = new JButton(Localization.lang("Get fulltext")); JButton download = new JButton(Localization.lang("Download from URL")); add.setMargin(new Insets(0, 0, 0, 0)); remove.setMargin(new Insets(0, 0, 0, 0)); up.setMargin(new Insets(0, 0, 0, 0)); down.setMargin(new Insets(0, 0, 0, 0)); add.addActionListener(e -> addEntry()); remove.addActionListener(e -> removeEntries()); up.addActionListener(e -> moveEntry(-1)); down.addActionListener(e -> moveEntry(1)); auto.addActionListener(e -> autoSetLinks()); download.addActionListener(e -> downloadFile()); FormBuilder builder = FormBuilder.create() .layout(new FormLayout("fill:pref,1dlu,fill:pref,1dlu,fill:pref", "fill:pref,fill:pref")); builder.add(up).xy(1, 1); builder.add(add).xy(3, 1); builder.add(auto).xy(5, 1); builder.add(down).xy(1, 2); builder.add(remove).xy(3, 2); builder.add(download).xy(5, 2); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(sPane, BorderLayout.CENTER); panel.add(builder.getPanel(), BorderLayout.EAST); TransferHandler transferHandler = new FileListEditorTransferHandler(frame, entryEditor, null); setTransferHandler(transferHandler); panel.setTransferHandler(transferHandler); // Add an input/action pair for deleting entries: getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "delete"); getActionMap().put("delete", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { int row = getSelectedRow(); removeEntries(); row = Math.min(row, getRowCount() - 1); if (row >= 0) { setRowSelectionInterval(row, row); } } }); // Add an input/action pair for inserting an entry: getInputMap().put(KeyStroke.getKeyStroke("INSERT"), "insert"); getActionMap().put("insert", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { addEntry(); } }); // Add input/action pair for moving an entry up: getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_UP), "move up"); getActionMap().put("move up", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { moveEntry(-1); } }); // Add input/action pair for moving an entry down: getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_DOWN), "move down"); getActionMap().put("move down", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { moveEntry(1); } }); JMenuItem openLink = new JMenuItem(Localization.lang("Open")); menu.add(openLink); openLink.addActionListener(e -> openSelectedFile()); JMenuItem openFolder = new JMenuItem(Localization.lang("Open folder")); menu.add(openFolder); openFolder.addActionListener(e -> { int row = getSelectedRow(); if (row >= 0) { FileListEntry entry = tableModel.getEntry(row); try { String path = ""; // absolute path if (Paths.get(entry.link).isAbsolute()) { path = Paths.get(entry.link).toString(); } else { // relative to file folder for (String folder : databaseContext.getFileDirectory()) { Path file = Paths.get(folder, entry.link); if (Files.exists(file)) { path = file.toString(); break; } } } if (!path.isEmpty()) { JabRefDesktop.openFolderAndSelectFile(path); } else { JOptionPane.showMessageDialog(frame, Localization.lang("File not found"), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { LOGGER.debug("Cannot open folder", ex); } } }); JMenuItem rename = new JMenuItem(Localization.lang("Move/Rename file")); menu.add(rename); rename.addActionListener(new MoveFileAction(frame, entryEditor, this, false)); JMenuItem moveToFileDir = new JMenuItem(Localization.lang("Move file to file directory")); menu.add(moveToFileDir); moveToFileDir.addActionListener(new MoveFileAction(frame, entryEditor, this, true)); JMenuItem deleteFile = new JMenuItem(Localization.lang("Delete local file")); menu.add(deleteFile); deleteFile.addActionListener(e -> { int row = getSelectedRow(); // no selection if (row != -1) { FileListEntry entry = tableModel.getEntry(row); // null if file does not exist Optional<File> file = FileUtil.expandFilename(databaseContext, entry.link); // transactional delete and unlink try { if (file.isPresent()) { Files.delete(file.get().toPath()); } removeEntries(); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang("File permission error"), Localization.lang("Cannot delete file"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("File permission error while deleting: " + entry.link, ex); } } }); adjustColumnWidth(); }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
/** * Returns the 'Update' action.//from www .j a va 2s . co m * * @return the action */ @SuppressWarnings("serial") private Action getUpdateAction() { if (updateAction == null) { String actionCommand = bundle.getString(UPDATE_NODE_KEY); String actionKey = bundle.getString(UPDATE_NODE_KEY + ".action"); updateAction = new AbstractAction(actionCommand, Icons.UPDATE) { @Override public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed(): action = " + e.getActionCommand()); if (checkAction()) { model.updateData(nodes[0].getPath(), taUpdate.getText().getBytes(getCharset())); } } private boolean checkAction() { // No node or several nodes selected if (nodes == null || nodes.length > 1) { return false; } // No parent if (nodes == null || nodes.length != 1) { JOptionPane.showMessageDialog(JZVNodePanel.this, bundle.getString("dlg.error.updateWithoutParent"), bundle.getString("dlg.error.title"), JOptionPane.ERROR_MESSAGE); return false; } return (JOptionPane.showConfirmDialog(JZVNodePanel.this, bundle.getString("dlg.confirm.update")) == JOptionPane.YES_OPTION); } }; updateAction.putValue(Action.ACTION_COMMAND_KEY, actionKey); } return updateAction; }
From source file:org.simbrain.plot.histogram.HistogramPanel.java
/** * Create the histogram panel based on the data. *//*from ww w . ja va 2 s.c o m*/ public void createHistogram() { try { if (this.getModel().getData() != null) { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); XYPlot plot = (XYPlot) mainChart.getPlot(); plot.setForegroundAlpha(0.75F); // Sets y-axis ticks to integers. NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); Iterator<ColoredDataSeries> series = model.getSeriesData().iterator(); for (int i = 0; i < model.getData().size(); i++) { if (i < colorPallet.length) { ColoredDataSeries s = series.next(); Color c = s.color; if (c == null) { c = assignColor(); s.color = c; } renderer.setSeriesPaint(i, c, true); } } } else { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); } } catch (IllegalArgumentException iaEx) { iaEx.printStackTrace(); JOptionPane.showMessageDialog(null, iaEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IllegalStateException isEx) { isEx.printStackTrace(); JOptionPane.showMessageDialog(null, isEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } mainPanel = new ChartPanel(mainChart); }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Persists out the timelord file and allows the user to choose where * the file should go./*from w w w . ja v a 2s .co m*/ * * @param rwClassName the name of the RW class * (e.g. "net.chaosserver.timelord.data.ExcelDataReaderWriter") * @param userSelect allows the user to select where the file should * be persisted. */ public void writeTimeTrackData(String rwClassName, boolean userSelect) { try { Class<?> rwClass = Class.forName(rwClassName); TimelordDataReaderWriter timelordDataRW = (TimelordDataReaderWriter) rwClass.newInstance(); int result = JFileChooser.APPROVE_OPTION; File outputFile = timelordDataRW.getDefaultOutputFile(); if (timelordDataRW instanceof TimelordDataReaderWriterUI) { TimelordDataReaderWriterUI timelordDataReaderWriterUI = (TimelordDataReaderWriterUI) timelordDataRW; timelordDataReaderWriterUI.setParentFrame(applicationFrame); JDialog configDialog = timelordDataReaderWriterUI.getConfigDialog(); configDialog.pack(); configDialog.setLocationRelativeTo(applicationFrame); configDialog.setVisible(true); } if (userSelect) { if (OsUtil.isMac()) { FileDialog fileDialog = new FileDialog(applicationFrame, "Select File", FileDialog.SAVE); fileDialog.setDirectory(outputFile.getParent()); fileDialog.setFile(outputFile.getName()); fileDialog.setVisible(true); if (fileDialog.getFile() != null) { outputFile = new File(fileDialog.getDirectory(), fileDialog.getFile()); } } else { JFileChooser fileChooser = new JFileChooser(outputFile.getParentFile()); fileChooser.setSelectedFile(outputFile); fileChooser.setFileFilter(timelordDataRW.getFileFilter()); result = fileChooser.showSaveDialog(applicationFrame); if (result == JFileChooser.APPROVE_OPTION) { outputFile = fileChooser.getSelectedFile(); } } } if (result == JFileChooser.APPROVE_OPTION) { timelordDataRW.writeTimelordData(getTimelordData(), outputFile); } } catch (Exception e) { JOptionPane.showMessageDialog(applicationFrame, "Error writing to file.\n" + "Do you have the output file open?", "Save Error", JOptionPane.ERROR_MESSAGE, applicationIcon); if (log.isErrorEnabled()) { log.error("Error persisting file", e); } } }