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.languagetool.gui.ResultArea.java

ResultArea(final ResourceBundle messages, final LanguageToolSupport ltSupport, final JTextPane statusPane) {
    this.messages = messages;
    this.ltSupport = ltSupport;
    this.statusPane = statusPane;
    statusPane.setContentType("text/html");
    statusPane.setText(Main.HTML_GREY_FONT_START + messages.getString("resultAreaText") + Main.HTML_FONT_END);
    statusPane.setEditable(false);//from   ww w. j a va 2 s . c o m
    statusPane.addHyperlinkListener(new MyHyperlinkListener());
    statusPane.setTransferHandler(new RetainLineBreakTransferHandler());
    ltSupport.addLanguageToolListener(new LanguageToolListener() {
        @Override
        public void languageToolEventOccurred(LanguageToolEvent event) {
            if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) {
                final Language lang = ltSupport.getLanguage();
                final String langName;
                if (lang.isExternal()) {
                    langName = lang.getTranslatedName(messages) + Main.EXTERNAL_LANGUAGE_SUFFIX;
                } else {
                    langName = lang.getTranslatedName(messages);
                }
                final String startCheckText = Main.HTML_GREY_FONT_START
                        + Tools.makeTexti18n(messages, "startChecking", langName) + "..." + Main.HTML_FONT_END;
                statusPane.setText(startCheckText);
                setStartText(startCheckText);
                if (event.getCaller() == marker) {
                    statusPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                }
            } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) {
                inputText = event.getSource().getTextComponent().getText();
                setRuleMatches(event.getSource().getMatches());
                if (event.getCaller() == marker || event.getCaller() == null) {
                    displayResult();
                    if (event.getCaller() == marker) {
                        statusPane.setCursor(Cursor.getDefaultCursor());
                    }
                }
            } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED
                    || event.getType() == LanguageToolEvent.Type.RULE_ENABLED) {
                inputText = event.getSource().getTextComponent().getText();
                setRuleMatches(event.getSource().getMatches());
                displayResult();
            }
        }
    });
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.actions.PublishToServerTask.java

public void run() {
    final MasterReport report = reportDesignerContext.getActiveContext().getContextRoot();
    final DocumentMetaData metaData = report.getBundle().getMetaData();

    try {//from  ww w  .  j a  v a2  s  . co  m
        final String oldName = extractLastFileName(report);

        SelectFileForPublishTask selectFileForPublishTask = new SelectFileForPublishTask(uiContext);
        readBundleMetaData(report, metaData, selectFileForPublishTask);

        final String selectedReport = selectFileForPublishTask.selectFile(loginData, oldName);
        if (selectedReport == null) {
            return;
        }

        loginData.setOption("lastFilename", selectedReport);
        storeBundleMetaData(report, selectedReport, selectFileForPublishTask);

        reportDesignerContext.getActiveContext().getAuthenticationStore().add(loginData, storeUpdates);

        final byte[] data = PublishUtil.createBundleData(report);
        int responseCode = PublishUtil.publish(data, selectedReport, loginData);

        if (responseCode == 200) {
            final Component glassPane = SwingUtilities.getRootPane(uiContext).getGlassPane();
            try {
                glassPane.setVisible(true);
                glassPane.setCursor(new Cursor(Cursor.WAIT_CURSOR));

                FileObject fileSystemRoot = PublishUtil.createVFSConnection(loginData);
                final JCRSolutionFileSystem fileSystem = (JCRSolutionFileSystem) fileSystemRoot.getFileSystem();
                fileSystem.getLocalFileModel().refresh();
            } catch (Exception e1) {
                UncaughtExceptionsModel.getInstance().addException(e1);
            } finally {
                glassPane.setVisible(false);
                glassPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            }
            if (JOptionPane.showConfirmDialog(uiContext,
                    Messages.getInstance().getString("PublishToServerAction.Successful.LaunchNow"),
                    Messages.getInstance().getString("PublishToServerAction.Successful.LaunchTitle"),
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                PublishUtil.launchReportOnServer(loginData.getUrl(), selectedReport);
            }
        } else if (responseCode == 403) {
            logger.error("Publish failed. Server responded with status-code " + responseCode);
            JOptionPane.showMessageDialog(uiContext,
                    Messages.getInstance().getString("PublishToServerAction.FailedAccess"),
                    Messages.getInstance().getString("PublishToServerAction.FailedAccessTitle"),
                    JOptionPane.ERROR_MESSAGE);
        } else {
            logger.error("Publish failed. Server responded with status-code " + responseCode);
            showErrorMessage();
        }
    } catch (Exception exception) {
        logger.error("Publish failed. Unexpected error:", exception);
        showErrorMessage();
    }
}

From source file:es.emergya.ui.base.BasicWindow.java

/**
 * Initialize the window with default values.
 *//*from   w  w w  .java  2 s  .c  om*/
private void inicializar() {
    frame = new JFrame(i18n.getString("title")); //$NON-NLS-1$
    getFrame().setBackground(Color.WHITE);
    getFrame().setIconImage(ICON_IMAGE); //$NON-NLS-1$
    getFrame().addWindowListener(new RemoveClientesConectadosListener());

    getFrame().setMinimumSize(new Dimension(900, 600));
    getFrame().addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            resize();
        }

    });

    busyCursor = new Cursor(Cursor.WAIT_CURSOR);
    defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = getImageIcon("/images/hand.gif");
    if (image != null)
        handCursor = toolkit.createCustomCursor(image, new Point(0, 0), "hand"); //$NON-NLS-1$
}

