Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

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

Prototype

int ERROR_MESSAGE

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

Click Source Link

Document

Used for error messages.

Usage

From source file:com.employee.scheduler.nurserostering.swingui.NurseRosteringPanel.java

private void advancePlanningWindowStart() {
    logger.info("Advancing planningWindowStart.");
    if (solutionBusiness.isSolving()) {
        JOptionPane.showMessageDialog(this.getTopLevelAncestor(),
                "The GUI does not support this action yet during solving.\nOptaPlanner itself does support it.\n"
                        + "\nTerminate solving first and try again.",
                "Unsupported in GUI", JOptionPane.ERROR_MESSAGE);
        return;//from   w  ww  . ja  v  a2s  . c o m
    }
    solutionBusiness.doProblemFactChange(new ProblemFactChange() {
        public void doChange(ScoreDirector scoreDirector) {
            NurseRoster nurseRoster = (NurseRoster) scoreDirector.getWorkingSolution();
            NurseRosterParametrization nurseRosterParametrization = nurseRoster.getNurseRosterParametrization();
            List<ShiftDate> shiftDateList = nurseRoster.getShiftDateList();
            ShiftDate planningWindowStart = nurseRosterParametrization.getPlanningWindowStart();
            int windowStartIndex = shiftDateList.indexOf(planningWindowStart);
            if (windowStartIndex < 0) {
                throw new IllegalStateException("The planningWindowStart (" + planningWindowStart
                        + ") must be in the shiftDateList (" + shiftDateList + ").");
            }
            ShiftDate oldLastShiftDate = shiftDateList.get(shiftDateList.size() - 1);
            ShiftDate newShiftDate = new ShiftDate();
            newShiftDate.setId(oldLastShiftDate.getId() + 1L);
            newShiftDate.setDayIndex(oldLastShiftDate.getDayIndex() + 1);
            newShiftDate.setDateString(oldLastShiftDate.determineNextDateString());
            newShiftDate.setDayOfWeek(oldLastShiftDate.getDayOfWeek().determineNextDayOfWeek());
            List<Shift> refShiftList = planningWindowStart.getShiftList();
            List<Shift> newShiftList = new ArrayList<Shift>(refShiftList.size());
            newShiftDate.setShiftList(newShiftList);
            nurseRoster.getShiftDateList().add(newShiftDate);
            scoreDirector.afterProblemFactAdded(newShiftDate);
            Shift oldLastShift = nurseRoster.getShiftList().get(nurseRoster.getShiftList().size() - 1);
            long shiftId = oldLastShift.getId() + 1L;
            int shiftIndex = oldLastShift.getIndex() + 1;
            long shiftAssignmentId = nurseRoster.getShiftAssignmentList()
                    .get(nurseRoster.getShiftAssignmentList().size() - 1).getId() + 1L;
            for (Shift refShift : refShiftList) {
                Shift newShift = new Shift();
                newShift.setId(shiftId);
                shiftId++;
                newShift.setShiftDate(newShiftDate);
                newShift.setShiftType(refShift.getShiftType());
                newShift.setIndex(shiftIndex);
                shiftIndex++;
                newShift.setRequiredEmployeeSize(refShift.getRequiredEmployeeSize());
                newShiftList.add(newShift);
                nurseRoster.getShiftList().add(newShift);
                scoreDirector.afterProblemFactAdded(newShift);
                for (int indexInShift = 0; indexInShift < newShift.getRequiredEmployeeSize(); indexInShift++) {
                    ShiftAssignment newShiftAssignment = new ShiftAssignment();
                    newShiftAssignment.setId(shiftAssignmentId);
                    shiftAssignmentId++;
                    newShiftAssignment.setShift(newShift);
                    newShiftAssignment.setIndexInShift(indexInShift);
                    nurseRoster.getShiftAssignmentList().add(newShiftAssignment);
                    scoreDirector.afterEntityAdded(newShiftAssignment);
                }
            }
            windowStartIndex++;
            ShiftDate newPlanningWindowStart = shiftDateList.get(windowStartIndex);
            nurseRosterParametrization.setPlanningWindowStart(newPlanningWindowStart);
            nurseRosterParametrization.setLastShiftDate(newShiftDate);
            scoreDirector.afterProblemFactChanged(nurseRosterParametrization);
        }
    });
    resetPanel(solutionBusiness.getSolution());
    validate();
}

