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.tinymediamanager.ui.movies.dialogs.MovieBatchEditorDialog.java

/**
 * Instantiates a new movie batch editor.
 * /*w w w. j a v a2  s  .c  om*/
 * @param movies
 *          the movies
 */
public MovieBatchEditorDialog(final List<Movie> movies) {
    super(BUNDLE.getString("movie.edit"), "movieBatchEditor"); //$NON-NLS-1$
    setBounds(5, 5, 350, 230);
    getContentPane().setLayout(new BorderLayout(0, 0));

    {
        JPanel panelContent = new JPanel();
        getContentPane().add(panelContent, BorderLayout.CENTER);
        panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
        panelContent.add(lblGenres, "2, 2, 2, 1, right, default");

        // cbGenres = new JComboBox(MediaGenres2.values());
        cbGenres = new AutocompleteComboBox(MediaGenres.values());
        cbGenres.setEditable(true);
        panelContent.add(cbGenres, "5, 2, fill, default");

        JButton btnAddGenre = new JButton("");
        btnAddGenre.setIcon(IconManager.LIST_ADD);
        btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
        btnAddGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = null;
                Object item = cbGenres.getSelectedItem();

                // genre
                if (item instanceof MediaGenres) {
                    genre = (MediaGenres) item;
                }

                // newly created genre?
                if (item instanceof String) {
                    genre = MediaGenres.getGenre((String) item);
                }
                // MediaGenres2 genre = (MediaGenres2) cbGenres.getSelectedItem();
                if (genre != null) {
                    for (Movie movie : moviesToEdit) {
                        movie.addGenre(genre);
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddGenre, "7, 2");

        JButton btnRemoveGenre = new JButton("");
        btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
        btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = (MediaGenres) cbGenres.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeGenre(genre);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveGenre, "9, 2");

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        panelContent.add(lblTags, "2, 4, 2, 1, right, default");

        cbTags = new AutocompleteComboBox(movieList.getTagsInMovies().toArray());
        cbTags.setEditable(true);
        panelContent.add(cbTags, "5, 4, fill, default");

        JButton btnAddTag = new JButton("");
        btnAddTag.setIcon(IconManager.LIST_ADD);
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                if (StringUtils.isBlank(tag)) {
                    return;
                }

                for (Movie movie : moviesToEdit) {
                    movie.addToTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddTag, "7, 4");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeFromTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveTag, "9, 4");

        JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
        panelContent.add(lblCertification, "2, 6, 2, 1, right, default");

        final JComboBox cbCertification = new JComboBox();
        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }
        panelContent.add(cbCertification, "5, 6, fill, default");

        JButton btnCertification = new JButton("");
        btnCertification.setMargin(new Insets(2, 2, 2, 2));
        btnCertification.setIcon(IconManager.APPLY);
        btnCertification.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                Certification cert = (Certification) cbCertification.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.setCertification(cert);
                    ;
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnCertification, "7, 6");

        JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
        panelContent.add(lblMovieSet, "2, 8, 2, 1, right, default");

        cbMovieSet = new JComboBox();
        panelContent.add(cbMovieSet, "5, 8, fill, default");

        JButton btnSetMovieSet = new JButton("");
        btnSetMovieSet.setMargin(new Insets(2, 2, 2, 2));
        btnSetMovieSet.setIcon(IconManager.APPLY);
        btnSetMovieSet.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // movie set
                Object obj = cbMovieSet.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    if (obj instanceof String) {
                        movie.removeFromMovieSet();
                    }
                    if (obj instanceof MovieSet) {
                        MovieSet movieSet = (MovieSet) obj;

                        if (movie.getMovieSet() != movieSet) {
                            movie.removeFromMovieSet();
                            movie.setMovieSet(movieSet);
                            movieSet.insertMovie(movie);
                        }
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnSetMovieSet, "7, 8");

        JButton btnNewMovieset = new JButton("");
        btnNewMovieset.setMargin(new Insets(2, 2, 2, 2));
        btnNewMovieset.setAction(new MovieSetAddAction(false));
        panelContent.add(btnNewMovieset, "9, 8");

        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        panelContent.add(lblWatched, "2, 10, 2, 1, right, default");

        chckbxWatched = new JCheckBox("");
        panelContent.add(chckbxWatched, "5, 10");

        JButton btnWatched = new JButton("");
        btnWatched.setMargin(new Insets(2, 2, 2, 2));
        btnWatched.setIcon(IconManager.APPLY);
        btnWatched.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setWatched(chckbxWatched.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnWatched, "7, 10");

        JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
        panelContent.add(lblVideo3D, "2, 12, 2, 1, right, default");

        final JCheckBox chckbxVideo3D = new JCheckBox("");
        panelContent.add(chckbxVideo3D, "5, 12");

        JButton btnVideo3D = new JButton("");
        btnVideo3D.setMargin(new Insets(2, 2, 2, 2));
        btnVideo3D.setIcon(IconManager.APPLY);
        btnVideo3D.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setVideoIn3D(chckbxVideo3D.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnVideo3D, "7, 12");

        JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
        panelContent.add(lblMediasource, "2, 14, 2, 1, right, default");

        final JComboBox cbMediaSource = new JComboBox(MediaSource.values());
        panelContent.add(cbMediaSource, "5, 14, fill, default");

        JButton btnMediaSource = new JButton("");
        btnMediaSource.setMargin(new Insets(2, 2, 2, 2));
        btnMediaSource.setIcon(IconManager.APPLY);
        btnMediaSource.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                Object obj = cbMediaSource.getSelectedItem();
                if (obj instanceof MediaSource) {
                    MediaSource mediaSource = (MediaSource) obj;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setMediaSource(mediaSource);
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }
        });
        panelContent.add(btnMediaSource, "7, 14");

        JLabel lblLanguage = new JLabel(BUNDLE.getString("metatag.language")); //$NON-NLS-1$
        panelContent.add(lblLanguage, "2, 16, 2, 1, right, default");

        tfLanguage = new JTextField();
        panelContent.add(tfLanguage, "5, 16, fill, default");
        tfLanguage.setColumns(10);

        JButton btnLanguage = new JButton("");
        btnLanguage.setMargin(new Insets(2, 2, 2, 2));
        btnLanguage.setIcon(IconManager.APPLY);
        btnLanguage.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setSpokenLanguages(tfLanguage.getText());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnLanguage, "7, 16");
        {

            JLabel lblSorttitleT = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            panelContent.add(lblSorttitleT, "2, 18, right, default");

            JButton btnSetSorttitle = new JButton(BUNDLE.getString("edit.setsorttitle")); //$NON-NLS-1$
            btnSetSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle(movie.getTitleSortable());
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });

            JLabel lblSorttitleInfo = new JLabel(IconManager.HINT);
            lblSorttitleInfo.setToolTipText(BUNDLE.getString("edit.setsorttitle.desc")); //$NON-NLS-1$
            panelContent.add(lblSorttitleInfo, "3, 18");
            panelContent.add(btnSetSorttitle, "5, 18");

            JButton btnClearSorttitle = new JButton(BUNDLE.getString("edit.clearsorttitle")); //$NON-NLS-1$
            btnClearSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle("");
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });
            panelContent.add(btnClearSorttitle, "5, 20");
        }
    }

    {
        JPanel panelButtons = new JPanel();
        FlowLayout flowLayout = (FlowLayout) panelButtons.getLayout();
        flowLayout.setAlignment(FlowLayout.RIGHT);
        getContentPane().add(panelButtons, BorderLayout.SOUTH);

        JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$
        btnClose.setIcon(IconManager.APPLY);
        btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // rewrite movies, if anything changed
                if (changed) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
                setVisible(false);
            }
        });
        panelButtons.add(btnClose);

        // add window listener to write changes (if the window close button "X" is
        // pressed)
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                // rewrite movies, if anything changed
                if (changed) {
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    // if configured - sync with trakt.tv
                    if (MovieModuleManager.MOVIE_SETTINGS.getSyncTrakt()) {
                        TmmTask task = new SyncTraktTvTask(moviesToEdit, null);
                        TmmTaskManager.getInstance().addUnnamedTask(task);
                    }
                }
            }
        });
    }

    {
        setMovieSets();
        moviesToEdit = movies;

        PropertyChangeListener listener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("addedMovieSet".equals(evt.getPropertyName())) {
                    setMovieSets();
                }
            }
        };
        movieList.addPropertyChangeListener(listener);
    }
}

