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:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java

private void initFilemenu() {
    final EditorMainWindow parentWinRef = this;

    exitMenuItem.addActionListener(new ActionListener() {
        @Override//  w w w  . ja  v a  2 s  .co m
        public void actionPerformed(ActionEvent e) {
            parentWinRef.dispose();
        }
    });

    openOvalMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            final JFileChooser fc = new JFileChooser();
            fc.setDialogType(JFileChooser.OPEN_DIALOG);

            File lastOpenedFrom = guiProps.getLastOpenedFromFile();

            // Set current directory
            fc.setCurrentDirectory(lastOpenedFrom);

            FileFilter ff = new OcilOrOvalFilesFilter("OVAL");
            fc.setFileFilter(ff);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);

            int ret = fc.showOpenDialog(EditorMainWindow.getInstance());

            if (ret == JFileChooser.APPROVE_OPTION) {
                File f = fc.getSelectedFile();
                File parent = f.getAbsoluteFile().getParentFile();
                guiProps.setLastOpenedFrom(parent.getAbsolutePath());
                guiProps.save();

                openFile(f, SCAPDocumentClassEnum.OVAL);
            }
        }
    });

    saveMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            // get the currently open window
            JInternalFrame selectedWin = desktopPane.getSelectedFrame();

            if (selectedWin != null) {
                SCAPDocument scapDoc = null;

                Document dom = null;
                String filename = null;

                if (selectedWin instanceof OvalEditorForm) {
                    OvalEditorForm oef = (OvalEditorForm) selectedWin;
                    scapDoc = oef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                } else if (selectedWin instanceof CPEDictionaryEditorForm) {
                    CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin;
                    scapDoc = cef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                }

                if (dom != null) {
                    // since this is a save operation, not save as, we won't
                    // prompt the user for where to store the file

                    try {
                        scapDoc.save();
                        ((EditorForm) selectedWin).setDirty(false);
                    } catch (Exception e) {
                        String message = "An error occured trying to save to file " + filename + ": "
                                + e.getMessage();
                        EditorUtil.showMessageDialog(parentWinRef, message,
                                EditorMessages.SAVE_ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        }
    });

    saveAsMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            // get the currently open window
            JInternalFrame selectedWin = desktopPane.getSelectedFrame();

            if (selectedWin != null) {
                SCAPDocument scapDoc = null;
                Document dom = null;
                String filename = null;
                String windowTitle = null;

                if (selectedWin instanceof OvalEditorForm) {
                    windowTitle = OvalEditorForm.WINDOW_TITLE_BASE;
                    OvalEditorForm oef = (OvalEditorForm) selectedWin;
                    scapDoc = oef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                } else if (selectedWin instanceof CPEDictionaryEditorForm) {
                    windowTitle = CPEDictionaryEditorForm.WINDOW_TITLE_BASE;
                    CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin;
                    scapDoc = cef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                } else {
                    return;
                }

                if (dom != null) {
                    String newFilename = null;
                    SCAPDocumentTypeEnum docType = scapDoc.getDocumentType();

                    FileSaveAsWizard saveAsWiz = new FileSaveAsWizard(EditorMainWindow.getInstance(), true,
                            docType);

                    //saveAsWiz.pack();
                    saveAsWiz.setLocationRelativeTo(EditorMainWindow.getInstance());
                    saveAsWiz.setVisible(true);

                    if (saveAsWiz.wasCancelled()) {
                        return;
                    }

                    newFilename = saveAsWiz.getFilename();

                    try {
                        scapDoc.setFilename(newFilename);
                        scapDoc.saveAs(newFilename);

                        EditorUtil.markActiveWindowDirty(EditorMainWindow.getInstance(), false);
                        ((EditorForm) selectedWin).refreshRootNode();

                    } catch (Exception e) {
                        LOG.error(e.getMessage(), e);

                        EditorUtil.showMessageDialog(parentWinRef, "An error occured trying to save to file "
                                + newFilename + ": " + e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    SCAPContentManager scm = SCAPContentManager.getInstance();

                    if (scm != null) {
                        scm.removeDocument(filename);
                        scm.addDocument(newFilename, scapDoc);
                        selectedWin.setTitle(windowTitle + (new File(newFilename)).getAbsolutePath());
                    } else {
                        LOG.error("SCM instance is null here!");
                    }
                }
            }
        }
    });

    newXCCDFFromOvalMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            //generateXccdfFromOvalOrOcil("OVAL");
            final JFileChooser fc = new JFileChooser();
            fc.setDialogType(JFileChooser.OPEN_DIALOG);
            File lastOpenedFrom = guiProps.getLastOpenedFromFile();

            // Set current directory
            fc.setCurrentDirectory(lastOpenedFrom);
            FileFilter ff = new OcilOrOvalFilesFilter("OVAL");
            fc.setFileFilter(ff);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int ret = fc.showOpenDialog(EditorMainWindow.getInstance());
            if (ret == JFileChooser.APPROVE_OPTION) {
                File f = fc.getSelectedFile();
                File parent = f.getAbsoluteFile().getParentFile();
                guiProps.setLastOpenedFrom(parent.getAbsolutePath());
                guiProps.save();
                try {
                    InputStream is = this.getClass().getClassLoader().getResourceAsStream("oval-to-xccdf.xsl");
                    File xsltfile = new File("oval-to-xccdf.xsl");
                    OutputStream outputStream = new FileOutputStream(xsltfile);
                    IOUtils.copy(is, outputStream);
                    outputStream.close();
                    OvalToXCCDF1.ovalToXccdf(f, xsltfile);
                    xsltfile.delete();
                    String reverseDNS = JOptionPane.showInputDialog("reverse_DNS:");
                    if (reverseDNS == null || reverseDNS.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Enter the reverse_DNS", "alert",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        JFileChooser fc1 = new JFileChooser();
                        fc1.setCurrentDirectory(f);
                        int ret1 = fc1.showSaveDialog(EditorMainWindow.getInstance());
                        if (ret1 == JFileChooser.APPROVE_OPTION) {
                            File savefile = fc1.getSelectedFile();
                            is = this.getClass().getClassLoader().getResourceAsStream("xccdf_1.1_to_1.2.xsl");
                            xsltfile = new File("oval-to-xccdf.xsl");
                            outputStream = new FileOutputStream(xsltfile);
                            IOUtils.copy(is, outputStream);
                            outputStream.close();
                            File temp = new File("temp.xml");
                            XCCDF1to2.xccdf12(savefile, reverseDNS, xsltfile, temp);
                            JOptionPane.showMessageDialog(null,
                                    "XCCDF File Created: " + savefile.getAbsolutePath(), "XCCDF Created",
                                    JOptionPane.PLAIN_MESSAGE);
                            xsltfile.delete();
                            temp.delete();
                            temp = null;
                        }

                    }

                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (URISyntaxException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (TransformerException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                //  openFile(f, SCAPDocumentClassEnum.OVAL);
            }

        }

    });

    newOvalMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            CreateOvalWizard wiz = new CreateOvalWizard(true);
            wiz.setName("create_oval_wizard");
            wiz.pack();
            wiz.setVisible(true);

            if (!wiz.wasCancelled()) {
                // User has been through the wizard to select
                // 1. an Oval schema version (eg, OVAL55)
                // 2. one or more platforms (eg, "windows", "solaris", etc)
                // 3. a file name for the new Oval file
                // Now we are ready to actually create the file
                String createdFilename = createNewOvalDocument(wiz);

                if (createdFilename == null) {
                    LOG.error("newOvalMenuItem.actionlistener: Created filename was null!");
                    return;
                }

                File f = new File(createdFilename);

                guiProps.setLastOpenedFromFile(f.getParentFile());
                guiProps.save();

                SCAPContentManager scm = SCAPContentManager.getInstance();

                if (scm != null) {
                    OvalDefinitionsDocument dd = (OvalDefinitionsDocument) scm.getDocument(f.getAbsolutePath());

                    openFile(dd);
                }
            }
            wiz.setVisible(false);
            wiz.dispose();
        }
    });

    /* wizModeMenuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        WizardModeWindow wizModeWin = new WizardModeWindow();
            
        EditorMainWindow emw = EditorMainWindow.getInstance();
        JDesktopPane emwDesktopPane = emw.getDesktopPane();
            
        wizModeWin.setTitle("Wizard Mode");
        wizModeWin.pack();
            
        wizModeWin.addInternalFrameListener(new WeakInternalFrameListener(EditorMainWindow.getInstance()));
            
        Dimension dpDim = emwDesktopPane.getSize();
        int x = (dpDim.width - wizModeWin.getWidth()) / 2;
        int y = (dpDim.height - wizModeWin.getHeight()) / 2;
            
        wizModeWin.setLocation(x, y);
        emwDesktopPane.add(wizModeWin);
        wizModeWin.setVisible(true);
            
        setWizMode(true);
    }
     });*/

    ugMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (Desktop.isDesktopSupported()) {
                Desktop desktop = Desktop.getDesktop();
                InputStream resource = this.getClass().getResourceAsStream("/User_Guide.pdf");
                try {
                    File userGuideFile = File.createTempFile("UserGuide", ".pdf");
                    userGuideFile.deleteOnExit();
                    OutputStream out = new FileOutputStream(userGuideFile);
                    try {
                        // copy contents from resource to out
                        IOUtils.copy(resource, out);
                    } catch (IOException ex) {
                        JOptionPane.showMessageDialog(null, "Couldn't copy between streams.");
                    } finally {
                        out.close();
                    }
                    desktop.open(userGuideFile);
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(null, "Could not call Open on desktop object.");
                } finally {
                    try {
                        if (resource != null) {
                            resource.close();
                        }
                    } catch (IOException ex) {
                        LOG.error("Error displaying user guide", ex);
                        JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide.");
                    }
                }
            } else {
                JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide.");
            }
        }
    });

}

