Example usage for javax.swing JToolBar add

List of usage examples for javax.swing JToolBar add

Introduction

In this page you can find the example usage for javax.swing JToolBar add.

Prototype

public JButton add(Action a) 

Source Link

Document

Adds a new JButton which dispatches the action.

Usage

From source file:org.terentich.pram.GUIPRAM.java

private void setContent() {

    FrameView mainview = getMainView();//  w  ww. j a v  a2 s . c o m
    Action openFileAction = mainview.getContext().getActionMap().get(ResourceNames.OPEN_FILE_ACTION_NAME);
    Action aboutDialogAction = mainview.getContext().getActionMap().get(ResourceNames.ABOUT_DIALOG_ACTION_NAME);

    JMenuBar bar = new JMenuBar();

    JMenu menuFile = new JMenu(getContext().getResourceMap().getString(ResourceNames.MENU_FILE_NAME));
    JMenu menuHelp = new JMenu(getContext().getResourceMap().getString(ResourceNames.MENU_HELP_NAME));

    menuFile.add(openFileAction);
    menuHelp.add(aboutDialogAction);

    bar.add(menuFile);
    bar.add(menuHelp);
    mainview.setMenuBar(bar);

    // Container panel = mainview.getRootPane().getContentPane();
    // panel.setLayout(new MigLayout());
    // panel.add(new JButton(mainview.getContext().getActionMap()
    // .get(OPEN_FILE_ACTION_NAME)));

    mainview.getFrame().setTitle(MessageFormat.format(APPLICATION_TITLE_FORMAT, metaReader.getApplicationName(),
            metaReader.getApplicationVersion()));

    Container content = mainview.getRootPane().getContentPane();
    tabPane = new JTabbedPane();
    content.add(tabPane);

    JToolBar toolbar = new JToolBar();
    toolbar.add(getContext().getActionMap().get(ResourceNames.OPEN_FILE_ACTION_NAME));
    toolbar.add(getContext().getActionMap().get(ResourceNames.ABOUT_DIALOG_ACTION_NAME));
    content.add(toolbar, BorderLayout.NORTH);

    initCLIOptions();

}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

/**
 * Create the panel./*from w  ww .  ja  v a 2s  .  c  om*/
 */
