Example usage for javax.swing JOptionPane NO_OPTION

List of usage examples for javax.swing JOptionPane NO_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane NO_OPTION.

Prototype

int NO_OPTION

To view the source code for javax.swing JOptionPane NO_OPTION.

Click Source Link

Document

Return value from class method if NO is chosen.

Usage

From source file:org.pmedv.blackboard.commands.CreateBoardCommand.java

@Override
public void execute(ActionEvent e) {

    final ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class);
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    /*//from w  w w .  j  ava 2  s. c  o m
     * Get the resource service
     */

    final ResourceService resources = ctx.getBean(ResourceService.class);

    /*
     * The infonode docking framework must be invoked later since swing is
     * not thread safe.
     */

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {

            BoardEditorModel model = new BoardEditorModel();
            model.addDefaultLayers();
            model.setWidth(IOUtils.BOARD_DEFAULT_WIDTH);
            model.setHeight(IOUtils.BOARD_DEFAULT_HEIGHT);

            String title = resources.getResourceByKey("CreateBoardCommand.name");
            String subTitle = resources.getResourceByKey("CreateBoardCommand.dialog.subtitle");

            BoardPropertiesDialog bpd = new BoardPropertiesDialog(title, subTitle,
                    resources.getIcon("icon.dialog.board"), model);
            bpd.setVisible(true);

            if (bpd.getResult() == AbstractNiceDialog.OPTION_CANCEL)
                return;

            final BoardEditor editor = new BoardEditor(model);

            // the center panel centers the editor inside the view no matter which dimensions it has
            CenterPanel panel = new CenterPanel();
            // go for the zoom
            JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints());
            panel.getCenterPanel().add(zoomLayer);
            editor.setZoomLayer(zoomLayer);
            panel.setBoardEditor(editor);
            // put the panel into a scroll pane
            JScrollPane s = new JScrollPane(panel);
            s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
            s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            s.getVerticalScrollBar().setUnitIncrement(512);
            // create new view and connect the view with the editor
            editorView = new View(title, resources.getIcon("icon.editor"), s);
            editor.setView(editorView);
            editor.setFileState(FileState.NEW_AND_UNSAVED);
            editor.setCurrentFile(null);
            // check all available open views
            ArrayList<View> views = EditorUtils.getCurrentPerspectiveViews(advisor.getCurrentPerspective());

            // we need this index for a new untitled view
            int lastUntitledIndex = 0;

            for (View v : views) {
                // found a view with an untitled editor
                if (v.getViewProperties().getTitle().startsWith("untitled")) {
                    // select index if it's greater than the last
                    int index = 0;

                    if (v.getViewProperties().getTitle().contains("*")) {
                        int end = v.getViewProperties().getTitle().lastIndexOf("*");
                        index = Integer.valueOf(v.getViewProperties().getTitle().substring(8, end));
                    } else {
                        index = Integer.valueOf(v.getViewProperties().getTitle().substring(8));
                    }

                    if (index > lastUntitledIndex)
                        lastUntitledIndex = index;
                }
            }
            // and finally add one in order to get the right name
            lastUntitledIndex++;

            editor.getView().getViewProperties().setTitle("untitled" + lastUntitledIndex);
            final int index = editor.getView().hashCode();

            EditorUtils.registerEditorListeners(editor);

            openEditor(editorView, index);

            log.info("Opening editor : " + title);

            // notifies the GUI about the editor change if a tab is switched by the mouse
            editorView.addTabMouseButtonListener(new MouseButtonListener() {

                @Override
                public void mouseButtonEvent(MouseEvent e) {
                    handleMouseEvent(e, editor);
                }

            });
            // wee need to know if a mouse click inside an editor occurs
            editor.addMouseListener(new MouseAdapter() {

                @Override
                public void mousePressed(MouseEvent e) {
                    handleMouseEvent(e, editor);
                }

            });
            // This listener handles the close of an editor tab
            editorView.addListener(new DockingWindowAdapter() {

                @Override
                public void windowClosing(DockingWindow arg0) throws OperationAbortedException {

                    if (editor != null)

                        if (editor.getFileState().equals(FileState.DIRTY)) {
                            int result = JOptionPane.showConfirmDialog(win,
                                    resources.getResourceByKey("msg.warning.notsaved"),
                                    resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION,
                                    JOptionPane.QUESTION_MESSAGE);

                            if (result == JOptionPane.NO_OPTION) {
                                throw new OperationAbortedException("Aborted.");
                            }
                        }

                    advisor.getCurrentPerspective().getViewMap().removeView(index);
                    editor.notifyListeners(EventType.EDITOR_CLOSED);
                }

                @Override
                public void windowClosed(DockingWindow window) {
                    editor.notifyListeners(EventType.EDITOR_CLOSED);
                }
            });
            editor.updateStatusBar();
            editor.notifyListeners(EventType.EDITOR_CHANGED);
            ctx.getBean(SetSelectModeCommand.class).execute(null);
        }
    });

}