From source file:analysis.postRun.PostRunWindow.java

/**
  * Method which creates a dialogue asking the user to input the indexes of the log files they wish to compare.
  *//* w  ww .j a v  a  2s .  c  o m*/
private String getFileList() {
    ImageIcon icon = new ImageIcon();
    Object[] possibilities = null;
    String s = (String) JOptionPane.showInputDialog(MainFrame,
            "Enter indexes of log files to compare, separated by commas. e.g. '1,2'", "Compare Log Files",
            JOptionPane.PLAIN_MESSAGE, icon, possibilities, ",");

    //If a string was returned, set it as the fileName and call getData.
    if ((s != null) && (s.length() > 0)) {
        //System.out.println("File indexes entered: " + s);
        return s;
    } else {
        //If you're here, the return value was null/empty.
        JOptionPane.showMessageDialog(MainFrame, "No filename entered.");
        return s;
    }
}

From source file:edu.harvard.i2b2.query.ui.QueryTopPanel.java

private void jRunQueryButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // System.out.println("value set on the slider: "+ jSlider1.getValue());
    if (dataModel.isAllPanelEmpty()) {
        JOptionPane.showMessageDialog(this, "All groups are empty.");
        return;/*from  w w  w. j  a  v a2 s .co m*/
    }

    if (jRunQueryButton.getText().indexOf("Run Query") < 0) {
        cancel();
        return;
    }

    String queryNametmp = jNameTextField.getText();
    // if(queryNametmp.equals("") || queryNametmp == null) {
    queryNametmp = dataModel.getTmpQueryName();
    // }
    Object selectedValue = JOptionPane.showInputDialog(this, "Please supply a name for this query: ",
            "Query Name Dialog", JOptionPane.PLAIN_MESSAGE, null, null, queryNametmp);

    if (selectedValue == null) {
        return;
    } else {
        queryNametmp = (String) selectedValue;
    }

    dataModel.queryName(queryNametmp);
    final String queryName = queryNametmp;
    // System.out.println("Provided query name: " + queryName);

    ImageIcon buttonIcon = createImageIcon("indicator_18.gif");
    this.jRunQueryButton.setIcon(buttonIcon);
    this.jRunQueryButton.setText("         Cancel    ");
    // final Color defaultcolor = jRunQueryButton.getBackground();
    dataModel.specificity(0);// jSlider1.getValue());

    // /create result option list from option selections
    ArrayList<String> optionList = new ArrayList<String>();
    if (jGetPatientCountCheckBox.isSelected()) {
        optionList.add("patient_count_xml");
    }
    if (jGetPatientSetCheckBox.isSelected() || jShowTimelineCheckBox.isSelected()) {
        optionList.add("patientset");
    }
    final String xmlStr = dataModel.wirteQueryXML(optionList);

    // parentPanel.lastRequestMessage(xmlStr);
    parentPanel.setPatientCount("");
    parentPanel.setRequestText(xmlStr);
    parentPanel.setResponseText("Waiting for response ...");
    // System.out.println("Query request: "+xmlStr);
    // jNameTextField.setText(queryName);
    jNameLabel.setText(" Query Name: " + queryName);

    queryThread = new Thread() {
        @Override
        public void run() {
            // setCursor(new Cursor(Cursor.WAIT_CURSOR));
            response = QueryRequestClient.sendQueryRequestREST(xmlStr);
            // parentPanel.lastResponseMessage(response);
            if (response != null) {
                // response =
                // response.substring(response.indexOf("<ns2:response"),
                // response.indexOf("</i2b2:response>"));
                parentPanel.setResponseText(response);
                JAXBUtil jaxbUtil = QueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    BodyType bt = messageType.getMessageBody();
                    MasterInstanceResultResponseType masterInstanceResultResponseType = (MasterInstanceResultResponseType) new JAXBUnWrapHelper()
                            .getObjectByClass(bt.getAny(), MasterInstanceResultResponseType.class);
                    String queryId = null;
                    // ResponseMessageType messageType =
                    // jaxbUtil.unMashallResponseMessageTypeFromString(
                    // response);
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();
                    String count = "N/A";
                    QueryMasterData nameNode = null;
                    if (status.equalsIgnoreCase("DONE")) {
                        String refId = null;
                        try {
                            edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.StatusType cellStatusType = masterInstanceResultResponseType
                                    .getStatus();
                            if (cellStatusType.getCondition().get(0).getType().equalsIgnoreCase("RUNNING")) {
                                JOptionPane.showMessageDialog(parentPanel,
                                        "Query is still running, you may check its status later \n"
                                                + "in the previous queries view by right clicking on a node\n"
                                                + "then selecting refresh all.");
                                jRunQueryButton.setIcon(null);
                                jRunQueryButton.setText("Run Query");
                                return;
                            } else if (cellStatusType.getCondition().get(0).getType()
                                    .equalsIgnoreCase("ERROR")) {
                                JOptionPane.showMessageDialog(parentPanel,
                                        "Error message delivered from the remote server, "
                                                + "you may wish to retry your last action");
                                jRunQueryButton.setIcon(null);
                                jRunQueryButton.setText("Run Query");
                                return;
                            }

                            queryId = new Integer(
                                    masterInstanceResultResponseType.getQueryMaster().getQueryMasterId())
                                            .toString();
                            // messageType.getResponseHeader().getInfo().
                            // getValue();
                            // System.out.println("Get query id: "+queryId);
                            nameNode = new QueryMasterData();
                            nameNode.name(queryName);
                            nameNode.visualAttribute("CA");
                            nameNode.userId(UserInfoBean.getInstance().getUserName());
                            nameNode.tooltip("A query run by " + nameNode.userId());
                            nameNode.id(queryId);
                            // nameNode.xmlContent(xmlStr);

                            // /loop thru all the results
                            for (int i = 0; i < masterInstanceResultResponseType.getQueryResultInstance()
                                    .size(); i++) {
                                QueryResultInstanceType queryResultInstanceType = masterInstanceResultResponseType
                                        .getQueryResultInstance().get(i);
                                if (queryResultInstanceType.getQueryResultType().getName()
                                        .equalsIgnoreCase("patientset")) {
                                    refId = new Integer(queryResultInstanceType.getResultInstanceId())
                                            .toString();
                                    // System.out.println("Set Ref id: "+
                                    // refId);
                                    count = new Integer(queryResultInstanceType.getSetSize()).toString();
                                } else if (queryResultInstanceType.getQueryResultType().getName()
                                        .equalsIgnoreCase("patient_count_xml")) {
                                    count = new Integer(queryResultInstanceType.getSetSize()).toString();

                                    QueryResultData resultData = new QueryResultData();
                                    resultData.queryId(queryResultInstanceType.getResultInstanceId());
                                    String xmlDocumentRequestStr = resultData.writeXMLDocumentQueryXML();
                                    System.out.println(
                                            "Generated XML document request: " + xmlDocumentRequestStr);
                                    // parentPanel.lastRequestMessage(
                                    // xmlDocumentRequestStr);
                                    response = QueryRequestClient.sendQueryRequestREST(xmlDocumentRequestStr);
                                    System.out.println("Generated XML document response: " + response);
                                    // parentPanel.lastResponseMessage(
                                    // response);
                                }
                            }
                            parentPanel.setPatientCount(count);
                            if (count.equalsIgnoreCase("N/A")) {
                                jSetSizeLabel.setText(" Patient(s) returned: " + count);
                            } else {
                                jSetSizeLabel.setText(" Patient(s) returned: " + count);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            JOptionPane.showMessageDialog(parentPanel,
                                    "Response delivered from the remote server could not be understood,\n"
                                            + "you may wish to retry your last action.");

                            jRunQueryButton.setIcon(null);
                            jRunQueryButton.setText("Run Query");
                            return;
                        }

                        final IWorkbenchPage page = ((QueryPanelInvestigator) parentPanel).parentview
                                .getViewSite().getPage();
                        ViewPart previousqueryview = (ViewPart) page.findView(
                                "edu.harvard.i2b2.eclipse.plugins.previousquery.views.PreviousQueryView");
                        ((ICommonMethod) previousqueryview).doSomething(nameNode.name() + " ["
                                + dataModel.getDayString() + "]" + "#i2b2seperater#" + nameNode.id());

                        final ArrayList<String> nodeXmls = new ArrayList<String>();
                        for (int i = 0; i < dataModel.getCurrentPanelCount(); i++) {
                            ArrayList<QueryConceptTreeNodeData> nodelist = dataModel.getTreePanel(i).getItems();
                            for (int j = 0; j < nodelist.size(); j++) {
                                QueryConceptTreeNodeData nodedata = nodelist.get(j);
                                String termStatus = nodedata.setXmlContent();
                                if (termStatus.equalsIgnoreCase("error")) {
                                    JOptionPane.showMessageDialog(parentPanel,
                                            "Response delivered from the remote server could not be understood,\n"
                                                    + "you may wish to retry your last action.");
                                    jRunQueryButton.setIcon(null);
                                    jRunQueryButton.setText("Run Query");
                                    return;
                                }
                                nodeXmls.add(nodedata.xmlContent());
                            }
                        }

                        if (jShowTimelineCheckBox.isSelected()) {
                            ViewPart explorerview = (ViewPart) page
                                    .findView("edu.harvard.i2b2.eclipse.plugins.explorer.views.ExplorerView");
                            if (explorerview != null) {
                                String str1 = "" + count;
                                String str2 = "-" + refId;
                                ((ICommonMethod) explorerview).doSomething(str1 + str2);
                                ((ICommonMethod) explorerview).doSomething(nodeXmls);
                            }
                        }
                    } else {
                        JOptionPane.showMessageDialog(parentPanel,
                                "Error message delivered from the remote server, "
                                        + "you may wish to retry your last action");

                        jRunQueryButton.setIcon(null);
                        jRunQueryButton.setText("Run Query");
                        return;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    // JOptionPane.showMessageDialog(parentPanel,
                    // "Response delivered from the remote server could not
                    // be understood,\n" +
                    // "you may wish to retry your last action.");
                    jRunQueryButton.setIcon(null);
                    jRunQueryButton.setText("Run Query");
                    return;
                }
            }
            // setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            jRunQueryButton.setIcon(null);
            jRunQueryButton.setText("Run Query");
            // jRunQueryButton.setBackground(defaultcolor);
        }
    };

    try {
        queryThread.start();
    } catch (Exception e) {
        e.printStackTrace();
        parentPanel.setResponseText(e.getMessage());
    }
}

