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:us.daveread.basicquery.BasicQuery.java

/**
 * Executes the query(ies). It is expected that this will be
 * run on its own thread -- hence it is a run method.
 *///from w  w w .j  a va 2s. c  o  m
public void run() {

    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    (flashRunIndicator = new Thread(
            new FlashForeground(runIndicator, Color.red.brighter(), Color.lightGray, 5))).start();
    (timeRunIndicator = new Thread(new InsertTime(timeIndicator, new java.util.Date().getTime(),
            QUERY_EXECUTION_TIMER_UPDATE_DELAY_MS))).start();
    try {
        if (runType == RUNTYPE_ALL) {
            runAllQueries();
        } else if (runType == RUNTYPE_TRIPLE_EXPORT) {
            message.setText("");
            messageOut(Resources.getString("msgStartExportToFile", exportFile.getAbsolutePath()), STYLE_BOLD);
            messageOut("");
            execute(getQuery().getSql(), new ListTableModel<Object>(), exportFile);
        } else {
            checkForNewString(querySelection);
            checkForNewString(connectString);
            processStatement();
        }
    } catch (Throwable any) {
        LOGGER.error("Failure while trying to execute query", any);
        messageOut(Resources.getString("errFailSQLText", any.getMessage()), STYLE_RED);
    }
    flashRunIndicator.interrupt();
    flashRunIndicator = null;
    timeRunIndicator.interrupt();
    timeRunIndicator = null;
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Executes all the queries/*from  www  . j a v a2s  .c o  m*/
 */
private void runAllQueries() {
    int numExecutions, numQueries;
    int execution, query;
    ProgressMonitor monitor;
    boolean canceled;
    java.util.Date start;
    int elapsed;
    long remaining;
    int hours, minutes, seconds;

    numQueries = querySelection.getModel().getSize();
    try {
        numExecutions = Integer
                .parseInt(JOptionPane.showInputDialog(this, Resources.getString("dlgAllQueriesText"),
                        Resources.getString("dlgAllQueriesTitle"), JOptionPane.QUESTION_MESSAGE));
    } catch (Exception any) {
        numExecutions = 0;
    }

    messageOut(Resources.getString("msgNumExecutions", numExecutions + ""));

    monitor = new ProgressMonitor(this, Resources.getString("dlgRunAllQueriesProgressTitle"),
            Resources.getString("dlgRunAllQueriesProgressNote", "0", numExecutions + "", "0", numQueries + ""),
            0, numQueries * Math.abs(numExecutions));

    getContentPane().setCursor(new Cursor(Cursor.WAIT_CURSOR));

    if (numExecutions < 0) {
        numExecutions = Math.abs(numExecutions);

        for (query = 0; !monitor.isCanceled() && query < numQueries; ++query) {
            querySelection.setSelectedIndex(query);
            elapsed = -1;
            for (execution = 0; !monitor.isCanceled() && execution < numExecutions; ++execution) {
                monitor.setProgress(query * numExecutions + execution);
                if (elapsed <= 0) {
                    monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "",
                            numExecutions + "", (query + 1) + "", numQueries + ""));
                } else {
                    remaining = elapsed
                            * ((numExecutions * (numQueries - (query + 1))) + (numExecutions - execution));
                    hours = (int) (remaining / SECONDS_PER_HOUR);
                    remaining -= hours * SECONDS_PER_HOUR;
                    minutes = (int) (remaining / SECONDS_PER_MINUTE);
                    remaining -= minutes * SECONDS_PER_MINUTE;
                    seconds = (int) remaining;

                    monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNoteWithRemainTime",
                            (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "",
                            Utility.formattedNumber(hours, "00"), Utility.formattedNumber(minutes, "00"),
                            Utility.formattedNumber(seconds, "00")));
                }
                messageOut(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "",
                        numExecutions + "", (query + 1) + "", numQueries + ""));
                start = new java.util.Date();
                processStatement(true);
                elapsed = (int) ((new java.util.Date().getTime() - start.getTime()) / 1000);
            }
        }
    } else {
        elapsed = -1;
        for (execution = 0; !monitor.isCanceled() && execution < numExecutions; ++execution) {
            start = new java.util.Date();
            for (query = 0; !monitor.isCanceled() && query < numQueries; ++query) {
                querySelection.setSelectedIndex(query);
                monitor.setProgress(execution * numQueries + query);

                if (elapsed <= 0) {
                    monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "",
                            numExecutions + "", (query + 1) + "", numQueries + ""));
                } else {
                    remaining = elapsed * (numExecutions - execution);
                    hours = (int) (remaining / SECONDS_PER_HOUR);
                    remaining -= hours * SECONDS_PER_HOUR;
                    minutes = (int) (remaining / SECONDS_PER_MINUTE);
                    remaining -= minutes * SECONDS_PER_MINUTE;
                    seconds = (int) remaining;

                    monitor.setNote(Resources.getString("dlgRunAllQueriesProgressNoteWithRemainTime",
                            (execution + 1) + "", numExecutions + "", (query + 1) + "", numQueries + "",
                            Utility.formattedNumber(hours, "00"), Utility.formattedNumber(minutes, "00"),
                            Utility.formattedNumber(seconds, "00")));
                }

                messageOut(Resources.getString("dlgRunAllQueriesProgressNote", (execution + 1) + "",
                        numExecutions + "", (query + 1) + "", numQueries + ""));
                processStatement(true);
            }
            elapsed = (int) ((new java.util.Date().getTime() - start.getTime()) / 1000);
        }
    }

    canceled = monitor.isCanceled();

    monitor.close();

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

    if (canceled) {
        userMessage(Resources.getString("dlgExecutionsCanceledText"),
                Resources.getString("dlgExecutionsCanceledTitle"), JOptionPane.WARNING_MESSAGE);
    } else if (numExecutions != 0) {
        userMessage(Resources.getString("dlgExecutionsCompletedText"),
                Resources.getString("dlgExecutionsCompletedTitle"), JOptionPane.INFORMATION_MESSAGE);
    } else {
        userMessage(Resources.getString("dlgExecutionsNoneText"), Resources.getString("dlgExecutionsNoneTitle"),
                JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:base.BasePlayer.Main.java

@Override
public void mousePressed(MouseEvent event) {
    //if(Logo.frame.isVisible()) {
    //   frame.requestFocus();
    //   }//from w  w  w .j a va  2 s  . c  o  m
    //   Logo.frame.setVisible(false);
    mouseX = event.getX();

    if (event.getSource() == refDropdown) {
        switch (event.getModifiers()) {
        case InputEvent.BUTTON1_MASK: {
            if (Main.genomehash.size() == 0) {
                if (AddGenome.frame == null) {
                    AddGenome.createAndShowGUI();
                }
                AddGenome.frame.setTitle("Add new genome");
                AddGenome.annotation = false;
                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);

                AddGenome.frame.setState(JFrame.NORMAL);
            }
            rightclick = false;
            break;
        }
        case InputEvent.BUTTON3_MASK: {
            rightclick = true;
            break;
        }
        }
    } else if (event.getSource() == geneDropdown) {
        switch (event.getModifiers()) {
        case InputEvent.BUTTON1_MASK: {
            if (Main.genomehash.size() == 0) {
                if (AddGenome.frame == null) {
                    AddGenome.createAndShowGUI();
                }
                AddGenome.frame.setTitle("Add new genome");
                AddGenome.annotation = false;
                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);

                AddGenome.frame.setState(JFrame.NORMAL);
            }
            rightclick = false;
            break;
        }
        case InputEvent.BUTTON3_MASK: {
            rightclick = true;
            break;
        }
        }
    } else if (event.getSource() == chromlabel) {
        chromosomeDropdown.showPopup();

    }

    else if (event.getSource() == splitPaneDivider) {
        Main.vardivider = bedCanvas.nodeImage.getHeight() / (double) varPaneDivider.getY();

        //      Main.bedCanvas.resize = true;
    } else if (event.getSource() == varPaneDivider) {
        //      Main.bedCanvas.resize = true;         
        Main.vardivider = bedCanvas.nodeImage.getHeight() / (double) varPaneDivider.getY();

    } else if (event.getSource() == filemenu) {
        /*if(!filemenu.isSelected()){            
           filemenu.doClick();         
        }
        */
    } else if (event.getSource() == toolmenu) {
        /*if(!toolmenu.isSelected()){            
           toolmenu.doClick();         
        }*/

    } else if (drawCanvas.loadingtext.equals("note")) {
        Main.drawCanvas.loadingtext = "";
        Main.drawCanvas.ready("note");

    }

    else if (event.getSource() == drawScroll.getVerticalScrollBar()) {

        if (Main.glassPane.getCursor().getType() != Cursor.WAIT_CURSOR) {
            Main.glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
        Draw.setGlasspane(true);

    } else if (event.getSource() == searchField) {
        searchField.requestFocus();
        searchField.setForeground(Color.black);
        if (searchField.getText().contains("Search by")) {
            searchField.setText("");
        }

    } else if (event.getSource() == addGenome) {
        if (AddGenome.frame == null) {
            AddGenome.createAndShowGUI();
        }
        AddGenome.frame.setTitle("Add new genome");
        AddGenome.annotation = false;
        AddGenome.remove.setEnabled(false);
        AddGenome.download.setEnabled(false);
        AddGenome.frame.setVisible(true);
        AddGenome.frame.setLocation(
                frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                frame.getLocationOnScreen().y + frame.getHeight() / 6);
        AddGenome.frame.setState(JFrame.NORMAL);

    } else if (event.getComponent().getName() != null) {
        if (event.getComponent().getName().equals("frame0")) {
            return;
        }

        try {
            if (event.getComponent().getName().equals("add_annotation")) {
                if (AddGenome.frame == null) {
                    AddGenome.createAndShowGUI();
                }
                AddGenome.annotation = true;
                AddGenome.frame.setTitle("Add new annotation file for " + Main.selectedGenome);
                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setLocation(
                        frame.getLocationOnScreen().x + frame.getWidth() / 2 - AddGenome.frame.getWidth() / 2,
                        frame.getLocationOnScreen().y + frame.getHeight() / 6);
                AddGenome.genomeName.setText(hoverGenome);
                return;
            }

            if (hoverAnnotation.length() > 0) {
                for (int j = 0; j < genomehash.get(hoverGenome).size(); j++) {
                    if (genomehash.get(hoverGenome).get(j).getName().contains(hoverAnnotation)) {
                        annotationfile = genomehash.get(hoverGenome).get(j).getName();
                        Main.annotation = j;
                        break;
                    }
                }

                defaultGenome = hoverGenome;

                setChromDrop(defaultGenome);
                getBands();
                if (genomehash.get(defaultGenome).size() > 0
                        && genomehash.get(defaultGenome).get(annotation) != null) {

                    changeAnnotation(annotation);

                }
                //drawCanvas.chrom = chromosomeDropdown.getItemAt(0);
                chromosomeDropdown.setSelectedIndex(0);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}