Example usage for java.awt Cursor WAIT_CURSOR

List of usage examples for java.awt Cursor WAIT_CURSOR

Introduction

In this page you can find the example usage for java.awt Cursor WAIT_CURSOR.

Prototype

int WAIT_CURSOR

To view the source code for java.awt Cursor WAIT_CURSOR.

Click Source Link

Document

The wait cursor type.

Usage

From source file:neg.JRViewerSin.java

private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
    // Add your handling code here:

    Thread thread = new Thread(new Runnable() {
        public void run() {
            try {

                btnPrint.setEnabled(false);
                JRViewerSin.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                JasperPrintManager.printReport(jasperPrint, true);
            } catch (Exception ex) {
                if (log.isErrorEnabled())
                    log.error("Print error.", ex);

                JOptionPane.showMessageDialog(JRViewerSin.this, getBundleString("error.printing"));
            } finally {
                JRViewerSin.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                btnPrint.setEnabled(true);
            }//from  w w w.ja  va  2 s .co  m
        }
    });

    thread.start();
}

From source file:lejos.pc.charting.LogChartFrame.java

/** Attempt to start a connection using a thread so the GUI stays responsive. Manage connect button state
 * @param e/*  w w  w  .  ja  v  a2s . c  om*/
 */
private void jButtonConnect_actionPerformed(ActionEvent e) {
    final ActionEvent ee = e;
    Runnable doAction = new Runnable() {
        public void run() {
            if (jButtonConnect.getText().equals("Connect")) {
                if (!isNXTConnected) {
                    jButtonConnect.setText("Connecting..");
                    jButtonConnect.setEnabled(false);
                    LogChartFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    if (makeConnection()) {
                        jButtonConnect.setText("Disconnect");
                    } else {
                        jButtonConnect.setText("Connect");
                    }
                    LogChartFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    jButtonConnect.setEnabled(true);
                }

                System.out.println(ee.getActionCommand().toString());
            } else {
                closeCurrentConnection();
            }
        }
    };
    new Thread(doAction).start();
}

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

protected void highlight(String toGroupBy, boolean exactMatch, boolean returnSampleNames) {
    if (tableGroupInformation != null && tableGroupInformation.isShowing()) {
        tableGroupInformation.dispose();
    }/* w ww.  j  av a 2s  .  c o  m*/

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    Map<String, List<Object>> groups = getDataGroupsByColumn(toGroupBy, exactMatch, returnSampleNames);

    Map<String, Color> groupColors = new ListOrderedMap<String, Color>();

    for (String s : groups.keySet()) {
        groupColors.put(s, UIHelper.createColorFromString(s, true));
    }
    // then pass the groups and the colours to the TableGroupInfo class to display the gui
    // showing group distribution!
    final Map<Integer, Color> rowColors = paintRows(groups, groupColors);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    tableGroupInformation = new TableGroupInfo(groups, groupColors, table.getRowCount());
    tableGroupInformation.setLocation(getWidth() / 2 - tableGroupInformation.getWidth(),
            getHeight() / 2 - tableGroupInformation.getHeight());
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            try {
                table.setDefaultRenderer(Class.forName("java.lang.Object"),
                        new CustomRowRenderer(rowColors, UIHelper.VER_11_PLAIN));
                table.repaint();
                tableGroupInformation.createGUI();
                highlightActive = true;
            } catch (ClassNotFoundException e) {
                //
            }
        }
    });
}

From source file:lejos.pc.charting.LogChartFrame.java

private void selectFolderButton_actionPerformed(ActionEvent e) {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    JFileChooser jfc = new JFileChooser(new File(FQPathTextArea.getText(), ""));
    jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    jfc.setApproveButtonText("Select");
    jfc.setDialogTitle("Select Directory");
    jfc.setDialogType(JFileChooser.OPEN_DIALOG);
    this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    int returnVal = jfc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        FQPathTextArea.setText(getCanonicalName(jfc.getSelectedFile()));
        jfc.setCurrentDirectory(jfc.getSelectedFile());
        System.out.println("folder set to \"" + getCanonicalName(jfc.getSelectedFile()) + "\"");
    }// www .  java 2 s .com
}

