Example usage for javax.swing JToolBar addSeparator

List of usage examples for javax.swing JToolBar addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Appends a separator of default size to the end of the tool bar.

Usage

From source file:org.apache.cayenne.modeler.editor.dbentity.DbEntityAttributeRelationshipTab.java

private void initToolBar() {
    JToolBar toolBar = new JToolBar();
    ActionManager actionManager = Application.getInstance().getActionManager();

    toolBar.add(actionManager.getAction(CreateObjEntityAction.class).buildButton());
    toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());
    toolBar.add(actionManager.getAction(CreateRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(DbEntitySyncAction.class).buildButton());
    toolBar.add(actionManager.getAction(DbEntityCounterpartAction.class).buildButton());
    toolBar.addSeparator();

    Icon ico = ModelerUtil.buildIcon("icon-info.gif");
    resolve.setToolTipText("Database Mapping");
    resolve.setIcon(ico);/*from  w ww.  j a v  a2 s  .co  m*/
    toolBar.add(resolve).setEnabled(false);

    cut = actionManager.getAction(CutAttributeRelationshipAction.class);
    remove = actionManager.getAction(RemoveAttributeRelationshipAction.class);
    copy = actionManager.getAction(CopyAttributeRelationshipAction.class);

    toolBar.addSeparator();
    toolBar.add(remove.buildButton());
    toolBar.addSeparator();
    toolBar.add(cut.buildButton());
    toolBar.add(copy.buildButton());
    toolBar.add(actionManager.getAction(PasteAction.class).buildButton());

    add(toolBar, BorderLayout.NORTH);
}

From source file:org.apache.cayenne.modeler.editor.EditorView.java

private void initView() {

    // init widgets
    JButton collapseButton = getAction(CollapseTreeAction.class).buildButton();
    collapseButton.setPreferredSize(new Dimension(30, 20));
    JButton filterButton = getAction(FilterAction.class).buildButton();
    filterButton.setPreferredSize(new Dimension(30, 20));
    actionManager.getAction(CollapseTreeAction.class).setAlwaysOn(true);
    actionManager.getAction(FilterAction.class).setAlwaysOn(true);

    JToolBar barPanel = new JToolBar();
    barPanel.setMinimumSize(new Dimension(75, 25));
    barPanel.setBorder(BorderFactory.createEtchedBorder());
    barPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    barPanel.add(Box.createHorizontalStrut(3));
    barPanel.add(filterButton);//from   w w  w .  ja  v  a  2  s .  co  m
    barPanel.addSeparator();
    barPanel.add(collapseButton);

    treePanel = new ProjectTreeView(eventController);
    treePanel.setMinimumSize(new Dimension(75, 180));
    JPanel treeNavigatePanel = new JPanel();
    treeNavigatePanel.setMinimumSize(new Dimension(75, 220));
    treeNavigatePanel.setLayout(new BorderLayout());
    treeNavigatePanel.add(treePanel, BorderLayout.CENTER);

    this.detailPanel = new JPanel();
    this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    this.leftPanel = new JPanel(new BorderLayout());
    // assemble...

    this.detailLayout = new CardLayout();
    detailPanel.setLayout(detailLayout);

    // some but not all panels must be wrapped in a scroll pane
    // those that are not wrapped usually have there own scrollers
    // in subpanels...

    detailPanel.add(new JPanel(), EMPTY_VIEW);

    dataDomainView = new DataDomainTabbedView(eventController);
    detailPanel.add(dataDomainView, DOMAIN_VIEW);

    DataNodeEditor nodeController = new DataNodeEditor(eventController);
    detailPanel.add(nodeController.getView(), NODE_VIEW);

    dataNodeView = nodeController.getTabComponent();

    dataMapView = new DataMapTabbedView(eventController);
    detailPanel.add(dataMapView, DATA_MAP_VIEW);

    procedureView = new ProcedureTabbedView(eventController);
    detailPanel.add(procedureView, PROCEDURE_VIEW);

    selectQueryView = new SelectQueryTabbedView(eventController);
    detailPanel.add(selectQueryView, SELECT_QUERY_VIEW);

    sqlTemplateView = new SQLTemplateTabbedView(eventController);
    detailPanel.add(sqlTemplateView, SQL_TEMPLATE_VIEW);

    Component procedureQueryView = new ProcedureQueryView(eventController);
    detailPanel.add(new JScrollPane(procedureQueryView), PROCEDURE_QUERY_VIEW);

    ejbqlQueryView = new EjbqlTabbedView(eventController);
    detailPanel.add(ejbqlQueryView, EJBQL_QUERY_VIEW);

    embeddableView = new EmbeddableTabbedView(eventController);
    detailPanel.add(embeddableView, EMBEDDABLE_VIEW);

    objDetailView = new ObjEntityTabbedView(eventController);
    detailPanel.add(objDetailView, OBJ_VIEW);

    dbDetailView = new DbEntityTabbedView(eventController);
    detailPanel.add(dbDetailView, DB_VIEW);

    leftPanel.add(barPanel, BorderLayout.NORTH);
    leftPanel.add(new JScrollPane(treeNavigatePanel), BorderLayout.CENTER);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(detailPanel);

    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);

}