From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java

private void launchApp() {
    try {/*from w  w w.  j a  v a  2s  .com*/
        jd.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        String serial = ((String) this.jcbDevices.getSelectedItem());
        Adb adb = new Adb(serial.split(":")[0]);
        device = new UiAutomatorDevice();
        device.setAdb(adb);
        device.setProductDetail(serial);
        device.start();
        this.setDevice(device);
        this.launch();
    } catch (Throwable ex) {
        LOG.error("Error", ex);
        JOptionPane.showMessageDialog(jbLaunch.getTopLevelAncestor(), "Cannot start app");
        return;
    } finally {
        jd.setCursor(Cursor.getDefaultCursor());
    }

    int debugMinutes = (int) jsDebugMinutes.getValue();
    jd.dispose();
    try {
        this.interactManually(debugMinutes);
    } catch (Throwable ex) {
        LOG.error("Error", ex);
        System.exit(1);
    } finally {
        System.exit(0);
    }
}

From source file:org.languagetool.gui.ResultAreaHelper.java

@Override
public void languageToolEventOccurred(LanguageToolEvent event) {
    if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) {
        Language lang = ltSupport.getLanguage();
        String langName;/*from  ww w .  ja  v a  2s .  c  o m*/
        if (lang.isExternal()) {
            langName = lang.getTranslatedName(messages) + Main.EXTERNAL_LANGUAGE_SUFFIX;
        } else {
            langName = lang.getTranslatedName(messages);
        }
        String msg = org.languagetool.tools.Tools.i18n(messages, "startChecking", langName) + "...";
        setHeader(msg);
        setMain(EMPTY_PARA);
        if (event.getCaller() == this) {
            statusPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
    } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) {
        setRunTime(event.getElapsedTime());
        String inputText = event.getSource().getTextComponent().getText();
        displayResult(inputText, event.getSource().getMatches());
        if (event.getCaller() == this) {
            statusPane.setCursor(Cursor.getDefaultCursor());
        }
    } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED
            || event.getType() == LanguageToolEvent.Type.RULE_ENABLED) {
        String inputText = event.getSource().getTextComponent().getText();
        displayResult(inputText, event.getSource().getMatches());
    }
}