From source file:com.ftb2om2.view.MultiplePane.java

private void autoFill(String path) {
    MP3TagWrapper mp3 = new MP3TagWrapper();
    try {/*from www .  ja  v a  2 s .  c  o m*/
        mp3.fillTags(path);
    } catch (TagException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.INFO, null, ex);
        if (ex.getCause().equals(IOException.class) || ex.getCause().equals(InvalidDataException.class)) {
            JOptionPane.showMessageDialog(jPanel6, "Your file isn't an mp3!", "Unexpected File",
                    JOptionPane.PLAIN_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(jPanel6,
                    "Your selected mp3 has unsupported tags, autofill won't work!", "Unsupported Tags!",
                    JOptionPane.PLAIN_MESSAGE);
        }
    } finally {
        mP3TagsPane1.setTags(mp3.getArtist(), "", "", mp3.getTitle(), mp3.getUnicodeArtist(),
                mp3.getUnicodeTitle());
    }
}

From source file:pi.bestdeal.gui.InterfacePrincipale.java

private void Add_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Add_ButtonActionPerformed

    Panel_Ajouter panajout = new Panel_Ajouter();

    Deal deal = new Deal();

    int result = JOptionPane.showConfirmDialog(null, panajout, "Test", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);

    if (result == JOptionPane.OK_OPTION) {
        deal.setTitreDeal_Deal(panajout.txtTitre.getText());
        Vendeur vendeur = new Vendeur();
        VendeurDAO daov = VendeurDAO.getInstance();

        for (Vendeur a : daov.displayvendeurByNom(String.valueOf(panajout.jList1.getSelectedValue()))) {
            vendeur = a;/*from   w  ww .  ja v a2  s.c o  m*/
        }
        if (panajout.jList1.getSelectedValue() == null) {
            vendeur.setIdVendeur(0);
        }

        deal.setDescDeal_Deal(panajout.txtDesc.getText());
        deal.setPrixDeal_Deal(Double.valueOf(panajout.txtPrix.getText()));
        deal.setNbrAchatValidation(Integer.valueOf(panajout.txtValidation.getText()));
        deal.setNbrAchatActuelDeal_Deal(0);
        deal.setNbrAffichage_Deal(0);
        deal.setEtatDeal_Deal("Comming");
        deal.setCategorie_Deal(panajout.ComboCategorie.getSelectedItem().toString());
        deal.setStatutDeal_Deal(false);
        java.util.Date d1 = panajout.jdateDebut.getCalendar().getTime();
        java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
        java.util.Date d2 = panajout.jdateFin.getCalendar().getTime();
        java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
        if (d1.after(d2)) {
            JOptionPane.showMessageDialog(null, "les Dates sont non compatibles");
        } else {
            deal.setDateDebutDeal_Deal(sqlDate);
            deal.setDateFinDeal_Deal(sqlDate2);
            deal.setIdVendeur_Deal(vendeur.getIdVendeur());
            DealDAO dealdao = DealDAO.getInstance();

            dealdao.insertDeal(deal);
            Deal dd = dealdao.displayDeal().get((dealdao.displayDeal().size() - 1));
            y = dd.getIdDeal_Deal();
            System.out.println(y);
            if (panajout.fc.getSelectedFiles().length != 0) {
                for (int i = 0; i < panajout.fc.getSelectedFiles().length; i++) {

                    FileInputStream fis = null;
                    try {
                        fis = new FileInputStream(panajout.file[i]);
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    ImageDeal imgdeal = new ImageDeal();
                    Path path = Paths.get(panajout.file[i].getAbsolutePath());
                    try {
                        imgdeal.setImage(Files.readAllBytes(path));

                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    imgdeal.setIdDeal(y);

                    ImageDAO im = ImageDAO.getInstance();
                    im.InsertImage(imgdeal);

                }
            }

            JOptionPane.showMessageDialog(null, "Ajout termin");
            DealTableModel mymodel = new DealTableModel(list.displayDeal());
            jTable1.setModel(mymodel);
            jTable1.removeColumn(jTable1.getColumn("ID"));
            jTable1.removeColumn(jTable1.getColumn("Description"));
            jTable1.removeColumn(jTable1.getColumn("Achat Actuel"));
            jTable1.removeColumn(jTable1.getColumn("Etat"));
            jTable1.removeColumn(jTable1.getColumn("Statut"));
            jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage"));
            jTable1.removeColumn(jTable1.getColumn("Vendeur"));

            jTable1.getColumnModel().setColumnMargin(20);
            jTable1.setRowSelectionInterval(0, 0);
            y = mymodel.getRowCount();
            panajout.w = y;
            System.out.println("la valeur de y est :" + y + "et " + panajout.w);
        }
    } else {
        System.out.println("Cancelled");
    }

}

From source file:datavis.Gui.java

private void button2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_button2ActionPerformed
{//GEN-HEADEREND:event_button2ActionPerformed

    int station = Integer.parseInt((String) ((String) JOptionPane.showInputDialog(null, "Select a station.",
            "Web Import", JOptionPane.PLAIN_MESSAGE, null, stations, stations[8])).subSequence(0, 3));
    int interval = intervals.get(JOptionPane.showInputDialog(null, "Select sample resolution", "Web Import",
            JOptionPane.PLAIN_MESSAGE, null, intervals.keySet().toArray(), intervals.keySet().toArray()[5]));
    JDatePicker sP = new JDateComponentFactory().createJDatePicker();
    JDatePicker eP = new JDateComponentFactory().createJDatePicker();
    Calendar today = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    sP.getModel().setDate(today.get(Calendar.YEAR) - 1, today.get(Calendar.MONTH),
            today.get(Calendar.DAY_OF_MONTH));
    sP.getModel().setSelected(true);//from   w  ww .  j  a  v  a  2  s.c  o m
    eP.getModel().setDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH),
            today.get(Calendar.DAY_OF_MONTH));
    eP.getModel().setSelected(true);
    JPanel panel = new JPanel();
    panel.add(new JLabel("Start date"));
    panel.add((Component) sP);
    panel.add(new JLabel("End date"));
    panel.add((Component) eP);
    JOptionPane.showMessageDialog(null, panel, "Web Import", JOptionPane.PLAIN_MESSAGE);
    try {
        dataset = getDataFromServer(station, interval, ((GregorianCalendar) sP.getModel().getValue()).getTime(),
                ((GregorianCalendar) eP.getModel().getValue()).getTime());
    } catch (UnsupportedEncodingException ex) {
        JOptionPane.showMessageDialog(null, "There was an error retreiving data from the server.");
        return;
    }

    updateGraphs_pieChart(dataset, true);
    updateGraphs_barGraph(dataset, true);
    updateGraphs_lineGraph(dataset, true);
    String sampleTypes[] = dataset.getDropMenu();

    jTextArea1.setText(dataset.toString());
    jTextArea1.setCaretPosition(0);

    jTextArea2.setText(dataset.getStationInfo() + displayDevelopers);

    jTextArea2.setCaretPosition(0);
    button1.setLabel("Import Existing");

    for (int i = 0; i < jComboBox1.getItemCount(); i++) {
        jComboBox1.remove(i);
        jComboBox2.remove(i);
        jComboBox3.remove(i);
    }

    for (int i = 0; i < sampleTypes.length; i++) {
        jComboBox1.addItem(sampleTypes[i]);
        jComboBox2.addItem(sampleTypes[i]);
        jComboBox3.addItem(sampleTypes[i]);
    }

}

