Example usage for javax.swing JOptionPane YES_NO_OPTION

List of usage examples for javax.swing JOptionPane YES_NO_OPTION

Introduction

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

Prototype

int YES_NO_OPTION

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

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:jeplus.JEPlusFrameMain.java

/**
 * Start batch operation//from  w  ww  . ja  v a2 s  .  com
 * @param file
 * @param dir
 * @return 
 */
public boolean createJobList(String file, String dir) {
    if (this.validateBatchJobs()) {
        // Check batch size and exec agent's capacity
        if (BatchManager.getBatchInfo()
                .getTotalNumberOfJobs() > 100000 /* BatchManager.getAgent().getQueueCapacity() */) {
            // Project is too large
            StringBuilder buf = new StringBuilder("<html><p>The estimated batch size (");
            buf.append(LargeIntFormatter.format(BatchManager.getBatchInfo().getTotalNumberOfJobs()));
            buf.append(") exceeds 10,000. </p><p>Are you sure to create a list of all jobs?</p>");
            buf.append("<p>Select Yes if you want to go ahead generate the job list file. </p>");
            int res = JOptionPane.showConfirmDialog(this, buf.toString(), "List is too long",
                    JOptionPane.YES_NO_OPTION);
            if (res == JOptionPane.NO_OPTION) {
                OutputPanel.appendContent("Operation cancelled.\n");
                return false;
            }
        }
        // Build jobs
        displayInfo("Building jobs ... ");
        BatchManager.buildJobs();
        displayInfo("" + BatchManager.getJobQueue().size() + " jobs created.\n");
        displayInfo("Saving job list in " + dir + file + "...\n");
        BatchManager.writeJobListFile(file, dir);
        displayInfo("Done.\n");
    } else {

    }
    return true;
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java

@Override
protected void okButtonPressed() {
    if (fieldsPanel.getEditBtn().isEnabled()) {
        int userChoice = JOptionPane.NO_OPTION;
        Object[] options = { getResourceString("Continue"), //$NON-NLS-1$
                getResourceString("CANCEL") //$NON-NLS-1$
        };//from   ww w .  jav a  2  s.com
        loadAndPushResourceBundle("masterusrpwd");

        userChoice = JOptionPane.showOptionDialog(this, getResourceString("UIFEDlg.ITEM_CHG"), //$NON-NLS-1$
                getResourceString("UIFEDlg.CHG_TITLE"), //$NON-NLS-1$
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        if (userChoice == JOptionPane.NO_OPTION) {
            return;
        }
    }
    super.okButtonPressed();
    getDataFromUI();
}

From source file:gdt.jgui.entity.folder.JFolderPanel.java

/**
 * Get the context menu./*from  w ww. j  ava 2s .c o  m*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = super.getContextMenu();
    mia = null;
    int cnt = menu.getItemCount();
    if (cnt > 0) {
        mia = new JMenuItem[cnt];
        for (int i = 0; i < cnt; i++)
            mia[i] = menu.getItem(i);
    }
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            //System.out.println("EntitiesPanel:getConextMenu:menu selected");
            menu.removeAll();
            if (mia != null) {
                for (JMenuItem mi : mia)
                    menu.add(mi);
                menu.addSeparator();
            }
            JMenuItem refreshItem = new JMenuItem("Refresh");
            refreshItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JConsoleHandler.execute(console, locator$);
                }
            });
            menu.add(refreshItem);
            JMenuItem openItem = new JMenuItem("Open folder");
            openItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        File folder = new File(entihome$ + "/" + entityKey$);
                        if (!folder.exists())
                            folder.mkdir();
                        Desktop.getDesktop().open(folder);
                    } catch (Exception ee) {
                        LOGGER.severe(ee.toString());
                    }
                }
            });
            menu.add(openItem);
            JMenuItem importItem = new JMenuItem("Import");
            importItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        File home = new File(System.getProperty("user.home"));
                        Desktop.getDesktop().open(home);
                    } catch (Exception ee) {
                        LOGGER.severe(ee.toString());
                    }
                }
            });

            menu.add(importItem);
            JMenuItem newItem = new JMenuItem("New text");
            newItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        JTextEditor textEditor = new JTextEditor();
                        String teLocator$ = textEditor.getLocator();
                        teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$);
                        String text$ = "New" + Identity.key().substring(0, 4) + ".txt";
                        teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, text$);
                        JFolderPanel fp = new JFolderPanel();
                        String fpLocator$ = fp.getLocator();
                        fpLocator$ = Locator.append(fpLocator$, Entigrator.ENTIHOME, entihome$);
                        fpLocator$ = Locator.append(fpLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                        fpLocator$ = Locator.append(fpLocator$, BaseHandler.HANDLER_METHOD, "response");
                        fpLocator$ = Locator.append(fpLocator$, JRequester.REQUESTER_ACTION,
                                ACTION_CREATE_FILE);
                        String requesterResponseLocator$ = Locator.compressText(fpLocator$);
                        teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                                requesterResponseLocator$);
                        JConsoleHandler.execute(console, teLocator$);
                    } catch (Exception ee) {
                        LOGGER.severe(ee.toString());
                    }
                }
            });

            menu.add(newItem);
            //menu.addSeparator();
            if (hasToInsert()) {
                menu.addSeparator();
                JMenuItem insertItem = new JMenuItem("Insert");
                insertItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        try {
                            Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                            Transferable clipboardContents = systemClipboard.getContents(null);
                            if (clipboardContents == null)
                                return;
                            Object transferData = clipboardContents
                                    .getTransferData(DataFlavor.javaFileListFlavor);
                            List<File> files = (List<File>) transferData;
                            for (int i = 0; i < files.size(); i++) {
                                File file = (File) files.get(i);
                                if (file.exists() && file.isFile()) {
                                    System.out.println("FolderPanel:insert:in=" + file.getPath());
                                    File dir = new File(entihome$ + "/" + entityKey$);
                                    if (!dir.exists())
                                        dir.mkdir();
                                    File out = new File(entihome$ + "/" + entityKey$ + "/" + file.getName());
                                    if (!out.exists())
                                        out.createNewFile();
                                    System.out.println("FolderPanel:insert:out=" + out.getPath());
                                    FileExpert.copyFile(file, out);
                                    JConsoleHandler.execute(console, getLocator());
                                }

                                //      System.out.println("FolderPanel:import:file="+file.getPath());
                            }
                        } catch (Exception ee) {
                            LOGGER.severe(ee.toString());

                        }

                    }
                });
                menu.add(insertItem);
            }
            if (hasToPaste()) {
                menu.addSeparator();
                JMenuItem pasteItem = new JMenuItem("Paste");
                pasteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String[] sa = console.clipboard.getContent();
                        Properties locator;
                        String file$;
                        File file;
                        File target;
                        String dir$ = entihome$ + "/" + entityKey$;
                        File dir = new File(dir$);
                        if (!dir.exists())
                            dir.mkdir();
                        for (String aSa : sa) {
                            try {
                                locator = Locator.toProperties(aSa);
                                if (LOCATOR_TYPE_FILE.equals(locator.getProperty(Locator.LOCATOR_TYPE))) {
                                    file$ = locator.getProperty(FILE_PATH);
                                    file = new File(file$);
                                    target = new File(dir$ + "/" + file.getName());
                                    if (!target.exists())
                                        target.createNewFile();
                                    FileExpert.copyFile(file, target);
                                }
                            } catch (Exception ee) {
                                LOGGER.info(ee.toString());
                            }
                        }
                        JConsoleHandler.execute(console, locator$);
                    }
                });
                menu.add(pasteItem);
            }
            if (hasSelectedItems()) {
                menu.addSeparator();
                JMenuItem deleteItem = new JMenuItem("Delete");
                deleteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?",
                                "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {
                            String[] sa = JFolderPanel.this.listSelectedItems();
                            if (sa == null)
                                return;
                            Properties locator;
                            String file$;
                            File file;
                            for (String aSa : sa) {
                                locator = Locator.toProperties(aSa);
                                file$ = locator.getProperty(FILE_PATH);
                                file = new File(file$);
                                try {
                                    if (file.isDirectory())
                                        FileExpert.clear(file$);
                                    file.delete();
                                } catch (Exception ee) {
                                    LOGGER.info(ee.toString());
                                }
                            }
                        }
                        JConsoleHandler.execute(console, locator$);
                    }
                });
                menu.add(deleteItem);
                JMenuItem copyItem = new JMenuItem("Copy");
                copyItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String[] sa = JFolderPanel.this.listSelectedItems();
                        console.clipboard.clear();
                        if (sa != null)
                            for (String aSa : sa)
                                console.clipboard.putString(aSa);
                    }
                });
                menu.add(copyItem);
                JMenuItem exportItem = new JMenuItem("Export");
                exportItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        try {
                            String[] sa = JFolderPanel.this.listSelectedItems();
                            Properties locator;
                            String file$;
                            File file;
                            ArrayList<File> fileList = new ArrayList<File>();
                            for (String aSa : sa) {
                                try {
                                    locator = Locator.toProperties(aSa);
                                    file$ = locator.getProperty(FILE_PATH);
                                    file = new File(file$);
                                    fileList.add(file);
                                } catch (Exception ee) {
                                    LOGGER.severe(ee.toString());
                                }
                            }
                            File[] fa = fileList.toArray(new File[0]);
                            if (fa.length < 1)
                                return;
                            //                             System.out.println("Folderpanel:finish:list="+fa.length);
                            JFileChooser chooser = new JFileChooser();
                            chooser.setCurrentDirectory(new java.io.File(System.getProperty("user.home")));
                            chooser.setDialogTitle("Export files");
                            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                            chooser.setAcceptAllFileFilterUsed(false);
                            if (chooser.showSaveDialog(JFolderPanel.this) == JFileChooser.APPROVE_OPTION) {
                                String dir$ = chooser.getSelectedFile().getPath();
                                File target;
                                for (File f : fa) {
                                    target = new File(dir$ + "/" + f.getName());
                                    if (!target.exists())
                                        target.createNewFile();
                                    FileExpert.copyFile(f, target);
                                }
                            } else {
                                Logger.getLogger(JMainConsole.class.getName()).info(" no selection");
                            }
                            //                            System.out.println("Folderpanel:finish:list="+fileList.size());  
                        } catch (Exception eee) {
                            LOGGER.severe(eee.toString());
                        }
                    }
                });
                menu.add(exportItem);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu;
}

From source file:org.ash.gui.MainFrame.java

/**
 * Menu file exit_action performed./*  w ww  . ja  va 2  s .  c o m*/
 * 
 * @param e the e
 */
public void menuFileExit_actionPerformed(ActionEvent e) {
    if (JOptionPane.showConfirmDialog(this, Options.getInstance().getResource("quit application?"),
            Options.getInstance().getResource("attention"), JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE) == 0) {
        if (this.collectorUI != null)
            this.collectorUI.stop();
        if (this.database != null)
            this.database.close();
        System.exit(0);
    }
}

From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java

private void populateChildNodes(DefaultMutableTreeNode node) {
    QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject();
    try {/*ww w  .  j  a  va  2 s .c  o m*/
        GetChildrenType parentType = new GetChildrenType();

        parentType.setMax(null);//Integer.parseInt(System.getProperty("OntMax")));
        parentType.setHiddens(Boolean.parseBoolean(System.getProperty("OntHiddens")));
        parentType.setSynonyms(Boolean.parseBoolean(System.getProperty("OntSynonyms")));

        //   log.info("sent : " + parentType.getMax() + System.getProperty("OntMax") + System.getProperty("OntHiddens")
        //      + System.getProperty("OntSynonyms") );

        parentType.setMax(parentPanel.max_child());
        //System.out.println("Max children set to: "+parentPanel.max_child());

        parentType.setBlob(true);
        //   parentType.setType("all");

        parentType.setParent(data.fullname());
        //System.out.println(parentType.getParent());

        //Long time = System.currentTimeMillis();
        //log.info("making web service call " + time);
        GetChildrenResponseMessage msg = new GetChildrenResponseMessage();
        StatusType procStatus = null;
        //while(procStatus == null || !procStatus.getType().equals("DONE")){
        String response = OntServiceDriver.getChildren(parentType, "");
        //System.out.println("Ontology service getchildren response: "+response);
        parentPanel.parentPanel.lastResponseMessage(response);
        //         Long time2 = System.currentTimeMillis();
        //         log.info("returned from 1st web service call " + (time2 - time));         
        procStatus = msg.processResult(response);
        //         log.info(procStatus.getType());
        //         log.info(procStatus.getValue());
        int result;
        if (procStatus.getValue().equals("MAX_EXCEEDED")) {
            result = JOptionPane.showConfirmDialog(parentPanel,
                    "The node has exceeded maximum number of children.\n" + "Do you want to continue?",
                    "Please note ...", JOptionPane.YES_NO_OPTION);

            if (result == JOptionPane.NO_OPTION) {
                DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0);
                QueryConceptTreeNodeData tmpdata = (QueryConceptTreeNodeData) tmpnode.getUserObject();
                tmpdata.name("Over maximum number of child nodes");
                //procStatus.setType("DONE");
                jTree1.repaint();
                jTree1.scrollPathToVisible(new TreePath(tmpnode.getPath()));
                return;
            } else {
                parentType.setMax(null);
                response = OntServiceDriver.getChildren(parentType, "");
                procStatus = msg.processResult(response);
            }
        }

        if (!procStatus.getType().equals("DONE")) {
            JOptionPane.showMessageDialog(parentPanel, "Error message delivered from the remote server, "
                    + "you may wish to retry your last action");
            return;
        }

        ConceptsType allConcepts = msg.doReadConcepts();
        List concepts = allConcepts.getConcept();
        if (concepts != null) {
            addNodesFromOntXML(concepts, node);
            DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0);
            treeModel.removeNodeFromParent(tmpnode);
            jTree1.scrollPathToVisible(new TreePath(node.getPath()));
        }

    } catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(parentPanel,
                "Response delivered from the remote server could not be understood,\n"
                        + "you may wish to retry your last action.");
        return;
    }
}

