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.nuclos.client.main.MainController.java

/**
 * the main frame is about to close/*from   w ww  .  ja  va 2s  . c om*/
 */
public void cmdWindowClosing(final ResultListener<Boolean> rl) {
    allControllersMayBeClosed(new ResultListener<Boolean>() {
        @Override
        public void done(Boolean result) {
            if (Boolean.TRUE.equals(result)) {
                getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                try {

                    getMainFrame().writeMainFramePreferences(prefs);
                    getRestoreUtils().storeWorkspace(getMainFrame().getWorkspace());

                    LocalUserCaches.getInstance().store();

                    if (ctlTasks != null) {
                        ctlTasks.close();
                    } else {
                        LOG.debug("TaskController is null!");
                    }

                    LOG.debug("removes unused preferences...");
                    removeUnusedPreferences();

                    closeAllControllers();
                } catch (Exception ex) {
                    final String sMessage = getSpringLocaleDelegate().getMessage("MainController.20",
                            "Die Sitzungsdaten, die Informationen \u00fcber die zuletzt ge\u00f6ffneten Fenster enthalten,\n"
                                    + "konnten nicht geschrieben werden. Bei der n\u00e4chsten Sitzung k\u00f6nnen nicht alle Fenster\n"
                                    + "wiederhergestellt werden. Bitte \u00f6ffnen Sie diese Fenster in der n\u00e4chsten Sitzung erneut.");
                    Errors.getInstance().showExceptionDialog(getMainFrame(), sMessage, ex);
                } catch (Error error) {
                    LOG.error("Beim Beenden des Clients ist ein fataler Fehler aufgetreten.", error);
                } finally {
                    // exit even on <code>Error</code>s, especially <code>NoClassDefFoundError</code>s,
                    // which may result from installing a different version while a client is running.
                    cmdExit();
                }

                rl.done(true);
            } else {
                rl.done(false);
            }
        }
    });
}

From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java