public MoviePanel() {
    super();
    // load movielist
    LOGGER.debug("loading MovieList");
    movieList = MovieList.getInstance();
    sortedMovies = new SortedList<>(GlazedListsSwing.swingThreadProxyList(movieList.getMovies()),
            new MovieComparator());
    sortedMovies.setMode(SortedList.AVOID_MOVING_ELEMENTS);

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("500px:grow"), }));

    splitPaneHorizontal = new JSplitPane();
    splitPaneHorizontal.setContinuousLayout(true);
    add(splitPaneHorizontal, "2, 2, fill, fill");

    JPanel panelMovieList = new JPanel();
    splitPaneHorizontal.setLeftComponent(panelMovieList);
    panelMovieList.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { RowSpec.decode("26px"), FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("fill:max(200px;default):grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelMovieList.add(toolBar, "2, 1, left, fill");

    // udpate datasource
    // toolBar.add(actionUpdateDataSources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDataSources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            JMenuItem item = new JMenuItem(actionUpdateDataSources2);
            buttonUpdateDatasource.getPopupMenu().add(item);
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)));
            }

            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("movie.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    item = new JMenuItem(actionScrapeUnscraped);
    popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);

    toolBar.add(actionEditMovie);

    btnRen = new JButton("REN");
    btnRen.setAction(actionRename);
    toolBar.add(btnRen);

    btnMediaInformation = new JButton("MI");
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    JButton btnCreateOflline = new JButton();
    btnCreateOflline.setAction(new MovieCreateOfflineAction(false));
    toolBar.add(btnCreateOflline);

    textField = EnhancedTextField.createSearchTextField();
    panelMovieList.add(textField, "3, 1, right, bottom");
    textField.setColumns(13);

    // table = new JTable();
    // build JTable

    MatcherEditor<Movie> textMatcherEditor = new TextComponentMatcherEditor<>(textField, new MovieFilterator());
    MovieMatcherEditor movieMatcherEditor = new MovieMatcherEditor();
    FilterList<Movie> extendedFilteredMovies = new FilterList<>(sortedMovies, movieMatcherEditor);
    textFilteredMovies = new FilterList<>(extendedFilteredMovies, textMatcherEditor);
    movieSelectionModel = new MovieSelectionModel(sortedMovies, textFilteredMovies, movieMatcherEditor);
    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(textFilteredMovies),
            new MovieTableFormat());
    table = new ZebraJTable(movieTableModel);

    movieTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount()));
            // select first movie if nothing is selected
            ListSelectionModel selectionModel = table.getSelectionModel();
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() > 0) {
                selectionModel.setSelectionInterval(0, 0);
            }
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() == 0) {
                movieSelectionModel.setSelectedMovie(null);
            }
        }
    });

    // install and save the comparator on the Table
    movieSelectionModel.setTableComparatorChooser(
            TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN));

    // table = new MyTable();
    table.setNewFontSize((float) ((int) Math.round(getFont().getSize() * 0.916)));
    // scrollPane.setViewportView(table);

    // JScrollPane scrollPane = new JScrollPane(table);
    JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table);
    panelMovieList.add(scrollPane, "2, 3, 4, 1, fill, fill");

    {
        final JToggleButton filterButton = new JToggleButton(IconManager.FILTER);
        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
        panelMovieList.add(filterButton, "5, 1, right, bottom");

        // add a propertychangelistener which reacts on setting a filter
        movieSelectionModel.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("filterChanged".equals(evt.getPropertyName())) {
                    if (Boolean.TRUE.equals(evt.getNewValue())) {
                        filterButton.setIcon(IconManager.FILTER_ACTIVE);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                    } else {
                        filterButton.setIcon(IconManager.FILTER);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                    }
                }
            }
        });

        panelExtendedSearch = new MovieExtendedSearchPanel(movieSelectionModel);
        panelExtendedSearch.setVisible(false);
        // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
        filterButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (panelExtendedSearch.isVisible() == true) {
                    panelExtendedSearch.setVisible(false);
                } else {
                    panelExtendedSearch.setVisible(true);
                }
            }
        });
    }

    JPanel panelStatus = new JPanel();
    panelMovieList.add(panelStatus, "2, 6, 2, 1");
    panelStatus.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("1px"),
                    ColumnSpec.decode("146px:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("fill:default:grow"), }));

    panelMovieCount = new JPanel();
    panelStatus.add(panelMovieCount, "3, 1, left, fill");

    lblMovieCount = new JLabel(BUNDLE.getString("tmm.movies") + ":"); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCount);

    lblMovieCountFiltered = new JLabel("");
    panelMovieCount.add(lblMovieCountFiltered);

    lblMovieCountOf = new JLabel(BUNDLE.getString("tmm.of")); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCountOf);

    lblMovieCountTotal = new JLabel("");
    panelMovieCount.add(lblMovieCountTotal);

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new MovieInformationPanel(movieSelectionModel);
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPaneHorizontal.setRightComponent(layeredPaneRight);
    splitPaneHorizontal.setContinuousLayout(true);

    // beansbinding init
    initDataBindings();

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();

    // filter
    if (MovieModuleManager.MOVIE_SETTINGS.isStoreUiFilters()) {
        movieList.searchDuplicates();
        movieSelectionModel.filterMovies(MovieModuleManager.MOVIE_SETTINGS.getUiFilters());
    }
}

From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java

/**
 * Instantiates a new tv show panel.//from   w w  w . ja v  a  2 s .co m
 */
