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:userinterface.DoctorWorkArea.DiagnosePatientJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    Employee patient = (Employee) patientCombo.getSelectedItem();
    int selectedRow = vitalSignTable.getSelectedRow();
    if (selectedRow >= 0) {
        VitalSign vs = (VitalSign) vitalSignTable.getValueAt(selectedRow, 0);
        respiratoryTextField.setText(String.valueOf(vs.getRespiratoryRate()));
        heartRateTextField.setText(String.valueOf(vs.getHeartRate()));
        bloodPressureTextField.setText(String.valueOf(vs.getBloodPressure()));
        weightTextField.setText(String.valueOf(vs.getWeight()));
        timestampTextField.setText(vs.getTimestamp());

        patientNameTextField.setText(patient.getName());
        patientIdTextField.setText(Integer.toString(patient.getId()));
        ageTextField.setText(Integer.toString(patient.getAge()));
        doctorTextField.setText(patient.getPrimaryDoctor());

    } else {/*w w  w . j  ava 2s  .c  o  m*/
        JOptionPane.showMessageDialog(null, "Please select a row from the first table", "Warning",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:Installer.java

public void run() {
    JOptionPane optionPane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION,
            null, new String[] { "Install", "Cancel" });

    emptyFrame = new Frame("Vivecraft Installer");
    emptyFrame.setUndecorated(true);//from  w  w  w. j  a va2 s. c  o  m
    emptyFrame.setVisible(true);
    emptyFrame.setLocationRelativeTo(null);
    dialog = optionPane.createDialog(emptyFrame, "Vivecraft Installer");
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
    String str = ((String) optionPane.getValue());
    if (str != null && ((String) optionPane.getValue()).equalsIgnoreCase("Install")) {
        int option = JOptionPane.showOptionDialog(null,
                "Please ensure you have closed the Minecraft launcher before proceeding.\n"
                //"Also, if installing with Forge please ensure you have installed Forge " + FORGE_VERSION + " first.",
                , "Important!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null);

        if (option == JOptionPane.OK_OPTION) {
            monitor = new ProgressMonitor(null, "Installing Vivecraft...", "", 0, 100);
            monitor.setMillisToDecideToPopup(0);
            monitor.setMillisToPopup(0);

            task = new InstallTask();
            task.addPropertyChangeListener(this);
            task.execute();
        } else {
            dialog.dispose();
            emptyFrame.dispose();
        }
    } else {
        dialog.dispose();
        emptyFrame.dispose();
    }
}

From source file:mondrian.gui.Workbench.java

private void newQueryMenuItemActionPerformed(ActionEvent evt) {
    JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame());

    final JInternalFrame jf = new JInternalFrame();
    jf.setTitle(getResourceConverter().getString("workbench.new.MDXQuery.title", "MDX Query"));
    QueryPanel qp = new QueryPanel(this);

    jf.getContentPane().add(qp);/* ww w.ja  v  a2s . co  m*/
    jf.setBounds(0, 0, 500, 480);
    jf.setClosable(true);
    jf.setIconifiable(true);
    jf.setMaximizable(true);
    jf.setResizable(true);
    jf.setVisible(true);

    desktopPane.add(jf);
    jf.show();
    try {
        jf.setSelected(true);
    } catch (Exception ex) {
        // do nothing
        LOGGER.error("newQueryMenuItemActionPerformed.setSelected", ex);
    }

    // add the mdx frame to this set of mdx frames for cascading method
    mdxWindows.add(jf);

    // create mdx menu item
    final javax.swing.JMenuItem queryMenuItem = new javax.swing.JMenuItem();
    queryMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.MDXQuery.menuitem",
            "{0} MDX", Integer.toString(windowMenuMapIndex)));
    queryMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (jf.isIcon()) {
                    jf.setIcon(false);
                } else {
                    jf.setSelected(true);
                }
            } catch (Exception ex) {
                LOGGER.error("queryMenuItem", ex);
            }
        }
    });

    // disable mdx frame close operation to provide our handler
    // to remove frame object from mdxframeset before closing
    jf.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    jf.addInternalFrameListener(new InternalFrameAdapter() {
        public void internalFrameClosing(InternalFrameEvent e) {
            mdxWindows.remove(jf);
            jf.dispose();
            // follow this by removing file from schemaWindowMap
            windowMenu.remove(queryMenuItem);
            return;
        }
    });

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

    qp.setMenuItem(queryMenuItem);
    qp.setSchemaWindowMap(schemaWindowMap);
    qp.setWindowMenuIndex(windowMenuMapIndex++);

    if (schemaMenuItem != null) {
        qp.initConnection(schemaMenuItem.getText());
    } else {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection",
                        "No Mondrian connection. Select a Schema to connect."),
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection.title", "Alert"),
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:com.clough.android.adbv.view.MainFrame.java