From source file:Forms.frm_Penghuni.java

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
    // TODO add your handling code here:
    int pilihan = JOptionPane.showConfirmDialog(this, "Apa anda yakin ingin Menutup? ", "Konfirmasi",
            JOptionPane.YES_NO_OPTION);
    if (pilihan == 0) {
        dispose();//from  w  w  w.j a v a2 s .  c  o  m
    }
}

From source file:jeplus.gui.JPanel_EPlusProjectFiles.java

private void cmdEditWeatherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditWeatherActionPerformed
    // Test if the template file is present
    String fn = (String) cboWeatherFile.getSelectedItem();
    String templfn = RelativeDirUtil.checkAbsolutePath(txtWthrDir.getText() + fn, Project.getBaseDir());
    File ftmpl = new File(templfn);
    if (!ftmpl.exists()) {
        int n = JOptionPane.showConfirmDialog(this,
                "<html><p><center>The weather file " + templfn + " does not exist."
                        + "Do you want to select one?</center></p><p> Select 'NO' to create this file. </p>",
                "Weather file not available", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.YES_OPTION) {
            this.cmdSelectWeatherFileActionPerformed(null);
            templfn = txtWthrDir.getText() + (String) cboWeatherFile.getSelectedItem();
        }//from  w ww  . j a va2s.  c  o  m
    }
    int idx = MainGUI.getTpnEditors().indexOfTab(fn);
    if (idx >= 0) {
        MainGUI.getTpnEditors().setSelectedIndex(idx);
    } else {
        //            EPlusTextPanel WthrFilePanel = new EPlusTextPanel(
        //                    MainGUI.getTpnEditors(),
        //                    fn,
        //                    EPlusTextPanel.VIEWER_MODE,
        //                    EPlusConfig.getFileFilter(EPlusConfig.EPW),
        //                    templfn,
        //                    null);
        EPlusEditorPanel WthrFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn,
                EPlusEditorPanel.FileType.EPW, null);
        int ti = MainGUI.getTpnEditors().getTabCount();
        WthrFilePanel.setTabId(ti);
        MainGUI.getTpnEditors().addTab(fn, WthrFilePanel);
        MainGUI.getTpnEditors().setSelectedIndex(ti);
        MainGUI.getTpnEditors().setTabComponentAt(ti,
                new ButtonTabComponent(MainGUI.getTpnEditors(), WthrFilePanel));
        MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn);
    }
}