From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java

public void doOpen() {

    final ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class);

    BoardEditorModel model = null;//from ww w . j  a  v a  2s  .  com

    String filename = file.getName().toLowerCase();

    try {
        if (filename.endsWith(".bb") || filename.endsWith(".bbs")) {
            File input;
            try {
                input = IOUtils.unpackBoard(file);
            } catch (Exception e1) {
                ErrorUtils.showErrorDialog(e1);
                return;
            }
            model = IOUtils.openBoard(input);
        } else // legacy xml support
            model = IOUtils.openBoard(file);
    } catch (Exception e1) {
        ErrorUtils.showErrorDialog(e1);
        file = null;
        return;
    }
    if (model == null) {
        ErrorUtils.showErrorDialog(
                new Exception(resources.getResourceByKey("OpenBoardCommand.error") + " : " + file.getName()));
        file = null;
        return;
    }

    final BoardEditor editor = new BoardEditor(model);
    CenterPanel panel = new CenterPanel();
    JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints());
    panel.getCenterPanel().add(zoomLayer);
    editor.setZoomLayer(zoomLayer);
    panel.setBoardEditor(editor);
    JScrollPane s = new JScrollPane(panel);
    s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    editorView = new View(title, resources.getIcon("icon.editor"), s);
    editor.setView(editorView);
    editor.setCurrentFile(file);
    editor.setFileState(FileState.OPENED);

    EditorUtils.registerEditorListeners(editor);

    editorView.getViewProperties().setTitle(file.getName());
    try {
        IOUtils.updateRecentFiles(file.getAbsolutePath());
    } catch (Exception e1) {
        ErrorUtils.showErrorDialog(e1);
    }
    openEditor(editorView, editor.getCurrentFile().hashCode());
    if (!fromRecentFileList)
        file = null;
    editorView.addTabMouseButtonListener(new MouseButtonListener() {
        @Override
        public void mouseButtonEvent(MouseEvent e) {
            handleMouseEvent(e, editor);
        }
    });
    editor.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            handleMouseEvent(e, editor);
        }
    });
    editorView.addListener(new DockingWindowAdapter() {
        @Override
        public void windowClosing(DockingWindow arg0) throws OperationAbortedException {
            if (editor.getFileState().equals(FileState.DIRTY)) {
                int result = JOptionPane.showConfirmDialog(ctx.getBean(ApplicationWindow.class),
                        resources.getResourceByKey("msg.warning.notsaved"),
                        resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE);
                if (result == JOptionPane.NO_OPTION) {
                    throw new OperationAbortedException("Aborted.");
                }
            }
            log.info("Removing view with index " + editor.getCurrentFile().hashCode() + " from perspective "
                    + advisor.getCurrentPerspective().ID);
            advisor.getCurrentPerspective().getViewMap().removeView(editor.getCurrentFile().hashCode());
            editor.notifyListeners(EventType.EDITOR_CLOSED);
        }

        @Override
        public void windowClosed(DockingWindow window) {
            editor.notifyListeners(EventType.EDITOR_CLOSED);
        }

    });
    editor.updateStatusBar();
    editor.notifyListeners(EventType.EDITOR_CHANGED);
    ctx.getBean(SetSelectModeCommand.class).execute(null);
}

From source file:org.pmedv.blackboard.commands.SaveNetlistCommand.java