From source file:dataviewer.DataViewer.java

/**
 * Creates new form DataViewer//  ww w .ja va2 s .  co m
 */
public DataViewer() {
    try {
        for (Enum ee : THREAD.values()) {
            t[ee.ordinal()] = new Thread();
        }
        initComponents();
        DropTarget dropTarget = new DropTarget(tr_files, new DropTargetListenerImpl());
        TreeSelectionListener treeSelectionListener = new TreeSelectionListener() {

            @Override
            public void valueChanged(TreeSelectionEvent e) {
                javax.swing.JTree tree = (javax.swing.JTree) e.getSource();
                TreePath path = tree.getSelectionPath();
                Object[] pnode = (Object[]) path.getPath();
                String name = pnode[pnode.length - 1].toString();
                String ex = getExtension(name);
                if (ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) {
                    selected_file = name;
                } else {
                    selected_file = "";
                }
            }
        };
        tr_files.addTreeSelectionListener(treeSelectionListener);

        tr_files.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent evt) {
                if (evt.getClickCount() >= 2) {
                    if (!"".equals(selected_file)) {
                        //count_data();
                        read_data();
                    } else {
                        TreePath path = tr_files.getSelectionPath();
                        if (path.getLastPathComponent().toString().equals(cur_path)) {
                            cur_path = (new File(cur_path)).getParent();
                        } else {
                            cur_path = cur_path + File.separator + path.getLastPathComponent().toString();
                        }
                        fill_tree();
                    }
                }
            }
        });

        tr_files.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                    cur_path = (new File(cur_path)).getParent();
                    fill_tree();
                } else if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                    if (!"".equals(selected_file)) {
                        //count_data();
                        read_data();
                    } else {
                        TreePath path = tr_files.getSelectionPath();
                        if (path.getLastPathComponent().toString().equals(cur_path)) {
                            cur_path = (new File(cur_path)).getParent();
                        } else {
                            cur_path = cur_path + File.separator + path.getLastPathComponent().toString();
                        }
                        fill_tree();
                    }
                } else if (evt.getKeyCode() == KeyEvent.VK_DELETE) {

                    if (!"".equals(selected_file)) {
                        String name = cur_path + File.separator + selected_file;
                        if ((new File(name)).isFile()) {
                            int dialogResult = JOptionPane.showConfirmDialog(null,
                                    "Selected file [" + selected_file
                                            + "] will be removed and not recoverable.",
                                    "Are you sure?", JOptionPane.YES_NO_OPTION);
                            if (dialogResult == JOptionPane.YES_OPTION) {
                                (new File(name)).delete();
                                fill_tree();
                            }
                        }

                    } else {
                        JOptionPane.showMessageDialog(null,
                                "For safety concern, removing folder is not supported.", "Information",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        });

        tr_files.setCellRenderer(new MyTreeCellRenderer());
        p_count.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

        //tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrl1, "tab_read");
        //tp_menu.getActionMap().put("tab_read", (Action) new ActionListenerImpl());
        //tp_menu.setMnemonicAt(0, KeyEvent.VK_1);
        //tp_menu.setMnemonicAt(1, KeyEvent.VK_2);
        /*InputMap inputMap = tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
         ActionMap actionMap = tp_menu.getActionMap();
                
         KeyStroke ctrl1 = KeyStroke.getKeyStroke("ctrl 1");
         inputMap.put(ctrl1, "tab_read");
         actionMap.put("tab_read", new AbstractAction() {
                
         @Override
         public void actionPerformed(ActionEvent arg0) {
         tp_menu.setSelectedIndex(0);
         }
         });
                
         KeyStroke ctrl2 = KeyStroke.getKeyStroke("ctrl 2");
         inputMap.put(ctrl2, "tab_analyze");
         actionMap.put("tab_analyze", new AbstractAction() {
                
         @Override
         public void actionPerformed(ActionEvent arg0) {
         tp_menu.setSelectedIndex(1);
         }
         });*/
        config();
    } catch (Exception e) {
        txt_count.setText(e.getMessage());
    }
}