public TvShowPanel() {
    super();

    treeModel = new TvShowTreeModel(tvShowList.getTvShows());
    tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel();
    tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel();

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setContinuousLayout(true);
    add(splitPane, "2, 2, fill, fill");

    JPanel panelTvShowTree = new JPanel();
    splitPane.setLeftComponent(panelTvShowTree);
    panelTvShowTree.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, }));

    textField = EnhancedTextField.createSearchTextField();
    panelTvShowTree.add(textField, "4, 1, right, bottom");
    textField.setColumns(12);
    textField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(final DocumentEvent e) {
            applyFilter();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            applyFilter();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            applyFilter();
        }

        public void applyFilter() {
            TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel();
            if (StringUtils.isNotBlank(textField.getText())) {
                filteredModel.setFilter(SearchOptions.TEXT, textField.getText());
            } else {
                filteredModel.removeFilter(SearchOptions.TEXT);
            }

            filteredModel.filter(tree);
        }
    });

    final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER);
    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
    panelTvShowTree.add(btnFilter, "6, 1, default, bottom");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill");

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelTvShowTree.add(toolBar, "2, 1");

    // toolBar.add(actionUpdateDatasources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDatasources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2));
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds)));
            }
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow));
            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        @Override
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        @Override
        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    // item = new JMenuItem(actionScrapeUnscraped);
    // popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    item = new JMenuItem(actionScrapeNewItems);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);
    toolBar.add(actionEdit);

    JButton btnMediaInformation = new JButton();
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    // install drawing of full with
    tree = new ZebraJTree(treeModel) {
        private static final long serialVersionUID = 2422163883324014637L;

        @Override
        public void paintComponent(Graphics g) {
            width = this.getWidth();
            super.paintComponent(g);
        }
    };
    tvShowSelectionModel = new TvShowSelectionModel(tree);

    TreeUI ui = new TreeUI() {
        @Override
        protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds,
                TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
            bounds.width = width - bounds.x;
            super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
        }
    };
    tree.setUI(ui);

    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setCellRenderer(new TvShowTreeCellRenderer());
    tree.setRowHeight(0);
    scrollPane.setViewportView(tree);

    JPanel panelHeader = new JPanel() {
        private static final long serialVersionUID = -6914183798172482157L;

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0,
                    getWidth(), getHeight());
        }
    };
    scrollPane.setColumnHeaderView(panelHeader);
    panelHeader.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"),
                    ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, }));

    JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$
    lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER);
    panelHeader.add(lblTvShowsColumn, "2, 1");

    JLabel lblNfoColumn = new JLabel("");
    lblNfoColumn.setHorizontalAlignment(JLabel.CENTER);
    lblNfoColumn.setIcon(IconManager.INFO);
    lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$
    panelHeader.add(lblNfoColumn, "4, 1");

    JLabel lblImageColumn = new JLabel("");
    lblImageColumn.setHorizontalAlignment(JLabel.CENTER);
    lblImageColumn.setIcon(IconManager.IMAGE);
    lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$
    panelHeader.add(lblImageColumn, "5, 1");

    JLabel lblSubtitleColumn = new JLabel("");
    lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER);
    lblSubtitleColumn.setIcon(IconManager.SUBTITLE);
    lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$
    panelHeader.add(lblSubtitleColumn, "6, 1");

    JPanel panel = new JPanel();
    panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill");
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$
    panel.add(lblTvShowsT, "1, 2, fill, fill");

    lblTvShows = new JLabel("");
    panel.add(lblTvShows, "3, 2");

    JLabel labelSlash = new JLabel("/");
    panel.add(labelSlash, "5, 2");

    JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$
    panel.add(lblEpisodesT, "7, 2");

    lblEpisodes = new JLabel("");
    panel.add(lblEpisodes, "9, 2");

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new JPanel();
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree);
    panelExtendedSearch.setVisible(false);
    // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
    btnFilter.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (panelExtendedSearch.isVisible() == true) {
                panelExtendedSearch.setVisible(false);
            } else {
                panelExtendedSearch.setVisible(true);
            }
        }
    });
    // add a propertychangelistener which reacts on setting a filter
    tree.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("filterChanged".equals(evt.getPropertyName())) {
                if (Boolean.TRUE.equals(evt.getNewValue())) {
                    btnFilter.setIcon(IconManager.FILTER_ACTIVE);
                    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                } else {
                    btnFilter.setIcon(IconManager.FILTER);
                    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                }
            }
        }
    });
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPane.setRightComponent(layeredPaneRight);
    panelRight.setLayout(new CardLayout(0, 0));

    JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel);
    panelRight.add(panelTvShow, "tvShow");

    JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel);
    panelRight.add(panelTvShowSeason, "tvShowSeason");

    JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel);
    panelRight.add(panelTvShowEpisode, "tvShowEpisode");

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            if (node != null) {
                // click on a tv show
                if (node.getUserObject() instanceof TvShow) {
                    TvShow tvShow = (TvShow) node.getUserObject();
                    tvShowSelectionModel.setSelectedTvShow(tvShow);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShow");
                }

                // click on a season
                if (node.getUserObject() instanceof TvShowSeason) {
                    TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject();
                    tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShowSeason");
                }

                // click on an episode
                if (node.getUserObject() instanceof TvShowEpisode) {
                    TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject();
                    tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShowEpisode");
                }
            } else {
                // check if there is at least one tv show in the model
                TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot();
                if (root.getChildCount() == 0) {
                    // sets an inital show
                    tvShowSelectionModel.setSelectedTvShow(null);
                }
            }
        }
    });

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();
    initDataBindings();

    // selecting first TV show at startup
    if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) {
        DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel()
                .getRoot()).getFirstChild();
        tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath()));
        tree.setSelectionPath(new TreePath(firstLeaf.getPath()));
    }
}

From source file:org.zaproxy.zap.extension.browserView.ResponseBrowserView.java

private JToolBar createToolbar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);//from ww  w .  j  av a 2  s  .  c  o  m
    toolBar.setMinimumSize(new Dimension(50, 50));
    JButton button = createAdjustHeightButton();
    toolBar.add(button);
    return toolBar;
}

From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java

private static void add(JToolBar toolbar, ButtonGroup g, AbstractButton b) {
    b.setFocusable(false);/*from   w w w  .j  a  v a  2 s.c  o m*/
    b.setBorder(null);
    b.setHorizontalAlignment(SwingConstants.LEFT);
    toolbar.add(b);
    if (g != null)
        g.add(b);
}