From source file:cobweb.Cobweb.java

/**
 * Load the neighbourhood (conected nodes) of the given node by sending a
 * request to the server using the defined neighbourhood-script
 * //from   w  ww.j  av a  2  s  . c o  m
 * @param n
 *            The node whose neighbourhood is to be loaded
 */
public void loadNeighbourhood(Node n) {
    if (params.getNeighbourhoodScript() != null) {
        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        callJavascriptFunctionStatusMessage("loading neighbourhood for " + n.getName(), true);

        String lines[] = loadStrings(
                params.getServerAdress() + params.getNeighbourhoodScript() + "?id=" + n.getId());
        StringBuffer stringBuf = new StringBuffer();
        for (int i = 0; i < lines.length; i++)
            stringBuf.append(lines[i]);
        String content = stringBuf.toString();

        addNetwork(content, n.getPosition().getX(), n.getPosition().getY());

        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

        callJavascriptFunctionStatusMessage("loaded neighbourhood for " + n.getName());
    }
}

From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java

private void openFile(File f, SCAPDocumentClassEnum expectedClass) {
    //    LOG.debug("openFile entered for file " + (f == null ? "null" : f.getAbsolutePath()));
    SCAPDocument sdoc = null;//from  w  w w. j  a va 2 s  .com
    Charset alternateEncoding = Charset.forName("UTF-8");

    try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        sdoc = SCAPDocumentFactory.loadDocument(f, alternateEncoding);
        if (sdoc == null) {
            // if the document is null here it's probably an unsupported version
            throw new UnsupportedDocumentTypeException("The document type is not supported at this time");
        }
    } catch (UnsupportedDocumentTypeException udte) {
        setCursor(null);
        String message = "The document contained in file " + f.getAbsolutePath() + " could not be loaded: "
                + udte.getMessage();

        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;

    } catch (CharacterSetEncodingException e) {
        setCursor(null);
        AlternateEncodingPicker encPicker = new AlternateEncodingPicker(this, true);

        encPicker.pack();
        encPicker.setLocationRelativeTo(this);
        encPicker.setVisible(true);

        if (!encPicker.wasCancelled()) {
            alternateEncoding = encPicker.getSelectedEncoding();
        } else {
            setCursor(null);
            String message = "Opening of file " + f.getName() + " Cancelled: " + e.getMessage();

            EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                    JOptionPane.ERROR_MESSAGE);
            return;
        }
    } catch (IOException e) {
        setCursor(null);
        LOG.error("EXCEPTION", e);
        String message = "File " + f.getName() + " couldn't be opened because of an I/O issue: "
                + e.getMessage();

        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;
    } catch (Exception eee) {
        setCursor(null);
        LOG.error("Exception", eee);
        String message = "An exception occurred trying to open file " + f.getAbsolutePath()
                + ", see log file for details";

        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    setCursor(null);

    if (sdoc != null) {
        SCAPDocumentClassEnum actualClass = sdoc.getDocumentClass();
        //      LOG.debug("openFile: document class is " + actualClass + ", expected is " + expectedClass);
        if (!expectedClass.equals(actualClass)) {
            setCursor(null);
            String message = "File " + f.getName() + " type mismatch: expected=" + expectedClass.toString()
                    + " actual=" + actualClass.toString();

            EditorUtil.showMessageDialog(this, message, EditorMessages.DOCUMENT_MISMATCH_ERROR_TITLE,
                    JOptionPane.ERROR_MESSAGE);
            return;
        }

        openFile(sdoc);
    } else {
        String message = "There was a problem trying to open file " + f.getAbsolutePath()
                + ": document returned was NULL";

        EditorUtil.showMessageDialog(this, message, EditorMessages.LOAD_DOCUMENT_ERROR_TITLE,
                JOptionPane.ERROR_MESSAGE);
        return;
    }
    //    LOG.debug("openFile returning for file " + (f == null ? "null" : f.getAbsolutePath()));
}

