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:dbseer.gui.user.DBSeerDataSet.java

public boolean validateTable() {
    boolean useEntire = false;
    for (int i = 0; i < tableModel.getRowCount(); ++i) {
        for (int j = 0; j < tableHeaders.length; ++j) {
            if (tableModel.getValueAt(i, 0).equals(tableHeaders[j])) {
                switch (j) {
                case TYPE_USE_ENTIRE_DATASET:
                    useEntire = ((Boolean) tableModel.getValueAt(i, 1)).booleanValue();
                    break;
                }//  ww w.ja  va 2  s.c om
            }
        }
    }

    HashSet<String> checkDuplicates = new HashSet<String>();

    for (int i = 0; i < tableModel.getRowCount(); ++i) {
        for (int j = 0; j < tableHeaders.length; ++j) {
            if (tableModel.getValueAt(i, 0).equals(tableHeaders[j])) {
                switch (j) {
                case TYPE_END_INDEX: {
                    if (!useEntire
                            && !UserInputValidator.validateNumber((String) tableModel.getValueAt(i, 1))) {
                        JOptionPane.showMessageDialog(null,
                                "Please enter end index correctly.\nIt has to be an integer.", "Warning",
                                JOptionPane.WARNING_MESSAGE);
                        return false;
                    }
                    break;
                }
                case TYPE_START_INDEX: {
                    if (!useEntire
                            && !UserInputValidator.validateNumber((String) tableModel.getValueAt(i, 1))) {
                        JOptionPane.showMessageDialog(null,
                                "Please enter start index correctly.\nIt has to be an integer.", "Warning",
                                JOptionPane.WARNING_MESSAGE);
                        return false;
                    }
                    break;
                }
                default:
                    break;
                }
                break;
            }
        }
        //         if (i > TYPE_NUM_TRANSACTION_TYPE && i < )
        if (i > TYPE_NUM_TRANSACTION_TYPE && i < TYPE_NUM_TRANSACTION_TYPE + this.numTransactionTypes) {
            if (!checkDuplicates.add((String) tableModel.getValueAt(i, 1))
                    && tableModel.getValueAt(i, 1) != "") {
                JOptionPane.showMessageDialog(null,
                        "Please enter transaction type names correctly.\nEach name has to be unique.",
                        "Warning", JOptionPane.WARNING_MESSAGE);
                return false;
            }
        }
    }
    return true;
}

From source file:client.ui.FilePane.java

private void deleteFileButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_deleteFileButtonActionPerformed
    CloudFile selectedFile = getSelectedFile();
    if (selectedFile == null) {
        JOptionPane.showMessageDialog(this, "", "", JOptionPane.WARNING_MESSAGE);
        return;//from  www.j a va  2s  .  c om
    }
    try {
        DeleteFileResult result = m_Business.deleteFile(selectedFile);
        switch (result) {
        case OK:
            JOptionPane.showMessageDialog(this, "?", "",
                    JOptionPane.INFORMATION_MESSAGE);
            getDirectory(currentID);
            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);
    }
    //fileInfoTable.clearSelection();
}