From source file:org.pgptool.gui.app.EntryPoint.java

public static void reportExceptionToUser(String errorMessageCode, Throwable cause, Object... messageArgs) {
    GenericException exc = new GenericException(errorMessageCode, cause, messageArgs);
    String versionInfo = NewVersionCheckerGitHubImpl.getVerisonsInfo();
    String msgs = ConsoleExceptionUtils.getAllMessages(exc);
    msgs += "\r\n" + versionInfo;
    UiUtils.messageBox(null, msgs, Messages.get("term.error") + versionInfo, JOptionPane.ERROR_MESSAGE);
}

From source file:au.org.ala.delta.intkey.ui.AddOrEditDataIndexItemDialog.java

@Action
public void AddOrEditDataIndexItemDialog_OK() {
    String description = _txtFldDescription.getText().trim();
    String filePath = _txtFldFilePath.getText().trim();

    if (StringUtils.isEmpty(description) || StringUtils.isEmpty(filePath)) {
        JOptionPane.showMessageDialog(this, missingDataMessage, "", JOptionPane.ERROR_MESSAGE);
    } else {/*w  w w . j  a v a2  s. c  om*/
        _descriptionPathPair = new Pair<String, String>(description, filePath);
        this.setVisible(false);
    }
}

From source file:cz.moz.ctmanager.main.MainAppFrame.java

private void removeContactButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeContactButtonActionPerformed
    int selectedRow = contactTable.getSelectedRow();
    if (selectedRow == -1) {
        JOptionPane.showMessageDialog(this, "Nothing Selected", "Error Message", JOptionPane.ERROR_MESSAGE);
    } else {/*  w ww  .  j  a  va 2 s  . c o  m*/
        Object[] options = { "Are you Sure?" };
        int choice = JOptionPane.showConfirmDialog(this, options, "Are you Sure", 2);
        if (choice == 0) {
            DefaultTableModel newTableModel = (DefaultTableModel) contactTable.getModel();
            int selectedContactID = (int) contactTable.getValueAt(contactTable.getSelectedRow(), 0);
            newTableModel.removeRow(selectedRow);
            emailsDao.removeAll(selectedContactID);
            phonesDao.removeAll(selectedContactID);
            contactsDao.removeContact(selectedContactID);
        }
    }

}

From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java

private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException {
    SaveSession session;/*from w w w  . j a  va  2 s  .com*/
    frame.block();
    try {
        SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs)
                .withEncoding(encoding);
        BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(FileSaveSession::new);
        if (selectedOnly) {
            session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(),
                    panel.getSelectedEntries(), prefs);
        } else {
            session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs);

        }
        panel.registerUndoableChanges(session);

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

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

    } finally {
        frame.unblock();
    }

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

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

    }

    try {
        if (commit) {
            session.commit(file.toPath());
            panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); // Make sure to remember which encoding we used.
        } else {
            session.cancel();
        }
    } catch (SaveException e) {
        int ans = JOptionPane.showConfirmDialog(null,
                Localization.lang("Save failed during backup creation") + ". "
                        + Localization.lang("Save without backup?"),
                Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION);
        if (ans == JOptionPane.YES_OPTION) {
            session.setUseBackup(false);
            session.commit(file.toPath());
            panel.getBibDatabaseContext().getMetaData().setEncoding(encoding);
        } else {
            commit = false;
        }
    }

    return commit;
}