From source file:EditorPaneExample6.java

public EditorPaneExample6() {
    super("JEditorPane Example 6");

    pane = new JEditorPane();
    pane.setEditable(false); // Start read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//from w ww . j  a  va2s.c om
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    c.gridwidth = 2;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    // Add a "Save" button
    saveButton = new JButton("Save");
    saveButton.setEnabled(false);
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 0;
    c.weightx = 0.0;
    panel.add(saveButton, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String fileName = textField.getText().trim();
            file = new File(fileName);
            absolutePath = file.getAbsolutePath();
            String url = "file:///" + absolutePath;

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);

                saveButton.setEnabled(false);
                saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setEditable(false);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");

                textField.setEnabled(true); // Allow entry of new file name
                textField.requestFocus();
                setCursor(Cursor.getDefaultCursor());

                // Allow editing and saving if appropriate
                pane.setEditable(file.canWrite());
                saveButton.setEnabled(file.canWrite());
            }
        }
    });

    // Save button
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                String type = pane.getContentType();
                OutputStream os = new BufferedOutputStream(new FileOutputStream(file + ".save"));
                pane.setEditable(false);
                textField.setEnabled(false);
                saveButton.setEnabled(false);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                Document doc = pane.getDocument();
                int length = doc.getLength();
                if (type.endsWith("/rtf")) {
                    // Saving RTF - use the OutputStream
                    try {
                        pane.getEditorKit().write(os, doc, 0, length);
                        os.close();
                    } catch (BadLocationException ex) {
                    }
                } else {
                    // Not RTF - use a Writer.
                    Writer w = new OutputStreamWriter(os);
                    pane.write(w);
                    w.close();
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to save file", file.getAbsolutePath(), }, "File Save Error",
                        JOptionPane.ERROR_MESSAGE);

            }
            pane.setEditable(file.canWrite());
            textField.setEnabled(true);
            saveButton.setEnabled(file.canWrite());
            setCursor(Cursor.getDefaultCursor());
        }
    });
}

From source file:com.mirth.connect.client.ui.MessageExportDialog.java

