Example usage for javax.swing JOptionPane PLAIN_MESSAGE

List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE

Introduction

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

Prototype

int PLAIN_MESSAGE

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

Click Source Link

Document

No icon is used.

Usage

From source file:marytts.tools.redstart.AdminWindow.java

private void jMenuItem_ImportTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_ImportTextActionPerformed
    JFileChooser fc = new JFileChooser(new File(voiceFolderPathString));
    fc.setDialogTitle("Choose text file to import");
    //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int returnVal = fc.showOpenDialog(this);
    if (returnVal != JFileChooser.APPROVE_OPTION)
        return;//from   w  ww  . j av  a2  s .com
    File file = fc.getSelectedFile();
    if (file == null)
        return;
    String[] lines = null;
    try {
        lines = StringUtils.readTextFile(file.getAbsolutePath(), "UTF-8");
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    if (lines == null || lines.length == 0)
        return;
    Object[] options = new Object[] { "Keep first column", "Discard first column" };
    int answer = JOptionPane.showOptionDialog(this,
            "File contains " + lines.length + " sentences.\n" + "Sample line:\n" + lines[0] + "\n"
                    + "Keep or discard first column?",
            "Import details", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
            options[1]);
    boolean discardFirstColumn = (answer == JOptionPane.NO_OPTION);

    String prefix = (String) JOptionPane.showInputDialog(this,
            "Prefix to use for individual sentence filenames:", "Choose filename prefix",
            JOptionPane.PLAIN_MESSAGE, null, null, "s");
    int numDigits = (int) Math.log10(lines.length) + 1;
    String pattern = prefix + "%0" + numDigits + "d.txt";
    File scriptFile = new File(voiceFolderPathString + "/" + file.getName() + ".script.txt");
    PrintWriter scriptWriter = null;
    try {
        scriptWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(scriptFile), "UTF-8"));
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this,
                "Cannot write to script file " + scriptFile.getAbsolutePath() + ":\n" + e.getMessage());
        if (scriptWriter != null)
            scriptWriter.close();
        return;
    }
    File textFolder = getPromptFolderPath();

    // if filename ends with ".txt_tr" then it has also transcriptions in it
    String selectedFile_ext = FilenameUtils.getExtension(file.getName());
    Boolean inputHasAlsoTranscription = false;
    File transcriptionFolder = new File("");

    // transcription folder name, and makedir
    if (selectedFile_ext.equals("txt_tr")) {
        System.out.println("txt_tr");
        if (lines.length % 2 == 0) {
            // even
        } else {
            // odd
            System.err.println(".txt_tr file has an odd number of lines, so it's corrupted, exiting.");
            System.exit(0);
        }
        inputHasAlsoTranscription = true;
        String transcriptionFolderName = voiceFolderPathString + AdminWindow.TRANSCRIPTION_FOLDER_NAME;
        transcriptionFolder = new File(transcriptionFolderName);
        if (transcriptionFolder.exists()) {
            System.out.println("transcription folder already exists");
        } else {
            if (transcriptionFolder.mkdirs()) {
                System.out.println("transcription folder created");
            } else {
                System.err.println("Cannot create transcription folder -- exiting.");
                System.exit(0);
            }
        }
    } else {
        System.out.println("input file extension is not txt_tr, but " + selectedFile_ext
                + ", so it contains ortographic sentences without transcriptions.");
    }

    for (int i = 0; i < lines.length; i++) {
        String line = lines[i];
        if (discardFirstColumn)
            line = line.substring(line.indexOf(' ') + 1);
        int sent_index = i + 1;
        if (inputHasAlsoTranscription == true) {
            sent_index = i / 2 + 1;
        }

        String filename = String.format(pattern, sent_index);
        System.out.println(filename + " " + line);
        File textFile = new File(textFolder, filename);
        if (textFile.exists()) {
            JOptionPane.showMessageDialog(this, "Cannot writing file " + filename + ":\n" + "File exists!\n"
                    + "Aborting text file import.");
            return;
        }
        PrintWriter pw = null;
        try {
            pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(textFile), "UTF-8"));
            pw.println(line);
            scriptWriter.println(filename.substring(0, filename.lastIndexOf('.')) + " " + line);
        } catch (IOException ioe) {
            JOptionPane.showMessageDialog(this, "Error writing file " + filename + ":\n" + ioe.getMessage());
            ioe.printStackTrace();
            return;
        } finally {
            if (pw != null)
                pw.close();
        }

        // transcription case:
        if (inputHasAlsoTranscription == true) {
            // modify pattern: best would be something like sed "s/.txt$/.tr$/"
            // easy but dirty:
            String transc_pattern = pattern.replace(".txt", ".tr");
            filename = String.format(transc_pattern, sent_index);
            i++;
            line = lines[i];
            if (discardFirstColumn)
                line = line.substring(line.indexOf(' ') + 1);
            File transcriptionTextFile = new File(transcriptionFolder, filename);
            if (transcriptionTextFile.exists()) {
                JOptionPane.showMessageDialog(this, "Cannot writing file " + transcriptionTextFile.getName()
                        + ":\n" + "File exists!\n" + "Aborting text file import.");
                return;
            }
            pw = null;
            try {
                pw = new PrintWriter(
                        new OutputStreamWriter(new FileOutputStream(transcriptionTextFile), "UTF-8"));
                pw.println(line);
                scriptWriter.println(filename.substring(0, filename.lastIndexOf('.')) + " " + line);
            } catch (IOException ioe) {
                JOptionPane.showMessageDialog(this,
                        "Error writing file " + filename + ":\n" + ioe.getMessage());
                ioe.printStackTrace();
                return;
            } finally {
                if (pw != null)
                    pw.close();
            }
        }

    }
    scriptWriter.close();
    setupVoice();
}