@Override
public void execute(ActionEvent e) {

    ApplicationContext ctx = AppContext.getContext();
    final ApplicationWindow win = ctx.getBean(ApplicationWindow.class);

    String path = System.getProperty("user.home");
    if (AppContext.getLastSelectedFolder() != null) {
        path = AppContext.getLastSelectedFolder();
    }//  w  w  w.  j a  v  a2s .  c o  m

    final JFileChooser fc = new JFileChooser(path);

    fc.setDialogTitle(resources.getResourceByKey("SaveNetlistCommand.dialog.subtitle"));
    fc.setApproveButtonText(resources.getResourceByKey("msg.save"));

    int result = fc.showOpenDialog(win);

    if (result != JFileChooser.APPROVE_OPTION) {
        return;
    }

    if (fc.getSelectedFile() == null)
        return;

    File selectedFile = fc.getSelectedFile();

    AppContext.setLastSelectedFolder(selectedFile.getParentFile().getAbsolutePath());

    if (selectedFile.exists()) {
        result = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.warning.fileexists"),
                resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        if (result == JOptionPane.NO_OPTION) {
            return;
        }
    }

    if (selectedFile != null && netlist != null) {
        try {
            FileUtils.writeStringToFile(selectedFile, netlist);
        } catch (IOException e1) {
            ErrorUtils.showErrorDialog(e1);
        }

    }

}

From source file:org.rdv.ui.ExportDialog.java

private void ok() {
    File file = new File(dataFileTextField.getText());

    if (file.exists()) {
        int overwriteReturn = JOptionPane.showConfirmDialog(null,
                file.getName() + " already exists. Do you want to overwrite it?", "Overwrite file?",
                JOptionPane.YES_NO_OPTION);
        if (overwriteReturn == JOptionPane.NO_OPTION) {
            return;
        }/*from w w w. ja v a2 s .  com*/
    }

    dispose();
}

From source file:org.rdv.ui.ExportVideoDialog.java

private boolean checkDirectory(File directory) {

    if (directory.exists()) {
        if (directory.isDirectory()) {
            int overwriteReturn = JOptionPane.showConfirmDialog(null,
                    directory.getName() + " already exists.\nResume writing in the same folder?",
                    "Write into existing directory?", JOptionPane.YES_NO_OPTION);
            if (overwriteReturn == JOptionPane.NO_OPTION) {
                return false;
            }//w  ww .ja v a  2 s.  co m
        } else {
            JOptionPane.showMessageDialog(null,
                    "Could not create directory " + directory.getPath()
                            + "\nA file with that name already exists!",
                    "Create Directory error", JOptionPane.INFORMATION_MESSAGE);
            return false;
        }

    } else {
        int createDir = JOptionPane.showConfirmDialog(null,
                directory.getPath() + " does NOT exist. Directory will be created", "Create new directory?",
                JOptionPane.YES_NO_OPTION);
        if (createDir == JOptionPane.YES_OPTION) {
            if (!createDirectory(directory)) {
                JOptionPane.showMessageDialog(null, "Error: Could not create directory " + directory.getPath(),
                        "Create Directory error", JOptionPane.INFORMATION_MESSAGE);
                return false;
            }

        } else {
            return false;
        }

    }

    return true;
}

From source file:org.rdv.ui.MainPanel.java