private synchronized boolean processResult(final boolean forTextOutput) {
    try {/* ww  w .j a va2 s .c  om*/
        final JSONArray jsonArray = new JSONArray(outputResult);
        final int jsonObjectLength = jsonArray.length();

        if (jsonObjectLength > 0) {
            new SwingWorker<Void, Void>() {

                boolean columnsFound = false;

                List<String> tableColumnList = null;
                List<Integer> tableColumnWidthList = null;
                List<List<String>> tableRowList = null;

                @Override
                protected Void doInBackground() throws Exception {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                    }

                    if (forTextOutput) {
                        tableColumnList = new ArrayList<String>();
                        tableColumnWidthList = new ArrayList<Integer>();
                        tableRowList = new ArrayList<List<String>>();
                    }

                    for (int i = 0; i < jsonObjectLength; i++) {
                        waitingDialog.incrementProgressBar();
                        JSONObject jsonObject = jsonArray.getJSONObject(i);

                        if (!columnsFound) {

                            if (forTextOutput) {
                                tableColumnList.add("#");
                                tableColumnWidthList.add(1);
                            } else {
                                defaultTableModel.addColumn("#");
                            }

                            JSONArray fieldNamesJSONArray = jsonObject.names();
                            for (int j = 0; j < fieldNamesJSONArray.length(); j++) {
                                final String columnName = fieldNamesJSONArray.getString(j);
                                if (forTextOutput) {
                                    tableColumnList.add(columnName);
                                    tableColumnWidthList.add(columnName.length());
                                } else {
                                    defaultTableModel.addColumn(columnName);
                                }
                            }
                            columnsFound = true;
                        }

                        String rowIndex = String.valueOf(i);

                        List<String> singleRowItemList = null;
                        Object[] rowData = null;
                        if (forTextOutput) {
                            singleRowItemList = new ArrayList<String>();
                            singleRowItemList.add(rowIndex);
                            if (tableColumnWidthList.get(0) < rowIndex.length()) {
                                tableColumnWidthList.set(0, rowIndex.length());
                            }
                        } else {
                            rowData = new Object[defaultTableModel.getColumnCount()];
                            rowData[0] = rowIndex;
                        }
                        int columnLength = (forTextOutput ? tableColumnList.size()
                                : resultTable.getColumnCount());
                        for (int j = 1; j < columnLength; j++) {
                            String columnValue = (forTextOutput ? tableColumnList.get(j)
                                    : resultTable.getColumnName(j));
                            String cellValue = String.valueOf(jsonObject.get(columnValue)).replaceAll("\n", "")
                                    .replaceAll("\t", " ");
                            if (forTextOutput) {
                                singleRowItemList.add(cellValue);
                                if (tableColumnWidthList.get(j) < cellValue.length()) {
                                    tableColumnWidthList.set(j, cellValue.length());
                                }
                            } else {
                                rowData[j] = cellValue;
                            }
                        }

                        if (forTextOutput) {
                            tableRowList.add(singleRowItemList);
                        } else {
                            defaultTableModel.addRow(rowData);
                        }

                    }

                    return null;
                }

                @Override
                protected void done() {
                    closeProgressDialog();
                    if (forTextOutput) {
                        if (tableColumnList.isEmpty() || tableRowList.isEmpty()
                                || tableColumnWidthList.isEmpty()) {
                            JOptionPane.showMessageDialog(null, "No result found", "Tabular output",
                                    JOptionPane.WARNING_MESSAGE);
                        } else {
                            new SwingWorker<Void, Void>() {

                                @Override
                                protected Void doInBackground() throws Exception {
                                    try {
                                        Thread.sleep(100);
                                    } catch (InterruptedException ex) {
                                    }
                                    int boardWidth = 0;
                                    for (Integer tableColumnWidthList1 : tableColumnWidthList) {
                                        boardWidth += tableColumnWidthList1;
                                    }
                                    boardWidth += tableColumnList.size() + 1;
                                    Board board = new Board(boardWidth);
                                    outputResultAsTextTable = board
                                            .setInitialBlock(new Table(board, boardWidth, tableColumnList,
                                                    tableRowList, tableColumnWidthList).tableToBlocks())
                                            .getPreview();
                                    return null;
                                }

                                @Override
                                protected void done() {
                                    closeProgressDialog();
                                }

                            }.execute();
                            showProgressDialog(true, 0, "Creating table for " + jsonObjectLength + " fields");
                        }
                    } else {
                        tableColumnAdjuster.adjustColumns();
                    }
                }

            }.execute();
            showProgressDialog(false, jsonObjectLength, "Processing " + jsonObjectLength + " fields");
            return false;
        } else {
            return true;
        }
    } catch (JSONException ex) {
        JOptionPane.showMessageDialog(null, outputResult, "Result error", JOptionPane.ERROR_MESSAGE);
        return true;
    }
}

