Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

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

Prototype

int WARNING_MESSAGE

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

Click Source Link

Document

Used for warning messages.

Usage

From source file:ru.spbspu.viewer.DataView.java

private void openItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openItemActionPerformed
    fileChooser.showOpenDialog(this);
    String path = null;//  w  w  w . ja  va2 s. co  m
    if (fileChooser.getSelectedFile() != null) {
        path = fileChooser.getSelectedFile().getAbsolutePath();
    } else {
        return;
    }
    _presenter.setEnabledStart(path);
    if (_presenter.isEnabledStart()) {

        chosenFileTextField.setText(path);
        load.setEnabled(_presenter.isEnabledStart());
        seekSlider.setEnabled(true);
        spinnerFrameWidth.setEnabled(true);
        spinnerWindowWidth.setEnabled(true);
        spectrogram.setEnabled(true);
        labelForFrameSpectr.setEnabled(true);
        sliderMenu.setEnabled(true);

    } else {
        JOptionPane.showMessageDialog(rootPane, "   .ana",
                "  ", JOptionPane.WARNING_MESSAGE);
    }
}

From source file:com.adito.server.DefaultAditoServerFactory.java

private boolean fullReset() {
    if (gui) {// w w w  .j  a  v a 2  s . com
        if (JOptionPane.showConfirmDialog(null, "The embedded configuration database will be\n"
                + "completely deleted and re-created the next\ntime you run the server. Are you absolutely\n"
                + "sure you wish to do this?", "Full Reset", JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION) != JOptionPane.OK_OPTION) {
            return false;
        }
    } else {
        System.out.println("The embedded configuration database will be");
        System.out.println("completely deleted and re-created the next");
        System.out.println("time you run the server. Are you absolutely");
        System.out.println("sure you wish to do this?");
        System.out.println();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            System.out.print("(Y)es or (N)o: ");
            String s;
            try {
                s = br.readLine();
                if (s == null) {
                    return false;
                }
                if (s.toLowerCase().equals("y") || s.toLowerCase().equals("yes")) {
                    break;
                }
                if (s.toLowerCase().equals("n") || s.toLowerCase().equals("no")) {
                    return false;
                }
                System.out.println(
                        "\nPlease answer 'y' or 'yes' to perform the reset, or 'n' or 'no' to abort the reset.");
            } catch (IOException e) {
                return false;
            }
        }
    }

    // Start the reset
    System.out.println("Resetting all configuration");
    File[] f = getDBDirectory().listFiles();
    if (f != null) {
        for (File f1 : f) {
            System.out.println("    Deleting " + f1.getPath());
            if (!f1.delete()) {
                System.out.println("        Failed to remove");
            }
        }
    }

    return true;
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