private void initActions() {
    fileAction = new DataViewerAction("File", "File Menu", KeyEvent.VK_F);

    connectAction = new DataViewerAction("Connect", "Connect to RBNB server", KeyEvent.VK_C,
            KeyStroke.getKeyStroke(KeyEvent.VK_C, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = 5038790506859429244L;

        public void actionPerformed(ActionEvent ae) {
            if (rbnbConnectionDialog == null) {
                rbnbConnectionDialog = new RBNBConnectionDialog(frame, rbnb, dataPanelManager);
            } else {
                rbnbConnectionDialog.setVisible(true);
            }/*ww w. j  a v  a  2  s . c  o  m*/
        }
    };

    disconnectAction = new DataViewerAction("Disconnect", "Disconnect from RBNB server", KeyEvent.VK_D,
            KeyStroke.getKeyStroke(KeyEvent.VK_D, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -1871076535376405181L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
            rbnb.disconnect();
        }
    };

    loginAction = new DataViewerAction("Login", "Login as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6105503896620555072L;

        public void actionPerformed(ActionEvent ae) {
            if (loginDialog == null) {
                loginDialog = new LoginDialog(frame);
            } else {
                loginDialog.setVisible(true);
            }
        }
    };

    logoutAction = new DataViewerAction("Logout", "Logout as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2517567766044673777L;

        public void actionPerformed(ActionEvent ae) {
            AuthenticationManager.getInstance().setAuthentication(null);
        }
    };

    loadAction = new DataViewerAction("Load Setup", "Load data viewer setup from file") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7197815395398039821L;

        public void actionPerformed(ActionEvent ae) {
            File configFile = UIUtilities.getFile(new RDVConfigurationFileFilter(), "Load");
            if (configFile != null) {
                try {
                    URL configURL = configFile.toURI().toURL();
                    ConfigurationManager.loadConfiguration(configURL);
                } catch (MalformedURLException e) {
                    DataViewer.alertError("\"" + configFile + "\" is not a valid configuration file URL.");
                }
            }
        }
    };

    saveAction = new DataViewerAction("Save Setup", "Save data viewer setup to file") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8259994975940624038L;

        public void actionPerformed(ActionEvent ae) {
            File file = UIUtilities.saveFile(new RDVConfigurationFileFilter());
            if (file != null) {
                if (file.getName().indexOf(".") == -1) {
                    file = new File(file.getAbsolutePath() + ".rdv");
                }

                // prompt for overwrite if file already exists
                if (file.exists()) {
                    int overwriteReturn = JOptionPane.showConfirmDialog(null,
                            file.getName() + " already exists. Do you want to overwrite it?", "Overwrite file?",
                            JOptionPane.YES_NO_OPTION);
                    if (overwriteReturn == JOptionPane.NO_OPTION) {
                        return;
                    }
                }

                ConfigurationManager.saveConfiguration(file);
            }
        }
    };

    importAction = new DataViewerAction("Import", "Import Menu", KeyEvent.VK_I, "icons/import.gif");

    exportAction = new DataViewerAction("Export", "Export Menu", KeyEvent.VK_E, "icons/export.gif");

    exportVideoAction = new DataViewerAction("Export video channels",
            "Export video on the server to the local computer") {
        /** serialization version identifier */
        private static final long serialVersionUID = -6420430928972633313L;

        public void actionPerformed(ActionEvent ae) {
            showExportVideoDialog();
        }
    };

    exitAction = new DataViewerAction("Exit", "Exit RDV", KeyEvent.VK_X) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3137490972014710133L;

        public void actionPerformed(ActionEvent ae) {
            Application.getInstance().exit(ae);
        }
    };

    controlAction = new DataViewerAction("Control", "Control Menu", KeyEvent.VK_C);

    realTimeAction = new DataViewerAction("Real Time", "View data in real time", KeyEvent.VK_R,
            KeyStroke.getKeyStroke(KeyEvent.VK_R, menuShortcutKeyMask), "icons/rt.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -7564783609370910512L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.monitor();
        }
    };

    playAction = new DataViewerAction("Play", "Playback data", KeyEvent.VK_P,
            KeyStroke.getKeyStroke(KeyEvent.VK_P, menuShortcutKeyMask), "icons/play.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 5974457444931142938L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.play();
        }
    };

    pauseAction = new DataViewerAction("Pause", "Pause data display", KeyEvent.VK_A,
            KeyStroke.getKeyStroke(KeyEvent.VK_S, menuShortcutKeyMask), "icons/pause.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5297742186923194460L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.pause();
        }
    };

    beginningAction = new DataViewerAction("Go to beginning", "Move the location to the start of the data",
            KeyEvent.VK_B, KeyStroke.getKeyStroke(KeyEvent.VK_B, menuShortcutKeyMask), "icons/begin.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 9171304956895497898L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationBegin();
        }
    };

    endAction = new DataViewerAction("Go to end", "Move the location to the end of the data", KeyEvent.VK_E,
            KeyStroke.getKeyStroke(KeyEvent.VK_E, menuShortcutKeyMask), "icons/end.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 1798579248452726211L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationEnd();
        }
    };

    gotoTimeAction = new DataViewerAction("Go to time", "Move the location to specific date time of the data",
            KeyEvent.VK_T, KeyStroke.getKeyStroke(KeyEvent.VK_T, menuShortcutKeyMask)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6411442297488926326L;

        public void actionPerformed(ActionEvent ae) {
            TimeRange timeRange = RBNBHelper.getChannelsTimeRange();
            double time = DateTimeDialog.showDialog(frame, rbnb.getLocation(), timeRange.start, timeRange.end);
            if (time >= 0) {
                rbnb.setLocation(time);
            }
        }
    };

    updateChannelListAction = new DataViewerAction("Update Channel List", "Update the channel list",
            KeyEvent.VK_U, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), "icons/refresh.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -170096772973697277L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.updateMetadata();
        }
    };

    dropDataAction = new DataViewerAction("Drop Data", "Drop data if plaback can't keep up with data rate",
            KeyEvent.VK_D, "icons/drop_data.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7079791364881120134L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            rbnb.dropData(menuItem.isSelected());
        }
    };

    viewAction = new DataViewerAction("View", "View Menu", KeyEvent.VK_V);

    showChannelListAction = new DataViewerAction("Show Channels", "", KeyEvent.VK_L, "icons/channels.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 4982129759386009112L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            channelListPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showMetadataPanelAction = new DataViewerAction("Show Properties", "", KeyEvent.VK_P,
            "icons/properties.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 430106771704397810L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            metadataPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showControlPanelAction = new DataViewerAction("Show Control Panel", "", KeyEvent.VK_C,
            "icons/control.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6401715717710735485L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            controlPanel.setVisible(menuItem.isSelected());
        }
    };

    showAudioPlayerPanelAction = new DataViewerAction("Show Audio Player", "", KeyEvent.VK_A,
            "icons/audio.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4248275698973916287L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            audioPlayerPanel.setVisible(menuItem.isSelected());
        }
    };

    showMarkerPanelAction = new DataViewerAction("Show Marker Panel", "", KeyEvent.VK_M, "icons/info.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5253555511660929640L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            markerSubmitPanel.setVisible(menuItem.isSelected());
        }
    };

    dataPanelAction = new DataViewerAction("Arrange", "Arrange Data Panel Orientation", KeyEvent.VK_D);

    dataPanelHorizontalLayoutAction = new DataViewerAction("Horizontal Data Panel Orientation", "", -1,
            "icons/vertical.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 3356151813557187908L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.VERTICAL_LAYOUT);
        }
    };

    dataPanelVerticalLayoutAction = new DataViewerAction("Vertical Data Panel Orientation", "", -1,
            "icons/horizontal.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4629920180285927138L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.HORIZONTAL_LAYOUT);
        }
    };

    showHiddenChannelsAction = new DataViewerAction("Show Hidden Channels", "", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_H, menuShortcutKeyMask), "icons/hidden.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2723464261568074033L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            channelListPanel.showHiddenChannels(selected);
        }
    };

    hideEmptyTimeAction = new DataViewerAction("Hide time with no data", "", KeyEvent.VK_D) {
        /** serialization version identifier */
        private static final long serialVersionUID = -3123608144249355642L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            controlPanel.hideEmptyTime(selected);
        }
    };

    fullScreenAction = new DataViewerAction("Full Screen", "", KeyEvent.VK_F,
            KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6882310862616235602L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            if (menuItem.isSelected()) {
                if (enterFullScreenMode()) {
                    menuItem.setSelected(true);
                } else {
                    menuItem.setSelected(false);
                }
            } else {
                leaveFullScreenMode();
                menuItem.setSelected(false);
            }
        }
    };

    windowAction = new DataViewerAction("Window", "Window Menu", KeyEvent.VK_W);

    closeAllDataPanelsAction = new DataViewerAction("Close all data panels", "", KeyEvent.VK_C,
            "icons/closeall.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8104876009869238037L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
        }
    };

    helpAction = new DataViewerAction("Help", "Help Menu", KeyEvent.VK_H);

    usersGuideAction = new DataViewerAction("RDV Help", "Open the RDV User's Guide", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -2837190869008153291L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL usersGuideURL = new URL("http://it.nees.org/library/telepresence/rdv-19-users-guide.php");
                DataViewer.browse(usersGuideURL);
            } catch (Exception e) {
            }
        }
    };

    supportAction = new DataViewerAction("RDV Support", "Get support from NEESit", KeyEvent.VK_S) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6855670513381679226L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL supportURL = new URL("http://it.nees.org/support/");
                DataViewer.browse(supportURL);
            } catch (Exception e) {
            }
        }
    };

    releaseNotesAction = new DataViewerAction("Release Notes", "Open the RDV Release Notes", KeyEvent.VK_R) {
        /** serialization version identifier */
        private static final long serialVersionUID = 7223639998298692494L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL releaseNotesURL = new URL("http://it.nees.org/library/rdv/rdv-release-notes.php");
                DataViewer.browse(releaseNotesURL);
            } catch (Exception e) {
            }
        }
    };

    aboutAction = new DataViewerAction("About RDV", "", KeyEvent.VK_A) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3978467903181198979L;

        public void actionPerformed(ActionEvent ae) {
            showAboutDialog();
        }
    };

}