From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipTab.java

private void init() {
    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(ObjEntitySyncAction.class).buildButton());
    toolBar.add(actionManager.getAction(ObjEntityCounterpartAction.class).buildButton());

    toolBar.addSeparator();

    Icon ico = ModelerUtil.buildIcon("icon-info.gif");

    resolve = new JButton();
    resolve.setIcon(ico);// www.j  a  va  2 s  .c  om
    resolve.setToolTipText("Edit Relationship");
    toolBar.add(resolve);

    toolBar.addSeparator();

    toolBar.add(actionManager.getAction(RemoveRelationshipAction.class).buildButton());

    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(CutRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(CopyRelationshipAction.class).buildButton());
    toolBar.add(actionManager.getAction(PasteAction.class).buildButton());

    add(toolBar, BorderLayout.NORTH);

    table = new CayenneTable();
    table.setDefaultRenderer(String.class, new StringRenderer());
    table.setDefaultRenderer(ObjEntity.class, new EntityRenderer());

    tablePreferences = new TableColumnPreferences(ObjRelationshipTableModel.class,
            "objEntity/relationshipTable");

    /**
     * Create and install a popup
     */
    resolveMenu = new JMenuItem("Database Mapping", ico);

    JPopupMenu popup = new JPopupMenu();
    popup.add(resolveMenu);
    popup.add(actionManager.getAction(RemoveRelationshipAction.class).buildMenu());

    popup.addSeparator();
    popup.add(actionManager.getAction(CutRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyRelationshipAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());

    TablePopupHandler.install(table, popup);

    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}

From source file:org.apache.cayenne.modeler.editor.ObjEntityTab.java