From source file:juicebox.windowui.QCDialog.java

public QCDialog(MainWindow mainWindow, HiC hic, String title) {
    super(mainWindow);

    Dataset dataset = hic.getDataset();/*from   w ww.  j a  v a  2 s.c o m*/

    String text = dataset.getStatistics();
    String textDescription = null;
    String textStatistics = null;
    String graphs = dataset.getGraphs();
    JTextPane description = null;
    JTabbedPane tabbedPane = new JTabbedPane();
    HTMLEditorKit kit = new HTMLEditorKit();

    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("table { border-collapse: collapse;}");
    styleSheet.addRule("body {font-family: Sans-Serif; font-size: 12;}");
    styleSheet.addRule("td { padding: 2px; }");
    styleSheet.addRule(
            "th {border-bottom: 1px solid #000; text-align: left; background-color: #D8D8D8; font-weight: normal;}");

    if (text != null) {
        int split = text.indexOf("</table>") + 8;
        textDescription = text.substring(0, split);
        textStatistics = text.substring(split);
        description = new JTextPane();
        description.setEditable(false);
        description.setContentType("text/html");
        description.setEditorKit(kit);
        description.setText(textDescription);
        tabbedPane.addTab("About Library", description);

        JTextPane textPane = new JTextPane();
        textPane.setEditable(false);
        textPane.setContentType("text/html");

        textPane.setEditorKit(kit);
        textPane.setText(textStatistics);
        JScrollPane pane = new JScrollPane(textPane);
        tabbedPane.addTab("Statistics", pane);
    }
    boolean success = true;
    if (graphs != null) {

        long[] A = new long[2000];
        long sumA = 0;
        long[] mapq1 = new long[201];
        long[] mapq2 = new long[201];
        long[] mapq3 = new long[201];
        long[] intraCount = new long[100];
        final XYSeries intra = new XYSeries("Intra Count");
        final XYSeries leftRead = new XYSeries("Left");
        final XYSeries rightRead = new XYSeries("Right");
        final XYSeries innerRead = new XYSeries("Inner");
        final XYSeries outerRead = new XYSeries("Outer");
        final XYSeries allMapq = new XYSeries("All MapQ");
        final XYSeries intraMapq = new XYSeries("Intra MapQ");
        final XYSeries interMapq = new XYSeries("Inter MapQ");

        Scanner scanner = new Scanner(graphs);
        try {
            while (!scanner.next().equals("["))
                ;

            for (int idx = 0; idx < 2000; idx++) {
                A[idx] = scanner.nextLong();
                sumA += A[idx];
            }

            while (!scanner.next().equals("["))
                ;
            for (int idx = 0; idx < 201; idx++) {
                mapq1[idx] = scanner.nextInt();
                mapq2[idx] = scanner.nextInt();
                mapq3[idx] = scanner.nextInt();

            }

            for (int idx = 199; idx >= 0; idx--) {
                mapq1[idx] = mapq1[idx] + mapq1[idx + 1];
                mapq2[idx] = mapq2[idx] + mapq2[idx + 1];
                mapq3[idx] = mapq3[idx] + mapq3[idx + 1];
                allMapq.add(idx, mapq1[idx]);
                intraMapq.add(idx, mapq2[idx]);
                interMapq.add(idx, mapq3[idx]);
            }
            while (!scanner.next().equals("["))
                ;
            for (int idx = 0; idx < 100; idx++) {
                int tmp = scanner.nextInt();
                if (tmp != 0)
                    innerRead.add(logXAxis[idx], tmp);
                intraCount[idx] = tmp;
                tmp = scanner.nextInt();
                if (tmp != 0)
                    outerRead.add(logXAxis[idx], tmp);
                intraCount[idx] += tmp;
                tmp = scanner.nextInt();
                if (tmp != 0)
                    rightRead.add(logXAxis[idx], tmp);
                intraCount[idx] += tmp;
                tmp = scanner.nextInt();
                if (tmp != 0)
                    leftRead.add(logXAxis[idx], tmp);
                intraCount[idx] += tmp;
                if (idx > 0)
                    intraCount[idx] += intraCount[idx - 1];
                if (intraCount[idx] != 0)
                    intra.add(logXAxis[idx], intraCount[idx]);
            }
        } catch (NoSuchElementException exception) {
            JOptionPane.showMessageDialog(getParent(), "Graphing file improperly formatted", "Error",
                    JOptionPane.ERROR_MESSAGE);
            success = false;
        }

        if (success) {
            final XYSeriesCollection readTypeCollection = new XYSeriesCollection();
            readTypeCollection.addSeries(innerRead);
            readTypeCollection.addSeries(outerRead);
            readTypeCollection.addSeries(leftRead);
            readTypeCollection.addSeries(rightRead);

            final JFreeChart readTypeChart = ChartFactory.createXYLineChart("Types of reads vs distance", // chart title
                    "Distance (log)", // domain axis label
                    "Binned Reads (log)", // range axis label
                    readTypeCollection, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, false);

            final XYPlot readTypePlot = readTypeChart.getXYPlot();

            readTypePlot.setDomainAxis(new LogarithmicAxis("Distance (log)"));
            readTypePlot.setRangeAxis(new LogarithmicAxis("Binned Reads (log)"));
            readTypePlot.setBackgroundPaint(Color.white);
            readTypePlot.setRangeGridlinePaint(Color.lightGray);
            readTypePlot.setDomainGridlinePaint(Color.lightGray);
            readTypeChart.setBackgroundPaint(Color.white);
            readTypePlot.setOutlinePaint(Color.black);
            final ChartPanel chartPanel = new ChartPanel(readTypeChart);

            final XYSeriesCollection reCollection = new XYSeriesCollection();
            final XYSeries reDistance = new XYSeries("Distance");

            for (int i = 0; i < A.length; i++) {
                if (A[i] != 0)
                    reDistance.add(i, A[i] / (float) sumA);
            }
            reCollection.addSeries(reDistance);

            final JFreeChart reChart = ChartFactory.createXYLineChart(
                    "Distance from closest restriction enzyme site", // chart title
                    "Distance (bp)", // domain axis label
                    "Fraction of Reads (log)", // range axis label
                    reCollection, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, false);

            final XYPlot rePlot = reChart.getXYPlot();
            rePlot.setDomainAxis(new NumberAxis("Distance (bp)"));
            rePlot.setRangeAxis(new LogarithmicAxis("Fraction of Reads (log)"));
            rePlot.setBackgroundPaint(Color.white);
            rePlot.setRangeGridlinePaint(Color.lightGray);
            rePlot.setDomainGridlinePaint(Color.lightGray);
            reChart.setBackgroundPaint(Color.white);
            rePlot.setOutlinePaint(Color.black);
            final ChartPanel chartPanel2 = new ChartPanel(reChart);

            final XYSeriesCollection intraCollection = new XYSeriesCollection();

            intraCollection.addSeries(intra);

            final JFreeChart intraChart = ChartFactory.createXYLineChart("Intra reads vs distance", // chart title
                    "Distance (log)", // domain axis label
                    "Cumulative Sum of Binned Reads (log)", // range axis label
                    intraCollection, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, false);

            final XYPlot intraPlot = intraChart.getXYPlot();
            intraPlot.setDomainAxis(new LogarithmicAxis("Distance (log)"));
            intraPlot.setRangeAxis(new NumberAxis("Cumulative Sum of Binned Reads (log)"));
            intraPlot.setBackgroundPaint(Color.white);
            intraPlot.setRangeGridlinePaint(Color.lightGray);
            intraPlot.setDomainGridlinePaint(Color.lightGray);
            intraChart.setBackgroundPaint(Color.white);
            intraPlot.setOutlinePaint(Color.black);
            final ChartPanel chartPanel3 = new ChartPanel(intraChart);

            final XYSeriesCollection mapqCollection = new XYSeriesCollection();
            mapqCollection.addSeries(allMapq);
            mapqCollection.addSeries(intraMapq);
            mapqCollection.addSeries(interMapq);

            final JFreeChart mapqChart = ChartFactory.createXYLineChart("MapQ Threshold Count", // chart title
                    "MapQ threshold", // domain axis label
                    "Count", // range axis label
                    mapqCollection, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // include tooltips
                    false);

            final XYPlot mapqPlot = mapqChart.getXYPlot();
            mapqPlot.setBackgroundPaint(Color.white);
            mapqPlot.setRangeGridlinePaint(Color.lightGray);
            mapqPlot.setDomainGridlinePaint(Color.lightGray);
            mapqChart.setBackgroundPaint(Color.white);
            mapqPlot.setOutlinePaint(Color.black);
            final ChartPanel chartPanel4 = new ChartPanel(mapqChart);

            tabbedPane.addTab("Pair Type", chartPanel);
            tabbedPane.addTab("Restriction", chartPanel2);
            tabbedPane.addTab("Intra vs Distance", chartPanel3);
            tabbedPane.addTab("MapQ", chartPanel4);
        }
    }

    final ExpectedValueFunction df = hic.getDataset().getExpectedValues(hic.getZoom(),
            hic.getNormalizationType());
    if (df != null) {
        double[] expected = df.getExpectedValues();
        final XYSeriesCollection collection = new XYSeriesCollection();
        final XYSeries expectedValues = new XYSeries("Expected");
        for (int i = 0; i < expected.length; i++) {
            if (expected[i] > 0)
                expectedValues.add(i + 1, expected[i]);
        }
        collection.addSeries(expectedValues);
        String title1 = "Expected at " + hic.getZoom() + " norm " + hic.getNormalizationType();
        final JFreeChart readTypeChart = ChartFactory.createXYLineChart(title1, // chart title
                "Distance between reads (log)", // domain axis label
                "Genome-wide expected (log)", // range axis label
                collection, // data
                PlotOrientation.VERTICAL, false, // include legend
                true, false);
        final XYPlot readTypePlot = readTypeChart.getXYPlot();

        readTypePlot.setDomainAxis(new LogarithmicAxis("Distance between reads (log)"));
        readTypePlot.setRangeAxis(new LogarithmicAxis("Genome-wide expected (log)"));
        readTypePlot.setBackgroundPaint(Color.white);
        readTypePlot.setRangeGridlinePaint(Color.lightGray);
        readTypePlot.setDomainGridlinePaint(Color.lightGray);
        readTypeChart.setBackgroundPaint(Color.white);
        readTypePlot.setOutlinePaint(Color.black);
        final ChartPanel chartPanel5 = new ChartPanel(readTypeChart);

        tabbedPane.addTab("Expected", chartPanel5);
    }

    if (text == null && graphs == null) {
        JOptionPane.showMessageDialog(this, "Sorry, no metrics are available for this dataset", "Error",
                JOptionPane.ERROR_MESSAGE);
        setVisible(false);
        dispose();

    } else {
        getContentPane().add(tabbedPane);
        pack();
        setModal(false);
        setLocation(100, 100);
        setTitle(title);
        setVisible(true);
    }
}