@SuppressWarnings("rawtypes")
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {

            QueryMasterData ndata = (QueryMasterData) node.getUserObject();
            Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ",
                    "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null,
                    ndata.name().substring(0, ndata.name().indexOf("[") - 1));

            if (inputValue != null) {
                String newQueryName = (String) inputValue;
                String requestXml = ndata.writeRenameQueryXML(newQueryName);

                setCursor(new Cursor(Cursor.WAIT_CURSOR));

                String response = null;
                if (System.getProperty("webServiceMethod").equals("SOAP")) {
                    // TO DO
                    // response =
                    // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
                } else {
                    response = QueryListNamesClient.sendQueryRequestREST(requestXml, true);
                }/*from www.ja v  a  2s.  co  m*/

                if (response.equalsIgnoreCase("CellDown")) {
                    final JPanel parent = this;
                    java.awt.EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            JOptionPane.showMessageDialog(parent,
                                    "Trouble with connection to the remote server, "
                                            + "this is often a network error, please try again",
                                    "Network Error", JOptionPane.INFORMATION_MESSAGE);
                        }
                    });
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    return;
                }

                if (response != null) {
                    JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();

                    try {
                        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                        StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                        String status = statusType.getType();

                        if (status.equalsIgnoreCase("DONE")) {
                            // XMLGregorianCalendar cldr =
                            // //queryMasterType.getCreateDate();
                            Calendar cldr = Calendar.getInstance(Locale.getDefault());
                            ndata.name(newQueryName + " [" + addZero(cldr.get(Calendar.MONTH) + 1) + "-"
                                    + addZero(cldr.get(Calendar.DAY_OF_MONTH)) + "-"
                                    + addZero(cldr.get(Calendar.YEAR)) + " ]" + " [" + ndata.userId() + "]");
                            // ndata.name(newQueryName + " [" +
                            // ndata.userId()
                            // + "]");
                            node.setUserObject(ndata);
                            // DefaultMutableTreeNode parent =
                            // (DefaultMutableTreeNode) node.getParent();

                            jTree1.repaint();
                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) {

            QueryResultData rdata = (QueryResultData) node.getUserObject();
            // if(!rdata.type().equalsIgnoreCase("PatientSet")) {
            // return;
            // }

            Object inputValue1 = JOptionPane.showInputDialog(this, "Rename this to: ", "Renaming Dialog",
                    JOptionPane.PLAIN_MESSAGE, null, null, rdata.name());
            // .substring(0, rdata.name().lastIndexOf("[") - 1));

            if (inputValue1 != null) {
                String newQueryName = (String) inputValue1;
                String requestXml = rdata.writeRenameQueryXML(newQueryName);

                setCursor(new Cursor(Cursor.WAIT_CURSOR));

                String response = null;
                if (System.getProperty("webServiceMethod").equals("SOAP")) {
                    // TO DO
                    // response =
                    // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
                } else {
                    response = QueryListNamesClient.sendQueryRequestREST(requestXml, true);
                }

                if (response.equalsIgnoreCase("CellDown")) {
                    final JPanel parent = this;
                    java.awt.EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            JOptionPane.showMessageDialog(parent,
                                    "Trouble with connection to the remote server, "
                                            + "this is often a network error, please try again",
                                    "Network Error", JOptionPane.INFORMATION_MESSAGE);

                        }
                    });
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    return;
                }

                if (response != null) {
                    JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();

                    try {
                        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                        StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                        String status = statusType.getType();

                        if (status.equalsIgnoreCase("DONE")) {
                            rdata.name(newQueryName);// + " [" +
                            // rdata.userId()
                            // + "]");
                            node.setUserObject(rdata);
                            // DefaultMutableTreeNode parent =
                            // (DefaultMutableTreeNode) node.getParent();

                            jTree1.repaint();
                        } else {
                            final String tmp = response;
                            final JPanel parent = this;
                            java.awt.EventQueue.invokeLater(new Runnable() {
                                public void run() {
                                    JOptionPane.showMessageDialog(parent,
                                            "Error message delivered from the remote server, "
                                                    + "you may wish to retry your last action",
                                            "Server Error", JOptionPane.INFORMATION_MESSAGE);
                                    log.error(tmp);
                                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                                }

                            });

                            return;
                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    } else if (e.getActionCommand().equalsIgnoreCase("Cancel")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {
            DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node.getFirstChild();
            if (node1.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent, "Please expand this node then try to cancel it.",
                                "Message", JOptionPane.INFORMATION_MESSAGE);

                    }
                });
                return;
            }
            QueryInstanceData rdata = (QueryInstanceData) node1.getUserObject();

            String requestXml = rdata.writeCancelQueryXML();

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml, true);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);

                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();
                    final JPanel parent = this;
                    if (status.equalsIgnoreCase("DONE")) {
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent, "The query is finished.", "Message",
                                        JOptionPane.INFORMATION_MESSAGE);
                                // log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });
                        rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" +
                        // rdata
                        // .userId()
                        // + "]");
                        node.setUserObject(rdata);
                        // DefaultMutableTreeNode parent =
                        // (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    } else {
                        final String tmp = response;
                        // final JPanel parent = this;
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent,
                                        "Error message delivered from the remote server, "
                                                + "you may wish to retry your last action",
                                        "Server Error", JOptionPane.INFORMATION_MESSAGE);
                                log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });

                        return;
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                // }
            }
        } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) {

            QueryInstanceData rdata = (QueryInstanceData) node.getUserObject();

            String requestXml = rdata.writeCancelQueryXML();

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml, true);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);

                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();
                    final JPanel parent = this;
                    if (status.equalsIgnoreCase("DONE")) {
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent, "The query is finished.", "Message",
                                        JOptionPane.INFORMATION_MESSAGE);
                                // log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });
                        rdata.name(rdata.name().substring(0, rdata.name().indexOf("-")));// + " [" +
                        // rdata
                        // .userId()
                        // + "]");
                        node.setUserObject(rdata);
                        // DefaultMutableTreeNode parent =
                        // (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    } else {
                        final String tmp = response;
                        // final JPanel parent = this;
                        java.awt.EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                JOptionPane.showMessageDialog(parent,
                                        "Error message delivered from the remote server, "
                                                + "you may wish to retry your last action",
                                        "Server Error", JOptionPane.INFORMATION_MESSAGE);
                                log.error(tmp);
                                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                            }

                        });

                        return;
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                // }
            }
        } else {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                    JOptionPane.showMessageDialog(parent, "Cancel action is not supported on this level",
                            "Message", JOptionPane.INFORMATION_MESSAGE);
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                }

            });
        }
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            // System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = null;
            if (System.getProperty("webServiceMethod").equals("SOAP")) {
                // TO DO
                // response =
                // QueryListNamesClient.sendQueryRequestSOAP(requestXml);
            } else {
                response = QueryListNamesClient.sendQueryRequestREST(requestXml, true);
            }

            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            if (response != null) {
                JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        // jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = "";
        if (isManager) {
            status = loadPreviousQueries(true);
        } else {
            status = loadPreviousQueries(false);
        }
        loadPatientSets();
        if (status.equalsIgnoreCase("")) {
            reset(200, false, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

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

private void formatCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
    int row = getSelectedMessageIndex();

    if (row >= 0) {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable.getPathForRow(row)
                .getLastPathComponent();
        Long messageId = messageNode.getMessageId();
        Integer metaDataId = messageNode.getMetaDataId();

        Message message = messageCache.get(messageId);
        ConnectorMessage connectorMessage;

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

        updateDescriptionMessages(connectorMessage);

        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }//from  w  w w  .  j a  va  2s.  c o  m
}

From source file:org.domainmath.gui.MainFrame.java

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    MainFrame.octavePanel.start();//w w  w  . ja va  2s  .  c o m

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,
            Locale.getDefault());

    String t = "# -- " + formatter.format(new Date()) + " -- #";

    histArea.append(t + "\n");

    String path = Character.toString('"') + System.getProperty("user.dir") + File.separator + "scripts"
            + Character.toString('"');

    MainFrame.octavePanel.evaluate("addpath(genpath(" + path + "));savepath();");
    MainFrame.octavePanel.evaluate("DomainMath_OctavePaths('" + parent_root + "DomainMath_OctavePaths.dat');");

    MainFrame.octavePanel
            .evaluate("DomainMath_OctavePackages('" + parent_root + "DomainMath_OctavePackages.dat');");
    MainFrame.octavePanel
            .evaluate("DomainMath_OctaveVariables('" + parent_root + "DomainMath_OctaveVariables.dat',whos);");
    // MainFrame.workspace.reload();
    MainFrame.octavePanel
            .evaluate("DomainMath_OctaveConfig('" + parent_root + "DomainMath_OctaveConfig.dat');");

    String f = System.getProperty("user.dir") + File.separator + "cache" + File.separator + "pkg_list.xml";
    MainFrame.octavePanel.evaluate("DomainMath_PkgContents('" + f + "');");

    loadLayout();
    MainFrame.reloadWorkspace();
    loadPackageAuto();
    setDirComboContent();
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    new ModuleLoader().load(this, false);
    DMILogger.msg("DMI is Ready.");
}