private void initView() {
    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    ActionManager actionManager = Application.getInstance().getActionManager();

    toolBar.add(actionManager.getAction(ObjEntitySyncAction.class).buildButton());
    toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());
    toolBar.add(actionManager.getAction(CreateRelationshipAction.class).buildButton());
    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(ShowGraphEntityAction.class).buildButton());
    toolBar.add(actionManager.getAction(ObjEntityCounterpartAction.class).buildButton());
    add(toolBar, BorderLayout.NORTH);

    // create widgets
    name = new TextAdapter(new JTextField()) {

        @Override//from www .jav  a  2s. com
        protected void updateModel(String text) {
            setEntityName(text);
        }
    };
    superClassName = new TextAdapter(new JTextField()) {

        @Override
        protected void updateModel(String text) {
            setSuperClassName(text);
        }
    };
    className = new TextAdapter(new JTextField()) {

        @Override
        protected void updateModel(String text) {
            setClassName(text);
        }
    };
    qualifier = new TextAdapter(new JTextField()) {

        @Override
        protected void updateModel(String text) {
            setQualifier(text);
        }
    };

    dbEntityCombo = Application.getWidgetFactory().createComboBox();
    superEntityCombo = Application.getWidgetFactory().createComboBox();

    AutoCompletion.enable(dbEntityCombo);
    AutoCompletion.enable(superEntityCombo);

    readOnly = new JCheckBox();
    optimisticLocking = new JCheckBox();
    excludeSuperclassListeners = new JCheckBox();
    excludeDefaultListeners = new JCheckBox();

    // borderless clickable button used as a label
    tableLabel = new JButton("Table/View:");
    tableLabel.setBorderPainted(false);
    tableLabel.setHorizontalAlignment(SwingConstants.LEFT);
    tableLabel.setFocusPainted(false);
    tableLabel.setMargin(new Insets(0, 0, 0, 0));
    tableLabel.setBorder(null);

    isAbstract = new JCheckBox();
    serverOnly = new JCheckBox();
    clientClassName = new TextAdapter(new JTextField()) {

        @Override
        protected void updateModel(String text) {
            setClientClassName(text);
        }
    };
    clientSuperClassName = new TextAdapter(new JTextField()) {

        @Override
        protected void updateModel(String text) {
            setClientSuperClassName(text);
        }
    };

    // assemble
    FormLayout layout = new FormLayout("right:pref, 3dlu, fill:200dlu", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();

    builder.appendSeparator("ObjEntity Configuration");
    builder.append("ObjEntity Name:", name.getComponent());
    builder.append("Inheritance:", superEntityCombo);
    builder.append(tableLabel, dbEntityCombo);
    isAbstractLabel = builder.append("Abstract class:", isAbstract);
    builder.appendSeparator();

    builder.append("Java Class:", className.getComponent());

    superclassLabel = builder.append("Superclass:", superClassName.getComponent());
    builder.append("Qualifier:", qualifier.getComponent());
    builder.append("Read-Only:", readOnly);
    builder.append("Optimistic Locking:", optimisticLocking);
    // add callback-related stuff
    builder.append("Exclude superclass listeners:", excludeSuperclassListeners);
    builder.append("Exclude default listeners:", excludeDefaultListeners);

    clientSeparator = builder.appendSeparator("Java Client");
    serverOnlyLabel = builder.append("Not for Client Use:", serverOnly);
    clientClassNameLabel = builder.append("Client Java Class:", clientClassName.getComponent());
    clientSuperClassNameLabel = builder.append("Client Superclass:", clientSuperClassName.getComponent());

    add(builder.getPanel(), BorderLayout.CENTER);
}

From source file:org.apache.log4j.chainsaw.LogUI.java

/**
 * Initialises the Help system and the WelcomePanel
 *
 *///w  ww . j  a  v  a 2 s .co m
private void setupHelpSystem() {
    welcomePanel = new WelcomePanel();

    JToolBar tb = welcomePanel.getToolbar();

    tb.add(new SmallButton(new AbstractAction("Tutorial", new ImageIcon(ChainsawIcons.HELP)) {
        public void actionPerformed(ActionEvent e) {
            setupTutorial();
        }
    }));
    tb.addSeparator();

    final Action exampleConfigAction = new AbstractAction("View example Receiver configuration") {
        public void actionPerformed(ActionEvent e) {
            HelpManager.getInstance().setHelpURL(ChainsawConstants.EXAMPLE_CONFIG_URL);
        }
    };

    exampleConfigAction.putValue(Action.SHORT_DESCRIPTION,
            "Displays an example Log4j configuration file with several Receivers defined.");

    JButton exampleButton = new SmallButton(exampleConfigAction);
    tb.add(exampleButton);

    tb.add(Box.createHorizontalGlue());

    /**
     * Setup a listener on the HelpURL property and automatically change the WelcomePages URL
     * to it.
     */
    HelpManager.getInstance().addPropertyChangeListener("helpURL", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            URL newURL = (URL) evt.getNewValue();

            if (newURL != null) {
                welcomePanel.setURL(newURL);
                ensureWelcomePanelVisible();
            }
        }
    });
}

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