From source file:fitnesserefactor.FitnesseRefactor.java

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

    if (ParentFolder.isSelected()) {
        if (!"".equals(JtreePath)) {
            File dir = new File(JtreePath);
            try {
                if (dir.getParent() != null && dir.isFile()) {
                    String Testcase = dir.getParent();
                    File dir1 = new File(Testcase);
                    if (dir1.getParent() != null && dir1.isDirectory()) {
                        String parent = dir1.getParent();
                        File dir2 = new File(Testcase);
                        if (dir2.getParent() != null) {
                            String GrandParent = dir2.getParent();
                            File dir3 = new File(GrandParent);
                            File[] allFiles = dir3.listFiles();
                            ArrayList al = new ArrayList();
                            for (File file : allFiles) {
                                if (allFiles.length <= al.size())
                                    break;
                                String TestcaseNames = file.getName();
                                al.add(TestcaseNames);
                            }// w ww.  j  a va2  s. c  o  m
                            if (!fromTxt.getText().isEmpty() && !toTxt.getText().isEmpty()) {
                                int FromTxtInt = Integer.parseInt(fromTxt.getText());
                                int ToTxtInt = Integer.parseInt(toTxt.getText());
                                int TotFiles = al.size();
                                if ((ToTxtInt > FromTxtInt) && (ToTxtInt > 0) && (FromTxtInt > 0)
                                        && ToTxtInt <= al.size() - 2) {
                                    for (int removeAfterToIndx = (ToTxtInt
                                            + 2); removeAfterToIndx < TotFiles; removeAfterToIndx++) {
                                        al.remove(ToTxtInt + 2);
                                    }
                                    if (FromTxtInt > 1) {
                                        for (int removeFromIndx = 1; removeFromIndx < FromTxtInt; removeFromIndx++) {
                                            al.remove(2);
                                        }
                                    }

                                } else {
                                    JOptionPane.showMessageDialog(null,
                                            "FROM test case number cannot be greater/equal to TO test case number.\nFROM and TO test case numbers should be greater than zero. \nTO test case number should not be greater than the testcase count ",
                                            "Warning", JOptionPane.WARNING_MESSAGE);
                                }
                            }
                            for (int i = 2; i <= al.size(); i++) {
                                System.out.println(dir2.getParent() + "\\" + al.get(i) + "\\content.txt");
                                File EachFile = new File(dir2.getParent() + "\\" + al.get(i) + "\\content.txt");
                                for (int j = 0; j < FileUtils.readLines(EachFile).size(); j++) {
                                    String line = (String) FileUtils.readLines(EachFile).get(j);
                                    if (line.matches("(.*)" + FitnesseTablesList.getSelectedItem().toString()
                                            + "(.*)")) {
                                        p = j;
                                        ReadAllLines(EachFile);
                                        int linNum = CountLines(EachFile);
                                        ModifiedTable(EachFile, Integer.parseInt(ColumnField.getText()));
                                        int ModifiedLen = ModifiedLines.size();
                                        System.out.println(ModifiedLen);
                                        int tblIndex = 1;
                                        for (int SetNew = 0; SetNew < ModifiedLen; SetNew++) {
                                            AllLines.set(p + tblIndex, ModifiedLines.get(SetNew).toString());
                                            tblIndex = tblIndex + 1;
                                        }
                                        WriteAllLines(EachFile);
                                    }
                                }
                            }
                        } else {
                            JOptionPane.showMessageDialog(null,
                                    "There are no testcases under the parent folder", "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "There are no testcases under the parent folder",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "Need to select atleast one content.txt file",
                            "Warning", JOptionPane.WARNING_MESSAGE);
                }
            } catch (Exception E) {
                //JOptionPane.showMessageDialog(null, E, "Java Runtime Error", JOptionPane.ERROR );
            }
        }

    }
}

From source file:edu.ku.brc.ui.UIRegistry.java

/**
 * Displays an error dialog with a non-localized error message.
 * @param dlgType Dialog type error or warning
 * @param msg the message//from   w w  w .j  a v a  2  s.c o m
 */
public static void showError(final Integer dlgType, final String msg) {
    log.error(msg);

    String titleKey = dlgType != null && dlgType == JOptionPane.WARNING_MESSAGE ? "WARNING"
            : "UIRegistry.UNRECOVERABLE_ERROR_TITLE";
    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), msg, getResourceString(titleKey),
            dlgType == null ? JOptionPane.ERROR_MESSAGE : dlgType);
}

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

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    int idd = (int) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 0);
    ChoixStat1 chStat = new ChoixStat1();
    ChoixStat2 chStat2 = new ChoixStat2();

    Object[] options = { "BACK", "NEXT" };
    int a = JOptionPane.showOptionDialog(null, chStat, "", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);
    int b = 0;/* ww w  .  ja  va 2s  .com*/
    if (chStat.jRadiosexe.isSelected() && chStat.jRadioconsult.isSelected()) {
        b = 0;
    }
    if (chStat.jRadiosexe.isSelected() && chStat.jRadiores.isSelected()) {
        b = 1;
    }
    if (chStat.jRadiooperation.isSelected() && chStat.jRadioconsult.isSelected()) {
        b = 2;
    }
    if (chStat.jRadiooperation.isSelected() && chStat.jRadiores.isSelected()) {
        b = 3;
    }
    if (a == 1 && b == 2) {
        chStat.setVisible(false);
        Object[] options2 = { "Annuler", "Afficher la Statistique" };
        int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options2, options[0]);
        if (c == 1) {
            java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime();
            java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
            java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime();
            java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
            Charts charts = new Charts();

            XYSeriesCollection dataxy = charts.createDataset(sqlDate.toString(), sqlDate2.toString(), idd);
            final JFreeChart chart = ChartFactory.createXYLineChart(
                    "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Consultations", //
                    dataxy, // Dataset
                    PlotOrientation.VERTICAL, // 

                    true, true, false);
            XYItemRenderer rend = chart.getXYPlot().getRenderer();

            ChartPanel crepart = new ChartPanel(chart);
            Plot plot = chart.getPlot();

            JPanel jpan = new JPanel();
            JButton button = new JButton("Sauvegarder");
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        JFileChooser chooser = new JFileChooser();
                        chooser.showSaveDialog(jPanel3);
                        String path = chooser.getSelectedFile().getPath();
                        if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                            path = path + ".png";
                        }
                        File f = new File(path);
                        ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600);

                        if (f.exists() && !f.isDirectory()) {
                            JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                            Desktop.getDesktop().open(f);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });

            jpan.add(crepart);
            jpan.add(button);
            JOptionPane.showConfirmDialog(null, jpan, "Chart d'volution des consultations",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        }
    }
    if (a == 1 && (b == 3)) {
        Object[] options2 = { "Annuler", "Afficher la Statistique" };
        int c = JOptionPane.showOptionDialog(null, chStat2, "", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options2, options[0]);
        if (c == 1) {
            java.util.Date d1 = chStat2.jDateDebut.getCalendar().getTime();
            java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
            java.util.Date d2 = chStat2.jDatefin.getCalendar().getTime();
            java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
            Charts charts = new Charts();
            //     JFreeChart chrt = ChartFactory.createXYStepAreaChart(null, null, null, null, PlotOrientation.HORIZONTAL, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled)
            XYSeriesCollection dataxy = charts.createDatasetRes(sqlDate.toString(), sqlDate2.toString(), idd);
            final JFreeChart chart = ChartFactory.createXYLineChart(
                    "Evolution des Consultation par rapport au temps", "Jours", "Nombre des Reservations",
                    dataxy, PlotOrientation.VERTICAL, true, true, false);
            XYItemRenderer rend = chart.getXYPlot().getRenderer();

            ChartPanel crepart = new ChartPanel(chart);
            Plot plot = chart.getPlot();

            JPanel jpan = new JPanel();
            jpan.setLayout(new FlowLayout(FlowLayout.LEADING));
            JButton button = new JButton();

            button.setText("Sauvegarder");
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        JFileChooser chooser = new JFileChooser();
                        chooser.showSaveDialog(jPanel3);
                        String path = chooser.getSelectedFile().getPath();
                        if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                            path = path + ".png";
                        }
                        File f = new File(path);
                        ChartUtilities.saveChartAsPNG(new File(path), chart, 800, 600);

                        if (f.exists() && !f.isDirectory()) {
                            JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                            Desktop.getDesktop().open(f);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });

            jpan.add(crepart);
            jpan.add(button);
            JOptionPane.showConfirmDialog(null, jpan, "Test", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);
        }

    }
    if (a == 1 && b == 0) {
        ConsultationDAO cdao = ConsultationDAO.getInstance();
        DefaultPieDataset union = new DefaultPieDataset();
        union.setValue("Homme", cdao.consultationCounterByGender(false, idd));
        union.setValue("Femme", cdao.consultationCounterByGender(true, idd));

        final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true,
                false);
        ChartPanel crepart = new ChartPanel(repart);
        Plot plot = repart.getPlot();
        JPanel jpan = new JPanel();
        JButton button = new JButton("Sauvegarder");
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    JFileChooser chooser = new JFileChooser();
                    chooser.showSaveDialog(jPanel3);
                    String path = chooser.getSelectedFile().getPath();
                    if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                        path = path + ".png";
                    }
                    File f = new File(path);
                    ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600);

                    if (f.exists() && !f.isDirectory()) {
                        JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                        Desktop.getDesktop().open(f);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        jpan.add(crepart);
        jpan.add(button);
        JOptionPane.showConfirmDialog(null, jpan, "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

    }
    if (a == 1 && b == 1) {
        DefaultPieDataset union = new DefaultPieDataset();
        ReservationDAO dAO = ReservationDAO.getInstance();
        union.setValue("Homme", dAO.reservationCounterByGender(false, idd));
        union.setValue("Femme", dAO.reservationCounterByGender(true, idd));

        final JFreeChart repart = ChartFactory.createPieChart3D("Rpartition par Sexe", union, true, true,
                false);
        ChartPanel crepart = new ChartPanel(repart);
        Plot plot = repart.getPlot();
        JPanel jpan = new JPanel();
        JButton button = new JButton("Sauvegarder");
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    JFileChooser chooser = new JFileChooser();
                    chooser.showSaveDialog(jPanel3);
                    String path = chooser.getSelectedFile().getPath();
                    if ((!path.contains("jpg")) || (!path.contains("png")) || (!path.contains("jpeg"))) {
                        path = path + ".png";
                    }
                    File f = new File(path);
                    ChartUtilities.saveChartAsPNG(new File(path), repart, 800, 600);

                    if (f.exists() && !f.isDirectory()) {
                        JOptionPane.showMessageDialog(null, "Sauvegarde Effectue");
                        Desktop.getDesktop().open(f);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        jpan.add(crepart);
        jpan.add(button);
        JOptionPane.showConfirmDialog(null, jpan, "Chart de la rpartition des achat par sexe",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

    }
}

From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java

private void fwdDoctorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fwdDoctorBtnActionPerformed
    int selectedRow = vitalSignjTable.getSelectedRow();
    Date requestDate = new Date();
    Person person = (Person) nameComboBox.getSelectedItem();
    //account.getPerson().getPersonName();
    String status = (String) vitalSignjTable.getValueAt(selectedRow, 6);
    for (Organization orgz : enterprise.getOrganizationList().getOrganizationList()) {
        if (orgz instanceof HospitalDoctorOrg) {
            for (UserAccount ua : orgz.getUserAccDir().getUserAccountList()) {
                account = ua;/*from ww w. j  av a2 s  .co m*/
            }
        }
    }
    if (selectedRow >= 0) {
        try {
            if (!status.equals("Normal")) {
                DefaultTableModel model = (DefaultTableModel) vitalSignjTable.getModel();
                Member member = (Member) model.getValueAt(selectedRow, 0);
                //VitalSign timestamp = (VitalSign)vitalSignjTable.getValueAt(selectedRow, 1);
                String message = member.getMemberName();
                VitalSign vs = (VitalSign) vitalSignjTable.getValueAt(selectedRow, 1);
                if (vs.getAlertStatus().equals("Requested doc")) {
                    JOptionPane.showMessageDialog(null, "Vital Sign data already sent to doctors", "WARNING",
                            JOptionPane.WARNING_MESSAGE);
                    return;
                } else if (vs.getAlertStatus().equals("Doc Reviewed")
                        || vs.getAlertStatus().equals("sent to house")) {
                    JOptionPane.showMessageDialog(null, "Vital Sign record already reviewed by doctor",
                            "WARNING", JOptionPane.WARNING_MESSAGE);
                    return;
                } else {
                    vs.setAlertStatus("Requested doc");
                    populateTable(person);
                    HospitalWorkRequest request = new HospitalWorkRequest();

                    request.setPerson(person);
                    request.setMessage(message);
                    request.setSender(userAccount);
                    request.setStatus("alert sent");
                    //            request.setRecordDate(timestamp);
                    Organization org = null;
                    for (Organization organization : enterprise.getOrganizationList().getOrganizationList()) {
                        if (organization instanceof HospitalDoctorOrg) {
                            org = organization;
                            break;
                        }
                    }
                    if (org != null) {
                        userAccount.getWorkQueue().getWorkRequestList().add(request);
                        org.getWorkQueue().getWorkRequestList().add(request);
                    }
                    populateDoctorAlertTable();
                    JOptionPane.showMessageDialog(null, "Alert Sent to doctor", "Infomation",
                            JOptionPane.INFORMATION_MESSAGE);

                }
            } else {
                JOptionPane.showMessageDialog(null, "Vital Sign is normal. Cannot forward to doctor", "MESSAGE",
                        JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception e) {
            //                JOptionPane.showMessageDialog(null, "","record",JOptionPane.INFORMATION_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(null, "Please Select a Row", "WARNING", JOptionPane.WARNING_MESSAGE);
    }
    //                for(WorkRequest req : userAccount.getWorkQueue().getWorkRequestList()){
    //                    if(req instanceof HospitalWorkRequest){
    //                        if(!((request.getMessage().equals(req.getMessage()))&&
    //                            (request.getRecordDate().equals(((HospitalWorkRequest)req).getRecordDate())))){

    //                            }
    //                            else{
    //                                JOptionPane.showMessageDialog(null, "Patient record is already sent to doctor", "WARNING", JOptionPane.WARNING_MESSAGE);
    //                            }
    //                        }
    //                    }

}

From source file:de.juwimm.cms.util.Communication.java

@SuppressWarnings("unchecked")
public boolean removeViewComponent(int intViewComponentId, String viewComponentName, byte onlineState) {
    boolean retVal = false;

    try {/*www .ja v a  2s .c o m*/
        // CHECK IF THIS NODE CONTAINS SUBNODES
        ViewIdAndInfoTextValue[] str = getAllChildrenNamesWithUnit(intViewComponentId);
        String units = "";
        if (str != null && str.length > 0) {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < str.length; i++) {
                sb.append(str[i].getInfoText().trim()).append("\n");
            }
            units = sb.toString();
        }
        if (!units.equalsIgnoreCase("")) {
            if (!isUserInRole(UserRights.SITE_ROOT)) {
                // dazwischen, damit sparen wir uns das zweite...
                String msg = Messages.getString("comm.removevc.containsunitsandcannotremove", units);
                JOptionPane.showMessageDialog(UIConstants.getMainFrame(), msg, rb.getString("dialog.title"),
                        JOptionPane.ERROR_MESSAGE);
                return false;
            }
            units = Messages.getString("comm.removevc.header_units", units);
        }

        String refVcs = "";
        ViewComponentValue[] refDao = getViewComponentsWithReferenceToViewComponentId(intViewComponentId);
        if (refDao != null && refDao.length > 0) {
            StringBuffer sb = new StringBuffer();
            for (int j = 0; j < refDao.length; j++) {
                if (refDao[j].getViewType() == Constants.VIEW_TYPE_INTERNAL_LINK) {
                    // InternalLink in the Tree
                    sb.append(Messages.getString("comm.removevc.refvc.internallink",
                            ("\"" + refDao[j].getDisplayLinkName() + "\""),
                            ("\"" + refDao[j].getMetaData().trim() + "\""))).append("\n");
                } else if (refDao[j].getViewType() == Constants.VIEW_TYPE_SYMLINK) {
                    // reference though Symlink in the Tree
                    sb.append(Messages.getString("comm.removevc.refvc.symlink",
                            ("\"" + refDao[j].getDisplayLinkName() + "\""),
                            ("\"" + refDao[j].getMetaData().trim() + "\""))).append("\n");
                } else {
                    // reference through links in the content
                    sb.append(Messages.getString("comm.removevc.refvc.content",
                            ("\"" + refDao[j].getDisplayLinkName() + "\""),
                            ("\"" + refDao[j].getMetaData().trim() + "\""))).append("\n");
                }
            }
            refVcs = sb.toString();
        }

        if (!refVcs.equals("")) {
            refVcs = Messages.getString("comm.removevc.header_refvcs", refVcs);
        }

        String teaserText = "";
        boolean teaserReferenced = false;
        try {
            StringBuilder refTeaser = new StringBuilder("");
            XmlSearchValue[] xmlSearchValues = this.searchXml(getSiteId(), "//teaserRef");
            if (xmlSearchValues != null && xmlSearchValues.length > 0) {
                // herausfinden, ob es sich um DIESEN Teaser handelt
                String resultRootStartElement = "<searchTeaserResult>";
                String resultRootEndElement = "</searchTeaserResult>";
                for (int i = 0; i < xmlSearchValues.length; i++) {
                    StringBuilder stringBuilder = new StringBuilder(xmlSearchValues[i].getContent());
                    stringBuilder.insert(0, resultRootStartElement);
                    stringBuilder.append(resultRootEndElement);
                    Document doc = XercesHelper.string2Dom(stringBuilder.toString());
                    Iterator<Element> teaserIterator = XercesHelper.findNodes(doc,
                            "searchTeaserResult/teaserRef");
                    while (teaserIterator.hasNext()) {
                        Element element = teaserIterator.next();
                        String viewComponentIdValue = element.getAttribute("viewComponentId");
                        if (viewComponentIdValue != null && viewComponentIdValue.trim().length() > 0) {
                            if (intViewComponentId == (new Integer(viewComponentIdValue)).intValue()) {
                                teaserReferenced = true;
                                refTeaser.append(this.getPathForViewComponentId(
                                        xmlSearchValues[i].getViewComponentId().intValue()) + "\n");
                            }
                        }
                    }
                }
                if (teaserReferenced) {
                    teaserText = Messages.getString("comm.removevc.header.teaser", refTeaser.toString());
                }
            }
        } catch (Exception exception) {
            log.error(exception.getMessage(), exception);
        }
        String msgHeader = "";
        if (onlineState == Constants.ONLINE_STATUS_UNDEF || onlineState == Constants.ONLINE_STATUS_OFFLINE) {
            msgHeader = rb.getString("comm.removevc.header_offline");
        } else {
            msgHeader = rb.getString("comm.removevc.header_online");
        }

        String msgstr = msgHeader + units + refVcs + teaserText;

        int i = JOptionPane.showConfirmDialog(UIConstants.getMainFrame(), msgstr, rb.getString("dialog.title"),
                JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

        if (i == JOptionPane.YES_OPTION) {
            if (onlineState == Constants.ONLINE_STATUS_UNDEF
                    || onlineState == Constants.ONLINE_STATUS_OFFLINE) {
                getClientService().removeViewComponent(Integer.valueOf(intViewComponentId), true);
                /*
                 * } else { // nothing at the moment, the code for here is
                 * currently in PanTree actionViewComponentPerformed
                 */
            }
            retVal = true;
        }
    } catch (Exception exe) {
        log.error("Error removing vc", exe);
    }

    if (retVal) {
        try {
            checkOutPages.remove(new Integer(getViewComponent(intViewComponentId).getReference()));
        } catch (Exception exe) {
        }
        UIConstants.setStatusInfo(rb.getString("comm.removevc.statusinfo"));
    }
    return retVal;
}

From source file:de.bfs.radon.omsimulation.gui.OMPanelTesting.java

/**
 * Initialises the interface of the results panel.
 *//*  w w w .j  a  va 2  s.c  o  m*/
protected void initialize() {

    setLayout(null);
    isSimulated = false;

    lblExportChartTo = new JLabel("Export chart to ...");
    lblExportChartTo.setBounds(436, 479, 144, 14);
    lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblExportChartTo.setVisible(false);
    add(lblExportChartTo);

    btnCsv = new JButton("CSV");
    btnCsv.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String csv;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("csv")) {
                    csv = "";
                } else {
                    csv = ".csv";
                }
                String csvPath = file.getAbsolutePath() + csv;
                double[] selectedValues;
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                final int day = 24;
                File csvFile = new File(csvPath);
                try {
                    OMCampaign campaign;
                    if (isResult) {
                        campaign = getResultCampaign();
                    } else {
                        campaign = new OMCampaign(start, rooms, 0);
                    }
                    FileWriter logWriter = new FileWriter(csvFile);
                    BufferedWriter csvOutput = new BufferedWriter(logWriter);
                    csvOutput.write("\"ID\";\"Room\";\"Radon\"");
                    csvOutput.newLine();
                    selectedValues = campaign.getValueChain();
                    int x = 0;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[0].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[1].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[2].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[3].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[4].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[5].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[6].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                    csvOutput.close();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnCsv.setBounds(590, 475, 70, 23);
    btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnCsv.setVisible(false);
    add(btnCsv);

    btnPdf = new JButton("PDF");
    btnPdf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String pdf;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("pdf")) {
                    pdf = "";
                } else {
                    pdf = ".pdf";
                }
                String pdfPath = file.getAbsolutePath() + pdf;
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                OMCampaign campaign;
                try {
                    if (isResult) {
                        campaign = getResultCampaign();
                    } else {
                        campaign = new OMCampaign(start, rooms, 0);
                    }
                    JFreeChart chart = OMCharts.createCampaignChart(campaign, false);
                    String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId()
                            + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId()
                            + ", Start: " + start;
                    int height = (int) PageSize.A4.getWidth();
                    int width = (int) PageSize.A4.getHeight();
                    try {
                        OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title);
                        JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success",
                                JOptionPane.INFORMATION_MESSAGE);
                    } catch (IOException ioe) {
                        JOptionPane.showMessageDialog(null,
                                "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed",
                                JOptionPane.ERROR_MESSAGE);
                        ioe.printStackTrace();
                    }
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null, "Failed to create chart!\n" + ioe.getMessage(),
                            "Failed", JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnPdf.setBounds(670, 475, 70, 23);
    btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnPdf.setVisible(false);
    add(btnPdf);

    lblSelectProject = new JLabel("Select Project");
    lblSelectProject.setBounds(10, 65, 132, 14);
    lblSelectProject.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblSelectProject);

    lblSelectRooms = new JLabel("Select Rooms");
    lblSelectRooms.setBounds(10, 94, 132, 14);
    lblSelectRooms.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblSelectRooms);

    lblStartTime = new JLabel("Start Time");
    lblStartTime.setBounds(10, 123, 132, 14);
    lblStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblStartTime);

    lblWarning = new JLabel("Select 6 rooms and 1 cellar!");
    lblWarning.setForeground(Color.RED);
    lblWarning.setBounds(565, 123, 175, 14);
    lblWarning.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblWarning.setVisible(false);
    add(lblWarning);

    sliderStartTime = new JSlider();
    sliderStartTime.setMaximum(0);
    sliderStartTime.setBounds(152, 119, 285, 24);
    sliderStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(sliderStartTime);

    spnrStartTime = new JSpinner();
    spnrStartTime.setModel(new SpinnerNumberModel(0, 0, 0, 1));
    spnrStartTime.setBounds(447, 120, 108, 22);
    spnrStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(spnrStartTime);

    btnRefresh = new JButton("Load");
    btnRefresh.setBounds(616, 61, 124, 23);
    btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(btnRefresh);

    btnMaximize = new JButton("Fullscreen");
    btnMaximize.setBounds(10, 475, 124, 23);
    btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(btnMaximize);

    panelCampaign = new JPanel();
    panelCampaign.setBounds(10, 150, 730, 315);
    panelCampaign.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(panelCampaign);

    progressBar = new JProgressBar();
    progressBar.setBounds(10, 475, 730, 23);
    progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11));
    progressBar.setVisible(false);
    add(progressBar);

    lblOpenOmbfile = new JLabel("Open OMB-File");
    lblOpenOmbfile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblOpenOmbfile.setBounds(10, 36, 132, 14);
    add(lblOpenOmbfile);

    lblHelp = new JLabel("Select an OMB-Object file to manually simulate virtual campaigns.");
    lblHelp.setForeground(Color.GRAY);
    lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblHelp.setBounds(10, 10, 730, 14);
    add(lblHelp);

    txtOmbFile = new JTextField();
    txtOmbFile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    txtOmbFile.setColumns(10);
    txtOmbFile.setBounds(152, 33, 454, 20);
    add(txtOmbFile);

    btnBrowse = new JButton("Browse");
    btnBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnBrowse.setBounds(616, 32, 124, 23);
    add(btnBrowse);

    comboBoxRoom1 = new JComboBox<OMRoom>();
    comboBoxRoom1.setBounds(152, 90, 75, 22);
    comboBoxRoom1.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom1);

    comboBoxRoom2 = new JComboBox<OMRoom>();
    comboBoxRoom2.setBounds(237, 90, 75, 22);
    comboBoxRoom2.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom2);

    comboBoxRoom3 = new JComboBox<OMRoom>();
    comboBoxRoom3.setBounds(323, 90, 75, 22);
    comboBoxRoom3.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom3);

    comboBoxRoom4 = new JComboBox<OMRoom>();
    comboBoxRoom4.setBounds(408, 90, 75, 22);
    comboBoxRoom4.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom4);

    comboBoxRoom5 = new JComboBox<OMRoom>();
    comboBoxRoom5.setBounds(494, 90, 75, 22);
    comboBoxRoom5.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom5);

    comboBoxRoom6 = new JComboBox<OMRoom>();
    comboBoxRoom6.setBounds(579, 90, 75, 22);
    comboBoxRoom6.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom6);

    comboBoxRoom7 = new JComboBox<OMRoom>();
    comboBoxRoom7.setBounds(665, 90, 75, 22);
    comboBoxRoom7.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom7);

    comboBoxProjects = new JComboBox<OMBuilding>();
    comboBoxProjects.setBounds(152, 61, 454, 22);
    comboBoxProjects.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxProjects);

    comboBoxRoom1.addActionListener(this);
    comboBoxRoom1.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom2.addActionListener(this);
    comboBoxRoom2.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom3.addActionListener(this);
    comboBoxRoom3.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom4.addActionListener(this);
    comboBoxRoom4.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom5.addActionListener(this);
    comboBoxRoom5.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom6.addActionListener(this);
    comboBoxRoom6.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom7.addActionListener(this);
    comboBoxRoom7.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });

    sliderStartTime.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (comboBoxProjects.isEnabled() || isResult) {
                if (comboBoxProjects.getSelectedItem() != null) {
                    spnrStartTime.setValue((int) sliderStartTime.getValue());
                    updateChart();
                }
            }
        }
    });
    spnrStartTime.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if (comboBoxProjects.isEnabled() || isResult) {
                if (comboBoxProjects.getSelectedItem() != null) {
                    sliderStartTime.setValue((Integer) spnrStartTime.getValue());
                    updateChart();
                }
            }
        }
    });
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("")
                    && !txtOmbFile.getText().equals(" ")) {
                txtOmbFile.setBackground(Color.WHITE);
                String ombPath = txtOmbFile.getText();
                String omb;
                String[] tmpFileName = ombPath.split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(ombPath + omb);
                setOmbFile(ombPath + omb);
                File ombFile = new File(ombPath + omb);
                if (ombFile.exists()) {
                    txtOmbFile.setBackground(Color.WHITE);
                    btnRefresh.setEnabled(false);
                    comboBoxProjects.setEnabled(false);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    progressBar.setVisible(true);
                    btnPdf.setVisible(false);
                    btnCsv.setVisible(false);
                    btnMaximize.setVisible(false);
                    lblExportChartTo.setVisible(false);
                    progressBar.setIndeterminate(true);
                    progressBar.setStringPainted(true);
                    refreshTask = new Refresh();
                    refreshTask.execute();
                } else {
                    txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                    JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    });
    btnMaximize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId()
                        + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId()
                        + ", Start: " + start;
                OMCampaign campaign;
                if (isResult) {
                    campaign = getResultCampaign();
                } else {
                    campaign = new OMCampaign(start, rooms, 0);
                }
                JPanel campaignChart = createCampaignPanel(campaign, false, true);
                JFrame chartFrame = new JFrame();
                chartFrame.getContentPane().add(campaignChart);
                chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight());
                chartFrame.setTitle(title);
                chartFrame.setResizable(true);
                chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                chartFrame.setVisible(true);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    });
    txtOmbFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            setOmbFile(txtOmbFile.getText());
        }
    });
    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb"));
            fileDialog.showOpenDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String omb;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(file.getAbsolutePath() + omb);
                setOmbFile(file.getAbsolutePath() + omb);
            }
        }
    });
}

