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:net.sf.jabref.importer.fetcher.OAI2Fetcher.java

/**
 * Import an entry from an OAI2 archive. The BibEntry provided has to
 * have the field OAI2_IDENTIFIER_FIELD set to the search string.
 *
 * @param key/*ww  w  .j a v  a2  s . co m*/
 *            The OAI2 key to fetch from ArXiv.
 * @return The imported BibEntry or null if none.
 */
public BibEntry importOai2Entry(String key) {
    /**
     * Fix for problem reported in mailing-list:
     *   https://sourceforge.net/forum/message.php?msg_id=4087158
     */
    String fixedKey = OAI2Fetcher.fixKey(key);

    String url = constructUrl(fixedKey);
    try {
        URL oai2Url = new URL(url);
        HttpURLConnection oai2Connection = (HttpURLConnection) oai2Url.openConnection();
        oai2Connection.setRequestProperty("User-Agent", "JabRef");

        /* create an empty BibEntry and set the oai2identifier field */
        BibEntry be = new BibEntry(IdGenerator.next(), "article");
        be.setField(OAI2Fetcher.OAI2_IDENTIFIER_FIELD, fixedKey);
        DefaultHandler handlerBase = new OAI2Handler(be);

        try (InputStream inputStream = oai2Connection.getInputStream()) {

            /* parse the result */
            saxParser.parse(inputStream, handlerBase);

            /* Correct line breaks and spacing */
            for (String name : be.getFieldNames()) {
                be.getFieldOptional(name)
                        .ifPresent(content -> be.setField(name, OAI2Fetcher.correctLineBreaks(content)));
            }

            if (fixedKey.matches("\\d\\d\\d\\d\\..*")) {
                be.setField(FieldName.YEAR, "20" + fixedKey.substring(0, 2));

                int monthNumber = Integer.parseInt(fixedKey.substring(2, 4));
                MonthUtil.Month month = MonthUtil.getMonthByNumber(monthNumber);
                if (month.isValid()) {
                    be.setField(FieldName.MONTH, month.bibtexFormat);
                }
            }
        }
        return be;
    } catch (IOException e) {
        status.showMessage(Localization.lang("An Exception occurred while accessing '%0'", url) + "\n\n" + e,
                getTitle(), JOptionPane.ERROR_MESSAGE);
    } catch (SAXException e) {
        status.showMessage(Localization.lang("An SAXException occurred while parsing '%0':", url) + "\n\n"
                + e.getMessage(), getTitle(), JOptionPane.ERROR_MESSAGE);
    } catch (RuntimeException e) {
        status.showMessage(
                Localization.lang("Error while fetching from %0", "OAI2 source (" + url + "):") + "\n\n"
                        + e.getMessage() + "\n\n" + Localization
                                .lang("Note: A full text search is currently not supported for %0", getTitle()),
                getTitle(), JOptionPane.ERROR_MESSAGE);
    }
    return null;
}

From source file:com.sec.ose.osi.sdk.protexsdk.discovery.report.DefaultEntityListCreator.java