From source file:com.vgi.mafscaling.ClosedLoop.java

protected void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(true);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//from  w w  w .  j a v  a2 s . c om
    boolean isPolSet = polfTable.isSet();
    File[] files = fileChooser.getSelectedFiles();
    for (File file : files) {
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
            String line = br.readLine();
            if (line != null) {
                String[] elements = line.split("(\\s*)?,(\\s*)?", -1);
                getColumnsFilters(elements);

                boolean resetColumns = false;
                if (logClOlStatusColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0
                        || logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0 || logTimeColIdx >= 0
                        || logMafvColIdx >= 0 || logIatColIdx >= 0) {
                    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                            "Would you like to reset column names or filter values?", "Columns/Filters Reset",
                            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE))
                        resetColumns = true;
                }

                if (resetColumns || logClOlStatusColIdx < 0 || logAfLearningColIdx < 0
                        || logAfCorrectionColIdx < 0 || logAfrColIdx < 0 || logRpmColIdx < 0
                        || logLoadColIdx < 0 || logTimeColIdx < 0 || logMafvColIdx < 0 || logIatColIdx < 0) {
                    ColumnsFiltersSelection selectionWindow = new CLColumnsFiltersSelection(isPolSet);
                    if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements))
                        return;
                }

                String[] flds;
                line = br.readLine();
                int clol;
                int i = 2;
                int row = getLogTableEmptyRow();
                double afr = 0;
                double dVdt = 0;
                double prevTime = 0;
                double time = 0;
                double timeMultiplier = 1.0;
                double pmafv = 0;
                double mafv = 0;
                double load;
                double iat;
                setCursor(new Cursor(Cursor.WAIT_CURSOR));

                while (line != null) {
                    flds = line.split(",", -1);
                    try {
                        // Calculate dV/dt
                        prevTime = time;
                        time = Double.valueOf(flds[logTimeColIdx]);
                        if (timeMultiplier == 1.0 && (int) time - time < 0) {
                            timeMultiplier = 1000.0;
                            prevTime *= timeMultiplier;
                        }
                        time *= timeMultiplier;
                        pmafv = mafv;
                        mafv = Double.valueOf(flds[logMafvColIdx]);
                        if ((time - prevTime) == 0.0)
                            dVdt = 100.0;
                        else
                            dVdt = Math.abs(((mafv - pmafv) / (time - prevTime)) * 1000.0);
                        clol = Integer.valueOf(flds[logClOlStatusColIdx]);
                        if (clol == clValue) {
                            // Filters
                            afr = Double.valueOf(flds[logAfrColIdx]);
                            load = Double.valueOf(flds[logLoadColIdx]);
                            iat = Double.valueOf(flds[logIatColIdx]);
                            if (afrMin <= afr && afr <= afrMax && minLoad <= load && dVdt <= maxDvDt
                                    && maxMafV >= mafv && maxIat >= iat) {
                                Utils.ensureRowCount(row + 1, logDataTable);
                                logDataTable.setValueAt(time, row, 0);
                                logDataTable.setValueAt(load, row, 1);
                                logDataTable.setValueAt(Double.valueOf(flds[logRpmColIdx]), row, 2);
                                logDataTable.setValueAt(mafv, row, 3);
                                logDataTable.setValueAt(afr, row, 4);
                                logDataTable.setValueAt(Double.valueOf(flds[logAfCorrectionColIdx]), row, 5);
                                logDataTable.setValueAt(Double.valueOf(flds[logAfLearningColIdx]), row, 6);
                                logDataTable.setValueAt(dVdt, row, 7);
                                logDataTable.setValueAt(iat, row, 8);
                                row += 1;
                            }
                        }
                    } catch (NumberFormatException e) {
                        logger.error(e);
                        JOptionPane.showMessageDialog(null,
                                "Error parsing number at " + file.getName() + " line " + i + ": " + e,
                                "Error processing file", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    line = br.readLine();
                    i += 1;
                }
            }
        } catch (Exception e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
    }
}

From source file:edu.harvard.mcz.imagecapture.MainFrame.java