From source file:net.pms.newgui.NavigationShareTab.java

private PanelBuilder initSharedFoldersGuiComponents(CellConstraints cc) {
    // Apply the orientation for the locale
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());
    String colSpec = FormLayoutUtil.getColSpec(SHARED_FOLDER_COL_SPEC, orientation);

    FormLayout layoutFolders = new FormLayout(colSpec, SHARED_FOLDER_ROW_SPEC);
    PanelBuilder builderFolder = new PanelBuilder(layoutFolders);
    builderFolder.opaque(true);//ww  w  .j av  a  2  s  .com

    JComponent cmp = builderFolder.addSeparator(Messages.getString("FoldTab.7"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 7), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    folderTableModel = new SharedFoldersTableModel();
    sharedFolders = new JTable(folderTableModel);

    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem menuItemMarkPlayed = new JMenuItem(Messages.getString("FoldTab.75"));
    JMenuItem menuItemMarkUnplayed = new JMenuItem(Messages.getString("FoldTab.76"));

    menuItemMarkPlayed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0);
            TableFilesStatus.setDirectoryFullyPlayed(path, true);
        }
    });

    menuItemMarkUnplayed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0);
            TableFilesStatus.setDirectoryFullyPlayed(path, false);
        }
    });

    popupMenu.add(menuItemMarkPlayed);
    popupMenu.add(menuItemMarkUnplayed);

    sharedFolders.setComponentPopupMenu(popupMenu);

    /* An attempt to set the correct row height adjusted for font scaling.
     * It sets all rows based on the font size of cell (0, 0). The + 4 is
     * to allow 2 pixels above and below the text. */
    DefaultTableCellRenderer cellRenderer = (DefaultTableCellRenderer) sharedFolders.getCellRenderer(0, 0);
    FontMetrics metrics = cellRenderer.getFontMetrics(cellRenderer.getFont());
    sharedFolders.setRowHeight(metrics.getLeading() + metrics.getMaxAscent() + metrics.getMaxDescent() + 4);
    sharedFolders.setIntercellSpacing(new Dimension(8, 2));

    final JPanel tmpsharedPanel = sharedPanel;

    addButton.setToolTipText(Messages.getString("FoldTab.9"));
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser;
            try {
                chooser = new JFileChooser();
            } catch (Exception ee) {
                chooser = new JFileChooser(new RestrictedFileSystemView());
            }
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog((Component) e.getSource());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                int firstSelectedRow = sharedFolders.getSelectedRow();
                if (firstSelectedRow >= 0) {
                    ((SharedFoldersTableModel) sharedFolders.getModel()).insertRow(firstSelectedRow,
                            new Object[] { chooser.getSelectedFile().getAbsolutePath(), true });
                } else {
                    ((SharedFoldersTableModel) sharedFolders.getModel())
                            .addRow(new Object[] { chooser.getSelectedFile().getAbsolutePath(), true });
                }
            }
        }
    });
    builderFolder.add(addButton, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation));

    removeButton.setToolTipText(Messages.getString("FoldTab.36"));
    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = sharedFolders.getSelectedRows();
            if (rows.length > 0) {
                if (rows.length > 1) {
                    if (JOptionPane.showConfirmDialog(tmpsharedPanel,
                            String.format(Messages.getString("SharedFolders.ConfirmRemove"), rows.length),
                            Messages.getString("Dialog.Confirm"), JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                        return;
                    }
                }
                for (int i = rows.length - 1; i >= 0; i--) {
                    PMS.get().getDatabase().removeMediaEntriesInFolder(
                            (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0));
                    ((SharedFoldersTableModel) sharedFolders.getModel()).removeRow(rows[i]);
                }
            }
        }
    });
    builderFolder.add(removeButton, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    arrowDownButton.setToolTipText(Messages.getString("SharedFolders.ArrowDown"));
    arrowDownButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < sharedFolders.getRowCount() - 1; i++) {
                if (sharedFolders.isRowSelected(i)) {
                    Object value1 = sharedFolders.getValueAt(i, 0);
                    boolean value2 = (boolean) sharedFolders.getValueAt(i, 1);

                    sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 0), i, 0);
                    sharedFolders.setValueAt(value1, i + 1, 0);
                    sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 1), i, 1);
                    sharedFolders.setValueAt(value2, i + 1, 1);
                    sharedFolders.changeSelection(i + 1, 1, false, false);

                    break;
                }
            }
        }
    });
    builderFolder.add(arrowDownButton, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation));

    arrowUpButton.setToolTipText(Messages.getString("SharedFolders.ArrowUp"));
    arrowUpButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 1; i < sharedFolders.getRowCount(); i++) {
                if (sharedFolders.isRowSelected(i)) {
                    Object value1 = sharedFolders.getValueAt(i, 0);
                    boolean value2 = (boolean) sharedFolders.getValueAt(i, 1);

                    sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 0), i, 0);
                    sharedFolders.setValueAt(value1, i - 1, 0);
                    sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 1), i, 1);
                    sharedFolders.setValueAt(value2, i - 1, 1);
                    sharedFolders.changeSelection(i - 1, 1, false, false);

                    break;

                }
            }
        }
    });
    builderFolder.add(arrowUpButton, FormLayoutUtil.flip(cc.xy(5, 3), colSpec, orientation));

    scanButton.setToolTipText(Messages.getString("FoldTab.2"));
    scanBusyIcon.start();
    scanBusyDisabledIcon.start();
    scanButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (configuration.getUseCache()) {
                DLNAMediaDatabase database = PMS.get().getDatabase();

                if (database != null) {
                    if (database.isScanLibraryRunning()) {
                        int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("FoldTab.10"),
                                Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION);
                        if (option == JOptionPane.YES_OPTION) {
                            database.stopScanLibrary();
                            looksFrame.setStatusLine(Messages.getString("FoldTab.41"));
                            scanButton.setEnabled(false);
                            scanButton.setToolTipText(Messages.getString("FoldTab.41"));
                        }
                    } else {
                        database.scanLibrary();
                        scanButton.setIcon(scanBusyIcon);
                        scanButton.setRolloverIcon(scanBusyRolloverIcon);
                        scanButton.setPressedIcon(scanBusyPressedIcon);
                        scanButton.setDisabledIcon(scanBusyDisabledIcon);
                        scanButton.setToolTipText(Messages.getString("FoldTab.40"));
                    }
                }
            }
        }
    });

    /*
     * Hide the scan button in basic mode since it's better to let it be done in
     * realtime.
     */
    if (!configuration.isHideAdvancedOptions()) {
        builderFolder.add(scanButton, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation));
    }

    scanButton.setEnabled(configuration.getUseCache());

    isScanSharedFoldersOnStartup = new JCheckBox(Messages.getString("NetworkTab.StartupScan"),
            configuration.isScanSharedFoldersOnStartup());
    isScanSharedFoldersOnStartup.setToolTipText(Messages.getString("NetworkTab.StartupScanTooltip"));
    isScanSharedFoldersOnStartup.setContentAreaFilled(false);
    isScanSharedFoldersOnStartup.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setScanSharedFoldersOnStartup((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    builderFolder.add(isScanSharedFoldersOnStartup, FormLayoutUtil.flip(cc.xy(7, 3), colSpec, orientation));

    updateSharedFolders();

    JScrollPane pane = new JScrollPane(sharedFolders);
    Dimension d = sharedFolders.getPreferredSize();
    pane.setPreferredSize(new Dimension(d.width, sharedFolders.getRowHeight() * 2));
    builderFolder.add(pane, FormLayoutUtil.flip(cc.xyw(1, 5, 7, CellConstraints.DEFAULT, CellConstraints.FILL),
            colSpec, orientation));

    return builderFolder;
}

From source file:client.ui.FilePane.java

private void downloadFileButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_downloadFileButtonActionPerformed
    CloudFile selectedFile = getSelectedFile();
    if (selectedFile == null) {
        JOptionPane.showMessageDialog(m_MainFrame, "", "",
                JOptionPane.WARNING_MESSAGE);
        return;/*from ww  w .  jav a 2 s.  com*/
    }
    DownloadFileResult result;
    try {
        result = m_Business.downloadFile(selectedFile);
        byte[] content = result.getContent();
        DownloadFileResult.DownloadFileStatus status = result.getResult();
        switch (status) {
        case OK:
            DownloadFileWindow downloadWindow = new DownloadFileWindow(m_MainFrame, selectedFile, content);
            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);
            break;
        default:
            JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);
            break;
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "", "", JOptionPane.ERROR_MESSAGE);
    }
    //fileInfoTable.clearSelection();
}