From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java

public void goToLiveMode() {
    JToolBar jToolBar = new JToolBar();
    createFollowCheckBox();/*  w  w  w .  ja  v a2 s .co m*/
    createPauseCheckBox();
    createReadingProgressBar();

    jToolBar.add(playTailing);
    jToolBar.add(follow);
    JButton clear = new JButton(new ClearLogTableAction(otrosApplication));
    clear.setBorderPainted(false);
    jToolBar.add(clear);
    jToolBar.add(progressBar);

    logViewPanel.add(jToolBar, BorderLayout.NORTH);
    logViewPanel.getLogsMarkersPanel().setLayout(new BorderLayout());
    TailingModeMarkersPanel markersPanel = new TailingModeMarkersPanel(logViewPanel.getDataTableModel());
    logViewPanel.getLogsMarkersPanel().add(markersPanel);

    switchToContentView();
    addRowAutoScroll();
}

From source file:pl.otros.logview.gui.Log4jPatternParserEditor.java

private void createGui() {
    this.setLayout(new BorderLayout());
    heading1Font = new JLabel().getFont().deriveFont(20f).deriveFont(Font.BOLD);
    heading2Font = new JLabel().getFont().deriveFont(14f).deriveFont(Font.BOLD);

    loadLog = new JButton("Load log", Icons.FOLDER_OPEN);
    testParser = new JButton("Test parser", Icons.WRENCH_ARROW);
    saveParser = new JButton("Save", Icons.DISK);
    logFileContent = new JTextArea();
    DefaultSyntaxKit.initKit();//from w  w  w .j av  a  2  s  .  c o  m
    propertyEditor = new JEditorPane();

    logFileContent = new JTextArea();
    logViewPanel = new LogViewPanel(new LogDataTableModel(), TableColumns.ALL_WITHOUT_LOG_SOURCE,
            otrosApplication);
    JPanel panelEditorActions = new JPanel(new BorderLayout(5, 5));
    JToolBar actionsToolBar = new JToolBar("Actions");
    actionsToolBar.setFloatable(false);
    actionsToolBar.add(testParser);
    actionsToolBar.add(saveParser);

    JToolBar propertyEditorToolbar = new JToolBar();
    JLabel labelEditProperties = new JLabel("Edit your properties: and test parser");
    labelEditProperties.setFont(heading2Font);
    propertyEditorToolbar.add(labelEditProperties);
    panelEditorActions.add(propertyEditorToolbar, BorderLayout.NORTH);
    panelEditorActions.add(actionsToolBar, BorderLayout.SOUTH);
    panelEditorActions.add(new JScrollPane(propertyEditor));

    logFileContentLabel = new JLabel(" Load your log file, paste from clipboard or drag and drop file. ");
    JToolBar loadToolbar = new JToolBar();
    loadToolbar.add(logFileContentLabel);
    loadToolbar.add(loadLog);
    logFileContentLabel.setFont(heading2Font);
    JPanel logContentPanel = new JPanel(new BorderLayout(5, 5));
    logContentPanel.add(new JScrollPane(logFileContent));
    logContentPanel.add(loadToolbar, BorderLayout.NORTH);

    JSplitPane northSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    northSplit.setOneTouchExpandable(true);
    northSplit.add(logContentPanel);
    northSplit.add(panelEditorActions);

    JPanel southPanel = new JPanel(new BorderLayout(5, 5));
    JLabel labelParsingResult = new JLabel(" Parsing result:");
    labelParsingResult.setFont(heading1Font);
    southPanel.add(labelParsingResult, BorderLayout.NORTH);
    southPanel.add(logViewPanel);

    JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainSplit.setOneTouchExpandable(true);
    mainSplit.add(northSplit);
    mainSplit.add(southPanel);
    mainSplit.setDividerLocation(0.5f);

    add(mainSplit);

    propertyEditor.setContentType("text/properties");

}

From source file:pl.otros.logview.gui.LogViewPanelWrapper.java