private JToolBar createToolBar() {

    // tool bar/*from  ww w.  j  a  va  2s  .  c  o  m*/
    JToolBar toolBar = new JToolBar();

    // file open
    JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png")));
    buttonOpen.setToolTipText(I18n.getString("tooltip.open"));
    buttonOpen.setActionCommand("ac_open");
    buttonOpen.addActionListener(this);
    buttonOpen.setMnemonic(KeyEvent.VK_O);
    buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonOpen);

    // file save
    JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png")));
    buttonSave.setToolTipText(I18n.getString("tooltip.save"));
    buttonSave.setActionCommand("ac_save");
    buttonSave.addActionListener(this);
    buttonSave.setMnemonic(KeyEvent.VK_S);
    buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonSave);
    toolBar.addSeparator();

    // open browser
    JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png")));
    buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser"));
    buttonBrowser.setActionCommand("ac_openinbrowser");
    buttonBrowser.addActionListener(this);
    buttonBrowser.setMnemonic(KeyEvent.VK_E);
    buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonBrowser);
    toolBar.addSeparator();

    // home
    JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png")));
    buttonHome.setToolTipText(I18n.getString("tooltip.home"));
    buttonHome.setActionCommand("ac_home");
    buttonHome.addActionListener(this);
    buttonHome.setMnemonic(KeyEvent.VK_H);
    toolBar.add(buttonHome);

    // refresh
    JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png")));
    buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh"));
    buttonRefresh.setActionCommand("ac_refresh");
    buttonRefresh.addActionListener(this);
    buttonRefresh.setMnemonic(KeyEvent.VK_L);
    toolBar.add(buttonRefresh);
    toolBar.addSeparator();

    // result
    JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png")));
    buttonResult.setToolTipText(I18n.getString("tooltip.results"));
    buttonResult.setActionCommand("ac_result");
    buttonResult.addActionListener(this);
    buttonResult.setMnemonic(KeyEvent.VK_R);
    toolBar.add(buttonResult);
    toolBar.addSeparator();

    // bookmark
    JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png")));
    buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark"));
    buttonBookMark.setActionCommand("ac_addbookmark");
    buttonBookMark.addActionListener(this);
    buttonBookMark.setMnemonic(KeyEvent.VK_M);
    toolBar.add(buttonBookMark);
    toolBar.addSeparator();

    // print
    JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png")));
    buttonPrint.setToolTipText(I18n.getString("tooltip.print"));
    buttonPrint.setActionCommand("ac_print");
    buttonPrint.addActionListener(this);
    buttonPrint.setMnemonic(KeyEvent.VK_P);
    toolBar.add(buttonPrint);
    toolBar.addSeparator();

    // setting
    JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png")));
    buttonSetting.setToolTipText(I18n.getString("tooltip.settings"));
    buttonSetting.setActionCommand("ac_settings");
    buttonSetting.addActionListener(this);
    buttonSetting.setMnemonic(KeyEvent.VK_HOME);
    toolBar.add(buttonSetting);
    toolBar.addSeparator();

    // stop
    buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png")));
    buttonStop.setToolTipText(I18n.getString("tooltip.stop"));
    buttonStop.setActionCommand("ac_stop");
    buttonStop.addActionListener(this);
    buttonStop.setMnemonic(KeyEvent.VK_X);
    toolBar.add(buttonStop);
    toolBar.addSeparator();

    //
    toolBar.setFloatable(false);

    // finished
    return toolBar;
}

From source file:org.jajuk.ui.views.CoverView.java