From source file:ome.formats.importer.gui.FileQueueHandler.java

private void addEnabled(boolean enabled) {
    if (enabled)//www  . j ava  2  s.c o m
        viewer.setCursor(Cursor.getDefaultCursor());
    else
        viewer.setCursor(java.awt.Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    qTable.addBtn.setEnabled(enabled);
    qTable.removeBtn.setEnabled(enabled);
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Supplies the JPanel which is displayed in the main Jogra window.
 *//*from   ww  w.j a  v  a2 s.co  m*/
public JPanel getMainWindowPlugin() {

    final JPanel ret = new JPanel();
    final JButton loadButton = new JButton("Load Term Rationaliser");
    final JLabel chooseType = new JLabel("Select term: ");
    final JComboBox termTypeBox = new JComboBox(instances.keySet().toArray());
    final JCheckBox showEVCFilter = new JCheckBox("Highlight terms with evidence codes", true);

    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {

            new SwingWorker<JFrame, Void>() {
                @Override
                protected JFrame doInBackground() throws Exception {
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    setTermType(instances.get((String) termTypeBox.getSelectedItem()));
                    setShowEVC(showEVCFilter.isSelected());
                    return makeWindow();
                }

                @Override
                public void done() {
                    try {
                        final GeneDBMessage e = new OpenWindowEvent(TermRationaliser.this, get());
                        EventBus.publish(e);
                    } catch (final InterruptedException exp) {
                        exp.printStackTrace();
                    } catch (final ExecutionException exp) {
                        exp.printStackTrace();
                    }
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }.execute();
        }
    });
    Box verticalBox = Box.createVerticalBox();
    Box horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(chooseType);
    horizontalBox.add(termTypeBox);
    verticalBox.add(horizontalBox);
    verticalBox.add(loadButton);
    verticalBox.add(showEVCFilter);
    ret.add(verticalBox);
    return ret;
}

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

private void importMessages() {
    if (StringUtils.isBlank(fileTextField.getText())) {
        fileTextField.setBackground(UIConstants.INVALID_COLOR);
        parent.alertError(parent, "Please enter a file/folder to import.");
        setVisible(true);//from   ww  w .  j  a  v  a  2  s  .  c  o  m
        return;
    } else {
        fileTextField.setBackground(null);
    }

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

    try {
        if (importLocalRadio.isSelected()) {
            MessageWriter messageWriter = new MessageWriter() {
                @Override
                public boolean write(Message message) throws MessageWriterException {
                    try {
                        parent.mirthClient.importMessage(channelId, message);
                    } catch (ClientException e) {
                        throw new MessageWriterException(e);
                    }

                    return true;
                }

                @Override
                public void finishWrite() {
                }

                @Override
                public void close() throws MessageWriterException {
                }
            };

            try {
                result = new MessageImporter().importMessages(fileTextField.getText(),
                        subfoldersCheckbox.isSelected(), messageWriter,
                        SystemUtils.getUserHome().getAbsolutePath());
            } catch (MessageImportInvalidPathException e) {
                setCursor(Cursor.getDefaultCursor());
                parent.alertError(parent, e.getMessage());
                setVisible(true);
                return;
            }
        } else {
            result = parent.mirthClient.importMessagesServer(channelId, fileTextField.getText(),
                    subfoldersCheckbox.isSelected());
        }

        setVisible(false);
        setCursor(Cursor.getDefaultCursor());

        if (result.getSuccessCount() == 0 && result.getTotalCount() == 0) {
            parent.alertInformation(parent, "No messages were found to import");
        } else {
            if (result.getSuccessCount() > 0 && messageBrowser != null) {
                messageBrowser.updateFilterButtonFont(Font.BOLD);
            }

            parent.alertInformation(parent, result.getSuccessCount() + " out of " + result.getTotalCount()
                    + " message(s) have been successfully imported from " + fileTextField.getText() + ".");
        }
    } catch (Exception e) {
        setCursor(Cursor.getDefaultCursor());
        Throwable cause = (e.getCause() == null) ? e : e.getCause();
        parent.alertThrowable(parent, cause);
    }
}

From source file:edu.harvard.mcz.imagecapture.ui.ButtonEditor.java

@Override
public void actionPerformed(ActionEvent e) {

    // Action might not be event_button_pressed on all systems.
    log.debug("Button event actionCommand: " + e.getActionCommand());
    if (e.getActionCommand().equals(EVENT_PRESSED)) {
        // Event is a click on the cell
        // Identify the row that was clicked on.
        JTable table = (JTable) ((JButton) e.getSource()).getParent();
        log.debug(e.getSource());/*from w ww  . j av a2s  .  c  o  m*/
        log.debug(table);
        int row = table.getEditingRow();
        // Stop editing - note, we need to have gotten e.getSource.getParent and getEditingRow first.
        fireEditingStopped(); //Make the renderer reappear.
        Singleton.getSingletonInstance().getMainFrame()
                .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        switch (formToOpen) {
        case OPEN_SPECIMEN_DETAILS:
            // Load the selected specimen record from its ID (the data value behind the button).
            //SpecimenLifeCycle sls = new SpecimenLifeCycle();
            //Specimen specimen = sls.findById((Long)targetId);
            //if (specimen!=null) {
            if (targetId != null) {
                // a specimen with this ID exists, bring up the details editor.
                try {
                    //SpecimenControler sc = new SpecimenControler(specimen);
                    if (((Specimen) targetId).getSpecimenId() != null) {
                        if (((Specimen) targetId).isStateDone()) {
                            // Specimens in state_done are no longer editable
                            JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                                    "This Specimen record has been migrated and can no longer be edited here ["
                                            + ((Specimen) targetId).getLoadFlags()
                                            + "].\nSee: http://mczbase.mcz.harvard.edu/guid/MCZ:Ent:"
                                            + ((Specimen) targetId).getCatNum(),
                                    "Migrated Specimen", JOptionPane.WARNING_MESSAGE);
                        } else {
                            // Specimen is still editable
                            if (table != null) {
                                // Pass the specimen object for the row, the table model, and the row number on to the specimen controler.
                                try {
                                    SpecimenControler sc = new SpecimenControler((Specimen) targetId,
                                            (SpecimenListTableModel) table.getModel(), table, row);
                                    if (table.getParent().getParent().getParent().getParent()
                                            .getClass() == SpecimenBrowser.class) {
                                        sc.addListener((DataChangeListener) table.getParent());
                                    } else {
                                        Component x = table;
                                        boolean done = false;
                                        while (!done) {
                                            log.debug(x.getParent());
                                            x = x.getParent();
                                            if (x.getClass() == SpecimenBrowser.class) {
                                                sc.addListener((DataChangeListener) x);
                                                done = true;
                                            }
                                        }
                                    }
                                    sc.displayInEditor();
                                } catch (java.lang.ClassCastException eNotSp) {
                                    // Request isn't coming from a SpecimenListTableModel
                                    // View just the specimen record.
                                    SpecimenControler sc = new SpecimenControler((Specimen) targetId);
                                    sc.displayInEditor();
                                }
                            } else {
                                log.debug(e.getSource());
                                //SpecimenControler sc = new SpecimenControler((Specimen)targetId);
                                //sc.displayInEditor();
                            }
                        }
                    } else {
                        log.debug("User clicked on table row containing a new Specimen()");
                        JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                                "No Specimen for this image", "Load Specimen Failed",
                                JOptionPane.WARNING_MESSAGE);
                    }
                } catch (NoSuchRecordException e1) {
                    log.error("Tested for specimen!=null, but SpecimenControler threw null specimen exception");
                    log.error(e1);
                }
            } else {
                log.debug("No matches found to specimen id=" + targetId);
                // TODO: Create new specimen record and bring up dialog
                JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                        "No specimen record.");
            }
            break;
        case OPEN_TEMPLATE:
            // Load the selected specimen record from its ID (the data value behind the button).
            try {
                // a template with this targetID exists, display it.
                ((PositionTemplateEditor) parentComponent).setTemplate((String) targetId);
            } catch (NoSuchTemplateException e1) {
                log.error("No such template on button press on a template in list.");
                log.error(e1);
                log.trace(e1);
            }

            break;
        case OPEN_USER:
            //TODO: tie to user
            log.debug("Open user");
            ((UserListBrowser) parentComponent).getEditUserPanel().setUser((Users) targetId);
            break;
        case OPEN_SPECIMEN_VERBATIM:
            log.debug("Open Verbatim Transcription");
            SpecimenLifeCycle sls = new SpecimenLifeCycle();
            List<Specimen> toTranscribe = sls.findForVerbatim(((GenusSpeciesCount) targetId).getGenus(),
                    ((GenusSpeciesCount) targetId).getSpecificEpithet(), WorkFlowStatus.STAGE_1);
            log.debug(toTranscribe.size());
            SpecimenListTableModel stm = new SpecimenListTableModel(toTranscribe);
            JTable stable = new JTable();
            stable.setModel(stm);
            SpecimenControler verbCont;
            try {
                verbCont = new SpecimenControler(toTranscribe.get(0), stm, stable, 0);
                VerbatimCaptureDialog dialog = new VerbatimCaptureDialog(toTranscribe.get(0), verbCont);
                dialog.setVisible(true);
            } catch (NoSuchRecordException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            break;
        case OPEN_VERBATIM_CLASSIFY:
            log.debug("Open Verbatim Classify dialog");
            try {
                VerbatimClassifyDialog dialog = new VerbatimClassifyDialog(
                        (VerbatimCount) table.getModel().getValueAt(row, 0));
                dialog.setVisible(true);
            } catch (ClassCastException e1) {
                log.error(e1.getMessage(), e1);
            }
            break;
        case ACTION_CANCEL_JOB:
            log.debug("Action Cancel requested on job " + targetId);
            Singleton.getSingletonInstance().getJobList().getJobAt((Integer) targetId).cancel();
            break;
        case OPEN_SPECIMENPARTATTRIBUTES:
            SpecimenPartAttributeDialog attrDialog = new SpecimenPartAttributeDialog((SpecimenPart) targetId);
            attrDialog.setVisible(true);
            break;
        }
        Singleton.getSingletonInstance().getMainFrame()
                .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        System.gc();
    }
}