private void export() {
    String errorMessage = messageExportPanel.validate(true);
    if (StringUtils.isNotEmpty(errorMessage)) {
        parent.alertError(this, errorMessage);
        return;/*from w  ww .j av  a 2 s  .  co m*/
    }

    int exportCount = 0;
    MessageWriterOptions writerOptions = messageExportPanel.getMessageWriterOptions();

    if (StringUtils.isBlank(writerOptions.getRootFolder())) {
        parent.alertError(parent, "Please enter a valid root path to store exported files.");
        setVisible(true);
        return;
    }

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

    try {
        if (messageExportPanel.isExportLocal()) {
            PaginatedMessageList messageList = new PaginatedMessageList();
            messageList.setChannelId(channelId);
            messageList.setClient(parent.mirthClient);
            messageList.setMessageFilter(messageFilter);
            messageList.setPageSize(pageSize);
            messageList.setIncludeContent(true);

            writerOptions.setBaseFolder(SystemUtils.getUserHome().getAbsolutePath());

            MessageWriter messageWriter = MessageWriterFactory.getInstance().getMessageWriter(writerOptions,
                    encryptor);

            AttachmentSource attachmentSource = null;
            if (writerOptions.includeAttachments()) {
                attachmentSource = new AttachmentSource() {
                    @Override
                    public List<Attachment> getMessageAttachments(Message message) throws ClientException {
                        return PlatformUI.MIRTH_FRAME.mirthClient
                                .getAttachmentsByMessageId(message.getChannelId(), message.getMessageId());
                    }
                };
            }

            try {
                exportCount = new MessageExporter().exportMessages(messageList, messageWriter,
                        attachmentSource);
                messageWriter.finishWrite();
            } finally {
                messageWriter.close();
            }
        } else {
            writerOptions.setIncludeAttachments(messageExportPanel.isIncludeAttachments());
            exportCount = parent.mirthClient.exportMessagesServer(channelId, messageFilter, pageSize,
                    writerOptions);
        }

        setVisible(false);
        setCursor(Cursor.getDefaultCursor());
        parent.alertInformation(parent, exportCount + " message" + ((exportCount == 1) ? " has" : "s have")
                + " been successfully exported to: " + writerOptions.getRootFolder());
    } catch (Exception e) {
        setCursor(Cursor.getDefaultCursor());
        Throwable cause = (e.getCause() == null) ? e : e.getCause();
        parent.alertThrowable(parent, cause);
    }
}

From source file:EditorPaneExample9.java

public EditorPaneExample9() {
    super("JEditorPane Example 9");
    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;// www. ja v a 2 s .  c o  m
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(new URL(url));
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
            }
        }
    });
}

From source file:org.multibit.viewsystem.swing.action.ShowPreferencesSubmitAction.java

/**
 * Change preferences./*w ww .j  a  v  a  2 s .c o m*/
 */