From source file:captureplugin.CapturePlugin.java

/**
 * Check the programs after data update.
 *///from   w w  w  .  j  a  v  a 2s. co m
public void handleTvDataUpdateFinished() {
    mNeedsUpdate = true;

    if (mAllowedToShowDialog) {
        mNeedsUpdate = false;

        DeviceIf[] devices = mConfig.getDeviceArray();

        final DefaultTableModel model = new DefaultTableModel() {
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };

        model.setColumnCount(5);
        model.setColumnIdentifiers(new String[] { mLocalizer.msg("device", "Device"),
                Localizer.getLocalization(Localizer.I18N_CHANNEL), mLocalizer.msg("date", "Date"),
                ProgramFieldType.START_TIME_TYPE.getLocalizedName(),
                ProgramFieldType.TITLE_TYPE.getLocalizedName() });

        JTable table = new JTable(model);
        table.getTableHeader().setReorderingAllowed(false);
        table.getTableHeader().setResizingAllowed(false);
        table.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(JTable renderTable, Object value, boolean isSelected,
                    boolean hasFocus, int row, int column) {
                Component c = super.getTableCellRendererComponent(renderTable, value, isSelected, hasFocus, row,
                        column);

                if (value instanceof DeviceIf) {
                    if (((DeviceIf) value).getDeleteRemovedProgramsAutomatically() && !isSelected) {
                        c.setForeground(Color.red);
                    }
                }

                return c;
            }
        });

        int[] columnWidth = new int[5];

        for (int i = 0; i < columnWidth.length; i++) {
            columnWidth[i] = UiUtilities.getStringWidth(table.getFont(), model.getColumnName(i)) + 10;
        }

        for (DeviceIf device : devices) {
            Program[] deleted = device.checkProgramsAfterDataUpdateAndGetDeleted();

            if (deleted != null && deleted.length > 0) {
                for (Program p : deleted) {
                    if (device.getDeleteRemovedProgramsAutomatically() && !p.isExpired() && !p.isOnAir()) {
                        device.remove(UiUtilities.getLastModalChildOf(getParentFrame()), p);
                    } else {
                        device.removeProgramWithoutExecution(p);
                    }

                    if (!p.isExpired()) {
                        Object[] o = new Object[] { device, p.getChannel().getName(), p.getDateString(),
                                p.getTimeString(), p.getTitle() };

                        for (int i = 0; i < columnWidth.length; i++) {
                            columnWidth[i] = Math.max(columnWidth[i],
                                    UiUtilities.getStringWidth(table.getFont(), o[i].toString()) + 10);
                        }

                        model.addRow(o);
                    }
                }
            }

            device.getProgramList();
        }

        if (model.getRowCount() > 0) {
            int sum = 0;

            for (int i = 0; i < columnWidth.length; i++) {
                table.getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]);

                if (i < columnWidth.length - 1) {
                    table.getColumnModel().getColumn(i).setMaxWidth(columnWidth[i]);
                }

                sum += columnWidth[i];
            }

            JScrollPane scrollPane = new JScrollPane(table);
            scrollPane.setPreferredSize(new Dimension(450, 250));

            if (sum > 500) {
                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                scrollPane.getViewport().setPreferredSize(
                        new Dimension(sum, scrollPane.getViewport().getPreferredSize().height));
            }

            JButton export = new JButton(mLocalizer.msg("exportList", "Export list"));
            export.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JFileChooser chooser = new JFileChooser();
                    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
                    chooser.setFileFilter(new FileFilter() {
                        public boolean accept(File f) {
                            return f.isDirectory() || f.toString().toLowerCase().endsWith(".txt");
                        }

                        public String getDescription() {
                            return "*.txt";
                        }
                    });

                    chooser.setSelectedFile(new File("RemovedPrograms.txt"));
                    if (chooser.showSaveDialog(
                            UiUtilities.getLastModalChildOf(getParentFrame())) == JFileChooser.APPROVE_OPTION) {
                        if (chooser.getSelectedFile() != null) {
                            String file = chooser.getSelectedFile().getAbsolutePath();

                            if (!file.toLowerCase().endsWith(".txt") && file.indexOf('.') == -1) {
                                file = file + ".txt";
                            }

                            if (file.indexOf('.') != -1) {
                                try {
                                    RandomAccessFile write = new RandomAccessFile(file, "rw");
                                    write.setLength(0);

                                    String eolStyle = File.separator.equals("/") ? "\n" : "\r\n";

                                    for (int i = 0; i < model.getRowCount(); i++) {
                                        StringBuilder line = new StringBuilder();

                                        for (int j = 0; j < model.getColumnCount(); j++) {
                                            line.append(model.getValueAt(i, j)).append(' ');
                                        }

                                        line.append(eolStyle);

                                        write.writeBytes(line.toString());
                                    }

                                    write.close();
                                } catch (Exception ee) {
                                }
                            }
                        }
                    }
                }
            });

            Object[] message = {
                    mLocalizer.msg("deletedText",
                            "The data was changed and the following programs were deleted:"),
                    scrollPane, export };

            JOptionPane pane = new JOptionPane();
            pane.setMessage(message);
            pane.setMessageType(JOptionPane.PLAIN_MESSAGE);

            final JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(getParentFrame()),
                    mLocalizer.msg("CapturePlugin", "CapturePlugin") + " - "
                            + mLocalizer.msg("deletedTitle", "Deleted programs"));
            d.setResizable(true);
            d.setModal(false);

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    d.setVisible(true);
                }
            });
        }
    }
}