public void mkdirActionAux() {
    try {/*from www  .  ja  va 2  s .c o m*/
        String newDirName;
        String newDirPath = null;

        do {
            // get new directory name from user
            newDirName = (String) JOptionPane.showInputDialog(this.getParent(), "Name of new directory",
                    "New Directory", JOptionPane.QUESTION_MESSAGE, null, null, "directory name");

            // check if user pressed 'cancel' button
            if (newDirName == null) {
                LOG.info("Mkdir cancelled\n");
                return;
            }

            /**
             * Validate the new directory name TODO: Complete validation based to target OS The
             * forward slash is never valid. On a local file system the file separator is
             * invalid.
             */
            ProfileType type = getSelectedProfile().getType();
            if (newDirName.contains("/")
                    || (type == ProfileType.FILESYSTEM && newDirName.contains(File.separator))
                    || (type == ProfileType.HCAP2 && newDirName.contains("&"))) {
                JOptionPane.showMessageDialog(this.getParent(), "Invalid directory name", "Error",
                        JOptionPane.WARNING_MESSAGE);
                newDirName = null;
                continue;
            }

            // build new directory path from current directory and user supplied name. We must
            // encode the part just entered by the user
            String encodedDirName = newDirName;
            try {
                encodedDirName = profileModel.getSelectedProfile().encode(newDirName);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this.getParent(), "An error occurred encoding the directory name",
                        "Error", JOptionPane.WARNING_MESSAGE);
                LOG.log(Level.WARNING, String.format("An error occurred encoding directory <%s>", newDirName));
                newDirName = null;
                continue;
            }

            newDirPath = FileUtil.resolvePath(currentDir.getPath(), encodedDirName,
                    profileModel.getSelectedProfile().getPathSeparator());
        } while (newDirName == null || newDirName.length() <= 0 || newDirPath == null);

        LOG.info("Creating new directory " + newDirPath);
        try {
            if (!arcMoverEngine.mkdir(profileModel.getSelectedProfile(), newDirPath)) {
                String msg = "Could not create directory: Permission Denied";
                throw new IOException(msg);
            }
            final ArcMoverDirectory dir = profileModel.getProfileAdapter().getDirectory(newDirPath);
            GUIHelper.invokeAndWait(new Runnable() {
                public void run() {
                    refreshPathAndFileList();
                    // refresh the other panel if necessary, but it won't do this panel because
                    // we are currently locked
                    HCPDataMigrator.getInstance().refreshMatchingPanels(profileModel.getSelectedProfile(),
                            currentDir);
                }
            }, "refresh after creating new directory");
        } catch (Exception e) {
            String uiErrorMsg;
            String logErrorMsg;

            if (e instanceof StorageAdapterException) {
                logErrorMsg = e.getMessage();
                uiErrorMsg = e.getMessage();
            } else {
                logErrorMsg = "Could not create directory: " + newDirPath;
                uiErrorMsg = DBUtils.getErrorMessage(
                        "Error creating directory " + profileModel.getSelectedProfile().decode(newDirPath), e);
            }
            LOG.log(Level.WARNING, logErrorMsg, e);
            GUIHelper.showMessageDialog(this.getParent(), uiErrorMsg, "Create Directory Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    } catch (RuntimeException e1) {
        // TODO: Implement Proper Error Handling
        LOG.log(Level.WARNING, "Unexpected Exception", e1);
        throw e1;
    }
}

From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java

/**
 * @param usrPwd/*from   w  w w  .j  a  v a  2s  .c o  m*/
 */
private void doCheckPermissions(final Pair<String, String> usrPwd) {
    if (System.getProperty("user.name").equals("rods")) {
        String dbDriver = DBConnection.getInstance().getDriver();
        String serverName = getServerName();
        String dbName = getDatabaseName();
        SQLException loginEx = DBConnection.getLoginException();

        if (StringUtils.isNotEmpty(dbDriver) && dbDriver.equals("com.mysql.jdbc.Driver") && loginEx != null
                && StringUtils.isNotEmpty(loginEx.getSQLState()) && loginEx.getSQLState().equals("08001")) {
            boolean doFixIt = UIRegistry.displayConfirmLocalized("MISSING_PRIV_TITLE", "MISSING_PRIV",
                    "MISSING_PRIV_FIX", "Cancel", JOptionPane.WARNING_MESSAGE);
            if (doFixIt) {
                DBConnection.getInstance().setServerName(serverName); // Needed for SchemaUpdateService

                Pair<String, String> itUP = getITUsernamePwd();
                DBMSUserMgr mgr = DBMSUserMgr.getInstance();
                try {
                    if (mgr != null && mgr.connectToDBMS(itUP.first, itUP.second, serverName)) {
                        boolean isOK = mgr.setPermissions(usrPwd.first, dbName, DBMSUserMgr.PERM_ALL_BASIC);
                        UIRegistry.showLocalizedMsg(
                                isOK ? JOptionPane.INFORMATION_MESSAGE : JOptionPane.ERROR_MESSAGE,
                                getResourceString("MISSING_PRIV_TITLE"),
                                (isOK ? "MISSING_PRIV_OK" : "MISSING_PRIV_ERR"));
                        mgr.close();
                    } else {
                        UIRegistry.showError("MISSING_PRIV_NO_LOGIN");
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
}

From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java

public void removeTraits(Collection<Trait> traitsToCheck) {

    KDSmartDatabase kdsDb = offlineData.getKdxploreDatabase().getKDXploreKSmartDatabase();
    List<Trait> okToDelete = new ArrayList<>();
    Map<Trait, List<Trial>> dontDelete = new TreeMap<>();

    try {//from   w  w w  .  j  av  a 2 s.c  o m

        checkOnTraitUsage(kdsDb, traitsToCheck, okToDelete, dontDelete);

        Function<Trait, Integer> dontDeleteNamer = new Function<Trait, Integer>() {
            @Override
            public Integer apply(Trait t) {
                List<Trial> list = dontDelete.get(t);
                return list == null ? 0 : list.size();
            }
        };

        if (okToDelete.isEmpty()) {
            Object msg;
            if (dontDelete.size() == 1) {
                String s = "";
                for (Trait t : dontDelete.keySet()) {
                    s = t.getTraitName() + ": used by " + dontDelete.get(t).size() + " Trials";
                    break;
                }
                msg = s;
            } else {
                msg = HelpUtils.makeTableInScrollPane("Trait", "# Trials", dontDelete.keySet(),
                        dontDeleteNamer);
                //                    msg = HelpUtils.makeListInScrollPane(dontDelete.entrySet(), namer);
            }
            JOptionPane.showMessageDialog(TraitExplorerPanel.this, msg,
                    "None of the selected Traits may be removed", JOptionPane.WARNING_MESSAGE);
        } else {

            Collections.sort(okToDelete);

            Box box = Box.createVerticalBox();
            box.add(GuiUtil.createLabelSeparator("Traits to Remove"));
            box.add(HelpUtils.makeListInScrollPane(okToDelete, Trait::getTraitName));

            if (!dontDelete.isEmpty()) {
                if (dontDelete.size() == 1) {
                    //                        box.add(GuiUtil.createLabelSeparator("These will not be removed"));
                    for (Trait t : dontDelete.keySet()) {
                        box.add(new JLabel("Will not be removed: " + t.getTraitName()));
                    }
                } else {
                    JScrollPane sp = HelpUtils.makeTableInScrollPane("Trait", "# Trials", dontDelete.keySet(),
                            dontDeleteNamer);
                    box.add(GuiUtil.createLabelSeparator("These will not be removed"));
                    box.add(sp);
                }
            }

            if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(TraitExplorerPanel.this, box,
                    "Confirm Trait Removal", JOptionPane.YES_NO_OPTION)) {
                int[] traitIds = new int[okToDelete.size()];
                for (int index = okToDelete.size(); --index >= 0;) {
                    traitIds[index] = okToDelete.get(index).getTraitId();
                }
                kdsDb.removeTraits(traitIds);
            }
        }

    } catch (IOException e1) {
        MsgBox.error(TraitExplorerPanel.this, e1, "Error Removing Traits");
    }
}

From source file:com.adito.server.Main.java

private boolean fullReset() {
    if (gui) {/*from www. ja va 2s. c  o m*/
        if (JOptionPane.showConfirmDialog(null, "The embedded configuration database will be\n"
                + "completely deleted and re-created the next\ntime you run the server. Are you absolutely\n"
                + "sure you wish to do this?", "Full Reset", JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION) != JOptionPane.OK_OPTION) {
            return false;
        }
    } else {
        System.out.println("The embedded configuration database will be");
        System.out.println("completely deleted and re-created the next");
        System.out.println("time you run the server. Are you absolutely");
        System.out.println("sure you wish to do this?");
        System.out.println();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            System.out.print("(Y)es or (N)o: ");
            String s;
            try {
                s = br.readLine();
                if (s == null) {
                    return false;
                }
                if (s.toLowerCase().equals("y") || s.toLowerCase().equals("yes")) {
                    break;
                }
                if (s.toLowerCase().equals("n") || s.toLowerCase().equals("no")) {
                    return false;
                }
                System.out.println(
                        "\nPlease answer 'y' or 'yes' to perform the reset, or 'n' or 'no' to abort the reset.");
            } catch (IOException e) {
                return false;
            }
        }
    }

    // Start the reset
    System.out.println("Resetting all configuration");
    File[] f = getDBDirectory().listFiles();
    if (f != null) {
        for (int i = 0; i < f.length; i++) {
            if (!f[i].getName().equals("CVS") && !f[i].equals(".cvsignore")) {
                System.out.println("    Deleting " + f[i].getPath());
                if (!f[i].delete()) {
                    System.out.println("        Failed to remove");
                }
            }
        }
    }

    return true;
}

From source file:client.ui.FilePane.java

private void getDirectory(String targetID) {
    FileDirectoryResult result;// w w w .  j  a v  a 2 s . c o m
    try {
        result = m_Business.getDirectory(targetID);
        FileDirectoryStatus status = result.getResult();
        switch (status) {
        case OK:
            ArrayList<CloudFile> directory = result.getFileDirectory();
            Collections.sort(directory);
            fileInfoTable.clearSelection();
            fileInfoTable.getRowSorter().setSortKeys(null);
            fileTableModel.setDirectory(directory);
            fileInfoTable.setModel(fileTableModel);
            fileInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
            fileInfoTable.setEnabled(true);
            setCurrentID(targetID);
            //fileInfoTable.repaint();
            repaint();
            break;
        case unAuthorized:
            JOptionPane.showMessageDialog(m_MainFrame, "?", "",
                    JOptionPane.WARNING_MESSAGE);
            m_MainFrame.setVisible(false);
            LoginDialog loginDialog = new LoginDialog(m_MainFrame, m_Business);
            break;
        case wrong:
            JOptionPane.showMessageDialog(m_MainFrame, "?",
                    "", JOptionPane.WARNING_MESSAGE);
            break;
        default:
            JOptionPane.showMessageDialog(m_MainFrame, "", "",
                    JOptionPane.ERROR_MESSAGE);
            break;
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(m_MainFrame, "", "",
                JOptionPane.ERROR_MESSAGE);
    }
    clearNoteAndText();
    fileInfoTable.clearSelection();
}

From source file:mondrian.gui.Workbench.java

private void openSchemaFrame(File file, boolean newFile) {
    try {/* ww  w.  j a  v  a  2s .c o  m*/
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        if (!newFile) {
            // check if file not already open
            if (checkFileOpen(file)) {
                return;
            }
            // check if schema file exists
            if (!file.exists()) {
                JOptionPane.showMessageDialog(this,
                        getResourceConverter().getFormattedString("workbench.open.schema.not.found",
                                "{0} File not found.", file.getAbsolutePath()),
                        getResourceConverter().getString("workbench.open.schema.not.found.title", "Alert"),
                        JOptionPane.WARNING_MESSAGE);
                return;
            }
            // check if file is writable
            if (!file.canWrite()) {
                JOptionPane.showMessageDialog(this,
                        getResourceConverter().getFormattedString("workbench.open.schema.not.writeable",
                                "{0} is not writeable.", file.getAbsolutePath()),
                        getResourceConverter().getString("workbench.open.schema.not.writeable.title", "Alert"),
                        JOptionPane.WARNING_MESSAGE);
                return;
            }
            checkSchemaFile(file);
        }

        final JInternalFrame schemaFrame = new JInternalFrame();
        schemaFrame.setTitle(getResourceConverter().getFormattedString("workbench.open.schema.title",
                "Schema - {0}", file.getName()));

        getNewJdbcMetadata();

        schemaFrame.getContentPane().add(new SchemaExplorer(this, file, jdbcMetaData, newFile, schemaFrame));

        String errorOpening = ((SchemaExplorer) schemaFrame.getContentPane().getComponent(0)).getErrMsg();
        if (errorOpening != null) {
            JOptionPane.showMessageDialog(this,
                    getResourceConverter().getFormattedString("workbench.open.schema.error",
                            "Error opening schema - {0}.", errorOpening),
                    getResourceConverter().getString("workbench.open.schema.error.title", "Error"),
                    JOptionPane.ERROR_MESSAGE);
            schemaFrame.setClosed(true);
            return;
        }

        schemaFrame.setBounds(0, 0, 1000, 650);
        schemaFrame.setClosable(true);
        schemaFrame.setIconifiable(true);
        schemaFrame.setMaximizable(true);
        schemaFrame.setResizable(true);
        schemaFrame.setVisible(true);

        desktopPane.add(schemaFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);
        schemaFrame.show();
        schemaFrame.setMaximum(true);

        displayWarningOnFailedConnection();

        final javax.swing.JMenuItem schemaMenuItem = new javax.swing.JMenuItem();
        schemaMenuItem.setText(windowMenuMapIndex++ + " " + file.getName());
        schemaMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    if (schemaFrame.isIcon()) {
                        schemaFrame.setIcon(false);
                    } else {
                        schemaFrame.setSelected(true);
                    }
                } catch (Exception ex) {
                    LOGGER.error("schemaMenuItem", ex);
                }
            }
        });

        windowMenu.add(schemaMenuItem, 0);
        windowMenu.setEnabled(true);

        windowMenu.add(jSeparator3, -1);
        windowMenu.add(cascadeMenuItem, -1);
        windowMenu.add(tileMenuItem, -1);
        windowMenu.add(minimizeMenuItem, -1);
        windowMenu.add(maximizeMenuItem, -1);
        windowMenu.add(closeAllMenuItem, -1);

        // add the file details in menu map
        schemaWindowMap.put(schemaFrame, schemaMenuItem);
        updateMDXCatalogList();

        schemaFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

        schemaFrame.addInternalFrameListener(new InternalFrameAdapter() {
            public void internalFrameClosing(InternalFrameEvent e) {
                if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                    SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0);
                    int response = confirmFrameClose(schemaFrame, se);
                    if (response == 3) { // not dirty
                        if (se.isNewFile()) {
                            se.getSchemaFile().delete();
                        }
                        // default case for no save and not dirty
                        schemaWindowMap.remove(schemaFrame);
                        updateMDXCatalogList();
                        schemaFrame.dispose();
                        windowMenu.remove(schemaMenuItem);
                    }
                }
            }
        });

        schemaFrame.setFocusable(true);
        schemaFrame.addFocusListener(new FocusAdapter() {
            public void focusGained(FocusEvent e) {
                if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                    SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0);
                    // update view menu based on schemaframe who gained
                    // focus
                    viewXmlMenuItem.setSelected(se.isEditModeXML());
                }
            }

            public void focusLost(FocusEvent e) {
                if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                    SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0);
                    // update view menu based on
                    viewXmlMenuItem.setSelected(se.isEditModeXML());
                }
            }
        });
        viewXmlMenuItem.setSelected(false);
    } catch (Exception ex) {
        LOGGER.error("openSchemaFrame", ex);
    } finally {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:com.freedomotic.jfrontend.MainWindow.java

/**
 * /* ww  w .  ja v  a 2 s .c om*/
 * @param evt 
 */
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
    String[] buttons = { i18n.msg("form_compilation"), i18n.msg("send_log"), i18n.msg("delete") };
    int option = JOptionPane.showOptionDialog(null, i18n.msg("report_issue_dialog"), i18n.msg("report_issue"),
            JOptionPane.WARNING_MESSAGE, 0, null, buttons, buttons[2]);
    switch (option) {
    case 0:
        this.openGoogleForm();
        break;
    case 1:
        this.sendLogByMail();
        break;
    default:
        break;
    }
}