From source file:org.rdv.viz.image.HighResImageViz.java

/**
 * If an image is currently being displayed, save it to a file. This will
 * bring up a file chooser to select the file.
 * /*from   ww  w .  j a  v a 2  s. c o m*/
 * @param directory the directory to start the file chooser in
 */
private void saveImage(File directory) {
    if (displayedImageData != null) {
        // create default file name
        String channelName = (String) seriesList_.getChannels().iterator().next();
        String fileName = channelName.replace("/", " - ");
        if (!fileName.endsWith(".jpg")) {
            fileName += ".jpg";
        }
        File selectedFile = new File(directory, fileName);

        // create filter to only show files that end with '.jpg'
        FileFilter fileFilter = new FileFilter() {
            public boolean accept(File f) {
                return (f.isDirectory() || f.getName().toLowerCase().endsWith(".jpg"));
            }

            public String getDescription() {
                return "JPEG Image Files";
            }
        };

        // show dialog
        File outFile = UIUtilities.getFile(fileFilter, "Save", null, selectedFile);
        if (outFile != null) {
            // prompt for overwrite if file already exists
            if (outFile.exists()) {
                int overwriteReturn = JOptionPane.showConfirmDialog(null,
                        outFile.getName() + " already exists. Do you want to replace it?", "Replace image?",
                        JOptionPane.YES_NO_OPTION);
                if (overwriteReturn == JOptionPane.NO_OPTION) {
                    saveImage(outFile.getParentFile());
                    return;
                }
            }

            // write image file
            try {
                FileOutputStream out = new FileOutputStream(outFile);
                out.write(displayedImageData);
                out.close();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Filed to write image file.", "Save Image Error",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    }
}

From source file:org.rdv.viz.image.ImageViz.java

/**
 * If an image is currently being displayed, save it to a file. This will
 * bring up a file chooser to select the file.
 * // w  ww  . j a v  a  2 s .  com
 * @param directory the directory to start the file chooser in
 */
private void saveImage(File directory) {
    if (displayedImageData != null) {
        // create default file name
        String channelName = (String) channels.iterator().next();
        String fileName = channelName.replace("/", " - ");
        if (!fileName.endsWith(".jpg")) {
            fileName += ".jpg";
        }
        File selectedFile = new File(directory, fileName);

        // create filter to only show files that end with '.jpg'
        FileFilter fileFilter = new FileFilter() {
            public boolean accept(File f) {
                return (f.isDirectory() || f.getName().toLowerCase().endsWith(".jpg"));
            }

            public String getDescription() {
                return "JPEG Image Files";
            }
        };

        // show dialog
        File outFile = UIUtilities.getFile(fileFilter, "Save", null, selectedFile);
        if (outFile != null) {
            // prompt for overwrite if file already exists
            if (outFile.exists()) {
                int overwriteReturn = JOptionPane.showConfirmDialog(null,
                        outFile.getName() + " already exists. Do you want to replace it?", "Replace image?",
                        JOptionPane.YES_NO_OPTION);
                if (overwriteReturn == JOptionPane.NO_OPTION) {
                    saveImage(outFile.getParentFile());
                    return;
                }
            }

            // write image file
            try {
                FileOutputStream out = new FileOutputStream(outFile);
                out.write(displayedImageData);
                out.close();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Filed to write image file.", "Save Image Error",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    }
}

From source file:org.roche.antibody.services.graphsynchronizer.GraphSynchronizer.java

/**
 * Syncs the changes back to the antibody and returns whether changes should be submitted (and the macromolecule
 * editor cleared)/*www  .  j  a  v  a  2s . c o m*/
 * 
 * @param helmCode
 * @return true when macromolecule editor should be cleared and the antibody synced back to abEditor. False when sync
 *         should be cancelled for further edit.
 * @throws FileNotFoundException
 */
public boolean syncBackToAntibody(String helmCode) throws FileNotFoundException {
    Map<HELMElement, Sequence> helmToSequence = new HashMap<HELMElement, Sequence>();
    HELMCode code = HelmNotationService.getInstance().toHELMCode(helmCode);
    List<HELMElement> handledElements = new ArrayList<HELMElement>();
    deletedConnectionCount = 0;
    createdConnectionCount = 0;

    // do not change anything, when molecule did not change
    try {
        if (ComplexNotationParser.getCanonicalNotation(helmSentToEditor)
                .equals(ComplexNotationParser.getCanonicalNotation(helmCode))) {
            return true;
        }
    } catch (Exception e) {
        LOG.error(e.getMessage());
    }

    int validationOption = validate(code);
    if (validationOption == JOptionPane.YES_OPTION) {
        removeBlocker(code);
        deleteOldSequencesAndConnections();
        handleActiveDomain(code, helmToSequence, handledElements);
        handleNewSequences(code, helmToSequence, handledElements);
        handleNewConnections(code, helmToSequence);

        // align non-domain Sequences, after they were created and connected
        AbstractGraphService.alignNonDomainSequences(abEditor.getAbstractGraph(), ab,
                (NodeMap) abEditor.getAbstractGraph().getDataProvider(GivenLayersLayerer.LAYER_ID_KEY));
        abEditor.updateLayoutHints();
        abEditor.updateGraphLayout();
    } else {
        //
        if (validationOption == JOptionPane.CANCEL_OPTION) {
            return false;
        } else if (validationOption == JOptionPane.NO_OPTION) {
            return true;
        }
    }

    try {
        DomainAnnotationAction.annotateDomain(AntibodyEditorAccess.getInstance().getAntibodyEditorPane(),
                activeDomain);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    // Show the user an appropriate message when the connection count
    // changed.
    int connectionCountChange = deletedConnectionCount - createdConnectionCount;
    if (connectionCountChange > 0) {
        String message = String.format("%d %s removed, because automated reconfiguration is not possible.",
                connectionCountChange, connectionCountChange > 1 ? "connections" : "connection");
        JOptionPane.showMessageDialog(this.abEditor, message, "Connection count changed",
                JOptionPane.INFORMATION_MESSAGE);
    } else if (connectionCountChange < 0) {
        String message = String.format("%d %s additional connections added.", -connectionCountChange,
                connectionCountChange < -1 ? "connections" : "connection");
        JOptionPane.showMessageDialog(this.abEditor, message, "Connection count changed",
                JOptionPane.INFORMATION_MESSAGE);
    }

    return true;
}

From source file:org.sleeksnap.ScreenSnapper.java

/**
 * Prompt the user for a configuration reset
 *//*  w w  w .  j a v  a  2  s. co m*/
public void promptConfigurationReset() {
    final int option = JOptionPane.showConfirmDialog(null, Language.getString("settingsCorrupted"),
            Language.getString("errorLoadingSettings"), JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (option == JOptionPane.YES_OPTION) {
        try {
            loadSettings(true);
        } catch (final Exception e) {
            logger.log(Level.SEVERE, "Unable to load default settings!", e);
        }
    } else if (option == JOptionPane.NO_OPTION) {
        // If no, let them set the configuration themselves..
        openSettings();
    } else if (option == JOptionPane.CANCEL_OPTION) {
        // Exit, they don't want anything to do with it.
        System.exit(0);
    }
}