@Override
public void actionPerformed(ActionEvent event) {
    //        boolean feeValidationError = false;

    boolean wantToFireDataStructureChanged = false;

    try {
        if (mainFrame != null) {
            mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }

        //            String updateStatusText = "";

        if (dataProvider != null) {
            controller.getModel().setUserPreference(CoreModel.PREVIOUS_UNDO_CHANGES_TEXT,
                    dataProvider.getPreviousUndoChangesText());

            //                String previousSendFee = dataProvider.getPreviousSendFee();
            //                String newSendFee = dataProvider.getNewSendFee();
            //                controller.getModel().setUserPreference(BitcoinModel.PREVIOUS_SEND_FEE, previousSendFee);
            //
            //                // Check fee is set.
            //                if (newSendFee == null || "".equals(newSendFee)) {
            //                    // Fee must be set validation error.
            //                    controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                    feeValidationError = true;
            //                    updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.aFeeMustBeSet");
            //                }
            //
            //                if (!feeValidationError) {
            //                    if (newSendFee.startsWith(ShowPreferencesPanel.UNPARSEABLE_FEE)) {
            //                        String newSendFeeTrimmed = newSendFee.substring(ShowPreferencesPanel.UNPARSEABLE_FEE.length() + 1);
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFeeTrimmed });
            //                    }
            //                }
            //                
            //                if (!feeValidationError) {
            //                    try {
            //                        // Check fee is a number.
            //                        BigInteger feeAsBigInteger = Utils.toNanoCoins(newSendFee);
            //
            //                        // Check fee is at least the minimum fee.
            //                        if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MINIMUM_FEE) < 0) {
            //                            feeValidationError = true;
            //                            updateStatusText = controller.getLocaliser().getString(
            //                                    "showPreferencesPanel.feeCannotBeSmallerThanMinimumFee");
            //                        } else {
            //                            if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MAXIMUM_FEE) >= 0) {
            //                                feeValidationError = true;
            //                                updateStatusText = controller.getLocaliser().getString(
            //                                        "showPreferencesPanel.feeCannotBeGreaterThanMaximumFee");
            //                            } else {
            //                                // Fee is ok.
            //                                controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, newSendFee);
            //                            }
            //                        }
            //                    } catch (NumberFormatException nfe) {
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFee });
            //                    } catch (ArithmeticException ae) {
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFee });
            //                    }
            //                }
        }

        // Disable language selection, uncomment to enable
        /*
             String previousLanguageCode = dataProvider.getPreviousUserLanguageCode();
             String newLanguageCode = dataProvider.getNewUserLanguageCode();
             controller.getModel().setUserPreference(CoreModel.PREVIOUS_USER_LANGUAGE_CODE, previousLanguageCode);
                
             if (previousLanguageCode != null && !previousLanguageCode.equals(newLanguageCode)) {
        // New language to set on model.
        controller.getModel().setUserPreference(CoreModel.USER_LANGUAGE_CODE, newLanguageCode);
        wantToFireDataStructureChanged = true;
             }
        */

        // Open URI - use dialog.
        String openUriDialog = dataProvider.getOpenUriDialog();
        if (openUriDialog != null) {
            controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_SHOW_DIALOG, openUriDialog);
        }

        // Open URI - use URI.
        String openUriUseUri = dataProvider.getOpenUriUseUri();
        if (openUriUseUri != null) {
            controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_USE_URI, openUriUseUri);
        }

        // Messaging servers
        boolean messagingServersHasChanged = false;
        String[] previousMessagingServerURLs = dataProvider.getPreviousMessagingServerURLs();
        String[] newMessagingServerURLs = dataProvider.getNewMessagingServerURLs();
        // newMessagingServerURLs might be NULL, and thus clear out the user preference.
        // So let's be explicit and say if no urls are set, we use the default.
        if (newMessagingServerURLs == null) {
            newMessagingServerURLs = CoreModel.DEFAULT_MESSAGING_SERVER_URLS; // not URL encoded but is okay as no strange characters.
        }
        if (!Arrays.equals(previousMessagingServerURLs, newMessagingServerURLs)) {
            messagingServersHasChanged = true;
            String s = StringUtils.join(newMessagingServerURLs, "|");
            controller.getModel().setUserPreference(CoreModel.MESSAGING_SERVERS, s);
        }

        // Font data.
        boolean fontHasChanged = false;
        String previousFontName = dataProvider.getPreviousFontName();
        String newFontName = dataProvider.getNewFontName();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_NAME, previousFontName);

        if (newFontName != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_NAME, newFontName);

            if (!newFontName.equals(previousFontName)) {
                fontHasChanged = true;
            }
        }

        String previousFontStyle = dataProvider.getPreviousFontStyle();
        String newFontStyle = dataProvider.getNewFontStyle();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_STYLE, previousFontStyle);

        if (newFontStyle != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_STYLE, newFontStyle);

            if (!newFontStyle.equals(previousFontStyle)) {
                fontHasChanged = true;
            }
        }

        String previousFontSize = dataProvider.getPreviousFontSize();
        String newFontSize = dataProvider.getNewFontSize();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_SIZE, previousFontSize);

        if (newFontSize != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_SIZE, newFontSize);

            if (!newFontSize.equals(previousFontSize)) {
                fontHasChanged = true;
            }
        }

        // Look and feel.
        boolean lookAndFeelHasChanged = false;
        String previousLookAndFeel = dataProvider.getPreviousLookAndFeel();
        String newLookAndFeel = dataProvider.getNewLookAndFeel();

        controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, previousLookAndFeel);

        if (newLookAndFeel != null && (!newLookAndFeel.equals(previousLookAndFeel)
                && !newLookAndFeel.equals(UIManager.getLookAndFeel().getName()))) {
            controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, newLookAndFeel);

            lookAndFeelHasChanged = true;
        }
        /*
                    // Currency ticker.
                    boolean showTicker = dataProvider.getNewShowTicker();
                    boolean showBitcoinConvertedToFiat = dataProvider.getNewShowBitcoinConvertedToFiat();
                    boolean showCurrency = dataProvider.getNewShowCurrency();
                    boolean showRate = dataProvider.getNewShowRate();
                    boolean showBid = dataProvider.getNewShowBid();
                    boolean showAsk = dataProvider.getNewShowAsk();
                    boolean showExchange = dataProvider.getNewShowExchange();
                
                    boolean restartTickerTimer = false;
                
                    if (dataProvider.getPreviousShowCurrency() != showCurrency) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowBitcoinConvertedToFiat() != showBitcoinConvertedToFiat) {
        wantToFireDataStructureChanged = true;
        if (showBitcoinConvertedToFiat) {
            restartTickerTimer = true;
        }
                    } else if (dataProvider.getPreviousShowTicker() != showTicker || showTicker != dataProvider.isTickerVisible()) {
        wantToFireDataStructureChanged = true;
        if (showTicker) {
            restartTickerTimer = true;
        }
                    } else if (dataProvider.getPreviousShowRate() != showRate) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowBid() != showBid) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowAsk() != showAsk) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowExchange() != showExchange) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } 
                
                    controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW, Boolean.valueOf(showTicker).toString());
                    controller.getModel().setUserPreference(ExchangeModel.SHOW_BITCOIN_CONVERTED_TO_FIAT,
                      Boolean.valueOf(showBitcoinConvertedToFiat).toString());
                
                    String columnsToShow = "";
                    if (showCurrency)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_CURRENCY;
                    if (showRate)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_LAST_PRICE;
                    if (showBid)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_BID;
                    if (showAsk)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_ASK;
                    if (showExchange)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_EXCHANGE;
                
                    if ("".equals(columnsToShow)) {
        // A user could just switch all the columns off in the settings
        // so
        // put a 'none' in the list of columns
        // this is to stop the default columns appearing.
        columnsToShow = TickerTableModel.TICKER_COLUMN_NONE;
                    }
                    controller.getModel().setUserPreference(ExchangeModel.TICKER_COLUMNS_TO_SHOW, columnsToShow);
                
                    String previousExchange1 = dataProvider.getPreviousExchange1();
                    String newExchange1 = dataProvider.getNewExchange1();
                    if (newExchange1 != null && !newExchange1.equals(previousExchange1)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE, newExchange1);
        ExchangeData newExchangeData = new ExchangeData();
        newExchangeData.setShortExchangeName(newExchange1);
        this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange1, newExchangeData);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousCurrency1 = dataProvider.getPreviousCurrency1();
                    String newCurrency1 = dataProvider.getNewCurrency1();
                    if (newCurrency1 != null && !newCurrency1.equals(previousCurrency1)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, newCurrency1);
        String newCurrencyCode = newCurrency1;
        if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(newExchange1)) {
            // Use only the last three characters - the currency code.
             if (newCurrency1.length() >= 3) {
                newCurrencyCode = newCurrency1.substring(newCurrency1.length() - 3);
            }
        }
        try {
            CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrencyCode));
        } catch ( org.joda.money.IllegalCurrencyException e) {
            e.printStackTrace();
        }
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousShowSecondRow = Boolean.valueOf(dataProvider.getPreviousShowSecondRow()).toString();
                    String newShowSecondRow = Boolean.valueOf(dataProvider.getNewShowSecondRow()).toString();
                    if (newShowSecondRow != null && !newShowSecondRow.equals(previousShowSecondRow)) {
        // New show second row is set on model.
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW, newShowSecondRow);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousExchange2 = dataProvider.getPreviousExchange2();
                    String newExchange2 = dataProvider.getNewExchange2();
                    if (newExchange2 != null && !newExchange2.equals(previousExchange2)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE, newExchange2);
        ExchangeData newExchangeData = new ExchangeData();
        newExchangeData.setShortExchangeName(newExchange2);
        this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange2, newExchangeData);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousCurrency2 = dataProvider.getPreviousCurrency2();
                    String newCurrency2 = dataProvider.getNewCurrency2();
                    if (newCurrency2 != null && !newCurrency2.equals(previousCurrency2)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY, newCurrency2);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                            
                    String previousOerApicode = dataProvider.getPreviousOpenExchangeRatesApiCode();
                    String newOerApiCode = dataProvider.getNewOpenExchangeRatesApiCode();
                    if (newOerApiCode != null && !newOerApiCode.equals(previousOerApicode)) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                
        controller.getModel().setUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE, newOerApiCode);
                    }
        */
        // Can undo.
        controller.getModel().setUserPreference(CoreModel.CAN_UNDO_PREFERENCES_CHANGES, "true");
        /*
                    if (restartTickerTimer) {
        // Reinitialise the currency converter.
        CurrencyConverter.INSTANCE.initialise(controller);
                
        // Cancel any existing timer.
        if (mainFrame.getTickerTimer1() != null) {
            mainFrame.getTickerTimer1().cancel();
        }
        if (mainFrame.getTickerTimer2() != null) {
            mainFrame.getTickerTimer2().cancel();
        }                // Start ticker timer.
        Timer tickerTimer1 = new Timer();
        mainFrame.setTickerTimer1(tickerTimer1);
                
        TickerTimerTask tickerTimerTask1 = new TickerTimerTask(this.exchangeController, mainFrame, true);
        tickerTimerTask1.createExchangeObjects(controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE));
        mainFrame.setTickerTimerTask1(tickerTimerTask1);
                
        tickerTimer1.schedule(tickerTimerTask1, 0, TickerTimerTask.DEFAULT_REPEAT_RATE);
                
        boolean showSecondRow = Boolean.TRUE.toString().equals(
                controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW));
                
        if (showSecondRow) {
            Timer tickerTimer2 = new Timer();
            mainFrame.setTickerTimer2(tickerTimer2);
                
            TickerTimerTask tickerTimerTask2 = new TickerTimerTask(this.exchangeController, mainFrame, false);
            tickerTimerTask2.createExchangeObjects(controller.getModel().getUserPreference(
                    ExchangeModel.TICKER_SECOND_ROW_EXCHANGE));
            mainFrame.setTickerTimerTask2(tickerTimerTask2);
                
            tickerTimer2.schedule(tickerTimerTask2, TickerTimerTask.TASK_SEPARATION, TickerTimerTask.DEFAULT_REPEAT_RATE);
        }
                    }
        */
        if (messagingServersHasChanged) {
            // TODO: Maybe something here so messaging servers are updated and go live immediately?
            // Currently servers are set here in class SendRequest:
            /*
                    public void setMessage(CoinSparkMessagePart [] MessageParts,String [] DeliveryServers)
            */

        }

        if (fontHasChanged) {
            wantToFireDataStructureChanged = true;
        }

        if (lookAndFeelHasChanged) {
            try {
                if (CoreModel.SYSTEM_LOOK_AND_FEEL.equals(newLookAndFeel)) {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } else {
                    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                        if (newLookAndFeel.equalsIgnoreCase(info.getName())) {
                            UIManager.setLookAndFeel(info.getClassName());
                            break;
                        }
                    }
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
        }

        Font newFont = dataProvider.getSelectedFont();
        if (newFont != null) {
            UIManager.put("ToolTip.font", newFont);
        }

        if (wantToFireDataStructureChanged || lookAndFeelHasChanged) {
            ColorAndFontConstants.init();
            FontSizer.INSTANCE.initialise(controller);
            HelpContentsPanel.clearBrowser();

            // Switch off blinks.
            this.bitcoinController.getModel().setBlinkEnabled(false);

            try {
                controller.fireDataStructureChanged();
                SwingUtilities.updateComponentTreeUI(mainFrame);
            } finally {
                // Switch blinks back on.
                this.bitcoinController.getModel().setBlinkEnabled(true);
            }
        }
    } finally {
        if (mainFrame != null) {
            mainFrame.setCursor(Cursor.getDefaultCursor());
        }
    }
}

