Example usage for javax.swing JOptionPane OK_OPTION

List of usage examples for javax.swing JOptionPane OK_OPTION

Introduction

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

Prototype

int OK_OPTION

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

Click Source Link

Document

Return value form class method if OK is chosen.

Usage

From source file:org.parosproxy.paros.extension.history.ExtensionHistory.java

protected int showFilterPlusDialog() {
    HistoryFilterPlusDialog dialog = getFilterPlusDialog();
    dialog.setModal(true);/*from   w  w  w.  ja  va 2s  .  c om*/
    try {
        dialog.setAllTags(getModel().getDb().getTableTag().getAllTags());
    } catch (DatabaseException e) {
        logger.error(e.getMessage(), e);
    }

    int exit = dialog.showDialog();
    int result = 0; // cancel, state unchanged
    HistoryFilter historyFilter = dialog.getFilter();
    if (exit == JOptionPane.OK_OPTION) {
        searchHistory(historyFilter);
        logPanel.setFilterStatus(historyFilter);
        result = 1; // applied

    } else if (exit == JOptionPane.NO_OPTION) {
        searchHistory(historyFilter);
        logPanel.setFilterStatus(historyFilter);
        result = -1; // reset
    }

    return result;
}

From source file:org.parosproxy.paros.extension.scanner.ExtensionScanner.java

/**
 * This method initializes menuItemPolicy   
 *    //from   www  .j  a  v  a  2  s  .  c  o m
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getMenuItemPolicy() {
    if (menuItemPolicy == null) {
        menuItemPolicy = new JMenuItem();
        menuItemPolicy.setText("Scan Policy...");
        menuItemPolicy.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {

                PolicyDialog dialog = new PolicyDialog(getView().getMainFrame());
                dialog.initParam(getModel().getOptionsParam());
                int result = dialog.showDialog(false);
                if (result == JOptionPane.OK_OPTION) {
                    try {
                        getModel().getOptionsParam().getConfig().save();
                    } catch (ConfigurationException ce) {
                        ce.printStackTrace();
                        getView().showWarningDialog("Error saving policy.");
                        return;
                    }
                }
            }
        });

    }
    return menuItemPolicy;
}

From source file:org.parosproxy.paros.extension.state.ExtensionState.java

/**
 * This method initializes jMenuItem   /*w  ww . j a  v  a  2  s  . co  m*/
 *    
 * @return javax.swing.JMenuItem   
 */
private ZapMenuItem getMenuResetSessionState() {
    if (menuResetSessionState == null) {
        menuResetSessionState = new ZapMenuItem("menu.edit.resetState");
        menuResetSessionState.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (getView().showConfirmDialog(
                        Constant.messages.getString("state.reset.warning")) == JOptionPane.OK_OPTION) {
                    resetSessionState();
                }

            }
        });
    }
    return menuResetSessionState;
}

From source file:org.parosproxy.paros.view.TabbedPanel.java

public void alternateParent() {
    if (alternativeParent == null)
        return;/*w ww .  j  a  va2  s. c o m*/

    if (Model.getSingleton().getOptionsParam().getViewParam().getWarnOnTabDoubleClick()) {
        if (View.getSingleton().showConfirmDialog(
                Constant.messages.getString("tab.doubleClick.warning")) != JOptionPane.OK_OPTION) {
            // They cancelled the dialog
            return;
        }
        // Only ever warn once
        Model.getSingleton().getOptionsParam().getViewParam().setWarnOnTabDoubleClick(false);
        try {
            Model.getSingleton().getOptionsParam().getViewParam().getConfig().save();
        } catch (ConfigurationException e) {
            log.error(e.getMessage(), e);
        }
    }

    if (isAlternative) {

        originalParent = this.getParent();
        originalParent.remove(this);
        backupChild = alternativeParent.getComponent(0);
        alternativeParent.remove(backupChild);
        alternativeParent.add(this);
    } else {
        alternativeParent.remove(this);
        alternativeParent.add(backupChild);
        originalParent.add(this);
    }
    originalParent.validate();
    alternativeParent.validate();
    this.validate();
    isAlternative = !isAlternative;
}

From source file:org.paxml.el.UtilFunctions.java