From source file:stainingestimation.StainingEstimation.java

@Override
public void updateOptionsToTMAspot(TMAspot visible_TMAspot, List<TMAspot> selected_TMAspots) {
    if (isShowing()) {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        updateOptionsToTMAspot(visible_TMAspot);
        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }//from w ww  .j  av a  2s.  c  om
}

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

/**
 * This method initializes jButton   // w  ww  .  ja v a 2 s. c o m
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButton() {
    if (jButton == null) {
        jButton = new JButton("Save");
        if (specimen.isStateDone()) {
            jButton.setEnabled(false);
            jButton.setText("Migrated " + specimen.getLoadFlags());
        }
        jButton.setMnemonic(KeyEvent.VK_S);
        jButton.setToolTipText(
                "Save changes to this record to the database.  No fields should have red backgrounds before you save.");
        jButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    thisPane.getParent().getParent().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                } catch (Exception ex) {
                    log.error(ex);
                }

                save();

                ((CollectorTableModel) jTableCollectors.getModel()).fireTableDataChanged();
                ((NumberTableModel) jTableNumbers.getModel()).fireTableDataChanged();

                try {
                    thisPane.getParent().getParent()
                            .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                } catch (Exception ex) {
                    log.error(ex);
                }
            }
        });
    }
    return jButton;
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public void showWaitCursor(boolean show) {
    Frame frame = getFrame();//from w ww .j av a2s.  c o  m
    if (frame == null)
        return;
    if (show)
        frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    else
        frame.setCursor(Cursor.getDefaultCursor());
}

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

/**
 * creates a new docSearcher index/* ww w.j a  va 2s.c  om*/
 *
 * @param di
 *            DocSearcherIndex
 * @param isCdRomIndx
 *            is CDROM index
 * @throws IOException
 *             IO problem
 */