From source file:com.microsoftopentechnologies.intellij.forms.TableForm.java

public TableForm() {
    final TableForm form = this;
    this.setResizable(false);
    this.setModal(true);
    this.setTitle("Create new table");
    this.setContentPane(mainPanel);

    createButton.setEnabled(false);//from w w w . ja va 2 s . c o m

    tableNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent keyEvent) {
            super.keyTyped(keyEvent);

            createButton.setEnabled(!tableNameTextField.getText().isEmpty());
        }
    });

    final PermissionItem[] tablePermissions = PermissionItem.getTablePermissions();

    insertPermisssionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));
    deletePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));
    updatePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));
    readPermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions));

    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            form.setVisible(false);
            form.dispose();
        }
    });

    createButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        TablePermissions tablePermissions = new TablePermissions();

                        tablePermissions.setDelete(
                                ((PermissionItem) deletePermissionComboBox.getSelectedItem()).getType());
                        tablePermissions.setUpdate(
                                ((PermissionItem) updatePermissionComboBox.getSelectedItem()).getType());
                        tablePermissions
                                .setRead(((PermissionItem) readPermissionComboBox.getSelectedItem()).getType());
                        tablePermissions.setInsert(
                                ((PermissionItem) insertPermisssionComboBox.getSelectedItem()).getType());

                        final String tableName = tableNameTextField.getText().trim();

                        if (!tableName.matches("^[A-Za-z][A-Za-z0-9_]+")) {
                            JOptionPane.showMessageDialog(form,
                                    "Invalid table name. Table name must start with a letter, \n"
                                            + "contain only letters, numbers, and underscores.",
                                    "Error creating the table", JOptionPane.ERROR_MESSAGE);
                            return;
                        }

                        int tableNameIndex = -1;
                        if (existingTableNames != null) {
                            tableNameIndex = Iterables.indexOf(existingTableNames, new Predicate<String>() {
                                @Override
                                public boolean apply(String name) {
                                    return tableName.equalsIgnoreCase(name);
                                }
                            });
                        }

                        if (tableNameIndex != -1) {
                            JOptionPane.showMessageDialog(form,
                                    "Invalid table name. A table with that name already exists in this service.",
                                    "Error creating the table", JOptionPane.ERROR_MESSAGE);
                            return;
                        }

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

                        if (editingTable == null) {
                            AzureRestAPIManager.getManager().createTable(subscriptionId, serviceName, tableName,
                                    tablePermissions);
                        } else {
                            AzureRestAPIManager.getManager().updateTable(subscriptionId, serviceName, tableName,
                                    tablePermissions);
                        }
                        if (afterSave != null)
                            afterSave.run();

                        form.setVisible(false);
                        form.dispose();
                        form.setCursor(Cursor.getDefaultCursor());

                    } catch (Throwable e) {
                        form.setCursor(Cursor.getDefaultCursor());
                        UIHelper.showException("Error creating table", e);
                    }

                }
            });
        }
    });
}