public void goToLiveMode() {
    mode = Mode.Live;/*from w  w  w  . ja  v a 2s  .  c  o  m*/
    JToolBar jToolBar = new JToolBar();
    createFollowCheckBox();
    createPauseCheckBox();

    jToolBar.add(playTailing);
    jToolBar.add(follow);
    JButton clear = new JButton(new ClearLogTableAction(otrosApplication));
    clear.setBorderPainted(false);
    jToolBar.add(clear);

    logViewPanel.add(jToolBar, BorderLayout.NORTH);
    logViewPanel.getLogsMarkersPanel().setLayout(new BorderLayout());
    TailingModeMarkersPanel markersPanel = new TailingModeMarkersPanel(logViewPanel.getDataTableModel());
    logViewPanel.getLogsMarkersPanel().add(markersPanel);

    switchToContentView();
    addRowScroller();
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

private void initGui(final String initialPath) {
    this.setLayout(new BorderLayout());
    JLabel pathLabel = new JLabel(Messages.getMessage("browser.location"));
    pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
    pathField = new JTextField(80);
    pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f));
    pathField.setToolTipText(Messages.getMessage("nav.pathTooltip"));
    GuiUtils.addBlinkOnFocusGain(pathField);
    pathLabel.setLabelFor(pathField);/*from   w w w  .  ja v a2 s .  c o m*/
    pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0));

    InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED);
    inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH");
    inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE);
    pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) {

        @Override
        protected void performLongOperation(CheckBeforeActionResult actionResult) {
            try {
                FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim());
                if (resolveFile != null && resolveFile.getType() == FileType.FILE) {
                    loadAndSelSingleFile(resolveFile);
                    pathField.setText(resolveFile.getURL().toString());
                    actionApproveDelegate.actionPerformed(
                            // TODO:  Does actionResult provide an ID for 2nd param here,
                            // or should use a Random number?
                            new ActionEvent(actionResult, (int) new java.util.Date().getTime(),
                                    "SELECTED_FILE"));
                    return;
                }
            } catch (FileSystemException fse) {
                // Intentionally empty
            }
            goToUrl(pathField.getText().trim());
        }

        @Override
        protected boolean canGoUrl() {
            return true;
        }

        @Override
        protected boolean canExecuteDefaultAction() {
            return false;
        }

    });
    actionFocusOnTable = new

    AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            tableFiles.requestFocusInWindow();
            if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) {
                tableFiles.getSelectionModel().setSelectionInterval(0, 0);
            }
        }
    };
    pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable);

    BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this);
    goUpButton = new JButton(goUpAction);

    BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this);
    JButton refreshButton = new JButton(refreshAction);

    JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName"));
    upperPanel.setRollover(true);
    upperPanel.add(pathLabel);
    upperPanel.add(pathField, "growx");
    upperPanel.add(goUpButton);
    upperPanel.add(refreshButton);

    AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction(
            this);
    JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction);
    addCurrentLocationToFavoriteButton.setText("");
    upperPanel.add(addCurrentLocationToFavoriteButton);

    previewComponent = new PreviewComponent();

    vfsTableModel = new VfsTableModel();

    tableFiles = new JTable(vfsTableModel);
    tableFiles.setFillsViewportHeight(true);
    tableFiles.getColumnModel().getColumn(0).setMinWidth(140);
    tableFiles.getColumnModel().getColumn(1).setMaxWidth(80);
    tableFiles.getColumnModel().getColumn(2).setMaxWidth(80);
    tableFiles.getColumnModel().getColumn(3).setMaxWidth(180);
    tableFiles.getColumnModel().getColumn(3).setMinWidth(120);

    sorter = new TableRowSorter<VfsTableModel>(vfsTableModel);
    final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator();
    sorter.addRowSorterListener(new RowSorterListener() {
        @Override
        public void sorterChanged(RowSorterEvent e) {
            RowSorterEvent.Type type = e.getType();
            if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) {
                List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys();
                for (RowSorter.SortKey sortKey : sortKeys) {
                    if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) {
                        fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder());
                    }
                }
            }
        }
    });
    sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator);

    tableFiles.setRowSorter(sorter);
    tableFiles.setShowGrid(false);
    tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            try {
                selectionChanged();
            } catch (FileSystemException e1) {
                LOGGER.error("Error during update state", e);
            }
        }
    });
    tableFiles.setColumnSelectionAllowed(false);
    vfsTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateStatusText();
        }
    });

    tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer());
    tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer());
    tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer());
    tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer());

    tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent));

    JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]"));
    favoritesUserListModel = new MutableListModel<Favorite>();

    List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations();
    List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration);
    List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks();
    for (Favorite favorite : favUser) {
        favoritesUserListModel.add(favorite);
    }
    favoritesUserListModel.addListDataListener(new ListDataListener() {
        @Override
        public void intervalAdded(ListDataEvent e) {
            saveFavorites();

        }

        @Override
        public void intervalRemoved(ListDataEvent e) {
            saveFavorites();
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
            saveFavorites();
        }

        protected void saveFavorites() {
            FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList());
        }
    });

    favoritesUserList = new JList(favoritesUserListModel);
    favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList));
    new MutableListDragListener(favoritesUserList);
    favoritesUserList.setCellRenderer(new FavoriteListCellRenderer());
    favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter());

    addOpenActionToList(favoritesUserList);
    addEditActionToList(favoritesUserList, favoritesUserListModel);

    favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction(
            Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) {

        @Override
        public void actionPerformed(ActionEvent e) {
            Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex());
            if (!Favorite.Type.USER.equals(favorite.getType())) {
                return;
            }
            int response = JOptionPane.showConfirmDialog(VfsBrowser.this,
                    Messages.getMessage("favorites.areYouSureToDeleteConnections"),
                    Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION);

            if (response == JOptionPane.YES_OPTION) {
                favoritesUserListModel.remove(favoritesUserList.getSelectedIndex());
            }
        }
    });
    InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED);
    favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE);

    ActionMap actionMap = tableFiles.getActionMap();
    actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this));
    actionMap.put(ACTION_GO_UP, goUpAction);
    actionMap.put(ACTION_APPROVE, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (actionApproveButton.isEnabled()) {
                actionApproveDelegate.actionPerformed(e);
            }
        }
    });

    InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED);
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE);

    inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP);
    addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE);

    JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations));
    favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer());
    addOpenActionToList(favoriteSystemList);
    addPopupMenu(favoriteSystemList, ACTION_OPEN);
    favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter());

    JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser));
    addOpenActionToList(favoriteJVfsList);
    favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer());
    addPopupMenu(favoriteJVfsList, ACTION_OPEN);
    favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter());

    JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"),
            COMPUTER_ICON);
    favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList);
    favoritesSystemLocationsLabel
            .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0));
    favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16");
    favoritesPanel.add(favoriteSystemList, "growx");
    JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"),
            Icons.getInstance().getStar());
    favoritesFavoritesLabel.setLabelFor(favoritesUserList);
    favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0));
    favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16");
    favoritesPanel.add(favoritesUserList, "growx");

    if (favoriteJVfsList.getModel().getSize() > 0) {
        JLabel favoritesJVfsFileChooser = getTitleListLabel(
                Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null);
        favoritesJVfsFileChooser.setDisplayedMnemonic(
                Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0));
        favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList);
        favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16");
        favoritesPanel.add(favoriteJVfsList, "growx");
    }

    tableFiles.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null);
            }
        }
    });
    tableFiles.addKeyListener(new QuickSearchKeyAdapter());

    cardLayout = new CardLayout();
    tablePanel = new JPanel(cardLayout);
    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString(Messages.getMessage("browser.loading"));
    loadingProgressBar.setIndeterminate(true);
    loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline());
    skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks"));
    skipCheckingLinksButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (taskContext != null) {
                taskContext.setStop(skipCheckingLinksButton.isSelected());
            }
        }
    });

    showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden);
    showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip"));
    showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0));
    Font tmpFont = showHidCheckBox.getFont();
    showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f));
    showHidCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUiFilters();
        }
    });

    final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText");
    filterField = new JTextField("", 16);
    filterField.setForeground(filterField.getDisabledTextColor());
    filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip"));
    PromptSupport.setPrompt(defaultFilterText, filterField);
    filterField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            documentChanged();
        }

        void documentChanged() {
            if (filterField.getText().length() == 0) {
                updateUiFilters();
            }
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            documentChanged();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            documentChanged();
        }
    });
    filterField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            updateUiFilters();
        }
    });

    AbstractAction actionClearRegexFilter = new

    AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            filterField.setText("");
        }
    };
    filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable);
    filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter);

    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
            ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            ACTION_CLEAR_REGEX_FILTER);

    JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter"));
    nameFilterLabel.setLabelFor(filterField);
    nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0));

    sorter.setRowFilter(createFilter());
    statusLabel = new JLabel();

    actionApproveButton = new JButton();
    actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD));
    actionCancelButton = new JButton();

    ActionMap browserActionMap = this.getActionMap();
    browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            filterField.requestFocus();
            filterField.selectAll();
            GuiUtils.blinkComponent(filterField);
        }
    });

    browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField));
    browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox));
    browserActionMap.put(ACTION_REFRESH, refreshAction);
    browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction);
    browserActionMap.put(ACTION_GO_UP, goUpAction);
    browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles));

    InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER);
    browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH);
    browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH);
    browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN);
    browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH);
    browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH);
    browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES);
    browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP);
    browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE);

    //DO layout
    // create the layer for the panel using our custom layerUI
    tableScrollPane = new JScrollPane(tableFiles);

    JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout());
    tableScrollPaneWithFilter.add(tableScrollPane);
    JToolBar filtersToolbar = new JToolBar("Filters");
    filtersToolbar.setFloatable(false);
    filtersToolbar.setBorderPainted(true);
    tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH);
    filtersToolbar.add(nameFilterLabel);
    filtersToolbar.add(filterField);
    filtersToolbar.add(showHidCheckBox);
    JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
            tableScrollPaneWithFilter, previewComponent);
    tableWithPreviewPane.setOneTouchExpandable(true);

    JPanel loadingPanel = new JPanel(new MigLayout());
    loadingPanel.add(loadingIconLabel, "right");
    loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap");
    loadingPanel.add(skipCheckingLinksButton, "span, right");
    tablePanel.add(loadingPanel, LOADING);
    tablePanel.add(tableWithPreviewPane, TABLE);

    JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel),
            tablePanel);
    jSplitPane.setOneTouchExpandable(true);
    jSplitPane.setDividerLocation(180);

    JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", ""));
    southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    southPanel.add(statusLabel);
    southPanel.add(actionApproveButton);
    southPanel.add(actionCancelButton);

    this.add(upperPanel, BorderLayout.NORTH);
    this.add(jSplitPane, BorderLayout.CENTER);
    this.add(southPanel, BorderLayout.SOUTH);

    try {
        selectionChanged();
    } catch (FileSystemException e) {
        LOGGER.error("Can't initialize default selection mode", e);
    }
    // Why this not done in EDT?
    // Is it assume that constructor is invoked from an  EDT?
    try {
        if (initialPath == null) {
            goToUrl(VFSUtils.getUserHome());
        } else {
            try {
                FileObject resolveFile = VFSUtils.resolveFileObject(initialPath);
                if (resolveFile != null && resolveFile.getType() == FileType.FILE) {
                    loadAndSelSingleFile(resolveFile);
                    pathField.setText(resolveFile.getURL().toString());
                    targetFileSelected = true;
                    return;
                }
            } catch (FileSystemException fse) {
                // Intentionally empty
            }
            goToUrl(initialPath);
        }
    } catch (FileSystemException e1) {
        LOGGER.error("Can't initialize default location", e1);
    }
    showTable();
}