public static String ask(String question, boolean mask) {
    class DummyFrame extends JFrame {
        DummyFrame(String title) {
            super(title);
            setUndecorated(true);/* ww w .  ja v  a2  s  . c om*/
            setVisible(true);
            setLocationRelativeTo(null);
        }
    }
    JPasswordField pf = new JPasswordField();
    DummyFrame frame = new DummyFrame(question);
    int okCxl = JOptionPane.showConfirmDialog(frame, pf, question, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    frame.setVisible(false);
    if (okCxl == JOptionPane.OK_OPTION) {
        return new String(pf.getPassword());
    }
    return null;
}

From source file:org.paxml.security.SecretRepository.java

public static String askForPasswordInput(String question) {

    class DummyFrame extends JFrame {
        DummyFrame(String title) {
            super(title);
            setUndecorated(true);//  w  w  w.  j av  a 2 s . c o m
            setVisible(true);
            setLocationRelativeTo(null);
        }
    }
    JPasswordField pf = new JPasswordField();
    int okCxl = JOptionPane.showConfirmDialog(new DummyFrame(question), pf, question,
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);

    if (okCxl == JOptionPane.OK_OPTION) {
        return new String(pf.getPassword());
    }
    return null;
}

From source file:org.pentaho.reporting.ui.datasources.kettle.EmbeddedKettleDataSourceDialog.java

@Override
protected boolean validateInputs(boolean onConfirm) {
    boolean valid = true;

    for (final KettleQueryEntry queryEntry : getQueryEntries()) {
        valid = queryEntry.isValidated();
        if (!valid) {
            break;
        }/*from  www .  ja v  a  2 s.  c  o  m*/
    }

    if (valid == false && onConfirm == true) {
        int val = JOptionPane.showConfirmDialog(this,
                Messages.getString("EmbeddedKettleDataSourceDialog.QueryErrorWarning"),
                Messages.getString("EmbeddedKettleDataSourceDialog.QueryErrorTitle"),
                JOptionPane.OK_CANCEL_OPTION);
        valid = (val == JOptionPane.OK_OPTION);
    }

    return valid && super.validateInputs(onConfirm);
}

From source file:org.pgptool.gui.ui.tools.UiUtils.java

public static boolean confirm(String userPromptMessageCode, Object[] messageArgs, Window parent) {
    int response = JOptionPane.OK_OPTION;

    String msg = Messages.get(userPromptMessageCode, messageArgs);
    if (msg.length() > 70) {
        response = JOptionPane.showConfirmDialog(parent, getMultilineMessage(msg),
                Messages.get("term.confirmation"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    } else {//from ww  w. jav  a 2  s  .c  om
        response = JOptionPane.showConfirmDialog(parent, msg, Messages.get("term.confirmation"),
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    }
    return response == JOptionPane.OK_OPTION;
}

From source file:org.richie.codeGen.ui.GenAndPreviewUI.java

private boolean initCustomerVelocityContext(CodeTemplateVo vo) throws Exception {
    Table selectedTable = parent.getTable();
    if (selectedTable == null) {
        int status = JOptionPane.showConfirmDialog(this, "?", "??",
                JOptionPane.OK_CANCEL_OPTION);
        if (status != JOptionPane.OK_OPTION) {
            return false;
        }//from   www.  ja  v  a  2s  .  c  o m
    }
    setTableValue();
    // ?????
    DataTypeUtils.setDataType(selectedTable);
    if (selectedTable != null && selectedTable.getChildTable() != null) {
        DataTypeUtils.setDataType(selectedTable.getChildTable());
    }
    Map<String, Object> map = GlobalData.getConstentMap();
    CodeGen.initCustomerVelocityContext(map);
    return true;
}

From source file:org.shelloid.vpt.agent.App.java

private void setupSystemTray() {
    if (SystemTray.isSupported()) {
        try {/*from w ww . j a v a2s . co  m*/
            final ConfigForm configForm = new ConfigForm(false);
            final PopupMenu popup = new PopupMenu();
            final TrayIcon trayIcon = new TrayIcon(createImage("/images/logo.jpg"), "Shelloid VPT Agent");
            tray = SystemTray.getSystemTray();
            MenuItem authenticateItem = new MenuItem("Configure Authentication");
            MenuItem aboutItem = new MenuItem("About Shelloid VPT Agent");
            MenuItem exitItem = new MenuItem("Exit");
            trayIcon.setPopupMenu(popup);
            tray.add(trayIcon);
            authenticateItem.addActionListener(new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    configForm.setVisible(true);
                }
            });
            aboutItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JOptionPane.showMessageDialog(null,
                            "Shelloid VPT Agent.\nVersion : " + getVersion()
                                    + "\n\n(c) 2014 Shelloid LLC. \nhttps://www.shelloid.com",
                            "Shelloid VPT Client", JOptionPane.INFORMATION_MESSAGE);
                }
            });
            exitItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (JOptionPane.showConfirmDialog(null, "Are you sure to exit Shelloid VPT Agent?",
                            "Shelloid VPT Agent", JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
                        shuttingDown = true;
                        closeAllConnections();
                        System.exit(0);
                    }
                }
            });
            popup.add(authenticateItem);
            popup.add(aboutItem);
            popup.addSeparator();
            popup.add(exitItem);
        } catch (Exception ex) {
            Platform.shelloidLogger.warn("System Tray Error: ", ex);
        }
    } else {
        System.out.println("System tray is not supported");
    }
}