/**
 * Inits the ui.//  w w  w . ja  v  a2  s  . co m
 *  
 * @param includeControls 
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public void initUI(boolean includeControls) {
    this.includeControls = includeControls;
    // Control panel
    jpControl = new JPanel();
    if (includeControls) {
        jpControl.setBorder(BorderFactory.createEtchedBorder());
    }
    final JToolBar jtb = new JajukJToolbar();
    jbPrevious = new JajukButton(IconLoader.getIcon(JajukIcons.PLAYER_PREVIOUS_SMALL));
    jbPrevious.addActionListener(this);
    jbPrevious.setToolTipText(Messages.getString("CoverView.4"));
    jbNext = new JajukButton(IconLoader.getIcon(JajukIcons.PLAYER_NEXT_SMALL));
    jbNext.addActionListener(this);
    jbNext.setToolTipText(Messages.getString("CoverView.5"));
    jbDelete = new JajukButton(IconLoader.getIcon(JajukIcons.DELETE));
    jbDelete.addActionListener(this);
    jbDelete.setToolTipText(Messages.getString("CoverView.2"));
    jbSave = new JajukButton(IconLoader.getIcon(JajukIcons.SAVE));
    jbSave.addActionListener(this);
    jbSave.setToolTipText(Messages.getString("CoverView.6"));
    jbDefault = new JajukButton(IconLoader.getIcon(JajukIcons.DEFAULT_COVER));
    jbDefault.addActionListener(this);
    jbDefault.setToolTipText(Messages.getString("CoverView.8"));
    jlSize = new JLabel("");
    jlFound = new JLabel("");
    jcbAccuracy = new JComboBox();
    // Add tooltips on combo items
    jcbAccuracy.setRenderer(new BasicComboBoxRenderer() {
        private static final long serialVersionUID = -6943363556191659895L;

        @Override
        public Component getListCellRendererComponent(final JList list, final Object value, final int index,
                final boolean isSelected, final boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            switch (index) {
            case 0:
                setToolTipText(Messages.getString("ParameterView.156"));
                break;
            case 1:
                setToolTipText(Messages.getString("ParameterView.157"));
                break;
            case 2:
                setToolTipText(Messages.getString("ParameterView.158"));
                break;
            case 3:
                setToolTipText(Messages.getString("ParameterView.216"));
                break;
            case 4:
                setToolTipText(Messages.getString("ParameterView.217"));
                break;
            case 5:
                setToolTipText(Messages.getString("ParameterView.218"));
                break;
            }
            setBorder(new EmptyBorder(0, 3, 0, 3));
            return this;
        }
    });
    jcbAccuracy.setToolTipText(Messages.getString("ParameterView.155"));
    jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ACCURACY_LOW));
    jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ACCURACY_MEDIUM));
    jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ACCURACY_HIGH));
    jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ARTIST));
    jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ALBUM));
    jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.TRACK));
    int accuracy = getCurrentAccuracy();
    jcbAccuracy.setSelectedIndex(accuracy);
    jcbAccuracy.addActionListener(this);
    jtb.add(jbPrevious);
    jtb.add(jbNext);
    jtb.addSeparator();
    jtb.add(jbDelete);
    jtb.add(jbSave);
    jtb.add(jbDefault);
    if (includeControls) {
        jpControl.setLayout(new MigLayout("insets 5 2 5 2", "[][grow][grow][]"));
        jpControl.add(jtb);
        jpControl.add(jlSize, "center,gapright 5::");
        jpControl.add(jlFound, "center,gapright 5::");
        jpControl.add(jcbAccuracy, "grow,width 47!,gapright 5");
    }
    // Cover view used in catalog view should not listen events
    if (fileReference == null) {
        ObservationManager.register(this);
    }
    // global layout
    MigLayout globalLayout = null;
    if (includeControls) {
        globalLayout = new MigLayout("ins 0,gapy 10", "[grow]", "[30!][grow]");
    } else {
        globalLayout = new MigLayout("ins 0,gapy 10", "[grow]", "[grow]");
    }
    setLayout(globalLayout);
    add(jpControl, "grow,wrap");
    //Force initial resizing (required after a perspective reset as the component event is not thrown in this case)
    componentResized(null);
    // Attach the listener for initial cover display and further manual actions against the view when resizing.
    addComponentListener(CoverView.this);
}

From source file:org.kuali.test.creator.TestCreator.java

private JPanel createToolBar() {
    JPanel retval = new JPanel(new BorderLayout(2, 2));

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);/*from   w  w  w .j  av  a  2 s  .  c o m*/
    toolbar.setMargin(new Insets(1, 5, 2, 0));
    ToolbarButton b;
    toolbar.add(b = new ToolbarButton(Constants.PLATFORM_TOOLBAR_ICON, "add platform"));
    b.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleAddPlatform(e);
        }

    });
    toolbar.add(b = new ToolbarButton(Constants.DATABASE_TOOLBAR_ICON, "add database connection"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            handleAddDatabaseConnection(e);
        }

    });
    toolbar.add(b = new ToolbarButton(Constants.JMX_CONNECTION_TOOLBAR_ICON, "add JMX connection"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            handleAddJmxConnection(e);
        }

    });

    toolbar.add(b = new ToolbarButton(Constants.WEB_SERVICE_TOOLBAR_ICON, "add web service"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            handleAddWebService(e);
        }

    });

    toolbar.add(b = new ToolbarButton(Constants.SCHEDULE_TEST_TOOLBAR_ICON, "schedule test"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            handleScheduleTests(e);
        }

    });

    toolbar.addSeparator();

    toolbar.add(saveConfigurationButton = new ToolbarButton(Constants.SAVE_CONFIGURATION_ICON,
            "save repository configuration") {
        @Override
        public void setEnabled(boolean enabled) {
            if (enabled) {
                getConfiguration().setModified(true);
            }

            super.setEnabled(enabled);
        }
    });
    saveConfigurationButton.setEnabled(false);
    saveConfigurationButton.setMargin(new Insets(1, 1, 1, 1));
    saveConfigurationButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleSaveConfiguration();
        }
    });

    toolbar.add(createTestButton = new ToolbarButton(Constants.TEST_ICON, "create new test"));
    createTestButton.setMargin(new Insets(1, 1, 1, 1));

    createTestButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleCreateTest(null);
        }
    });

    toolbar.addSeparator();

    toolbar.add(
            exitApplication = new ToolbarButton(Constants.EXIT_APPLICATION_TOOLBAR_ICON, "exit application"));

    exitApplication.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(TestCreator.this, "Exit Test Application?", "Exit",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                startSpinner("Shutting down application...");
                handleExit(0);
            }
        }
    });

    toolbar.addSeparator();

    toolbar.add(spinner = new Spinner());
    toolbar.add(spinner2 = new Spinner(true));

    retval.add(new JSeparator(), BorderLayout.NORTH);
    retval.add(toolbar, BorderLayout.CENTER);

    this.enableCreateTestActions(havePlatforms());

    return retval;
}