From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java

public void reload() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            setCursor(new Cursor(Cursor.WAIT_CURSOR));
            try {
                setPickerEnabled(false);
                tblUser.setEnabled(false);
                userTableModel = new UserTableModel(false);
                TableSorter tblSorter = new TableSorter(userTableModel, tblUser.getTableHeader());

                GroupValue[] groups = null;
                if (!comm.isUserInRole(UserRights.SITE_ROOT)) {
                    groups = comm.getGroups();
                } else {
                    groups = comm.getAllGroups();
                }//  ww w . java 2s  .  c  o m
                if (groups != null) {
                    allGroupsOfCaller = new DropDownHolder[groups.length];
                    for (int i = groups.length - 1; i >= 0; i--) {
                        allGroupsOfCaller[i] = new DropDownHolder(groups[i], groups[i].getGroupName());
                    }
                }
                UnitValue[] units = comm.getUnits();
                if (units != null) {
                    allUnits = new DropDownHolder[units.length];
                    for (int i = units.length - 1; i >= 0; i--) {
                        allUnits[i] = new DropDownHolder(units[i], units[i].getName());
                    }
                }

                UserValue[] uv = comm.getAllUser();
                if (uv != null) {
                    if (comm.isUserInRole(UserRights.SITE_ROOT)) {
                        userTableModel.addRows(uv);
                    } else {
                        UserValue me = comm.getUser();
                        for (int i = 0; i < uv.length; i++) {
                            boolean isSiteRoot = comm.isUserInRole(uv[i], UserRights.SITE_ROOT);
                            boolean isMe = uv[i].getUserName().equalsIgnoreCase(me.getUserName());
                            if (!isSiteRoot) {
                                userTableModel.addRow(uv[i]);
                            }
                        }
                    }
                }

                tblUser.setModel(tblSorter);
                unitPickData.getLstLeftModel().clear();
                unitPickData.getLstRightModel().clear();
                groupPickData.getLstLeftModel().clear();
                groupPickData.getLstRightModel().clear();
            } catch (Exception exe) {
                log.error("Error reloading tables: ", exe);
            }
            tblUser.setEnabled(true);
            setCursor(Cursor.getDefaultCursor());
        }
    });
}