From source file:com.sshtools.sshterm.SshTerminalPanel.java

public void actionPerformed(ActionEvent event) {
    // Get the name of the action command
    String command = event.getActionCommand();

    if (sessionActions.containsKey(event.getActionCommand())) {
        SessionProviderAction action = (SessionProviderAction) sessionActions.get(event.getActionCommand());
        SessionProviderFrame frame;//w  ww . j  av  a  2 s.  c  o  m
        // Do we have an existing frame?
        for (Iterator it = sessionFrames.iterator(); it.hasNext();) {
            frame = (SessionProviderFrame) it.next();
            if (action.getProvider().getProviderClass().isInstance(frame.getSessionPanel())
                    && frame.getSessionPanel().singleFrame()) {
                frame.show();
                return;
            }
        }

        try {
            frame = new SessionProviderFrame(getCurrentConnectionProfile(), ssh, action.getProvider());
            if (frame.initFrame(getApplication())) {
                frame.show();
                sessionFrames.add(frame);
            }

        } catch (Throwable ex) {
            ex.printStackTrace();
        }
    }
    /*if ((shiftAction != null)
        && command.equals(shiftAction.getActionCommand())) {
      //boolean error = false;
        try {
          SessionProviderFrame browserFrame = new SessionProviderFrame(
         getCurrentConnectionProfile(),
                                ssh,
         SessionProviderFactory.getInstance().getProvider("shift"));
          if (PreferencesStore.preferenceExists(PREF_SHIFT_GEOMETRY)) {
    browserFrame.setBounds(PreferencesStore.getRectangle(
        PREF_SHIFT_GEOMETRY, browserFrame.getBounds()));
          }
          else {
    browserFrame.setLocation(40, 40);
          }
          browserFrame.init(getApplication());
          browserFrame.show();
          browserFrames.add(browserFrame);
        }
        catch (Exception e) {
          showExceptionMessage("Error", e.getMessage());
        }
      }
      /*if (browserFrame != null) {
         //  We need to go back to windowed mode if in full screen mode
         if (!browserFrame.isVisible()) {
           setFullScreenMode(false);
         }
         browserFrame.setVisible(!browserFrame.isVisible());
       }*/

    /* if ( (tunnelingAction != null)
         && command.equals(tunnelingAction.getActionCommand())) {
         try {
    if(tunnelingFrame==null) {
    tunnelingFrame = new SessionProviderFrame(
         getCurrentConnectionProfile(),
                                  ssh,
         SessionProviderFactory.getInstance().getProvider("tunneling"));
    /*if (PreferencesStore.preferenceExists(PREF_SHIFT_GEOMETRY)) {
       tunnelingFrame.setBounds(PreferencesStore.getRectangle(
           PREF_SHIFT_GEOMETRY, tunnelingFrame.getBounds()));
     }
     else {
       tunnelingFrame.setLocation(40, 40);
     }*/

    /*      }
    tunnelingFrame.init(getApplication());
    tunnelingFrame.show();
        }
        catch (Exception e) {
    showExceptionMessage("Error", e.getMessage());
        }*/

    /*if (portForwardingDialog == null) {
         Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class,
     this);
       if (parent instanceof JFrame) {
         portForwardingDialog = new JDialog( (JFrame) parent,
                                      "Port Forwarding", false);
       }
       else if (parent instanceof JDialog) {
         portForwardingDialog = new JDialog( (JDialog) parent,
                                      "Port Forwarding", false);
       }
       else {
         portForwardingDialog = new JDialog( (JFrame)null,
                                      "Port Forwarding", false);
       }
       portForwardingDialog.getContentPane().setLayout(new BorderLayout());
       portForwardingDialog.getContentPane().add(portForwardingPane,
                                           BorderLayout.CENTER);
       portForwardingDialog.pack();
       if (PreferencesStore.preferenceExists(
     PREF_PORT_FORWARDING_GEOMETRY)) {
         portForwardingDialog.setBounds(PreferencesStore
                                  .getRectangle(
       PREF_PORT_FORWARDING_GEOMETRY,
       portForwardingDialog.getBounds()));
       }
       else {
         portForwardingDialog.setLocation(40, 40);
         portForwardingDialog.setSize(new Dimension(260, 420));
       }
       PreferencesStore.restoreTableMetrics(portForwardingPane
                                      .getPortForwardingTable(),
     PREF_PORT_FORWARDING_FORWARDS_TABLE_METRICS,
     new int[] {68, 62, 44, 54, 98, 78});
       PreferencesStore.restoreTableMetrics(portForwardingPane.
                                      getActiveChannelPane()
                                      .getActiveChannelTable(),
     PREF_PORT_FORWARDING_ACTIVE_TABLE_METRICS,
     new int[] {22, 22, 92, 264});
       if (PreferencesStore.preferenceExists(
     PREF_PORT_FORWARDING_DIVIDER_LOCATION)) {
         portForwardingPane.setDividerLocation(PreferencesStore
                                         .getInt(
       PREF_PORT_FORWARDING_DIVIDER_LOCATION, 100));
       }
       else {
         portForwardingPane.setDividerLocation(0.75d);
       }
     }
     //  We need to go back to windowed mode if in full screen mode
     if (!portForwardingDialog.isVisible()) {
       setFullScreenMode(false);
     }
     portForwardingDialog.setVisible(!portForwardingDialog.isVisible());*/
    //}

    if ((stopAction != null) && command.equals(stopAction.getActionCommand())) {
        stopRecording();
    }

    if ((recordAction != null) && command.equals(recordAction.getActionCommand())) {
        //  We need to go back to windowed mode if in full screen mode
        setFullScreenMode(false);

        // Select the file to record to
        JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home"));
        int ret = fileDialog.showSaveDialog(this);

        if (ret == fileDialog.APPROVE_OPTION) {
            recordingFile = fileDialog.getSelectedFile();

            if (recordingFile.exists()
                    && (JOptionPane.showConfirmDialog(this, "File exists. Are you sure?", "File exists",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION)) {
                return;
            }

            try {
                recordingOutputStream = new FileOutputStream(recordingFile);
                statusBar.setStatusText("Recording to " + recordingFile.getName());
                setAvailableActions();
            } catch (IOException ioe) {
                showExceptionMessage("Error", "Could not open file for recording\n\n" + ioe.getMessage());
            }
        }
    }

    if ((playAction != null) && command.equals(playAction.getActionCommand())) {
        //  We need to go back to windowed mode if in full screen mode
        setFullScreenMode(false);

        // Select the file to record to
        JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home"));
        int ret = fileDialog.showOpenDialog(this);

        if (ret == fileDialog.APPROVE_OPTION) {
            File playingFile = fileDialog.getSelectedFile();
            InputStream in = null;

            try {
                statusBar.setStatusText("Playing from " + playingFile.getName());
                in = new FileInputStream(playingFile);

                byte[] b = null;
                int a = 0;

                while (true) {
                    a = in.available();

                    if (a == -1) {
                        break;
                    }

                    if (a == 0) {
                        a = 1;
                    }

                    b = new byte[a];
                    a = in.read(b);

                    if (a == -1) {
                        break;
                    }

                    //emulation.write(b);
                    emulation.getOutputStream().write(b);
                }

                statusBar.setStatusText("Finished playing " + playingFile.getName());
                setAvailableActions();
            } catch (IOException ioe) {
                statusBar.setStatusText("Error playing " + playingFile.getName());
                showExceptionMessage("Error", "Could not open file for playback\n\n" + ioe.getMessage());
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException ioe) {
                        log.error(ioe);
                    }
                }
            }
        }
    }

    if ((newAction != null) && command.equals(newAction.getActionCommand())) {
        setFullScreenMode(false);

        // Clear the screen
        emulation.clearScreen();
        emulation.setCursorPosition(0, 0);

        // Force a repaint
        terminal.refresh();

        SshToolsConnectionProfile p = SshToolsConnectionPanel.showConnectionDialog(this,
                getCurrentConnectionProfile(), getAdditionalConnectionTabs());

        if (p != null) {
            currentConnectionProfile = p;
            setContainerTitle(null);
            setNeedSave(true);
            connect(p, true);
        } else {
            log.info("New connection cancelled");
        }

        return;
    }

    if ((closeAction != null) && command.equals(closeAction.getActionCommand())) {
        if (ssh != null) {
            if (performVerifiedDisconnect(true)) {
                disconnecting = true;
                ssh.disconnect();
            }
        }
    }

    if ((openAction != null) && command.equals(openAction.getActionCommand())) {
        open();
    }

    if ((saveAction != null) && command.equals(saveAction.getActionCommand())) {
        // Make sure we dont have a null connection object
        saveConnection(false);
    }

    if ((saveAsAction != null) && command.equals(saveAsAction.getActionCommand())) {
        saveConnection(true);
    }

    //  Keygen
    if ((keygenAction != null) && event.getActionCommand().equals(keygenAction.getActionCommand())) {
        if (keygenFrame == null) {
            keygenFrame = new com.sshtools.common.keygen.Main();
            keygenFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            keygenFrame.pack();
            UIUtil.positionComponent(SwingConstants.CENTER, keygenFrame);
        }

        if (!keygenFrame.isVisible()) {
            setFullScreenMode(false);
        }

        keygenFrame.setVisible(!keygenFrame.isVisible());
    }

    //GSI options
    if ((proxyInfoAction != null) && command.equals(proxyInfoAction.getActionCommand())) {
        ProxyHelper.showProxyInfo(getContainer().getWindow());
    }
    if ((proxyDestroyAction != null) && command.equals(proxyDestroyAction.getActionCommand())) {
        ProxyHelper.destroyProxy();
        setAvailableActions();
    }
}