From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java

public ResPlanPanel(ResPlanController cntrl, CollectableResPlanModel model, DateTimeModel timeModel) {
    final SpringLocaleDelegate localeDelegate = SpringLocaleDelegate.getInstance();

    this.controller = cntrl;
    this.timeModel = timeModel;
    this.resPlanModel = model;
    setLayout(new BorderLayout());

    JToolBar tb = UIUtils.createNonFloatableToolBar();
    tb.setFloatable(false);//w ww  . j  av a 2s. co  m
    tb.add(new AbstractAction(localeDelegate.getText("nuclos.resplan.action.refresh"),
            Icons.getInstance().getIconRefresh16()) {

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.refresh();
        }
    });
    tb.add(exportAction);
    tb.addSeparator();

    this.timeHorizon = new Interval<Date>(model.getDefaultViewFrom(), model.getDefaultViewUntil());

    final LabeledComponentSupport support = new LabeledComponentSupport();
    startDateChooser = new DateChooser(support, timeHorizon.getStart());
    startDateChooser.setMinimumSize(startDateChooser.getPreferredSize());
    startDateChooser.setMaximumSize(startDateChooser.getPreferredSize());
    endDateChooser = new DateChooser(support, timeHorizon.getEnd());
    endDateChooser.setMinimumSize(endDateChooser.getPreferredSize());
    endDateChooser.setMaximumSize(endDateChooser.getPreferredSize());

    tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.from")));
    tb.add(startDateChooser);
    tb.add(Box.createHorizontalStrut(5));
    tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.until")));
    tb.add(endDateChooser);

    timeGranularityModel = new ListComboBoxModel<ResPlanController.TimeGranularity>(
            controller.getTimeGranularityOptions());
    tb.addSeparator();
    tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.granularity")));
    timeGranularityComboBox = new JComboBox(timeGranularityModel);
    tb.add(timeGranularityComboBox);
    timeGranularityComboBox
            .setMaximumSize(Orientation.VERTICAL.updateExtent(timeGranularityComboBox.getPreferredSize(), 20));

    tb.addSeparator();
    tb.add(new JLabel(localeDelegate.getText("nuclos.resplan.toolbar.resourceFilter")));
    searchFilterComboBox = new JComboBox();
    searchFilterComboBox.setRenderer(new SearchFilterListCellRenderer());
    refreshSearchFilter();
    tb.add(searchFilterComboBox);
    searchFilterComboBox
            .setMaximumSize(Orientation.VERTICAL.updateExtent(searchFilterComboBox.getPreferredSize(), 20));

    tb.add(Box.createGlue());

    infoButton = new JButton(infoAction);
    infoButton.setVisible(false);
    tb.add(infoButton);

    tb.add(Box.createHorizontalStrut(3));

    initJResPlan();

    ActionListener dateChooserListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            timeHorzionChanged();
        }
    };
    startDateChooser.addActionListener(dateChooserListener);
    endDateChooser.addActionListener(dateChooserListener);

    timeGranularityComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                Runnable runnable = createScrollToCurrentAreaRunnable();
                ResPlanController.TimeGranularity granularity = timeGranularityModel.getSelectedItem();
                resPlan.setTimeModel(granularity.getTimeModel());
                resPlan.getTimelineHeader().setCategoryModel(granularity.getHeaderCategories());
                SwingUtilities.invokeLater(runnable);
            }
        }
    });
    searchFilterComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                EntitySearchFilter filter = (EntitySearchFilter) searchFilterComboBox.getSelectedItem();
                if (filter instanceof NewCustomSearchFilter) {
                    runCustomSearch();
                    return;
                }
                setSearchCondition(filter.getSearchCondition());
            }
        }
    });

    scrollPane = new JScrollPane(resPlan);

    JButton corner = new JButton(switchOrientationAction);
    corner.setBorderPainted(false);
    scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, corner);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    add(tb, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);

    resPlan.setTimeHorizon(this.timeHorizon);
    resPlan.invalidate();

    setFocusable(true);
    setFocusCycleRoot(true);
    getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("DELETE"), "delete");
    //getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("control F"), "find");
    getActionMap().put("delete", removeAction);
    //getActionMap().put("find", findAction);
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.ACTIVATE_SEARCH_PANEL_2, findAction, this);
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private JComponent createPaletteToolBar() {
    final JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);//from www  .j ava2 s.c  o m
    toolBar.setOrientation(JToolBar.VERTICAL);

    final ElementMetaData[] datas = ElementTypeRegistry.getInstance().getAllElementTypes();
    Arrays.sort(datas, new GroupedMetaDataComparator());
    Object grouping = null;
    boolean firstElement = true;
    for (int i = 0; i < datas.length; i++) {
        final ElementMetaData data = datas[i];
        if (data.isHidden()) {
            continue;
        }

        if (!WorkspaceSettings.getInstance().isVisible(data)) {
            continue;
        }

        final String currentGrouping = data.getGrouping(Locale.getDefault());
        if (firstElement == false) {
            if (ObjectUtilities.equal(currentGrouping, grouping) == false) {
                grouping = currentGrouping;
                toolBar.addSeparator();
            }
        } else {
            grouping = currentGrouping;
            firstElement = false;
        }
        final InsertElementAction action = new InsertElementAction(data);
        action.setReportDesignerContext(context);
        toolBar.add(new PaletteButton(data, context));
    }

    final JScrollPane paletteScrollpane = new JScrollPane(toolBar);
    paletteScrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    paletteScrollpane
            .addComponentListener(new ScrollbarSyncHandler(paletteScrollpane.getVerticalScrollBar(), toolBar));
    return paletteScrollpane;
}