/**
 * This method initializes jMenuItem5   
 *    /*from   w  w w. j  a va 2  s .  c  o m*/
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getJMenuItemQCBarcodes() {
    if (jMenuItemQCBarcodes == null) {
        jMenuItemQCBarcodes = new JMenuItem();
        jMenuItemQCBarcodes.setText("QC Barcodes");
        jMenuItemQCBarcodes.setMnemonic(KeyEvent.VK_B);
        jMenuItemQCBarcodes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                Singleton.getSingletonInstance().getMainFrame().setStatusMessage("Running barcode QC checks");
                String[] missingBarcodes = SpecimenLifeCycle.getMissingBarcodes();
                ilb = new ImageListBrowser(true);
                if (slb != null) {
                    jPanelCenter.remove(slb);
                }
                if (ulb != null) {
                    jPanelCenter.remove(ulb);
                }
                jPanelCenter.removeAll();
                jPanelCenter.add(ilb, BorderLayout.CENTER);
                jPanelCenter.revalidate();
                jPanelCenter.repaint();
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                log.debug(missingBarcodes.length);
                if (missingBarcodes.length > 0) {
                    Counter errorCount = new Counter();
                    for (int i = 0; i < missingBarcodes.length; i++) {
                        BarcodeBuilder builder = Singleton.getSingletonInstance().getBarcodeBuilder();
                        BarcodeMatcher matcher = Singleton.getSingletonInstance().getBarcodeMatcher();
                        String previous = builder.makeFromNumber(matcher.extractNumber(missingBarcodes[i]) - 1);
                        String previousFile = "";
                        String previousPath = "";
                        SpecimenLifeCycle sls = new SpecimenLifeCycle();
                        List<Specimen> result = sls.findByBarcode(previous);
                        if (result != null && (!result.isEmpty())) {
                            Set<ICImage> images = result.get(0).getICImages();

                            if (images != null && (!images.isEmpty())) {
                                Iterator<ICImage> it = images.iterator();
                                if (it.hasNext()) {
                                    ICImage image = it.next();
                                    previousFile = image.getFilename();
                                    previousPath = image.getPath();
                                }
                            }
                        }
                        RunnableJobError err = new RunnableJobError(previousFile, missingBarcodes[i],
                                previousPath, "", "Barcode not found", null, null, null,
                                RunnableJobError.TYPE_BARCODE_MISSING_FROM_SEQUENCE, previousFile,
                                previousPath);
                        errorCount.appendError(err);
                    }
                    String report = "There are at least " + missingBarcodes.length
                            + " barcodes missing from the sequence.\nMissing numbers are shown below.\nIf two or more numbers are missing in sequence, only the first will be listed here.\n\nFiles with mismmatched barcodes are shown in main window.\n";
                    RunnableJobReportDialog errorReportDialog = new RunnableJobReportDialog(
                            Singleton.getSingletonInstance().getMainFrame(), report, errorCount.getErrors(),
                            RunnableJobErrorTableModel.TYPE_MISSING_BARCODES, "QC Barcodes Report");
                    errorReportDialog.setVisible(true);
                } else {
                    JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                            "No barcodes are missing from the sequence.\nAny missmatches are shown in table.",
                            "Barcode QC Report", JOptionPane.OK_OPTION);
                }
                System.gc();
            }
        });
    }
    return jMenuItemQCBarcodes;
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    String selectedFunction = (String) functionCombo.getSelectedItem();
    if (e.getSource() == functionCombo) {
        if (selectedFunction.equals(comboOptions.getFunctionOptions()[0])) {
            // show necessary input arguments for computing distance matrix
            showPanel(displayInstructionPanel);
            hidePanel(performancePanel);
            hidePanel(miningFunctionParamsSelectionPanel);
            hidePanel(plotDensityMapPanel);
        } else if (selectedFunction.equals(comboOptions.getFunctionOptions()[1])) {
            // show necessary input arguments for computing sigLevel
            showPanel(miningFunctionParamsSelectionPanel, MINING_FUNC_PARAMS_SELECTION_PANEL_TITLE);
            showPanel(sigLevelParamsPanel);
            showPanel(displayInstructionPanel);
            hidePanel(plotMapParamsPanel);
            hidePanel(performancePanel);
            hidePanel(this.followingParamsPanel);
            hidePanel(this.plotDensityMapPanel);
        } else if (selectedFunction.equals(comboOptions.getFunctionOptions()[2])) {
            // show necessary input arguments for ploting a map
            showPanel(miningFunctionParamsSelectionPanel, MINING_FUNC_PARAMS_SELECTION_PANEL_TITLE);
            showPanel(plotMapParamsPanel);
            hidePanel(sigLevelParamsPanel);
            hidePanel(performancePanel);
            hidePanel(displayInstructionPanel);
            hidePanel(this.followingParamsPanel);
            hidePanel(this.plotDensityMapPanel);
        } else if (selectedFunction.equals(comboOptions.getFunctionOptions()[3])) {
            showPanel(miningFunctionParamsSelectionPanel, MINING_FUNC_PARAMS_SELECTION_PANEL_TITLE);
            showPanel(this.followingParamsPanel);
            showPanel(displayInstructionPanel);
            hidePanel(plotMapParamsPanel);
            hidePanel(sigLevelParamsPanel);
            hidePanel(performancePanel);
            hidePanel(this.plotDensityMapPanel);
        } else if (selectedFunction.equals(comboOptions.getFunctionOptions()[4])) {
            showPanel(miningFunctionParamsSelectionPanel, MINING_FUNC_PARAMS_SELECTION_PANEL_TITLE);
            showPanel(this.plotDensityMapPanel);
            hidePanel(this.followingParamsPanel);
            hidePanel(displayInstructionPanel);
            hidePanel(plotMapParamsPanel);
            hidePanel(sigLevelParamsPanel);
            hidePanel(performancePanel);
        }/* w  w w  . j a v a 2s.  co  m*/
    }

    if (e.getSource() == useLocalCopyButton) {
        useLocalCopyButton.setEnabled(false);
        loadDatasetButton.setEnabled(false);
        downloadOnlineButton.setEnabled(false);
        stats.setText("");
        showPanel(downloadDatasetProgressPanel);
        datasetCombo.setEnabled(false);
        downloadDatasetProgressBar.setValue(0);
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        showPanel(selectTimespanPanel);
        showPanel(displayStatsPanel, DISPLAY_STATS_PANEL_TITLE);
        stats.setText("Fetching License Terms from server ...");
        String selectedDatasetName = (String) datasetCombo.getSelectedItem();
        downloadTask = new DownloadDatasetTask(selectedDatasetName);
        downloadTask.addPropertyChangeListener(this);
        downloadTask.execute();
    }

    if (e.getSource() == downloadOnlineButton) {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        useLocalCopyButton.setEnabled(false);
        loadDatasetButton.setEnabled(false);
        downloadOnlineButton.setEnabled(false);
        hidePanel(interpolationParamsSelectionPanel);
        hidePanel(miningFunctionSelectionPanel);
        hidePanel(miningFunctionParamsSelectionPanel);
        hidePanel(displayInstructionPanel);
        hidePanel(performancePanel);
        hidePanel(displayStatsPanel);
        hidePanel(selectIndividualsPanel);
        hidePanel(selectTimespanPanel);

        stats.setText("");

        showPanel(downloadDatasetProgressPanel);
        showPanel(displayStatsPanel, DISPLAY_STATS_PANEL_TITLE);
        instructionLabel.setText("");
        datasetCombo.setEnabled(false);
        downloadDatasetProgressBar.setValue(0);

        stats.setText("Fetching License Terms from server ...");
        String selectedDatasetName = (String) datasetCombo.getSelectedItem();
        downloadTask = new DownloadDatasetTask(selectedDatasetName, true);
        downloadTask.addPropertyChangeListener(this);
        downloadTask.execute();
    }

    if (e.getSource() == loadDatasetButton) {

        if (useLocalCopyButton != null) {
            useLocalCopyButton.setEnabled(false);
        }
        if (downloadOnlineButton != null) {
            downloadOnlineButton.setEnabled(false);
        }
        loadDatasetButton.setEnabled(false);

        JFileChooser fc = new JFileChooser();
        String workingDir = System.getProperty("user.dir");
        fc.setCurrentDirectory(new File(workingDir));
        int returnVal = fc.showOpenDialog(ParametersSelectionFrame.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            final File file = fc.getSelectedFile();
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            System.out.println("Opening " + file.getName());
            downloadDatasetProgressBar.setVisible(true);
            downloadDatasetProgressBar.setIndeterminate(true);
            downloadDatasetProgressBar.setStringPainted(false);

            hidePanel(interpolationParamsSelectionPanel);
            hidePanel(miningFunctionSelectionPanel);
            hidePanel(miningFunctionParamsSelectionPanel);
            hidePanel(displayInstructionPanel);
            hidePanel(performancePanel);
            hidePanel(displayStatsPanel);
            hidePanel(selectIndividualsPanel);
            hidePanel(selectTimespanPanel);

            stats.setText("");

            showPanel(downloadDatasetProgressPanel);
            showPanel(displayStatsPanel, DISPLAY_STATS_PANEL_TITLE);
            instructionLabel.setText("");

            LoadDatasetTask loadDatasetTask = new LoadDatasetTask(file.getAbsolutePath()) {
                @Override
                public void done() {
                    if (this.isFailToParse()) {
                        stats.setText(this.getErrorMsg());
                        downloadDatasetProgressPanel.setVisible(false);
                        hidePanel(interpolationParamsSelectionPanel);
                        hidePanel(miningFunctionSelectionPanel);
                        hidePanel(miningFunctionParamsSelectionPanel);
                        hidePanel(displayInstructionPanel);
                        hidePanel(performancePanel);
                        hidePanel(selectIndividualsPanel);
                        hidePanel(selectTimespanPanel);
                    } else {
                        trajsMap = this.getTrajsMap();
                        ArrayList<Trajectory> trajs = new ArrayList(trajsMap.values());

                        Dataset dataset = new Dataset();
                        dataset.storeData(trajs, trajsMap);
                        dataset.setDatasetName(file.getName());
                        curSelectedDatasetName = file.getName();
                        initIndividualNames();
                        downloadDatasetProgressPanel.setVisible(false);
                        showStats(dataset);
                        initSelectTimespanRange(dataset.getStartTime(), dataset.getEndTime());

                        showPanel(selectTimespanPanel);
                        showPanel(interpolationParamsSelectionPanel, INTERPOLATE_PARAMS_PANEL_TITLE);
                        showPanel(selectIndividualsPanel);
                        showPanel(selectTimespanPanel);

                        setCursor(null); //turn off the wait cursor
                        downloadDatasetProgressBar.setIndeterminate(false);
                        downloadDatasetProgressBar.setStringPainted(true);
                    }
                }
            };
            loadDatasetTask.addPropertyChangeListener(this);
            loadDatasetTask.execute();
        } else {
            System.out.println("Open command cancelled by user.");
        }
        loadDatasetButton.setEnabled(true);
        setCursor(null);
        if (useLocalCopyButton != null) {
            useLocalCopyButton.setEnabled(true);
        }
        if (downloadOnlineButton != null) {
            downloadOnlineButton.setEnabled(true);
        }
    }

    if (e.getSource() == goButton) {
        showPanel(performancePanel);
        //            String selectedDatasetName = (String) datasetCombo
        //                    .getSelectedItem();
        String selectedDatasetName = curSelectedDatasetName;
        instructionLabel.setText("Loading ...");
        String displayMethod = (String) displayMethodCombo.getSelectedItem();
        String gap = (String) gapCombo.getSelectedItem();
        String thresGap = (String) thresGapCombo.getSelectedItem();
        String numRound = (String) numRoundCombo.getSelectedItem();
        String distThres = distThresTextedField.getText();

        /*Fei*/
        String ml = (String) this.minIntervalLengthField.getText();
        String lMax = (String) this.lMaxLabelTextedField.getText();
        String dMax = (String) this.dMaxLabelTextedField.getText();
        /**/
        boolean needInterpolation = this.interpFlag;
        try {
            MiningFunctionParameters params;
            instructionLabel.setText("Running mining algorithm ...");
            params = new MiningFunctionParameters();
            params.setSelectedDatasetName(selectedDatasetName);
            params.setSelectedFunction(selectedFunction);
            params.setDisplayMethod(displayMethod);
            params.setNeedInterpolation(needInterpolation);
            params.setGap(gap);
            params.setThresGap(thresGap);
            params.setNumRound(numRound);
            params.setDistThres(distThres);
            /*Fei*/
            int lmax_int = (int) Math.floor(Double.parseDouble(lMax));
            params.setlMax("" + lmax_int);
            params.setdMax(dMax);
            params.setMinL(ml);
            /**/
            params.setStartTime(selectStartTimePicker.getDate());
            params.setEndTime(selectEndTimePicker.getDate());
            ArrayList<Trajectory> trajs = getSelectedTrajectories(selectedIndividualIndicesForDv);
            List<Trajectory> subTrajs = getSubTrajectory(trajs, selectStartTimePicker.getDate(),
                    selectEndTimePicker.getDate());
            if (selectedFunction.equalsIgnoreCase("Following mining") && trajs.size() != 2) {
                JOptionPane.showMessageDialog(this.contentPane,
                        "Please select two animals for following mining.");
            } else if (!selectedFunction.equalsIgnoreCase("Following mining") && needInterpolation == false) {
                JOptionPane.showMessageDialog(this.contentPane,
                        "Selected function requires interpolation. Please check the interpolation option.");
            } else if (!selectedFunction.equalsIgnoreCase("Plotting") && trajs.size() < 2) {
                JOptionPane.showMessageDialog(this.contentPane, "Please select at least two animals.");

            } else {
                boolean dothejob = false;
                int dialogresult = JOptionPane.YES_OPTION;
                if (this.aveSampling >= 1 && selectedFunction.equalsIgnoreCase("Following mining")) {
                    dialogresult = JOptionPane.showConfirmDialog(this.contentPane,
                            "Recommend to use dataset having higher sampling rate (less than 1 minper sample) for this function. \n Do you still want to proceed?",
                            "", JOptionPane.YES_NO_OPTION);
                }
                if (dialogresult == JOptionPane.YES_OPTION)
                    dothejob = true;
                if (dothejob) {
                    goButton.setEnabled(false);
                    disablePanel(datasetSelectionPanel);
                    disablePanel(interpolationParamsSelectionPanel);
                    disablePanel(miningFunctionSelectionPanel);
                    disablePanel(miningFunctionParamsSelectionPanel);
                    disablePanel(selectIndividualsPanel);
                    disablePanel(sigLevelParamsPanel);
                    disablePanel(selectTimespanPanel);
                    /*Fei*/
                    disablePanel(this.followingParamsPanel);
                    /**/

                    JFrame dvPanel = new DataVisualization(subTrajs, params, this);
                    dvPanel.setLocation(this.getX() + this.getWidth(), this.getY());
                    dvPanel.setVisible(true);
                }

                //this.saveKmlButtonF.setVisible(true);
            }

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

    if (e.getSource() == saveDensityMapButton) {
        String selectedDatasetName = curSelectedDatasetName;
        String displayMethod = (String) displayMethodCombo.getSelectedItem();
        MiningFunctionParameters params = new MiningFunctionParameters();
        String gap = (String) gapCombo.getSelectedItem();
        String thresGap = (String) thresGapCombo.getSelectedItem();
        boolean needInterpolation = false;
        params.setSelectedDatasetName(selectedDatasetName);
        params.setSelectedFunction(selectedFunction);
        params.setDisplayMethod(displayMethod);
        params.setNeedInterpolation(needInterpolation);
        params.setGap(gap);
        params.setThresGap(thresGap);

        ArrayList<Trajectory> trajs = getSelectedTrajectories(selectedIndividualIndicesForDv);
        List<Trajectory> subTrajs = getSubTrajectory(trajs, selectStartTimePicker.getDate(),
                selectEndTimePicker.getDate());
        JFrame dvPanel = new DataVisualization(subTrajs, params, this);
        dvPanel.setLocation(this.getX() + this.getWidth(), this.getY());
        dvPanel.setVisible(true);
    }

    if (e.getSource() == selectIndividualsButton) {
        ArrayList<String> selectedNames = ListDialog.showDialog(this, selectIndividualsButton,
                "All the individuals in the data set: ( hold Ctrl key to select multiple objects)",
                "Select individuals: ", individualNames, selectedIndividualIndicesForDv, "Index 1234567890");
        selectedIndividualIndicesForDv = getSelectedIndices(selectedNames);
        ArrayList<Trajectory> trajs = getSelectedTrajectories(selectedIndividualIndicesForDv);
        updateTimeSpanRange(trajs);
    }

    if (e.getSource() == saveKmlButton) {
        String selectedDatasetName = curSelectedDatasetName;
        String displayMethod = (String) displayMethodCombo.getSelectedItem();
        String gap = (String) gapCombo.getSelectedItem();
        String thresGap = (String) thresGapCombo.getSelectedItem();
        String numRound = (String) numRoundCombo.getSelectedItem();
        String distThres = distThresTextedField.getText();
        boolean needInterpolation = this.interpFlag;

        MiningFunctionParameters params = new MiningFunctionParameters();
        params.setSelectedDatasetName(selectedDatasetName);
        params.setSelectedFunction(selectedFunction);
        params.setDisplayMethod(displayMethod);
        params.setNeedInterpolation(needInterpolation);
        params.setGap(gap);
        params.setThresGap(thresGap);
        params.setNumRound(numRound);
        params.setDistThres(distThres);

        params.setStartTime(selectStartTimePicker.getDate());
        params.setEndTime(selectEndTimePicker.getDate());
        DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HHmmss");
        //get current date time with Date()
        Date date = new Date();
        String outputPath = "result/" + "Plot_"
                + params.getSelectedDatasetName().substring(0, 4).replace(" ", "_") + "_"
                + dateFormat.format(date) + "/";
        new File(outputPath).mkdirs();
        ArrayList<Trajectory> trajs = getSelectedTrajectories(selectedIndividualIndicesForDv);
        List<Trajectory> subTrajs = getSubTrajectory(trajs, selectStartTimePicker.getDate(),
                selectEndTimePicker.getDate());
        JFrame computeKML = new GenerateKMLFile(trajsMap, params, outputPath, subTrajs);
        computeKML.setVisible(true);
    }
}

From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java

/**
 * Creates a new load profile configuration. This method is registered on the {@link EventBus}
 * and called when the specified event is posted.
 * //www  .ja  v  a 2s  .c om
 * @param e
 *            the event that triggers calling of this method when posted on the event bus
 */
@Subscribe
public void openSettingsDialog(final ToolsSettingsAction.Event e) {
    if (checkLoadProfileEntityDirty() && checkLoadProfilePropertiesDirty()) {
        Cursor oldCursor = getCursor();
        SettingsDialog dlg = new SettingsDialog(AppFrame.this, configController);
        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            dlg.setLocationRelativeTo(AppFrame.this);
            dlg.setVisible(true);

            if (dlg.getModalResult() == ModalResult.OK) {
                boolean oldDirty = dirty;

                updateLists();
                ModelUtils.updateTargetDecorators(decoratedTargets, oneTimeDecoratedTargets,
                        loadProfilesController.getTargets(), true);
                loadProfilesController.updateTreeItems();
                expandTree();

                tblClients.repaint();
                tblTargets.repaint();
                if (activeLoadProfileEntityPanel != null) {
                    activeLoadProfileEntityPanel.repaint();
                }
                dirty = oldDirty;
            }
        } finally {
            setCursor(oldCursor);
        }
    }
}