protected ReportEntityList buildEntityListFromHTML(BufferedReader htmlReportReader,
        ArrayList<String> entityKeyList, ArrayList<String> duplicationCheckingField) {
    ReportEntityList reportEntityList = new ReportEntityList();
    ReportEntity reportEntity = null;//from  w ww.j av a  2s .c  o m
    String tmpLine = null;

    if (duplicationCheckingField == null) {
        duplicationCheckingField = new ArrayList<String>();
    }

    int insertedCnt = 0;

    try {
        StringBuffer tmpValue = new StringBuffer("");
        while ((tmpLine = htmlReportReader.readLine()) != null) {
            tmpLine = tmpLine.trim();
            if (tmpLine.startsWith("<tr ")) {
                reportEntity = new ReportEntity();
                int index = 0;
                while ((tmpLine = htmlReportReader.readLine()) != null) {
                    tmpLine = tmpLine.trim();
                    if (tmpLine.startsWith("<td ")) {
                        while ((tmpLine = htmlReportReader.readLine()) != null) {
                            tmpLine = tmpLine.trim();
                            if (tmpLine.startsWith("</td>")) {
                                String key = entityKeyList.get(index);
                                String value = "";

                                if (key.equals(ReportInfo.COMPARE_CODE_MATCHES.COMPARE_CODE_MATCHES_LINK)) {
                                    value = extractURL(tmpValue);
                                } else {
                                    value = removeTag(tmpValue);
                                }
                                reportEntity.setValue(key, value);
                                tmpValue.setLength(0);
                                ++index;
                                break;
                            }
                            tmpValue.append(tmpLine);
                        }
                    }
                    if (tmpLine.startsWith("</tr>")) {
                        if (hasNoData(entityKeyList, index)) {
                            break;
                        }
                        reportEntityList.addEntity(reportEntity);
                        insertedCnt++;
                        if (insertedCnt % 10000 == 0) {
                            log.debug("buildEntityList insertedCnt: " + insertedCnt);
                        }
                        break;
                    }
                }
            }
            if (tmpLine.startsWith(HTML_DATA_TABLE_END_TAG)) {
                break;
            }
        }
    } catch (IOException e) {
        log.warn(e);
        String[] buttonOK = { "OK" };
        JOptionPane.showOptionDialog(null, "Out Of Memory Error", "Java heap space", JOptionPane.OK_OPTION,
                JOptionPane.ERROR_MESSAGE, null, buttonOK, "OK");
    }
    log.debug("buildEntityList insertedCnt finally : " + insertedCnt);
    return reportEntityList;
}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame./*  w w  w . ja  v a  2 s .  c om*/
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel mainPanel = new JPanel();
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout(0, 0));

    JPanel contentPanel = new JPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}

From source file:edu.wpi.cs.wpisuitetng.janeway.gui.login.LoginController.java

/**
 * Method that is called by {@link ProjectSelectRequestObserver} if the project select
 * request was unsuccessful.//from  ww  w .  j  a  va  2  s. c  o m
 * 
 * @param error A string representing the error that occurred.
 */
public void projectSelectFailed(String error) {
    JOptionPane.showMessageDialog(view, "Unable to select projectc: " + error, "Project Selection Error",
            JOptionPane.ERROR_MESSAGE);
}

From source file:com.emr.schemas.EditMappingsForm.java

/**
 * Method for getting a tables' columns//from  ww  w  .  j a v  a 2  s .c om
 * @param tableName {@link String} The table name
 * @return {@link List} List of the table's columns
 */
private List getTableColumns(String tableName) {
    List tableColumns = new ArrayList();
    try {
        DatabaseMetaData dbmd = mpiConn.getMetaData();
        ResultSet rs = dbmd.getColumns(null, null, tableName, "%");
        while (rs.next()) {
            String colName = rs.getString(4);
            tableColumns.add(colName);
        }
    } catch (SQLException e) {

        String stacktrace = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e);
        JOptionPane.showMessageDialog(this,
                "Could not fetch Tables for the KenyaEMR Database. Error Details: " + stacktrace,
                "Table Names Error", JOptionPane.ERROR_MESSAGE);
    }
    return tableColumns;
}

From source file:com.googlecode.logVisualizer.LogVisualizer.java