private void createNewIndex(DocSearcherIndex di, boolean isCdRomIndx) throws IOException {
    setStatus(I18n.getString("indexing") + " (" + di.getIndexPath() + ") ");
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    checkDefaults();
    StringBuffer failedBuf = new StringBuffer();
    String indexDirNew = di.getIndexPath();
    File indexFolder = new File(indexDirNew);
    long curFileSizeBytes = 0;
    int addedSuccessfully = 0;
    StringBuilder noRobotsBuf = new StringBuilder();
    noRobotsBuf.append('\n').append(I18n.getString("files_not_indexed_robot"));
    int numNoIndex = 0;
    boolean newIndex = false;
    if (!indexFolder.exists()) {
        setStatus(indexDirNew + " " + I18n.getString("lower_not_exist"));
        indexFolder.mkdir();
        newIndex = true;
    }
    // BUILD THE INDEX
    File contentFolder = new File(di.getPath());
    int totalFolders = 1;
    int totalFiles = 0;
    int numErrors = 0;
    // String urlStr = "";
    // String dateStr = "";
    // File tempDFile;
    int curSize = 1;
    if (contentFolder.exists()) {
        ArrayList<String> folderList = new ArrayList<String>();
        folderList.add(di.getPath()); // add in our contentDir
        String curFolderString = di.getPath();
        String[] filesString;
        String[] foldersString;
        File curFolderFile;
        int curItemNo = 0;
        int lastItemNo = 0;
        int numFiles = 0;
        int numFolders = 0;
        int curSubNum = 0;
        int startSubNum = Utils.countSlash(di.getPath());
        int maxSubNum = startSubNum + di.getDepth();
        // creating the index
        IndexWriter writer = new IndexWriter(indexDirNew, new StandardAnalyzer(), newIndex);
        // writer.setUseCompoundFile(true);
        do {
            // create our folder file
            curFolderString = folderList.get(curItemNo);
            curFolderFile = new File(curFolderString);
            curSubNum = Utils.countSlash(curFolderString);
            try {
                // handle any subfolders --> add them to our folderlist
                foldersString = curFolderFile.list(ff);
                numFolders = foldersString.length;
                for (int i = 0; i < numFolders; i++) {
                    // add them to our folderlist
                    String curFold = curFolderString + pathSep + foldersString[i] + pathSep;
                    curFold = Utils.replaceAll(pathSep + pathSep, curFold, pathSep);
                    folderList.add(curFold);
                    lastItemNo++;
                    totalFolders++;
                    // debug output
                    setStatus(dsFndFldr + " " + curFold);
                }
                // end for having more than 0 folder
            } catch (Exception e) {
                logger.fatal("createNewIndex() failed", e);
                setStatus(curFolderString + " : " + e.toString());
            }

            // add our files
            try {
                filesString = curFolderFile.list(wf);
                numFiles = filesString.length;
                logger.info("createNewIndex() Indexing " + numFiles + " files...");
                for (int i = 0; i < numFiles; i++) {
                    // add them to our folderlist
                    String curFi = curFolderString + pathSep + filesString[i];
                    curFi = Utils.replaceAll(pathSep + pathSep, curFi, pathSep);
                    curFileSizeBytes = FileUtils.getFileSize(curFi);
                    if (curFileSizeBytes > getMaxFileSize()) {
                        setStatus(I18n.getString("skipping_file_too_big") + " (" + curFileSizeBytes + ") "
                                + filesString[i]);
                    } else { // file size is not too big
                        setStatus(I18n.getString("please_wait...") + " " + curFi + " # " + curSize);
                        curSize++;
                        addedSuccessfully = idx.addDocToIndex(curFi, writer, di, isCdRomIndx, null);
                        switch (addedSuccessfully) {
                        case 1: // error
                            numErrors++;
                            if (numErrors < 8) {
                                failedBuf.append('\n').append(curFi);
                            }
                            break;
                        case 2: // meta robots = noindex
                            numNoIndex++;
                            if (numNoIndex < 8) {
                                noRobotsBuf.append('\n').append(curFi);
                            }
                            break;
                        default: // OK
                            totalFiles++;
                            break;
                        } // end of switch
                    } // end for not skipping, file size is not too big
                }
                // end for files
            }
            // end of trying to get files
            catch (Exception e) {
                logger.error("createNewIndex() failed", e);
                setStatus(I18n.getString("error") + " " + e.toString());
            }
            // increment our curItem
            folderList.set(curItemNo, null); // remove memory overhead as
            // you go!
            curItemNo++;
            if (curSubNum >= maxSubNum) {
                break;
            }
        } while (curItemNo <= lastItemNo);

        writer.close(); // close the writer
        indexes.add(di);
    } else {
        hasErr = true;
        errString = fEnv.getContentDirectory() + " " + I18n.getString("lower_not_exist");
    }
    // end for content dir Missing
    if (hasErr) {
        showMessage(I18n.getString("error_creating_index"), errString);
    } else {
        StringBuilder resultsBuf = new StringBuilder();
        resultsBuf.append(I18n.getString("added_to_index"));
        resultsBuf.append(" \"");
        resultsBuf.append(di.getName());
        resultsBuf.append("\" ");
        resultsBuf.append(totalFiles);
        resultsBuf.append(' ');
        resultsBuf.append(I18n.getString("files_from"));
        resultsBuf.append(' ');
        resultsBuf.append(totalFolders);
        resultsBuf.append(' ');
        resultsBuf.append(I18n.getString("folders"));
        resultsBuf.append("\n\n");
        resultsBuf.append(I18n.getString("starting_in_folder"));
        resultsBuf.append("\n\n\t");
        resultsBuf.append(' ');
        resultsBuf.append(di.getPath());
        resultsBuf.append("\n\n");
        resultsBuf.append(I18n.getString("for_a_depth_of"));
        resultsBuf.append(' ');
        resultsBuf.append(di.getDepth());
        resultsBuf.append('.');

        if (numErrors > 0) {
            resultsBuf.append('\n');
            resultsBuf.append(numErrors);
            resultsBuf.append(' ');
            resultsBuf.append(I18n.getString("files_not_indexed")).append('.');
            resultsBuf.append(failedBuf);
        }

        if (numNoIndex > 0) {
            resultsBuf.append("\n\n" + numNoIndex);
            resultsBuf.append('\n');
            resultsBuf.append(I18n.getString("files_not_indexed_robot"));
            resultsBuf.append(noRobotsBuf);
        }

        showMessage(dsIdxCrtd, resultsBuf.toString());
    }

    setStatus(dsIdxCrtd);
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:v800_trainer.JCicloTronic.java

private void Histogramm_PanelComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_Histogramm_PanelComponentShown
    // Add your handling code here:
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (SelectionChanged) {
        Statistik_PanelComponentShown_StatistikStarten(evt);
        Update_Graphik_paint = true;/*from w w  w. j  av a 2 s .  c  o  m*/
        Update_Map_paint = true;
        alteAuswahl = -2;
    }

    if (Auswahl_Histogramm.getSelectedIndex() == 0) {
        Summenhistogramm_Check.setEnabled(true);
    } else {
        Summenhistogramm_Check.setEnabled(false);
    }

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

}

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