From source file:it.imtech.configuration.StartWizard.java

/**
 * Creates a new wizard with active card (Select Language/Server)
 *///from  w w w  .  j  ava2 s  . com
public StartWizard() {
    Globals.setGlobalVariables();
    ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader);

    if (!checkAppDataFiles()) {
        JOptionPane.showMessageDialog(null, Utility.getBundleString("copy_appdata", bundle),
                Utility.getBundleString("copy_appdata_title", bundle), JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }

    DOMConfigurator.configure(Globals.LOG4J);
    logger = Logger.getLogger(StartWizard.class);
    logger.info("Starting Application Phaidra Importer");

    mainFrame = new JFrame();

    if (Utility.internetConnectionAvailable()) {
        Globals.ONLINE = true;
    }

    it.imtech.utility.Utility.cleanUndoDir();

    XMLConfiguration internalConf = setConfiguration();
    logger.info("Configuration path estabilished");

    XMLConfiguration config = setConfigurationPaths(internalConf, bundle);

    headerPanel = new HeaderPanel();
    footerPanel = new FooterPanel();

    JButton nextButton = (JButton) footerPanel.getComponentByName("next_button");
    JButton prevButton = (JButton) footerPanel.getComponentByName("prev_button");

    nextButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (getCurrentCard() instanceof ChooseServer) {
                ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE,
                        Globals.loader);

                try {
                    mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                    Server selected = chooseServer.getSelectedServer();
                    logger.info("Selected Server = " + selected.getServername());
                    SelectedServer.getInstance(null).makeEmpty();
                    SelectedServer.getInstance(selected);

                    if (Globals.ONLINE) {
                        logger.info("Testing server connection...");
                        ChooseServer.testServerConnection(SelectedServer.getInstance(null).getBaseUrl());
                    }
                    chooseFolder.updateLanguage();

                    MetaUtility.getInstance().preInitializeData();
                    logger.info("Preinitialization done (Vocabulary and Languages");

                    c1.next(cardsPanel);
                    mainFrame.setCursor(null);
                } catch (Exception ex) {
                    logger.error(ex.getMessage());
                    JOptionPane.showMessageDialog(new Frame(),
                            Utility.getBundleString("preinitializemetadataex", bundle));
                }
            } else if (getCurrentCard() instanceof ChooseFolder) {
                mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                boolean error = chooseFolder.checkFolderSelectionValidity();

                if (error == false) {
                    BookImporter x = BookImporter.getInstance();
                    mainFrame.setCursor(null);
                    mainFrame.setVisible(false);
                }
            }
        }
    });

    prevButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (getCurrentCard() instanceof ChooseServer) {
                ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE,
                        Globals.loader);
                String title = Utility.getBundleString("dialog_1_title", bundle);
                String text = Utility.getBundleString("dialog_1", bundle);

                ConfirmDialog confirm = new ConfirmDialog(mainFrame, true, title, text,
                        Utility.getBundleString("confirm", bundle), Utility.getBundleString("back", bundle));

                confirm.setVisible(true);
                boolean close = confirm.getChoice();
                confirm.dispose();

                if (close == true) {
                    mainFrame.dispose();
                }
            } else {
                c1.previous(cardsPanel);
            }
        }
    });

    cardsPanel = new JPanel(new CardLayout());
    cardsPanel.setBackground(Color.WHITE);

    chooseServer = new ChooseServer(config);
    chooseFolder = new ChooseFolder();

    cardsPanel.add(chooseServer, "1");
    cardsPanel.add(chooseFolder, "2");

    cardsPanel.setLayout(c1);
    c1.show(cardsPanel, "1");

    //Main Panel style
    mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(BorderLayout.NORTH, headerPanel);
    mainPanel.add(BorderLayout.CENTER, cardsPanel);
    mainPanel.add(BorderLayout.PAGE_END, footerPanel);
    mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    mainFrame.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE,
                    Globals.loader);
            String title = Utility.getBundleString("dialog_1_title", bundle);
            String text = Utility.getBundleString("dialog_1", bundle);

            ConfirmDialog confirm = new ConfirmDialog(mainFrame, true, title, text,
                    Utility.getBundleString("confirm", bundle), Utility.getBundleString("back", bundle));

            confirm.setVisible(true);
            boolean close = confirm.getChoice();
            confirm.dispose();

            if (close == true) {
                mainFrame.dispose();
            }
        }
    });

    //Add Style 
    mainFrame.getContentPane().setBackground(Color.white);
    mainFrame.getContentPane().setLayout(new BorderLayout());
    mainFrame.getContentPane().setPreferredSize(new Dimension(640, 400));
    mainFrame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    mainFrame.pack();

    //Center frame in the screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (dim.width - mainFrame.getSize().width) / 2;
    int y = (dim.height - mainFrame.getSize().height) / 2;
    mainFrame.setLocation(x, y);

    mainFrame.setVisible(true);
}

