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:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#onDataObjectSave(DataObject, DataObject, int)
 *//* ww  w . ja  v  a  2 s . c o m*/
public void onDataObjectSave(DataObject data, DataObject parent, int operation) {
    int state = model.getState();
    if (operation == REMOVE_OBJECT && state != SAVE)
        throw new IllegalStateException("This method can only be " + "invoked in the SAVE state");
    switch (state) {
    case DISCARDED:
        throw new IllegalStateException("This method cannot be " + "invoked in the DISCARDED state");
    }
    if (data == null)
        throw new IllegalArgumentException("No data object. ");
    switch (operation) {
    case CREATE_OBJECT:
    case UPDATE_OBJECT:
    case REMOVE_OBJECT:
        break;
    default:
        throw new IllegalArgumentException("Save operation not " + "supported.");
    }
    //removeEditor(); //remove the currently selected editor.
    if (operation == REMOVE_OBJECT) {
        model.setState(READY);
        fireStateChange();
    }
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    Browser browser = null;
    if (operation == CREATE_OBJECT) {
        if (parent == null) {
            if ((data instanceof ProjectData) || (data instanceof DatasetData))
                browser = model.getBrowser(Browser.PROJECTS_EXPLORER);
            else if (data instanceof ScreenData)
                browser = model.getBrowser(Browser.SCREENS_EXPLORER);
            else if (data instanceof TagAnnotationData)
                browser = model.getBrowser(Browser.TAGS_EXPLORER);
        }
        if (browser != null) {
            model.setSelectedBrowser(browser);
            view.addBrowser(browser);
            removeEditor();
        }
    }
    browser = model.getSelectedBrowser();
    if (browser != null && operation != UPDATE_OBJECT)
        browser.refreshTree(null, null);
    if (operation == REMOVE_OBJECT || operation == CREATE_OBJECT) {
        DataBrowserFactory.discardAll();
        view.removeAllFromWorkingPane();
    }
    if (operation == UPDATE_OBJECT && browser != null) {
        browser.accept(new UpdateVisitor(browser, data));
        browser.getUI().repaint();
    }
    setStatus(false, "", true);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:ffx.ui.MainPanel.java

/**
 * Opens a file from the PDB//from  w  w w . j  a v a  2s.  co  m
 */
public void openFromPDB() {
    if (openThread != null && openThread.isAlive()) {
        return;
    }
    String code = JOptionPane.showInputDialog("Enter the PDB Identifier (4 characters)", "");
    if (code == null) {
        return;
    }
    code = code.toLowerCase().trim();
    if (code == null || code.length() != 4) {
        return;
    }
    String fileName = code + ".pdb";
    String path = getPWD().getAbsolutePath();
    File pdbFile = new File(path + File.separatorChar + fileName);
    CompositeConfiguration properties = Keyword.loadProperties(pdbFile);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    FFXSystem newSystem = new FFXSystem(pdbFile, "PDB", properties);
    newSystem.setForceField(forceField);
    if (!pdbFile.exists()) {
        String fromURL = pdbForID(code);
        pdbFile = downloadURL(fromURL);
        if (pdbFile == null || !pdbFile.exists()) {
            return;
        }
    } else {
        String message = String.format(" Reading the local copy of the PDB file %s.", pdbFile);
        logger.info(message);
    }
    PDBFilter pdbFilter = new PDBFilter(pdbFile, newSystem, forceField, properties);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    UIFileOpener openFile = new UIFileOpener(pdbFilter, this);
    if (fileOpenerThreads > 0) {
        openFile.setNThreads(fileOpenerThreads);
    }
    openThread = new Thread(openFile);
    openThread.start();
    setPanel(GRAPHICS);
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#onOrphanDataObjectCreated(DataObject, int)
 *//*w  ww  .j a  v  a  2 s  . com*/
public void onOrphanDataObjectCreated(DataObject data) {
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Browser browser = model.getSelectedBrowser();
    if (browser != null)
        browser.onOrphanDataObjectCreated(data);

    setStatus(false, "", true);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * An action for when a row is selected in the table
 *//*  w  ww . j a  v  a  2  s.c om*/
private void MessageListSelected(ListSelectionEvent evt) {
    if (!evt.getValueIsAdjusting()) {
        int row = getSelectedMessageIndex();

        if (row >= 0) {
            // Cancel all pretty printing tasks
            for (Future<Void> worker : prettyPrintWorkers) {
                worker.cancel(true);
            }
            prettyPrintWorkers.clear();

            parent.setVisibleTasks(parent.messageTasks, parent.messagePopupMenu, 6, 6, true);
            parent.setVisibleTasks(parent.messageTasks, parent.messagePopupMenu, 7, -1, isChannelDeployed);

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

            // Get the table node
            MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable.getPathForRow(row)
                    .getLastPathComponent();

            if (messageNode.isNodeActive()) {
                // Get the messageId from the message node
                Long messageId = messageNode.getMessageId();
                // Get the metaDataId from the message node
                Integer metaDataId = messageNode.getMetaDataId();

                // Attempt to get the message from the message cache
                Message message = messageCache.get(messageId);
                List<Attachment> attachments = attachmentCache.get(messageId);

                // If the message is not in the cache, retrieve it from the server
                if (message == null) {
                    try {
                        message = parent.mirthClient.getMessageContent(channelId, messageId,
                                selectedMetaDataIds);
                        // If the message was not found (ie. it may have been deleted during the request), do nothing
                        if (message == null || message.getConnectorMessages().size() == 0) {
                            clearDescription(
                                    "Could not retrieve message content. The message may have been deleted.");
                            this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                            return;
                        }

                        attachments = parent.mirthClient.getAttachmentsByMessageId(channelId, messageId, false);
                    } catch (Throwable t) {
                        if (t.getMessage().contains("Java heap space")) {
                            parent.alertError(parent,
                                    "There was an out of memory error when trying to retrieve message content.\nIncrease your heap size and try again.");
                        } else if (t instanceof RequestAbortedException) {
                            // The client is no longer waiting for the message content request
                        } else {
                            parent.alertThrowable(parent, t);
                        }
                        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                        return;
                    }
                    // Add the retrieved message to the message cache
                    messageCache.put(messageId, message);
                    attachmentCache.put(messageId, attachments);
                }

                ConnectorMessage connectorMessage = message.getConnectorMessages().get(metaDataId);

                if (connectorMessage != null) {
                    // Update the message tabs
                    updateDescriptionMessages(connectorMessage);
                    // Update the mappings tab
                    updateDescriptionMappings(connectorMessage);
                    // Update the attachments tab
                    updateAttachmentsTable(messageId);
                    // Update the errors tab
                    updateDescriptionErrors(connectorMessage);
                    // Show relevant tabs. Not using errorCode here just in case for some reason there are errors even though errorCode is 0
                    updateDescriptionTabs(connectorMessage.getProcessingError() != null
                            || connectorMessage.getPostProcessorError() != null
                            || connectorMessage.getResponseError() != null, attachments.size() > 0);
                    updateMessageRadioGroup();

                    if (attachmentTable == null || attachmentTable.getSelectedRow() == -1
                            || descriptionTabbedPane.indexOfTab("Attachments") == -1) {
                        parent.setVisibleTasks(parent.messageTasks, parent.messagePopupMenu, 9, 10, false);
                    }
                }
            } else {
                clearDescription(null);
            }

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

        }
    }
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#onDataObjectSave(List, int)
 *//* w  w  w  .  j ava  2s.  com*/
public void onDataObjectSave(List data, int operation) {
    int state = model.getState();
    if (operation == REMOVE_OBJECT && state != SAVE)
        throw new IllegalStateException("This method can only be " + "invoked in the SAVE state");
    switch (state) {
    case DISCARDED:
        throw new IllegalStateException("This method cannot be " + "invoked in the DISCARDED state");
    }
    if (data == null)
        throw new IllegalArgumentException("No data object. ");
    switch (operation) {
    case CREATE_OBJECT:
    case UPDATE_OBJECT:
    case REMOVE_OBJECT:
        break;
    default:
        throw new IllegalArgumentException("Save operation not " + "supported.");
    }
    //removeEditor(); //remove the currently selected editor.
    if (operation == REMOVE_OBJECT) {
        model.setState(READY);
        fireStateChange();
    }
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    setStatus(false, "", true);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#clearFoundResults()/* w  w w . java 2  s . co m*/
 */
public void clearFoundResults() {
    switch (model.getState()) {
    case DISCARDED:
    case SAVE:
        return;
    }
    Browser browser = model.getSelectedBrowser();
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    if (browser != null) {
        browser.accept(new ClearVisitor());
        browser.setFoundInBrowser(null);
    }
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

/**
 * Show Settings Dialog for a specific TabId
 *
 * @param visibleTabId//from   w w  w.j av  a  2s .  c  o  m
 *          Id of the specific Tab
 */
public void showSettingsDialog(final String visibleTabId) {
    if (mSettingsWillBeOpened) {
        return;
    }

    new Thread(new Runnable() {
        public void run() {
            mSettingsWillBeOpened = true;

            // show busy cursor
            Window comp = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
            ProgramTable programTable = MainFrame.getInstance().getProgramTableScrollPane().getProgramTable();
            Cursor oldWindowCursor = comp.getCursor();
            Cursor oldTableCursor = programTable.getCursor();
            comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            programTable.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            SettingsDialog dlg = new SettingsDialog(MainFrame.this, visibleTabId);
            dlg.centerAndShow();

            // restore cursors
            programTable.setCursor(oldTableCursor);
            comp.setCursor(oldWindowCursor);

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    Settings.handleChangedSettings();
                    if (mPluginView != null) {
                        mPluginView.refreshTree();
                    }
                }
            });
            mSettingsWillBeOpened = false;
        }
    }, "Show settings dialog").start();
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#addExistingObjects(DataObject)
 */// w  ww  .jav a  2 s  .  c  om
public void addExistingObjects(DataObject ho) {
    if (model.getState() == DISCARDED)
        throw new IllegalStateException("This method cannot be invoked in the DISCARDED state.");
    if (ho == null)
        throw new IllegalArgumentException("No object.");
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    model.fireDataExistingObjectsLoader(ho);
    fireStateChange();
}

From source file:org.jab.docsearch.DocSearch.java

/**
 * Load properties file./*from  ww w .j ava2 s  .c o  m*/
 *
 * @param propertiesFile
 *            Properties file
 * @return Properties
 */
private Properties loadProperties(String propertiesFile) {
    logger.debug("loadProperties('" + propertiesFile + "') entered");

    // cursor "wait"
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    // read property file
    Properties props = new Properties();
    FileInputStream fileIn = null;
    try {
        File propsFile = new File(propertiesFile);
        if (propsFile.isFile()) {
            fileIn = new FileInputStream(propsFile);
            props.load(fileIn);
        } else {
            logger.error("loadProperties() " + propertiesFile + " isn't a file!");
        }
    } catch (IOException ioe) {
        logger.fatal("loadProperties() failed", ioe);
        showMessage(dsErrLdgFi, "\n" + propertiesFile + "\n\n : " + ioe.toString());
    } finally {
        IOUtils.closeQuietly(fileIn);
    }

    // cursor "default"
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    return props;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#addExistingObjects(Set)
 *///from w  ww  . j av a 2 s. com
public void addExistingObjects(Set set) {
    if (model.getState() != LOADING_SELECTION)
        throw new IllegalStateException("This method cannot be invoked in the LOADING_DATA state.");
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    if (set == null || set.size() == 0)
        model.setState(READY);
    else {
        model.fireAddExistingObjects(set);
    }
    fireStateChange();
}