private void deleteRecursive(String folderToDelete) {
    int curFoldNum = 0;
    File curFolderFile;//  w  ww  . ja v  a 2 s  .  c  o  m
    String curFold = "";
    String[] subFolds;
    int numSubFolds = 0;
    int totalFolds = 0;
    int numFiles = 0;
    String curFolderString = "";
    String curFileString = "";
    File testFile;
    try {
        // first obtain a list of all folders
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        ArrayList<String> allFold = new ArrayList<String>();
        allFold.add(folderToDelete);
        setStatus(dsRmvgIdxFis);
        do {
            // get list of sub folders
            curFolderString = allFold.get(curFoldNum);
            curFolderFile = new File(curFolderString);
            subFolds = curFolderFile.list(ff);
            numSubFolds = subFolds.length;
            for (int y = 0; y < numSubFolds; y++) {
                curFold = curFolderString + pathSep + subFolds[y] + pathSep;
                curFold = Utils.replaceAll(pathSep + pathSep, curFold, pathSep);
                allFold.add(curFold);
                totalFolds++;
            }
            curFoldNum++;
        } while (curFoldNum < totalFolds);
        // next get a list of all files
        ArrayList<String> allFiles = new ArrayList<String>();
        Iterator<String> foldIt = allFold.iterator();
        String[] filesString;
        while (foldIt.hasNext()) {
            curFolderString = foldIt.next();
            curFolderFile = new File(curFolderString);
            // get the files
            filesString = curFolderFile.list();
            numFiles = filesString.length;
            for (int y = 0; y < numFiles; y++) {
                // add the files
                curFileString = curFolderString + pathSep + filesString[y];
                curFileString = Utils.replaceAll(pathSep + pathSep, curFileString, pathSep);
                testFile = new File(curFileString);
                if (!testFile.isDirectory()) {
                    allFiles.add(curFileString);
                }
            }
        }
        // end for iterating
        // delete all files
        Iterator<String> fileIt = allFiles.iterator();
        while (fileIt.hasNext()) {
            curFileString = fileIt.next();
            testFile = new File(curFileString);
            testFile.delete();
        }
        // end while deleteing
        // delete all folders
        int numFoldTotal = allFiles.size();
        for (int y = numFoldTotal - 1; y >= 0; y--) {
            curFolderString = allFiles.get(y);
            curFolderFile = new File(curFolderString);
            logger.info("deleteRecursive() " + I18n.getString("deleting") + " " + curFolderString);
            curFolderFile.delete();
        }
        // delete last folder
        curFolderFile = new File(folderToDelete);
        curFolderFile.delete();
    }
    // end for trrying recursive delete
    catch (Exception e) {
        showMessage(I18n.getString("error"), e.toString());
    } finally {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        setStatus(I18n.getString("index_removed"));
    }
}