From source file:com.ftb2om2.view.MultiplePane.java

private void createDifficultiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createDifficultiesActionPerformed
    Converter converter;//w  w  w. j  a  v a2  s.  c  o  m
    Reader reader = null;
    Writer writer = null;

    switch (jComboBox1.getSelectedIndex()) {
    case 0:
        reader = new FtbAirReader();
        break;
    case 1:
        reader = new FtbOldReader();
        break;
    }

    switch (jComboBox2.getSelectedIndex()) {
    case 0:
        writer = new OsuManiaV14Writer();
    }

    converter = new Converter(reader, writer);

    Metadata metadata = new Metadata(mP3TagsPane1.getTitleField(), mP3TagsPane1.getUnicodeTitleField(),
            mP3TagsPane1.getArtistField(), mP3TagsPane1.getUnicodeArtistField(), mP3TagsPane1.getCreatorField(),
            mP3TagsPane1.getSourceField());

    DefaultTableModel model = (DefaultTableModel) difficultyTable.getModel();
    List<List<Object>> data = model.getDataVector();

    Boolean valid = true;

    for (List row : data) {
        if (row.get(2).toString().isEmpty() && valid == true) {
            JOptionPane.showMessageDialog(jPanel6,
                    "Difficulty " + row.get(1).toString() + " Has no output name!", "Error",
                    JOptionPane.ERROR_MESSAGE);
            valid = false;
        }
    }

    if (valid) {
        try {
            for (List row : data) {
                converter.convert(row.get(1).toString(), outputFolder.getText(), row.get(2).toString(),
                        Integer.parseInt(hitsoundVolume.getModel().getValue().toString()), metadata);
            }
            JOptionPane.showMessageDialog(jPanel6, "Difficulty created succesfully!", "Success!",
                    JOptionPane.PLAIN_MESSAGE);
        } catch (IOException e) {
            handleError(e);
        }
    }
}