private void loadLog(final File file, final LogParser parser) {
    try {/*from www  . j  a  v a2 s. c  o m*/
        parser.parse();
        addLogGUI(file, parser.getLogData());
    } catch (final IOException e) {
        // If there was an IO error of some kind while reading the
        // log file, print the stack trace and show an error dialog,
        // so the user actually knows something is up.
        e.printStackTrace();
        JOptionPane.showMessageDialog(gui,
                "There was a problem with reading and/or parsing the ascension log.\n\n"
                        + "Make sure that the ascension log file isn't corrupted or doesn't contain any line longer than 500 characters\n"
                        + "and try again. If it still doesn't work, try contacting the developers of the Ascension Log Visualizer for\n"
                        + "further help.",
                "Problem occurred", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:net.rptools.maptool.client.ui.AddResourceDialog.java

@Override
public boolean commit() {
    if (!super.commit()) {
        return false;
    }//www .java2  s .  co m

    // Add the resource
    final List<LibraryRow> rowList = new ArrayList<LibraryRow>();

    switch (model.getTab()) {
    case LOCAL:
        if (StringUtils.isEmpty(model.getLocalDirectory())) {
            MapTool.showMessage("dialog.addresource.warn.filenotfound", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        File root = new File(model.getLocalDirectory());
        if (!root.exists()) {
            MapTool.showMessage("dialog.addresource.warn.filenotfound", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        if (!root.isDirectory()) {
            MapTool.showMessage("dialog.addresource.warn.directoryrequired", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        try {
            AppSetup.installLibrary(FileUtil.getNameWithoutExtension(root), root);
        } catch (MalformedURLException e) {
            log.error("Bad path url: " + root.getPath(), e);
            MapTool.showMessage("dialog.addresource.warn.badpath", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        } catch (IOException e) {
            log.error("IOException adding local root: " + root.getPath(), e);
            MapTool.showMessage("dialog.addresource.warn.badpath", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        return true;

    case WEB:
        if (StringUtils.isEmpty(model.getUrlName())) {
            MapTool.showMessage("dialog.addresource.warn.musthavename", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        // validate the url format so that we don't hit it later
        try {
            new URL(model.getUrl());
        } catch (MalformedURLException e) {
            MapTool.showMessage("dialog.addresource.warn.invalidurl", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getUrl());
            return false;
        }
        rowList.add(new LibraryRow(model.getUrlName(), model.getUrl(), -1));
        break;

    case RPTOOLS:
        Object[] selectedRows = getLibraryList().getSelectedValues();
        if (selectedRows == null || selectedRows.length == 0) {
            MapTool.showMessage("dialog.addresource.warn.mustselectone", "Error", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        for (Object obj : selectedRows) {
            LibraryRow row = (LibraryRow) obj;

            //validate the url format
            row.path = LIBRARY_URL + "/" + row.path;
            try {
                new URL(row.path);
            } catch (MalformedURLException e) {
                MapTool.showMessage("dialog.addresource.warn.invalidurl", "Error", JOptionPane.ERROR_MESSAGE,
                        row.path);
                return false;
            }
            rowList.add(row);
        }
        break;
    }

    new SwingWorker<Object, Object>() {
        @Override
        protected Object doInBackground() throws Exception {
            for (LibraryRow row : rowList) {
                try {
                    RemoteFileDownloader downloader = new RemoteFileDownloader(new URL(row.path));
                    File tmpFile = downloader.read();
                    AppSetup.installLibrary(row.name, tmpFile.toURL());
                    tmpFile.delete();
                } catch (IOException e) {
                    log.error("Error downloading library: " + e, e);
                    MapTool.showInformation("dialog.addresource.warn.couldnotload");
                }
            }
            return null;
        }
    }.execute();
    return true;
}

From source file:ca.uviccscu.lp.persistence.ChooseFolderDialog.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    String path = jTextField3.getText();
    File f = new File(path);
    l.trace("WFolder path entered: [" + path + "]");
    int verification = SettingsManager.verifyWorkingFolder(path);
    l.trace("Initial WFolder verification: " + verification);
    if (verification != 0) {
        switch (verification) {
        case (1): {
            if (path == null || path.equals("")) {
                verification = 8;/* w ww  .j  ava2s.c om*/
                l.trace("WFolder  verification ch: " + verification);
                JOptionPane.showMessageDialog(this, "Path field empty!", "WFolder creation error",
                        JOptionPane.ERROR_MESSAGE);
            }
            if (verification == 1) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ex) {
                    java.util.logging.Logger.getLogger(ChooseFolderDialog.class.getName()).log(Level.SEVERE,
                            null, ex);
                }
                int resp = JOptionPane.showConfirmDialog(this, "Directory doesn't exist! Create?",
                        "WFolder creation warning", JOptionPane.YES_NO_OPTION);
                if (resp == JOptionPane.YES_OPTION) {
                    verification = 0;
                    l.trace("WFolder verification ch: " + verification);
                } else if (resp == JOptionPane.NO_OPTION) {
                    verification = 7;
                    l.trace("WFolder verification ch: " + verification);
                }
            }
            break;
        }
        case (2): {
            if (path == null || path.equals("")) {
                verification = 8;
                l.trace("WFolder verification ch: " + verification);
                JOptionPane.showMessageDialog(this, "Path field empty!", "WFolder creation error",
                        JOptionPane.ERROR_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(this, "Path not absolute!", "WFolder creation error",
                        JOptionPane.ERROR_MESSAGE);
            }
            break;
        }
        case (3): {
            JOptionPane.showMessageDialog(this, "Can't read!", "WFolder creation error",
                    JOptionPane.ERROR_MESSAGE);
            break;
        }
        case (4): {
            JOptionPane.showMessageDialog(this, "Can't write!", "WFolder creation error",
                    JOptionPane.ERROR_MESSAGE);
            break;
        }
        case (5): {
            JOptionPane.showMessageDialog(this, "File error!", "WFolder creation error",
                    JOptionPane.ERROR_MESSAGE);
            break;
        }
        case (6): {
            //JOptionPane.showMessageDialog(this, "File error!", "WFolder creation error", JOptionPane.ERROR_MESSAGE);
            l.error("Directory not empty");
            l.trace("WFolder verification ch: " + verification);
            //JDialog jd = new JDialog((JFrame) null, true);
            int resp = JOptionPane.showConfirmDialog(null,
                    "Directory nonempty: " + f.getAbsolutePath() + ". Wipe and proceed?", "Confirm deletion",
                    JOptionPane.YES_NO_OPTION);
            if (resp == JOptionPane.YES_OPTION) {
                try {
                    FileUtils.deleteDirectory(f);
                    verification = 0;
                } catch (IOException ex) {
                    l.fatal("Can't wipe directory", ex);
                    System.exit(1);
                }
            }
            break;
        }
        }
    }
    l.trace("Final WFolder verification: " + verification);
    if (verification == 0) {
        Shared.lastFolder_path = path;
        Shared.lastFolder_verification = verification;
        Shared.lastFolder_wasCancelled = false;
        this.setVisible(false);
    }
}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

public static JFreeChart createXYLineChart(String chartName, DBSeerDataSet dataset) throws Exception {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval("[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";");

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");

    timestamp = runner.getVariableDouble("timestamp");

    XYSeriesCollection XYdataSet = new XYSeriesCollection();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
        JOptionPane.showMessageDialog(null, "The number of X dataset and Y dataset does not match.",
                "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE);
        System.out.println(numXCellArray + " : " + numYCellArray);
        return null;
    }//from   w  ww . ja v a2  s.  co  m

    java.util.List<String> transactionNames = dataset.getTransactionTypeNames();

    for (int i = 0; i < numLegends; ++i) {
        String legend = (String) legends[i];
        for (int j = 0; j < transactionNames.size(); ++j) {
            if (legend.contains("Type " + (j + 1))) {
                legends[i] = legend.replace("Type " + (j + 1), transactionNames.get(j));
                break;
            }
        }
    }

    for (int i = 0; i < numYCellArray; ++i) {
        double[] xArray = (double[]) xCellArray[i];
        int row = 0, col = 0;
        int xLength = 0;

        runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
        runner.eval("yArray = Ydata{" + (i + 1) + "};");
        double[] yArraySize = runner.getVariableDouble("yArraySize");
        double[] yArray = runner.getVariableDouble("yArray");

        xLength = xArray.length;
        row = (int) yArraySize[0];
        col = (int) yArraySize[1];

        for (int c = 0; c < col; ++c) {
            XYSeries series;
            String legend = "";
            int legendIdx = (dataCount >= numLegends) ? numLegends - 1 : dataCount;
            if (legendIdx >= 0) {
                legend = (String) legends[legendIdx];
            }
            if (numLegends == 0) {
                series = new XYSeries("Data " + dataCount + 1);
            } else if (dataCount >= numLegends) {
                series = new XYSeries(legend + (dataCount + 1));
            } else {
                series = new XYSeries(legend);
            }

            for (int r = 0; r < row; ++r) {
                int xRow = (r >= xLength) ? xLength - 1 : r;
                double yValue = yArray[r + c * row];
                // remove negatives
                if (yValue < 0) {
                    yValue = 0;
                }
                series.add(xArray[xRow], yValue);
            }
            XYdataSet.addSeries(series);
            ++dataCount;
        }
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, XYdataSet);
    boolean isTransactionSampleChart = false;
    for (String name : DBSeerGUI.transactionSampleCharts) {
        if (name.equals(chartName)) {
            isTransactionSampleChart = true;
            break;
        }
    }

    // Renderer to highlight selected normal or outlier points.
    if (isTransactionSampleChart) {
        chart.getXYPlot().setRenderer(new DBSeerXYLineAndShapeRenderer(timestamp, dataset));
    } else {
        chart.getXYPlot().setRenderer(new DBSeerXYLineAndShapeRenderer());

    }

    chart.getXYPlot().getDomainAxis().setUpperMargin(0);

    return chart;
}

From source file:com.t3.client.ui.AddResourceDialog.java

@Override
public boolean commit() {
    if (!super.commit()) {
        return false;
    }//from ww  w.  ja v a2s  .  co  m

    // Add the resource
    final List<LibraryRow> rowList = new ArrayList<LibraryRow>();

    switch (model.getTab()) {
    case LOCAL:
        if (StringUtils.isEmpty(model.getLocalDirectory())) {
            TabletopTool.showMessage("dialog.addresource.warn.filenotfound", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        File root = new File(model.getLocalDirectory());
        if (!root.exists()) {
            TabletopTool.showMessage("dialog.addresource.warn.filenotfound", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        if (!root.isDirectory()) {
            TabletopTool.showMessage("dialog.addresource.warn.directoryrequired", "Error",
                    JOptionPane.ERROR_MESSAGE, model.getLocalDirectory());
            return false;
        }
        AppSetup.installLibrary(FileUtil.getNameWithoutExtension(root), root);
        return true;

    case WEB:
        if (StringUtils.isEmpty(model.getUrlName())) {
            TabletopTool.showMessage("dialog.addresource.warn.musthavename", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getLocalDirectory());
            return false;
        }
        // validate the url format so that we don't hit it later
        try {
            new URL(model.getUrl());
        } catch (MalformedURLException e) {
            TabletopTool.showMessage("dialog.addresource.warn.invalidurl", "Error", JOptionPane.ERROR_MESSAGE,
                    model.getUrl());
            return false;
        }
        rowList.add(new LibraryRow(model.getUrlName(), model.getUrl(), -1));
        break;

    case TABLETOPTOOL_SITE:
        List<LibraryRow> selectedRows = getLibraryList().getSelectedValuesList();
        if (selectedRows == null || selectedRows.isEmpty()) {
            TabletopTool.showMessage("dialog.addresource.warn.mustselectone", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }
        for (LibraryRow row : selectedRows) {

            //validate the url format
            row.path = LIBRARY_URL + "/" + row.path;
            try {
                new URL(row.path);
            } catch (MalformedURLException e) {
                TabletopTool.showMessage("dialog.addresource.warn.invalidurl", "Error",
                        JOptionPane.ERROR_MESSAGE, row.path);
                return false;
            }
            rowList.add(row);
        }
        break;
    }

    new SwingWorker<Object, Object>() {
        @Override
        protected Object doInBackground() throws Exception {
            for (LibraryRow row : rowList) {
                try {
                    RemoteFileDownloader downloader = new RemoteFileDownloader(new URL(row.path));
                    File tmpFile = downloader.read();
                    AppSetup.installLibrary(row.name, tmpFile.toURL());
                    tmpFile.delete();
                } catch (IOException e) {
                    log.error("Error downloading library: " + e, e);
                    TabletopTool.showInformation("dialog.addresource.warn.couldnotload");
                }
            }
            return null;
        }
    }.execute();
    return true;
}