From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java

public void actionPerformed(ActionEvent arg0) {
    JMenuItem source = (JMenuItem) (arg0.getSource());

    if (source.getText().equals(MENU_ABOUT)) {
        JOptionPane.showMessageDialog(this, WDBearManager.VERSION_INFO + "\n" + "by kizura\n"
                + WDBearManager.EMAIL + "\n\n" + "\n" + "Supports any WDB version\n" + "\n" + "Thanks to:\n"
                + "DarkMan for testing,\n" + "John for the 1.10 specs, Annunaki for helping with the header,\n"
                + "Andrikos for the 1.6.x WDB specs, Pyro's WDBViewer, WDDG Forum,\n"
                + "blizzhackers, etc etc\n\n" + "This program uses: \n"
                + "JGoodies from http://www.jgoodies.com/\n" + "Hypersonic SQL database 1.7.3\n"
                + "Apache Log4J, Xerces\n" + "Jakarta Commons Logging and CLI\n" + "Castor from ExoLab\n"
                + "MySQL JDBC connector 3.1.7\n" + "HTTPUNIT from Russell Gold\n" + "Jython 2.1\n"
                + "Refer to directory 'licenses' for more details about the software used\n" + "PLEASE:\n"
                + "If you like this program and find it usefull:\n"
                + "Please donate money to a charity oranization of your choice.\n"
                + "I recommend any organization that fights cancer.\n\n" + "License:\n"
                + "WDBearMgr is placed under the GNU GPL. \n" + "For further information, see the page :\n"
                + "http://www.gnu.org/copyleft/gpl.html.\n" + "See licenses/GPL_license.html\n" + "\n"
                + "For a different license please contact the author.", "Info " + VERSION_INFO,
                JOptionPane.INFORMATION_MESSAGE);
        return;//  www .  j a v a  2  s .  co m
    } else if (source.getText().equals(MENU_HELP)) {
        JFrame myFrame = new JFrame("doc/html/index.html");
        //myFrame.setFont(   );
        URL urlHTML = null;
        try {
            JEditorPane htmlPane = new JEditorPane();
            //htmlPane.setFont(sourceFont);
            // .out.println("/scripts/"+source.getName()+".py");
            File scriptFile = new File("doc/html/index.html");
            urlHTML = scriptFile.toURL();//this.getClass().getResource("/scripts/"+source.getName()+".py");
            //          .out.println( urlHTML );
            //          .out.println( urlHTML.toExternalForm() );
            htmlPane.setPage(urlHTML);
            htmlPane.setEditable(false);
            JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane);
            htmlPane.addHyperlinkListener(myJEPHL);
            myFrame.getContentPane().add(new JScrollPane(htmlPane));
            myFrame.pack();
            myFrame.setSize(640, 480);
            myFrame.show();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                            + "Could not open 'doc/html/index.html'",
                    "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
        }
    } else if (source.getText().equals(MENU_JDOCS)) {
        JFrame myFrame = new JFrame("doc/javadoc/index.html");
        //myFrame.setFont(   );
        URL urlHTML = null;
        try {
            JEditorPane htmlPane = new JEditorPane();
            //htmlPane.setFont(sourceFont);
            // .out.println("/scripts/"+source.getName()+".py");
            File scriptFile = new File("doc/javadoc/index.html");
            urlHTML = scriptFile.toURL();
            htmlPane.setPage(urlHTML);
            htmlPane.setEditable(false);
            JEPyperlinkListener myJEPHL = new JEPyperlinkListener(htmlPane);
            htmlPane.addHyperlinkListener(myJEPHL);
            myFrame.getContentPane().add(new JScrollPane(htmlPane));
            myFrame.pack();
            myFrame.setSize(640, 480);
            myFrame.show();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                            + "Could not open 'doc/javadoc/index.html'",
                    "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
        }
    } else if (source.getText().equals(MENU_CHECKUPDATE)) {
        Properties dbProps = null;
        String filName = PROPS_CHECK_UPDATE;
        try {
            dbProps = ReadPropertiesFile.readProperties(filName);
            String updFile = dbProps.getProperty(KEY_UPD_FILE);
            if (updFile == null) {
                JOptionPane.showMessageDialog(this,
                        VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                                + "Could not find update information",
                        "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
                return;
            }
            String updSite = dbProps.getProperty(KEY_WDBMGR_SITE);
            if (updFile == null) {
                JOptionPane.showMessageDialog(this,
                        VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                                + "Could not find SITE information",
                        "Warning " + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
                return;
            }

            URL urlUpdScript = new URL(updFile);
            BufferedReader in = new BufferedReader(new InputStreamReader(urlUpdScript.openStream()));

            String versionTXT = in.readLine();
            String downloadName = in.readLine();
            in.close();

            if (versionTXT.equals(WDBearManager.VERSION_INFO)) {
                JOptionPane.showMessageDialog(this,
                        VERSION_INFO + "\n" + "by kizura\n" + WDBearManager.EMAIL + "\n\n"
                                + "You are using the latest version, no updates available",
                        "Info " + VERSION_INFO, JOptionPane.INFORMATION_MESSAGE);
                return;
            } else {
                // Read version.txt
                String versionInfo = (String) dbProps.getProperty(KEY_VERSION_INFO);
                URL urlversionInfo = new URL(versionInfo);
                BufferedReader brVInfo = new BufferedReader(new InputStreamReader(urlversionInfo.openStream()));
                StringBuffer sbuVInfo = new StringBuffer();
                String strLine = "";
                boolean foundStart = false;
                while ((strLine = brVInfo.readLine()) != null) {
                    if (strLine.startsWith("---")) {
                        break;
                    }
                    if (foundStart == true) {
                        sbuVInfo.append(strLine);
                        sbuVInfo.append("\n");
                        continue;
                    }
                    if (strLine.startsWith(versionTXT)) {
                        foundStart = true;
                        continue;
                    }
                }
                brVInfo.close();

                int n = JOptionPane.showConfirmDialog(this,
                        "New version available - Please visit " + updSite + "\n\n" + versionTXT + "\n" + "\n"
                                + "You are using version:\n" + WDBearManager.VERSION_INFO + "\n" + "\n"
                                + "Do you want to download this version?\n\n" + "Version information:\n"
                                + sbuVInfo.toString(),
                        VERSION_INFO + "by kizura", JOptionPane.YES_NO_OPTION);
                //          JOptionPane.showMessageDialog(this, VERSION_INFO + "\n"
                //              + "by kizura\n" + WDBManager.EMAIL + "\n\n"
                //              + "New version available - Please visit " + updSite,
                //              "Warning "
                //              + VERSION_INFO, JOptionPane.WARNING_MESSAGE);
                if (n == 0) {
                    JFileChooser chooser = new JFileChooser(new File("."));
                    chooser.setDialogTitle("Please select download location");
                    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

                    int returnVal = chooser.showOpenDialog(this);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        try {
                            URL urlUpd = new URL(downloadName);
                            BufferedInputStream bin = new BufferedInputStream(urlUpd.openStream());
                            System.out.println(
                                    new File(chooser.getSelectedFile(), urlUpd.getFile()).getAbsolutePath());
                            File thisFile = new File(chooser.getSelectedFile(), urlUpd.getFile());
                            BufferedOutputStream bout = new BufferedOutputStream(
                                    new FileOutputStream(thisFile));

                            byte[] bufFile = new byte[102400];
                            int bytesRead = 0;
                            while ((bytesRead = bin.read(bufFile)) != -1) {
                                bout.write(bufFile, 0, bytesRead);
                            }
                            bin.close();
                            bout.close();

                            JOptionPane.showMessageDialog(this,
                                    "Update downloaded successfully" + "\n" + "Please check '"
                                            + thisFile.getAbsolutePath() + "'",
                                    "Success " + WDBearManager.VERSION_INFO, JOptionPane.INFORMATION_MESSAGE);
                            //String msg = WriteCSV.writeCSV(chooser.getSelectedFile(), this.items);
                        } catch (Exception ex) {
                            String msg = ex.getMessage();
                            JOptionPane.showMessageDialog(this, msg + "\n" + "Error downloading update",
                                    "Error " + WDBearManager.VERSION_INFO, JOptionPane.ERROR_MESSAGE);
                        }
                    }
                } // user selected "download"
                return;
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    } else {
        System.exit(0);
    }

}

From source file:client.ui.FilePane.java

private void addNoteButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_addNoteButtonActionPerformed
    String content = noteInputArea.getText();
    if (content.equals(""))
        return;//www.j  a  v  a2 s .com
    try {
        String fileID = getSelectedFile().getFileID();
        String creator = m_Business.getUser().getUserID();
        Note note = new Note(content, fileID, creator);
        AddNoteResult result = m_Business.addNote(note);
        switch (result) {
        case OK:
            JOptionPane.showMessageDialog(this, "?", "",
                    JOptionPane.INFORMATION_MESSAGE);
            refreshNoteAndText();
            break;
        case unAuthorized:
            JOptionPane.showMessageDialog(this, "?", "",
                    JOptionPane.WARNING_MESSAGE);
            m_MainFrame.setVisible(false);
            LoginDialog loginDialog = new LoginDialog(m_MainFrame, m_Business);
            break;
        case wrong:
            JOptionPane.showMessageDialog(this, "?", "", JOptionPane.WARNING_MESSAGE);
            getDirectory(currentID);
            break;
        default:
            JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);
            break;
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:de.cismet.verdis.CidsAppBackend.java

/**
 * former synchronized method./*  w  ww . j  ava2 s. c  om*/
 *
 * @param  kassenzeichen   DOCUMENT ME!
 * @param  edit            DOCUMENT ME!
 * @param  historyEnabled  DOCUMENT ME!
 */
private void gotoKassenzeichen(final String kassenzeichen, final boolean edit, final boolean historyEnabled) {
    final String[] test = kassenzeichen.split(":");

    final String kassenzeichenNummer;
    final String flaechenBez;
    if (test.length > 1) {
        kassenzeichenNummer = test[0];
        flaechenBez = test[1];
    } else {
        kassenzeichenNummer = kassenzeichen;
        flaechenBez = "";
    }

    if (!Main.getInstance().isInEditMode()) {
        Main.getInstance().disableKassenzeichenCmds();
        Main.getInstance().getKassenzeichenPanel().setSearchStarted();
        GrundbuchblattSucheDialog.getInstance().setEnabled(false);
        Main.getInstance().getKassenzeichenPanel().setSearchField(kassenzeichen);

        WaitDialog.getInstance().showDialog();
        WaitDialog.getInstance().startLoadingKassenzeichen(1);

        new SwingWorker<CidsBean, Void>() {

            @Override
            protected CidsBean doInBackground() throws Exception {
                final CidsBean cidsBean = loadKassenzeichenByNummer(Integer.parseInt(kassenzeichenNummer));
                updateCrossReferences(cidsBean);
                return cidsBean;
            }

            @Override
            protected void done() {
                try {
                    final CidsBean cidsBean = get();

                    if (cidsBean != null) {
                        setCidsBean(cidsBean);
                        selectCidsBeanByIdentifier(flaechenBez);
                        Main.getInstance().getKassenzeichenPanel().flashSearchField(Color.GREEN);
                        if (historyEnabled) {
                            historyModel.addToHistory(kassenzeichen);
                        }
                    } else {
                        setCidsBean(null);
                        Main.getInstance().getKassenzeichenPanel().flashSearchField(Color.RED);
                    }
                } catch (final Exception ex) {
                    setCidsBean(null);
                    LOG.error("Exception in Background Thread", ex);
                    Main.getInstance().getKassenzeichenPanel().flashSearchField(Color.RED);
                    showError("Fehler beim Laden", "Kassenzeichen konnte nicht geladen werden", ex);
                }
                Main.getInstance().getKassenzeichenPanel().setSearchFinished();
                GrundbuchblattSucheDialog.getInstance().setEnabled(true);
                Main.getInstance().refreshKassenzeichenButtons();

                WaitDialog.getInstance().progressLoadingKassenzeichen(1);
                if (edit) {
                    new SwingWorker<Boolean, Void>() {

                        @Override
                        protected Boolean doInBackground() throws Exception {
                            if (Main.getInstance().acquireLocks()) { // try to acquire
                                return true;
                            }
                            return null;
                        }

                        @Override
                        protected void done() {
                            try {
                                final Boolean enableEditing = get();
                                if (enableEditing != null) {
                                    Main.getInstance().setEditMode(enableEditing);
                                }
                            } catch (final Exception ex) {
                                LOG.error(ex, ex);
                            } finally {
                                WaitDialog.getInstance().dispose();
                            }
                        }
                    }.execute();
                } else {
                    WaitDialog.getInstance().dispose();
                }
            }
        }.execute();
    } else {
        JOptionPane.showMessageDialog(Main.getInstance(),
                "Das Kassenzeichen kann nur gewechselt werden wenn alle \u00C4nderungen gespeichert oder verworfen worden sind.",
                "Wechseln nicht m\u00F6glich", JOptionPane.WARNING_MESSAGE);
    }
}

From source file:de.dal33t.powerfolder.Controller.java

/**
 * Call to notify the Controller of a problem while binding a required
 * listening socket.//from  ww  w .  j ava 2  s. c o  m
 *
 * @param ports
 */
private void portBindFailureProblem(String ports) {
    if (!isUIEnabled()) {
        logSevere("Unable to open incoming port from the portlist: " + ports);
        exit(1);
        return;
    }

    // Must use JOptionPane here because there is no Controller yet for
    // DialogFactory!
    int response = JOptionPane.showOptionDialog(null,
            Translation.getTranslation("dialog.bind_error.option.text"),
            Translation.getTranslation("dialog.bind_error.option.title"), JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE, null,
            new String[] { Translation.getTranslation("dialog.bind_error.option.ignore"),
                    Translation.getTranslation("dialog.bind_error.option.exit") },
            0);
    switch (response) {
    case 1:
        exit(0);
        break;
    default:
        bindRandomPort();
        break;
    }
}

From source file:client.ui.FilePane.java

private void deleteNoteButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_deleteNoteButtonActionPerformed
    Note selectedNote = getSelectedNote();
    if (selectedNote == null) {
        JOptionPane.showMessageDialog(this, "", "", JOptionPane.WARNING_MESSAGE);
        return;/*from  w w w  . j a va  2  s .  c o m*/
    }
    try {
        DeleteNoteResult result = m_Business.deleteNote(selectedNote);
        switch (result) {
        case OK:
            JOptionPane.showMessageDialog(this, "?", "",
                    JOptionPane.INFORMATION_MESSAGE);
            refreshNoteAndText();
            break;
        case unAuthorized:
            JOptionPane.showMessageDialog(this, "?", "",
                    JOptionPane.WARNING_MESSAGE);
            m_MainFrame.setVisible(false);
            LoginDialog loginDialog = new LoginDialog(m_MainFrame, m_Business);
            break;
        case wrong:
            JOptionPane.showMessageDialog(this, "?", "", JOptionPane.WARNING_MESSAGE);
            getDirectory(currentID);
            break;
        default:
            JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);
            break;
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:net.sf.jabref.gui.BasePanel.java

private boolean saveDatabase(File file, boolean selectedOnly, Charset enc,
        SavePreferences.DatabaseSaveType saveType) throws SaveException {
    SaveSession session;//from  w  ww  .j a v  a2 s  .  c  o m
    frame.block();
    final String SAVE_DATABASE = Localization.lang("Save database");
    try {
        SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs).withEncoding(enc)
                .withSaveType(saveType);
        BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(FileSaveSession::new);
        if (selectedOnly) {
            session = databaseWriter.savePartOfDatabase(bibDatabaseContext, mainTable.getSelectedEntries(),
                    prefs);
        } else {
            session = databaseWriter.saveDatabase(bibDatabaseContext, prefs);
        }

        registerUndoableChanges(session);

    } catch (UnsupportedCharsetException ex2) {
        JOptionPane.showMessageDialog(frame,
                Localization.lang("Could not save file.") + ' '
                        + Localization.lang("Character encoding '%0' is not supported.", enc.displayName()),
                SAVE_DATABASE, JOptionPane.ERROR_MESSAGE);
        throw new SaveException("rt");
    } catch (SaveException ex) {
        if (ex.specificEntry()) {
            // Error occurred during processing of
            // be. Highlight it:
            final int row = mainTable.findEntry(ex.getEntry());
            final int topShow = Math.max(0, row - 3);
            mainTable.setRowSelectionInterval(row, row);
            mainTable.scrollTo(topShow);
            showEntry(ex.getEntry());
        } else {
            LOGGER.warn("Could not save", ex);
        }

        JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + "\n" + ex.getMessage(),
                SAVE_DATABASE, JOptionPane.ERROR_MESSAGE);
        throw new SaveException("rt");

    } finally {
        frame.unblock();
    }

    boolean commit = true;
    if (!session.getWriter().couldEncodeAll()) {
        FormBuilder builder = FormBuilder.create()
                .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref"));
        JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters());
        ta.setEditable(false);
        builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:",
                session.getEncoding().displayName())).xy(1, 1);
        builder.add(ta).xy(3, 1);
        builder.add(Localization.lang("What do you want to do?")).xy(1, 3);
        String tryDiff = Localization.lang("Try different encoding");
        int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), SAVE_DATABASE,
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
                new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff);

        if (answer == JOptionPane.NO_OPTION) {
            // The user wants to use another encoding.
            Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"),
                    SAVE_DATABASE, JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, enc);
            if (choice == null) {
                commit = false;
            } else {
                Charset newEncoding = Charset.forName((String) choice);
                return saveDatabase(file, selectedOnly, newEncoding, saveType);

            }
        } else if (answer == JOptionPane.CANCEL_OPTION) {
            commit = false;
        }

    }

    if (commit) {
        session.commit(file.toPath());
        this.bibDatabaseContext.getMetaData().setEncoding(enc); // Make sure to remember which encoding we used.
    } else {
        session.cancel();
    }

    return commit;
}