From source file:coffeshop.PaymentPage.java

private void btnScanBTCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnScanBTCActionPerformed
    timeStop = false;/*from w  ww.j  ava  2 s . c o m*/
    btnScanBTC.setEnabled(false);
    btcTimer();
    String btcPay = txtPayAmt.getText();
    BigDecimal USD = new BigDecimal(btcPay);
    BigDecimal USDtoBTC = btcPriceIndex();
    BigDecimal BTCDue = USD.divide(USDtoBTC, 5, BigDecimal.ROUND_HALF_UP);
    USDtoBTC = USDtoBTC.setScale(2, BigDecimal.ROUND_HALF_UP);
    lblUSDtoBTC.setText("USD/BTC = " + USDtoBTC);
    lblBTCDue.setText("BTC Due: " + BTCDue);
    try {
        generateQR(btcPay);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Error generating QR Code");
        ex.printStackTrace();
    }
    try {
        BufferedImage image = ImageIO.read(new File("src/ImageRes/QR.jpg"));
        ImageIcon icon = new ImageIcon(image);
        icon.getImage().flush();
        lblQRC.setIcon(icon);
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
    }

    if (lblQRC.getIcon() == null) {
        lblQRC.setIcon(defaultQR);
        JOptionPane.showMessageDialog(null, "Wrong QR Code. Please try again.", "Wrong QR Code",
                JOptionPane.PLAIN_MESSAGE);
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void menuItemChangeStrategy_actionPerformed(ActionEvent event) {
    try {/*from w  w  w.j  ava2s .  c o m*/
        String newStrategyName = (String) JOptionPane.showInputDialog(this,
                "Which elution curve strategy would you like to use?", "Elution Strategy",
                JOptionPane.PLAIN_MESSAGE, null, MRMCommandLineModule.strategies,
                MRMCommandLineModule.strategies[0]);
        newStrategyName = "org.fhcrc.cpl.viewer.mrm." + newStrategyName;
        if (newStrategyName != _ecurveclass.getName()) {
            Class newClass = Class.forName(newStrategyName);
            _ecurveclass = newClass;
            initStuff();
        }
    } catch (Exception e) {
        ApplicationContext.infoMessage("Cannot change elution curve strategy: " + e);
    }
}

From source file:coffeshop.PaymentPage.java

private void btnPayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPayActionPerformed
    if (validatePayment()) {

        BigDecimal payAmt = new BigDecimal(txtPayAmt.getText());
        if (due.compareTo(payAmt) >= 0) {
            due = due.subtract(payAmt);/* w ww  .j a  v a  2  s.  c om*/
            paid = paid.add(payAmt);
            payments.add(new Payment(paymentMethod, transID, payAmt));
            if (cboSplit.getSelectedIndex() > 0) {
                cboSplit.setSelectedIndex(cboSplit.getSelectedIndex() - 1);
            }
            calculateDue();
            resetAll();
            JOptionPane.showConfirmDialog(null, "Do you want to print receipt?", "Payment Completed.",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "Payment Amount is wrong. Please check again.",
                    "Wrong Payment Amount", JOptionPane.PLAIN_MESSAGE);
        }
        if (due.compareTo(BigDecimal.ZERO) == 0 && paid.compareTo(total) == 0) {
            JOptionPane.showMessageDialog(null, "Payment Completed.", "Payment Completed",
                    JOptionPane.PLAIN_MESSAGE);
            try {
                accessor = new DBAccessor();
                accessor.connectDB();
                if (accessor.insertPayment(emp_id, transType, transID, tax, total, promoCode, products,
                        payments)) {
                    JOptionPane.showMessageDialog(null, "Records have been saved", "Records saved",
                            JOptionPane.PLAIN_MESSAGE);
                }
                rsMan.beforeFirst();
            } catch (SQLException ex) {
                Logger.getLogger(PaymentPage.class.getName()).log(Level.SEVERE, null, ex);
            }
            main.dispose();
            main = new MainPage(rsMan);
            main.setVisible(true);
            this.dispose();
        }
    } else {
        JOptionPane.showMessageDialog(null, "Invalid payment input. Please check again.",
                "Wrong Payment Amount", JOptionPane.PLAIN_MESSAGE);
    }
}