From source file:agendapoo.View.FrmMinhaAtividade.java

private void btnSaveChangesActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSaveChangesActionPerformed
{//GEN-HEADEREND:event_btnSaveChangesActionPerformed
    try {/*from w  w w .  java  2 s .c  om*/
        int opcao = JOptionPane.showConfirmDialog(this,
                "Tem certeza que desejas atualizar as informaes dessa atividade?", "Aviso",
                JOptionPane.YES_NO_OPTION);
        switch (opcao) {
        case JOptionPane.YES_OPTION:
            saveChanges(selectedAtividade);
            JOptionPane.showMessageDialog(this, "Atualizao realizada com sucesso!");
            usuarioMain.loadAtividades();
            this.dispose();
            break;
        }
    } catch (SQLException | IOException | ClassNotFoundException | InvalidTimeRangeException
            | TimeInterferenceException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (DateTimeParseException dtpe) {
        JOptionPane.showMessageDialog(this, "Por favor, Insira uma hora vlida!", "Hora Invlida",
                JOptionPane.ERROR_MESSAGE);
    } catch (EmailException ex) {
        JOptionPane.showMessageDialog(this,
                "No foi possvel enviar o e-mail para os convidados, por favor, "
                        + "verifique sua conexo com a internet e tente novamente.",
                "Problema ao enviar e-mail", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:ded.ui.DiagramController.java

/** Clear the current diagram. */
public void newFile() {
    if (this.isDirty()) {
        int res = JOptionPane.showConfirmDialog(this, "There are unsaved changes.  Create new diagram anyway?",
                "New Diagram Confirmation", JOptionPane.YES_NO_OPTION);
        if (res != JOptionPane.YES_OPTION) {
            return;
        }/*from   w  w  w  .j ava 2 s  . com*/
    }

    // Reset file status.
    this.dirty = false;
    this.setFileName("");

    // Clear the diagram.
    this.setDiagram(new Diagram());
}