From source file:savant.view.swing.NavigationBar.java

NavigationBar() {

    this.setOpaque(false);
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    String buttonStyle = "segmentedCapsule";

    String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl";

    add(getRigidPadding());/*w  w  w. j  av a 2  s .  c  o m*/

    JButton loadGenomeButton = (JButton) add(new JButton(""));
    loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME));
    loadGenomeButton.setToolTipText("Load or change genome");
    loadGenomeButton.setFocusable(false);
    loadGenomeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().showOpenGenomeDialog();
        }
    });
    loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadGenomeButton.putClientProperty("JButton.segmentPosition", "first");
    loadGenomeButton.setPreferredSize(ICON_SIZE);
    loadGenomeButton.setMinimumSize(ICON_SIZE);
    loadGenomeButton.setMaximumSize(ICON_SIZE);

    JButton loadTrackButton = (JButton) add(new JButton(""));
    loadTrackButton.setFocusable(false);
    loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    loadTrackButton.setToolTipText("Load a track");
    loadTrackButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().openTrack();
        }
    });
    loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadTrackButton.putClientProperty("JButton.segmentPosition", "last");
    loadTrackButton.setPreferredSize(ICON_SIZE);
    loadTrackButton.setMinimumSize(ICON_SIZE);
    loadTrackButton.setMaximumSize(ICON_SIZE);

    if (!Savant.getInstance().isStandalone()) {
        add(loadGenomeButton);
        add(loadTrackButton);
        add(getRigidPadding());
        add(getRigidPadding());
    } else {
        loadGenomeButton.setVisible(false);
        loadTrackButton.setVisible(false);
    }

    JLabel rangeText = new JLabel("Location ");
    add(rangeText);

    String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " };
    locationField = new JComboBox(a);
    locationField.setEditable(true);
    locationField.setRenderer(new ReferenceListRenderer());

    // When the item is chosen from the menu, navigate to the given feature/reference.
    locationField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (!currentlyPopulating) {
                if (ae.getActionCommand().equals("comboBoxChanged")) {
                    // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)".
                    String itemText = locationField.getSelectedItem().toString();
                    int lastBracketPos = itemText.lastIndexOf('(');
                    if (lastBracketPos > 0) {
                        itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1);
                    }
                    setRangeFromText(itemText);

                }
            }
        }
    });

    // When the combo-box is popped open, we may want to repopulate the menu.
    locationField.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
            String text = (String) locationField.getEditor().getItem();
            if (!text.equals(lastPoppedUp)) {
                try {
                    // Building the menu could take a while.
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    populateCombo();
                } finally {
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent pme) {
        }
    });

    // Add our special keystroke-handling to the JComboBox' text-field.
    // We have to turn off default tab-handling so that tab can pop up our list.
    Component textField = locationField.getEditor().getEditorComponent();
    textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
    textField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                locationField.showPopup();
            } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) {
                switch (evt.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    locationController.shiftRangeLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_RIGHT:
                    locationController.shiftRangeRight();
                    evt.consume();
                    break;
                case KeyEvent.VK_UP:
                    locationController.zoomIn();
                    evt.consume();
                    break;
                case KeyEvent.VK_DOWN:
                    locationController.zoomOut();
                    evt.consume();
                    break;
                case KeyEvent.VK_HOME:
                    locationController.shiftRangeFarLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_END:
                    locationController.shiftRangeFarRight();
                    evt.consume();
                    break;
                }
            }
        }
    });
    add(locationField);
    locationField.setToolTipText("Current display range");
    locationField.setPreferredSize(LOCATION_SIZE);
    locationField.setMaximumSize(LOCATION_SIZE);
    locationField.setMinimumSize(LOCATION_SIZE);

    add(getRigidPadding());

    JButton goButton = (JButton) add(new JButton("  Go  "));
    goButton.putClientProperty("JButton.buttonType", buttonStyle);
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.setToolTipText("Go to specified range (Enter)");
    goButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeFromText(locationField.getEditor().getItem().toString());
        }
    });

    add(getRigidPadding());

    JLabel l = new JLabel("Length: ");
    add(l);

    lengthLabel = (JLabel) add(new JLabel());
    lengthLabel.setToolTipText("Length of the current range");
    lengthLabel.setPreferredSize(LENGTH_SIZE);
    lengthLabel.setMaximumSize(LENGTH_SIZE);
    lengthLabel.setMinimumSize(LENGTH_SIZE);

    add(Box.createGlue());

    double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth();

    JButton afterGo = null;
    //if (screenwidth > 800) {
    final JButton undoButton = (JButton) add(new JButton(""));
    afterGo = undoButton;
    undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO));
    undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)");
    undoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.undoLocationChange();
        }
    });
    undoButton.putClientProperty("JButton.buttonType", buttonStyle);
    undoButton.putClientProperty("JButton.segmentPosition", "first");
    undoButton.setPreferredSize(ICON_SIZE);
    undoButton.setMinimumSize(ICON_SIZE);
    undoButton.setMaximumSize(ICON_SIZE);

    final JButton redo = (JButton) add(new JButton(""));
    redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO));
    redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)");
    redo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.redoLocationChange();
        }
    });
    redo.putClientProperty("JButton.buttonType", buttonStyle);
    redo.putClientProperty("JButton.segmentPosition", "last");
    redo.setPreferredSize(ICON_SIZE);
    redo.setMinimumSize(ICON_SIZE);
    redo.setMaximumSize(ICON_SIZE);
    //}

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton zoomInButton = (JButton) add(new JButton());
    if (afterGo == null) {
        afterGo = zoomInButton;
    }
    zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN));
    zoomInButton.putClientProperty("JButton.buttonType", buttonStyle);
    zoomInButton.putClientProperty("JButton.segmentPosition", "first");
    zoomInButton.setPreferredSize(ICON_SIZE);
    zoomInButton.setMinimumSize(ICON_SIZE);
    zoomInButton.setMaximumSize(ICON_SIZE);
    zoomInButton.setToolTipText("Zoom in (Shift+Up)");
    zoomInButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomIn();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "in"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton zoomOut = (JButton) add(new JButton(""));
    zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT));
    zoomOut.setToolTipText("Zoom out (Shift+Down)");
    zoomOut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomOut();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "out"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });
    zoomOut.putClientProperty("JButton.buttonType", buttonStyle);
    zoomOut.putClientProperty("JButton.segmentPosition", "last");
    zoomOut.setPreferredSize(ICON_SIZE);
    zoomOut.setMinimumSize(ICON_SIZE);
    zoomOut.setMaximumSize(ICON_SIZE);

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton shiftFarLeft = (JButton) add(new JButton());
    shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT));
    shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarLeft.putClientProperty("JButton.segmentPosition", "first");
    shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)");
    shiftFarLeft.setPreferredSize(ICON_SIZE);
    shiftFarLeft.setMinimumSize(ICON_SIZE);
    shiftFarLeft.setMaximumSize(ICON_SIZE);
    shiftFarLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftLeft = (JButton) add(new JButton());
    shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT));
    shiftLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
    shiftLeft.setToolTipText("Move left (Shift+Left)");
    shiftLeft.setPreferredSize(ICON_SIZE);
    shiftLeft.setMinimumSize(ICON_SIZE);
    shiftLeft.setMaximumSize(ICON_SIZE);
    shiftLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftRight = (JButton) add(new JButton());
    shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT));
    shiftRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftRight.putClientProperty("JButton.segmentPosition", "middle");
    shiftRight.setToolTipText("Move right (Shift+Right)");
    shiftRight.setPreferredSize(ICON_SIZE);
    shiftRight.setMinimumSize(ICON_SIZE);
    shiftRight.setMaximumSize(ICON_SIZE);
    shiftRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftFarRight = (JButton) add(new JButton());
    shiftFarRight
            .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT));
    shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarRight.putClientProperty("JButton.segmentPosition", "last");
    shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)");
    shiftFarRight.setPreferredSize(ICON_SIZE);
    shiftFarRight.setMinimumSize(ICON_SIZE);
    shiftFarRight.setMaximumSize(ICON_SIZE);
    shiftFarRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    add(getRigidPadding());

    locationController.addListener(new Listener<LocationChangedEvent>() {
        @Override
        public void handleEvent(LocationChangedEvent event) {
            updateLocation(event.getReference(), (Range) event.getRange());
        }
    });

    // When the genome changes, we may need to invalidate our menu.
    GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() {
        @Override
        public void handleEvent(GenomeChangedEvent event) {
            lastPoppedUp = "INVALID";
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentResized(ComponentEvent ce) {
            int width = ce.getComponent().getWidth();

            undoButton.setVisible(true);
            redo.setVisible(true);
            zoomInButton.setVisible(true);
            zoomOut.setVisible(true);
            shiftFarLeft.setVisible(true);
            shiftLeft.setVisible(true);
            shiftRight.setVisible(true);
            shiftFarRight.setVisible(true);

            // hide some components if the window isn't wide enough
            if (width < 1200) {
                undoButton.setVisible(false);
                redo.setVisible(false);
            }
            if (width < 1000) {
                shiftFarLeft.setVisible(false);
                shiftFarRight.setVisible(false);

                shiftRight.putClientProperty("JButton.segmentPosition", "last");
                shiftLeft.putClientProperty("JButton.segmentPosition", "first");
            } else {
                shiftRight.putClientProperty("JButton.segmentPosition", "middle");
                shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
            }
        }

        public void componentMoved(ComponentEvent ce) {
        }

        @Override
        public void componentShown(ComponentEvent ce) {
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
        }
    });
}