From source file:course_generator.param.frmEditCurve.java

/**
 * Duplicate the selected curve//from w  w w.  ja  v  a  2 s  .  c  o m
 * Its new name is requested
 */
private void DuplicateCurve() {
    if (!bEditMode) {
        Old_Paramfile = Paramfile;

        //-- Configuration of the panel
        JPanel panel = new JPanel(new GridLayout(0, 1));
        panel.add(new JLabel(bundle.getString("frmEditCurve.DuplicatePanel.name.text")));
        JTextField tfName = new JTextField("");
        panel.add(tfName);
        int result = JOptionPane.showConfirmDialog(this, panel,
                bundle.getString("frmEditCurve.DuplicatePanel.title"), JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE);
        if ((result == JOptionPane.OK_OPTION) && (!tfName.getText().isEmpty())) {
            if (Utils.FileExist(Utils.GetHomeDir() + "/" + CgConst.CG_DIR + "/" + tfName.getText() + ".par")) {
                JOptionPane.showMessageDialog(this, bundle.getString("frmEditCurve.DuplicatePanel.fileexist"));
                return;
            }
            param.name = tfName.getText();
            Paramfile = param.name;
            param.Save(Utils.GetHomeDir() + "/" + CgConst.CG_DIR + "/" + param.name + ".par");
            ChangeEditStatus();
            RefreshCurveList();
            RefreshView();
        }
    }
}