From source file:net.sf.jabref.gui.openoffice.OpenOfficePanel.java

private void initPanel() {

    connect.addActionListener(e -> connect(true));
    manualConnect.addActionListener(e -> connect(false));

    selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on"));
    selectDocument.addActionListener(e -> {

        try {/*w w w  .  j a va  2 s .  c  om*/
            ooBase.selectDocument();
            frame.output(Localization.lang("Connected to document") + ": "
                    + ooBase.getCurrentDocumentTitle().orElse(""));
        } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException
                | NoSuchElementException | NoDocumentException ex) {
            JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"),
                    JOptionPane.ERROR_MESSAGE);
            LOGGER.warn("Problem connecting", ex);
        }

    });

    setStyleFile.addActionListener(event -> {

        if (styleDialog == null) {
            styleDialog = new StyleSelectDialog(frame, preferences, loader);
        }
        styleDialog.setVisible(true);
        styleDialog.getStyle().ifPresent(selectedStyle -> {
            style = selectedStyle;
            try {
                style.ensureUpToDate();
            } catch (IOException e) {
                LOGGER.warn("Unable to reload style file '" + style.getPath() + "'", e);
            }
            frame.setStatus(Localization.lang("Current style is '%0'", style.getName()));
        });

    });

    pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis"));
    pushEntries.addActionListener(e -> pushEntries(true, true, false));
    pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation"));
    pushEntriesInt.addActionListener(e -> pushEntries(false, true, false));
    pushEntriesEmpty.setToolTipText(
            Localization.lang("Insert a citation without text (the entry will appear in the reference list)"));
    pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false));
    pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information"));
    pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true));

    update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date"));
    Action updateAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (style == null) {
                    style = loader.getUsedStyle();
                } else {
                    style.ensureUpToDate();
                }

                ooBase.updateSortedReferenceMarks();

                List<BibDatabase> databases = getBaseList();
                List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style);
                ooBase.rebuildBibTextSection(databases, style);
                if (!unresolvedKeys.isEmpty()) {
                    JOptionPane.showMessageDialog(frame, Localization.lang(
                            "Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current database.",
                            unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"),
                            JOptionPane.ERROR_MESSAGE);
                }
            } catch (UndefinedCharacterFormatException ex) {
                reportUndefinedCharacterFormat(ex);
            } catch (UndefinedParagraphFormatException ex) {
                reportUndefinedParagraphFormat(ex);
            } catch (ConnectionLostException ex) {
                showConnectionLostErrorMessage();
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(frame,
                        Localization.lang(
                                "You must select either a valid style file, or use one of the default styles."),
                        Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE);
                LOGGER.warn("Problem with style file", ex);
            } catch (BibEntryNotFoundException ex) {
                JOptionPane.showMessageDialog(frame, Localization.lang(
                        "Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current database.",
                        ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"),
                        JOptionPane.ERROR_MESSAGE);
                LOGGER.debug("BibEntry not found", ex);
            } catch (Exception ex) {
                LOGGER.warn("Could not update bibliography", ex);
            }
        }
    };
    update.addActionListener(updateAction);

    merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only"));
    merge.addActionListener(e -> {
        try {
            ooBase.combineCiteMarkers(getBaseList(), style);
        } catch (UndefinedCharacterFormatException ex) {
            reportUndefinedCharacterFormat(ex);
        } catch (Exception ex) {
            LOGGER.warn("Problem combining cite markers", ex);
        }

    });
    settingsB.addActionListener(e -> showSettingsPopup());
    manageCitations.addActionListener(e -> {
        try {
            CitationManager cm = new CitationManager(frame, ooBase);
            cm.showDialog();
        } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) {
            LOGGER.warn("Problem showing citation manager", ex);
        }
    });

    selectDocument.setEnabled(false);
    pushEntries.setEnabled(false);
    pushEntriesInt.setEnabled(false);
    pushEntriesEmpty.setEnabled(false);
    pushEntriesAdvanced.setEnabled(false);
    update.setEnabled(false);
    merge.setEnabled(false);
    manageCitations.setEnabled(false);
    diag = new JDialog((JFrame) null, "OpenOffice/LibreOffice panel", false);

    FormBuilder mainBuilder = FormBuilder.create()
            .layout(new FormLayout("fill:pref:grow", "p,p,p,p,p,p,p,p,p,p"));

    FormBuilder topRowBuilder = FormBuilder.create()
            .layout(new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, "
                    + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", "pref"));
    topRowBuilder.add(connect).xy(1, 1);
    topRowBuilder.add(manualConnect).xy(3, 1);
    topRowBuilder.add(selectDocument).xy(5, 1);
    topRowBuilder.add(update).xy(7, 1);
    topRowBuilder.add(help).xy(9, 1);
    mainBuilder.add(topRowBuilder.getPanel()).xy(1, 1);
    mainBuilder.add(setStyleFile).xy(1, 2);
    mainBuilder.add(pushEntries).xy(1, 3);
    mainBuilder.add(pushEntriesInt).xy(1, 4);
    mainBuilder.add(pushEntriesAdvanced).xy(1, 5);
    mainBuilder.add(pushEntriesEmpty).xy(1, 6);
    mainBuilder.add(merge).xy(1, 7);
    mainBuilder.add(manageCitations).xy(1, 8);
    mainBuilder.add(settingsB).xy(1, 9);

    JPanel content = new JPanel();
    comp.setContentContainer(content);
    content.setLayout(new BorderLayout());
    content.add(mainBuilder.getPanel(), BorderLayout.CENTER);

    frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO");
    frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction);

}