From source file:GUI.PizzaCat.java

@Override
public void actionPerformed(ActionEvent e) {
    startButton.setEnabled(false);//from   w  w w  . ja  v  a  2  s  .  com
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    // Instances of javax.swing.SwingWorker are not reusuable, so
    // we create new instances as needed.
    task = new Task();
    task.addPropertyChangeListener(this);
    task.execute();
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLExtractorGUI.java

public void actionPerformed(ActionEvent e) {
    try {/*  www .  j  a  v  a2s  .c  om*/
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (e.getSource() == jbnFileXML)
            gc.fileChooser(jtfFileXML, "", "open");
        else if (e.getSource() == jbnRunExtractor) {
            URL template = templateForExcel();
            File fileExcelOutput = extract(template);
            if (fileExcelOutput != null) {
                log.info("Opening excel file through Desktop: " + fileExcelOutput);
                Desktop.getDesktop().open(fileExcelOutput);
            }
        } else if (e.getSource() == jbnCreateReport) {
            URL template = getClass().getClassLoader().getResource("ExcelTemplate.xlsx");
            File fileExcelOutput = extract(template);
            if (fileExcelOutput != null) {
                log.info("Opening report through Desktop: " + fileExcelOutput);
                String fileName = FilenameUtils.removeExtension(fileExcelOutput.getAbsolutePath());
                File filePDFOutput = new File(fileName + ".pdf");
                File fileWordOutput = new File(fileName + ".docx");
                filePDFOutput.deleteOnExit();
                fileWordOutput.deleteOnExit();
                new ReportController().createReport(pcDep, fileExcelOutput, filePDFOutput, fileWordOutput,
                        isInternal);
                gc.openPDF(isInternal, filePDFOutput, this);
                Desktop.getDesktop().open(fileWordOutput);
            }
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } catch (Throwable throwable) {
        SwingGUI.handleError(this, throwable);
    }

}