From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java

public void actionPerformed(ActionEvent e) {
    if ("test".equals(e.getActionCommand())) {
        //TODO test whether the caGrid execution service is online
        System.out.println("testing caGrid services......successful!");

    }/*from  w ww  .  j  ava  2  s  .c o m*/
    if (e.getActionCommand().equals("refresh")) {
        Object selection = runList.getSelectedValue();
        if (selection instanceof CaGridRun) {

            CaGridRun dataflowRun = (CaGridRun) selection;
            // update status and refresh outputPanel
            String resultDisplayString = updateResultDisplayString(dataflowRun);
            resultText.setText(resultDisplayString);
            resultText.setLineWrap(true);
            resultText.setEditable(false);
            outputPanel.revalidate();
            revalidate();
        }

    }
    //download the output file
    if (e.getActionCommand().equals("download")) {
        Object selection = runList.getSelectedValue();
        if (selection instanceof CaGridRun) {
            CaGridRun dataflowRun = (CaGridRun) selection;
            //if there is any output file
            if (dataflowRun.wfp.needTransfer == dataflowRun.wfp.TRANSFER_DOWNLOAD_ONLY
                    || dataflowRun.wfp.needTransfer == dataflowRun.wfp.TRANSFER_BOTH) {
                // download only when workflow is finished
                if (dataflowRun.workflowStatusElement.equals(WorkflowStatusType.Done)) {
                    File outFile;
                    try {
                        outFile = TavernaWorkflowServiceClient.getOutputDataHelper(dataflowRun.workflowEPR,
                                dataflowRun.proxy, System.getProperty("user.home"));
                        JOptionPane.showMessageDialog(null,
                                "The workflow output file is downloaed to: " + outFile.getAbsolutePath(),
                                "Message", JOptionPane.PLAIN_MESSAGE);
                        System.out.println("caTransfer Output: " + outFile.getAbsolutePath());
                    } catch (MalformedURIException ex) {

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

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

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

                        ex.printStackTrace();
                    }

                } else if (dataflowRun.workflowStatusElement.equals(WorkflowStatusType.Failed)) {
                    JOptionPane.showMessageDialog(null, "The workflow has failed.", "Message",
                            JOptionPane.PLAIN_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(null, "The workflow is running. Please check back later",
                            "Message", JOptionPane.PLAIN_MESSAGE);

                }
            }
            //no output file through caGrid transfer
            else {
                JOptionPane.showMessageDialog(null, "This workflow does not have any fileOutputs.", "Message",
                        JOptionPane.PLAIN_MESSAGE);

            }
        }

    }
}