From source file:co.com.soinsoftware.hotelero.view.JFRoomService.java

private boolean validateDataForSave() {
    boolean valid = true;
    final Invoice invoice = this.getInvoiceSelected();
    final Date invoiceItemDate = this.jdcInitialDate.getDate();
    final ServiceType serviceType = this.getServiceTypeSelected();
    final Service service = this.getServiceSelected();
    final int quantity = this.getServiceQuantity();
    final long value = this.getServiceValue();
    if (invoice == null) {
        valid = false;/*w ww . j  a  v  a2 s.c o  m*/
        ViewUtils.showMessage(this, MSG_ROOM_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS,
                JOptionPane.ERROR_MESSAGE);
    } else if (invoiceItemDate == null) {
        valid = false;
        ViewUtils.showMessage(this, MSG_DATE_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS,
                JOptionPane.ERROR_MESSAGE);
    } else if (serviceType == null) {
        valid = false;
        ViewUtils.showMessage(this, MSG_SERVICE_CATEGORY_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS,
                JOptionPane.ERROR_MESSAGE);
    } else if (service == null) {
        valid = false;
        ViewUtils.showMessage(this, MSG_SERVICE_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS,
                JOptionPane.ERROR_MESSAGE);
    } else if (quantity == 0) {
        valid = false;
        ViewUtils.showMessage(this, MSG_QUANTITY_EQUALS_TO_ZERO, ViewUtils.TITLE_REQUIRED_FIELDS,
                JOptionPane.ERROR_MESSAGE);
    } else if (value == 0) {
        valid = false;
        ViewUtils.showMessage(this, MSG_VALUE_EQUALS_TO_ZERO_REQUIRED, ViewUtils.TITLE_REQUIRED_FIELDS,
                JOptionPane.ERROR_MESSAGE);
    }
    return valid;
}

From source file:dotaSoundEditor.Controls.EditorPanel.java

protected void playSelectedTreeSound(TreePath selPath, Path vpkToPlayFrom) {
    try {/*from  w  w w  . j a  v a2s  . c  om*/
        DefaultMutableTreeNode selectedFile = ((DefaultMutableTreeNode) selPath.getLastPathComponent());
        String waveString = selectedFile.getUserObject().toString();
        File soundFile = createSoundFileFromWaveString(waveString, vpkToPlayFrom);
        soundPlayer.loadSound(soundFile.getAbsolutePath());
        soundPlayer.playSound();
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "The selected node does not represent a valid sound file.", "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}