From source file:coffeshop.PaymentPage.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    if (jtfGiftCardNum.getText().matches(giftRegExp)) {
        String balance = jtfGiftCardNum.getText();
        balance = balance.substring(0, 1) + balance.substring(balance.length() - 1);
        JOptionPane.showMessageDialog(null, "Balance: $" + balance, "Balance", JOptionPane.PLAIN_MESSAGE);
    } else {//from  ww  w .j  av  a  2s .  co  m
        JOptionPane.showMessageDialog(null, "Invalid Gift Card Number", "Invalid Card",
                JOptionPane.PLAIN_MESSAGE);
    }
}

From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {

            QueryMasterData ndata = (QueryMasterData) node.getUserObject();
            Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ",
                    "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null,
                    ndata.name().substring(0, ndata.name().indexOf("[") - 1));

            if (inputValue != null) {
                String newQueryName = (String) inputValue;
                String requestXml = ndata.writeRenameQueryXML(newQueryName);

                setCursor(new Cursor(Cursor.WAIT_CURSOR));

                String response = null;
                if (System.getProperty("webServiceMethod").equals("SOAP")) {
                    // TO DO
                    // response =
                    // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
                } else {
                    response = QueryListNamesClient.sendQueryRequestREST(requestXml);
                }//  ww w. jav a 2 s. c  om

                if (response.equalsIgnoreCase("CellDown")) {
                    final JPanel parent = this;
                    java.awt.EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            JOptionPane.showMessageDialog(parent,
                                    "Trouble with connection to the remote server, "
                                            + "this is often a network error, please try again",
                                    "Network Error", JOptionPane.INFORMATION_MESSAGE);
                        }
                    });
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    return;
                }

                if (response != null) {
                    JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                    try {
                        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                        StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                        String status = statusType.getType();

                        if (status.equalsIgnoreCase("DONE")) {
                            // XMLGregorianCalendar cldr =
                            // //queryMasterType.getCreateDate();
                            Calendar cldr = Calendar.getInstance(Locale.getDefault());
                            ndata.name(newQueryName + " [" + addZero(cldr.get(Calendar.MONTH) + 1) + "-"
                                    + addZero(cldr.get(Calendar.DAY_OF_MONTH)) + "-"
                                    + addZero(cldr.get(Calendar.YEAR)) + " ]" + " [" + ndata.userId() + "]");
                            // ndata.name(newQueryName + " [" +
                            // ndata.userId()
                            // + "]");
                            node.setUserObject(ndata);
                            // DefaultMutableTreeNode parent =
                            // (DefaultMutableTreeNode) node.getParent();

                            jTree1.repaint();
                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) {

            QueryResultData rdata = (QueryResultData) node.getUserObject();
            // if(!rdata.type().equalsIgnoreCase("PatientSet")) {
            // return;
            // }

            Object inputValue1 = JOptionPane.showInputDialog(this, "Rename this to: ", "Renaming Dialog",
                    JOptionPane.PLAIN_MESSAGE, null, null, rdata.name());
            // .substring(0, rdata.name().lastIndexOf("[") - 1));

            if (inputValue1 != null) {
                String newQueryName = (String) inputValue1;
                String requestXml = rdata.writeRenameQueryXML(newQueryName);

                setCursor(new Cursor(Cursor.WAIT_CURSOR));

                String response = null;
                if (System.getProperty("webServiceMethod").equals("SOAP")) {
                    // TO DO
                    // response =
                    // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
                } else {
                    response = QueryListNamesClient.sendQueryRequestREST(requestXml);
                }

                if (response.equalsIgnoreCase("CellDown")) {
                    final JPanel parent = this;
                    java.awt.EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            JOptionPane.showMessageDialog(parent,
                                    "Trouble with connection to the remote server, "
                                            + "this is often a network error, please try again",
                                    "Network Error", JOptionPane.INFORMATION_MESSAGE);

                        }
                    });
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    return;
                }

                if (response != null) {
                    JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                    try {
                        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                        StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                        String status = statusType.getType();

                        if (status.equalsIgnoreCase("DONE")) {
                            rdata.name(newQueryName);// + " [" +
                            // rdata.userId()
                            // + "]");
                            node.setUserObject(rdata);
                            // DefaultMutableTreeNode parent =
                            // (DefaultMutableTreeNode) node.getParent();

                            jTree1.repaint();
                        } else {
                            final String tmp = response;
                            final JPanel parent = this;
                            java.awt.EventQueue.invokeLater(new Runnable() {
                                public void run() {
                                    JOptionPane.showMessageDialog(parent,
                                            "Error message delivered from the remote server, "
                                                    + "you may wish to retry your last action",
                                            "Server Error", JOptionPane.INFORMATION_MESSAGE);
                                    log.error(tmp);
                                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                                }

                            });

                            return;
                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    } else if (e.getActionCommand().equalsIgnoreCase("Cancel")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {
            DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node.getFirstChild();
            if (node1.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent, "Please expand this node then try to cancel it.",
                                "Message", JOptionPane.INFORMATION_MESSAGE);

                    }
                });
                return;
            }
            QueryInstanceData rdata = (QueryInstanceData) node1.getUserObject();

            String requestXml = rdata.writeCancelQueryXML();

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);

                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();
                    final JPanel parent = this;
                    if (status.equalsIgnoreCase("DONE")) {
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent, "The query is finished.", "Message",
                                        JOptionPane.INFORMATION_MESSAGE);
                                // log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });
                        rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" +
                        // rdata
                        // .userId()
                        // + "]");
                        node.setUserObject(rdata);
                        // DefaultMutableTreeNode parent =
                        // (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    } else {
                        final String tmp = response;
                        // final JPanel parent = this;
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent,
                                        "Error message delivered from the remote server, "
                                                + "you may wish to retry your last action",
                                        "Server Error", JOptionPane.INFORMATION_MESSAGE);
                                log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });

                        return;
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                // }
            }
        } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) {

            QueryInstanceData rdata = (QueryInstanceData) node.getUserObject();

            String requestXml = rdata.writeCancelQueryXML();

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);

                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();
                    final JPanel parent = this;
                    if (status.equalsIgnoreCase("DONE")) {
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent, "The query is finished.", "Message",
                                        JOptionPane.INFORMATION_MESSAGE);
                                // log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });
                        rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" +
                        // rdata
                        // .userId()
                        // + "]");
                        node.setUserObject(rdata);
                        // DefaultMutableTreeNode parent =
                        // (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    } else {
                        final String tmp = response;
                        // final JPanel parent = this;
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent,
                                        "Error message delivered from the remote server, "
                                                + "you may wish to retry your last action",
                                        "Server Error", JOptionPane.INFORMATION_MESSAGE);
                                log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });

                        return;
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                // }
            }
        } else {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                    JOptionPane.showMessageDialog(parent, "Cancel action is not supported on this level",
                            "Message", JOptionPane.INFORMATION_MESSAGE);
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                }

            });
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            // System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        // jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = "";
        if (isManager) {
            status = loadPreviousQueries("all users");
        } else {
            status = loadPreviousQueries(UserInfoBean.getInstance().getUserName());
        }
        if (status.equalsIgnoreCase("")) {
            reset(200, false, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openDecodeDialog() {
    JTextField sourceFile = new JTextField();
    JTextField destinationDir = new JTextField();
    FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false);
    sourceFileSelectionPanel.setFileFilter(".bin", "Firmware file (*.bin)");
    final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel,
            new FileSelectionPanel("Destination dir", destinationDir, true) };
    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs,
            "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        try {//from w  w w  .  j av  a2 s  . c o m
            new FirmwareDecoder().decode(sourceFile.getText(), destinationDir.getText(), false);
            JOptionPane.showMessageDialog(this, "Decoding complete", "Done", JOptionPane.INFORMATION_MESSAGE);
        } catch (FirmwareFormatException e) {
            JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace",
                    "Error decoding files", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openEncodeDialog() {
    JTextField destinationFile = new JTextField();
    JTextField sourceFile1 = new JTextField();
    JTextField sourceFile2 = new JTextField();
    FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file",
            destinationFile, false);/*from   www.  ja  v  a2  s  .co  m*/
    destinationFileSelectionPanel.setFileFilter(".bin", "Encoded firmware file (*.bin)");
    FileSelectionPanel sourceFile1SelectionPanel = new FileSelectionPanel("Source file 1", sourceFile1, false);
    destinationFileSelectionPanel.setFileFilter("a*.bin", "Decoded A firmware file (a*.bin)");
    FileSelectionPanel sourceFile2SelectionPanel = new FileSelectionPanel("Source file 2", sourceFile2, false);
    destinationFileSelectionPanel.setFileFilter("b*.bin", "Decoded B firmware file (b*.bin)");
    final JComponent[] inputs = new JComponent[] { destinationFileSelectionPanel, sourceFile1SelectionPanel,
            sourceFile2SelectionPanel };
    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs,
            "Choose target encoded file and source files", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        try {
            ArrayList<String> inputFilenames = new ArrayList<String>();
            inputFilenames.add(sourceFile1.getText());
            inputFilenames.add(sourceFile2.getText());
            new FirmwareEncoder().encode(inputFilenames, destinationFile.getText());
            JOptionPane.showMessageDialog(this, "Encoding complete", "Done", JOptionPane.INFORMATION_MESSAGE);
        } catch (FirmwareFormatException e) {
            JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace",
                    "Error encoding files", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openDecodeNkldDialog() {
    JTextField sourceFile = new JTextField();
    JTextField destinationFile = new JTextField();
    FileSelectionPanel sourceFileSelectionPanel = new FileSelectionPanel("Source file", sourceFile, false);
    sourceFileSelectionPanel.setFileFilter("nkld*.bin", "Lens correction data file (nkld*.bin)");
    final JComponent[] inputs = new JComponent[] { sourceFileSelectionPanel,
            new FileSelectionPanel("Destination file", destinationFile, true) };
    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs,
            "Choose source file and destination dir", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, JOptionPane.DEFAULT_OPTION)) {
        try {/* w w  w . j  a  v  a  2s . c  o  m*/
            new NkldDecoder().decode(sourceFile.getText(), destinationFile.getText(), false);
            JOptionPane
                    .showMessageDialog(
                            this, "Decoding complete.\nFile '"
                                    + new File(destinationFile.getText()).getAbsolutePath() + "' was created.",
                            "Done", JOptionPane.INFORMATION_MESSAGE);
        } catch (FirmwareFormatException e) {
            JOptionPane.showMessageDialog(this, e.getMessage() + "\nPlease see console for full stack trace",
                    "Error decoding files", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Displays a dialog that allows the user to edit the properties for the current chart.
 * /*  ww  w.j av a2  s .  com*/
 * @since 1.0.3
 */
public void doEditChartProperties() {
    ChartEditor editor = ChartEditorManager.getChartEditor(this.chart);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(this.chart);
    }

}