From source file:ro.nextreports.designer.querybuilder.QueryBuilderPanel.java

private void initUI() {
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.setDividerLocation(250);// ww  w.  j a  v  a 2  s.co  m
    split.setOneTouchExpandable(true);

    JToolBar toolBar = new JToolBar();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar.setBorderPainted(false);

    // add refresh action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("refresh");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.refresh");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            try {
                if (Globals.getConnection() == null) {
                    return;
                }

                // refresh tables, views, procedures
                TreeUtil.refreshDatabase();

                // add new queries to tree
                TreeUtil.refreshQueries();

                // add new reports to tree
                TreeUtil.refreshReports();

                // add new charts to tree
                TreeUtil.refreshCharts();

            } catch (Exception ex) {
                Show.error(ex);
            }
        }

    });

    // add expand action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("expandall");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.expand.all");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            TreeUtil.expandAll(dbBrowserTree);
        }

    });

    // add collapse action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("collapseall");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.collapse.all");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            TreeUtil.collapseAll(dbBrowserTree);
        }

    });

    // add properties button
    /*
      JButton propButton = new MagicButton(new AbstractAction() {
            
      public Object getValue(String key) {
          if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("properties");
          }
            
          return super.getValue(key);
      }
            
      public void actionPerformed(ActionEvent e) {
          DBBrowserPropertiesPanel joinPanel = new DBBrowserPropertiesPanel();
          JDialog dlg = new DBBrowserPropertiesDialog(joinPanel);
          dlg.pack();
          dlg.setResizable(false);
          Show.centrateComponent(Globals.getMainFrame(), dlg);
          dlg.setVisible(true);
      }
            
      });
      propButton.setToolTipText(I18NSupport.getString("querybuilder.properties"));
      */
    //browserButtonsPanel.add(propButton);

    //        ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(browserButtonsPanel);

    browserPanel = new JXPanel(new BorderLayout());
    browserPanel.add(toolBar, BorderLayout.NORTH);

    // browser tree
    JScrollPane scroll = new JScrollPane(dbBrowserTree);
    browserPanel.add(scroll, BorderLayout.CENTER);
    split.setLeftComponent(browserPanel);

    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    //        tabbedPane.putClientProperty(Options.EMBEDDED_TABS_KEY, Boolean.TRUE); // look like eclipse

    JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split2.setResizeWeight(0.66);
    split2.setOneTouchExpandable(true);

    // desktop pane
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    desktop.setDropTarget(
            new DropTarget(desktop, DnDConstants.ACTION_MOVE, new DesktopPaneDropTargetListener(), true));

    // create the toolbar
    JToolBar toolBar2 = new JToolBar();
    toolBar2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar2.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar2.setBorderPainted(false);

    Action distinctAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            if (distinctButton.isSelected()) {
                selectQuery.setDistinct(true);
            } else {
                selectQuery.setDistinct(false);
            }
        }

    };
    distinctAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.distinct"));
    distinctAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.distinct"));
    toolBar2.add(distinctButton = new JToggleButton(distinctAction));

    Action groupByAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            groupBy = groupByButton.isSelected();
            Globals.getEventBus().publish(new GroupByEvent(QueryBuilderPanel.this.desktop, groupBy));
        }

    };
    groupByAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.group_by"));
    groupByAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.group.by"));
    toolBar2.add(groupByButton = new JToggleButton(groupByAction));

    Action clearAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            clear(false);
        }

    };
    clearAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("clear"));
    clearAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.clear"));
    toolBar2.add(clearAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar2);

    // add run button
    Action runQueryAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            selectSQLViewTab();
            sqlView.doRun();
        }

    };
    runQueryAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run"));
    KeyStroke ks = KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4"));
    runQueryAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " ("
            + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")");
    runQueryAction.putValue(Action.ACCELERATOR_KEY, ks);
    toolBar2.add(runQueryAction);
    // register run query shortcut
    GlobalHotkeyManager hotkeyManager = GlobalHotkeyManager.getInstance();
    InputMap inputMap = hotkeyManager.getInputMap();
    ActionMap actionMap = hotkeyManager.getActionMap();
    inputMap.put((KeyStroke) runQueryAction.getValue(Action.ACCELERATOR_KEY), "runQueryAction");
    actionMap.put("runQueryAction", runQueryAction);

    JScrollPane scroll2 = new JScrollPane(desktop, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll2.setPreferredSize(DBTablesDesktopPane.PREFFERED_SIZE);
    DecoratedScrollPane.decorate(scroll2);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());
    topPanel.add(toolBar2, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    topPanel.add(scroll2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    split2.setTopComponent(topPanel);
    designPanel = new DesignerTablePanel(selectQuery);
    split2.setBottomComponent(designPanel);
    split2.setDividerLocation(400);

    tabbedPane.addTab(I18NSupport.getString("querybuilder.query.designer"), ImageUtil.getImageIcon("designer"),
            split2);
    tabbedPane.setMnemonicAt(0, 'D');

    sqlView = new SQLViewPanel();
    sqlView.getEditorPane().setDropTarget(new DropTarget(sqlView.getEditorPane(), DnDConstants.ACTION_MOVE,
            new SQLViewDropTargetListener(), true));
    tabbedPane.addTab(I18NSupport.getString("querybuilder.query.editor"), ImageUtil.getImageIcon("sql"),
            sqlView);
    tabbedPane.setMnemonicAt(1, 'E');

    split.setRightComponent(tabbedPane);

    // register a change listener
    tabbedPane.addChangeListener(new ChangeListener() {

        // this method is called whenever the selected tab changes
        public void stateChanged(ChangeEvent ev) {
            if (ev.getSource() == QueryBuilderPanel.this.tabbedPane) {
                // get current tab
                int sel = QueryBuilderPanel.this.tabbedPane.getSelectedIndex();
                if (sel == 1) { // sql view
                    String query;
                    if (!synchronizedPanels) {
                        query = sqlView.getQueryString();
                        synchronizedPanels = true;
                    } else {
                        if (Globals.getConnection() != null) {
                            query = getSelectQuery().toString();
                        } else {
                            query = "";
                        }
                        //                     if (query.equals("")) {
                        //                        query = sqlView.getQueryString();
                        //                     }
                    }
                    if (resetTable) {
                        sqlView.clear();
                        resetTable = false;
                    }
                    //System.out.println("query="+query);
                    sqlView.setQueryString(query);
                } else if (sel == 0) { // design view
                    if (queryWasModified(false)) {
                        Object[] options = { I18NSupport.getString("optionpanel.yes"),
                                I18NSupport.getString("optionpanel.no") };
                        String m1 = I18NSupport.getString("querybuilder.lost");
                        String m2 = I18NSupport.getString("querybuilder.continue");
                        int option = JOptionPane.showOptionDialog(Globals.getMainFrame(),
                                "<HTML>" + m1 + "<BR>" + m2 + "</HTML>",
                                I18NSupport.getString("querybuilder.confirm"), JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE, null, options, options[1]);

                        if (option != JOptionPane.YES_OPTION) {
                            synchronizedPanels = false;
                            tabbedPane.setSelectedIndex(1);
                        } else {
                            resetTable = true;
                        }
                    }
                } else if (sel == 2) { // report view

                }
            }
        }

    });

    //        this.add(split, BorderLayout.CENTER);

    parametersPanel = new ParametersPanel();
}