Example usage for javax.swing JToolBar JToolBar

List of usage examples for javax.swing JToolBar JToolBar

Introduction

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

Prototype

public JToolBar() 

Source Link

Document

Creates a new tool bar; orientation defaults to HORIZONTAL.

Usage

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java

/**
 * Helper method to create the tool bar hosting the management items.
 * /*from  w  w w.j a v a2s  .co  m*/
 * @return See above.
 */
private JComponent createManagementBar() {
    bar = new JToolBar();
    bar.setFloatable(false);
    bar.setRollover(true);
    bar.setBorder(null);
    JToggleButton button = new JToggleButton(controller.getAction(TreeViewerControl.INSPECTOR));
    button.setSelected(true);
    bar.add(button);

    button = new JToggleButton(controller.getAction(TreeViewerControl.METADATA));
    button.setSelected(true);
    bar.add(button);

    JButton b = new JButton(controller.getAction(TreeViewerControl.BROWSE));
    UIUtilities.unifiedButtonLookAndFeel(b);
    bar.add(b);
    switch (TreeViewerAgent.runAsPlugin()) {
    case TreeViewer.IMAGE_J:
        b = UIUtilities.formatButtonFromAction(controller.getAction(TreeViewerControl.VIEW));
        UIUtilities.unifiedButtonLookAndFeel(b);
        b.addMouseListener(new MouseAdapter() {

            /**
             * Displays the menu when the user releases the mouse.
             * @see MouseListener#mouseReleased(MouseEvent)
             */
            public void mouseReleased(MouseEvent e) {
                controller.showMenu(TreeViewer.VIEW_MENU, (JComponent) e.getSource(), e.getPoint());
            }
        });
        bar.add(b);
        break;
    default:
        b = new JButton(controller.getAction(TreeViewerControl.VIEW));
        UIUtilities.unifiedButtonLookAndFeel(b);
        bar.add(b);
    }

    bar.add(new JSeparator(JSeparator.VERTICAL));
    //Now register the agent if any
    TaskBar tb = TreeViewerAgent.getRegistry().getTaskBar();
    List<JComponent> l = tb.getToolBarEntries(TaskBar.AGENTS);
    if (l != null) {
        Iterator<JComponent> i = l.iterator();
        JComponent comp;
        while (i.hasNext()) {
            comp = i.next();
            UIUtilities.unifiedButtonLookAndFeel(comp);
            bar.add(comp);
        }
        bar.add(new JSeparator(JSeparator.VERTICAL));
    }
    fullScreen = new JToggleButton(controller.getAction(TreeViewerControl.FULLSCREEN));
    fullScreen.setSelected(model.isFullScreen());
    //bar.add(fullScreen);
    if (TreeViewerAgent.isAdministrator()) {
        b = new JButton(controller.getAction(TreeViewerControl.UPLOAD_SCRIPT));
        UIUtilities.unifiedButtonLookAndFeel(b);
        bar.add(b);
    }
    TreeViewerAction a = controller.getAction(TreeViewerControl.AVAILABLE_SCRIPTS);
    b = new JButton(a);
    Icon icon = b.getIcon();
    Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH, UIUtilities.DEFAULT_ICON_HEIGHT);
    if (icon != null)
        d = new Dimension(icon.getIconWidth(), icon.getIconHeight());
    busyLabel = new JXBusyLabel(d);
    busyLabel.setVisible(true);
    b.addMouseListener((RunScriptAction) a);
    UIUtilities.unifiedButtonLookAndFeel(b);
    scriptButton = b;
    bar.add(b);
    index = bar.getComponentCount() - 1;

    bar.add(new JSeparator(JSeparator.VERTICAL));

    MouseAdapter adapter = new MouseAdapter() {

        /**
         * Shows the menu corresponding to the display mode.
         */
        public void mousePressed(MouseEvent me) {
            createGroupsAndUsersMenu((Component) me.getSource(), me.getPoint());
        }
    };

    a = controller.getAction(TreeViewerControl.SWITCH_USER);
    IconManager icons = IconManager.getInstance();
    menuButton = new JButton(icons.getIcon(IconManager.FILTER_MENU));
    menuButton.setVisible(true);
    menuButton.setText(GROUP_DISPLAY_TEXT);
    menuButton.setHorizontalTextPosition(SwingConstants.LEFT);
    menuButton.addMouseListener(adapter);
    bar.add(menuButton);
    setPermissions();
    return bar;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java

/**
 * Helper method to create the tool bar hosting the edit items.
 * //w  w  w .  j a v  a  2 s  . co  m
 * @return See above.
 */
private JToolBar createSearchBar() {
    JToolBar bar = new JToolBar();
    bar.setFloatable(false);
    bar.setRollover(true);
    bar.setBorder(null);
    bar.add(new JSeparator(JSeparator.VERTICAL));
    bar.add(new JToggleButton(controller.getAction(TreeViewerControl.SEARCH)));
    return bar;
}

From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java

/**
 * Returns the tool bar.// w  ww  . jav  a2s. co  m
 * 
 * @return See above.
 */
private JComponent createToolBar() {
    toolBar = new JToolBar();
    toolBar.setOpaque(false);
    toolBar.setFloatable(false);
    toolBar.setBorder(null);
    buttonIndex = 0;
    toolBar.add(exceptionButton);
    toolBar.add(Box.createHorizontalStrut(5));
    buttonIndex = 2;
    toolBar.add(cancelButton);
    JLabel l = new JLabel();
    Font f = l.getFont();
    l.setForeground(UIUtilities.LIGHT_GREY.darker());
    l.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2));
    String s = UIUtilities.formatShortDateTime(null);
    String[] values = s.split(" ");
    if (values.length > 1) {
        String v = values[1];
        if (values.length > 2)
            v += " " + values[2];
        l.setText(v);
        toolBar.add(Box.createHorizontalStrut(5));
        toolBar.add(l);
        toolBar.add(Box.createHorizontalStrut(5));
    }
    return toolBar;
}

From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java

/** 
 * Invokes when the activity end. /*  w ww.jav  a  2 s  .c  om*/
 * 
 * @param result The result of the activity.
 */
public void endActivity(Object result) {
    this.result = result;
    boolean busy = status.isBusy();
    reset();
    if (result instanceof Map) {
        Map<String, Object> m = convertResult((Map<String, Object>) result);
        int size = m.size();
        this.result = m;
        remove(resultPane);
        Color c = getBackground();
        if (size == 0) {
            JToolBar row = new JToolBar();
            row.setOpaque(false);
            row.setFloatable(false);
            row.setBorder(null);
            row.setBackground(c);
            JButton button;
            if (errorObject != null) {
                button = createButton(ActivityResultRow.ERROR_TEXT, ERROR, this);
                button.addMouseListener(new MouseAdapter() {

                    public void mouseReleased(MouseEvent e) {
                        showMenu((JComponent) e.getSource(), ERROR, e.getX(), e.getY());
                    }
                });
                row.add(button);
            }
            if (infoObject != null) {
                button = createButton(ActivityResultRow.INFO_TEXT, INFO, this);
                button.addMouseListener(new MouseAdapter() {

                    public void mouseReleased(MouseEvent e) {
                        showMenu((JComponent) e.getSource(), INFO, e.getX(), e.getY());
                    }
                });
                row.add(button);
            }
            add(row, paneIndex);
        } else {
            Entry<String, Object> entry;
            Iterator<Entry<String, Object>> i = m.entrySet().iterator();
            ActivityResultRow row = null;
            JPanel content = new JPanel();
            content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

            content.setBackground(c);
            int index = 0;
            int max = 2;
            JButton moreButton = null;
            while (i.hasNext()) {
                entry = (Entry<String, Object>) i.next();
                this.result = entry.getValue();
                row = new ActivityResultRow((String) entry.getKey(), entry.getValue(), this);
                row.setBackground(c);
                row.addPropertyChangeListener(listener);
                resultButtons.add(row);
                if (index < max)
                    content.add(row);
                else {
                    if (moreButton == null) {
                        moreButton = createButton("" + (m.size() - max) + " more", ALL_RESULT, this);
                        content.add(moreButton);
                    }
                }
                index++;
            }

            if (m.size() == 1)
                add(row, paneIndex);
            else
                add(content, paneIndex);
            resultPane = content;
        }

        repaint();
    }

    firePropertyChange(UNREGISTER_ACTIVITY_PROPERTY, null, this);
    notifyActivityEnd();
    //Post an event to 
    //if (busy) {
    EventBus bus = registry.getEventBus();
    bus.post(new ActivityProcessEvent(this, busy));
    //}
}

From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java

/**
 * Helper method to create an empty, floatable toolbar with rollover
 * effect for the icon buttons and an etched border.
 *
 * @return See above./*from w w  w  .j  ava 2  s.c  o  m*/
 */
private JToolBar createToolBar() {
    JToolBar bar = new JToolBar();
    bar.setBorder(BorderFactory.createEtchedBorder());
    bar.setFloatable(false);
    bar.putClientProperty("JToolBar.isRollover", Boolean.valueOf(true));
    return bar;
}

From source file:org.openmicroscopy.shoola.util.ui.omeeditpane.OMEWikiComponent.java

/**
 * Creates a new component./* w  w w. jav  a2s  .c o m*/
 * 
 * @param formatters    The formatters for the text.
 * @param toolbar      Pass <code>true</code> to install a default toolbar, 
 *                   <code>false</code> otherwise.
 */
private void initComponents(Map<String, FormatSelectionAction> formatters, boolean toolbar) {
    defaultText = "";
    pane = new OMEEditPane(this, formatters);
    installDefaultAction();
    if (toolbar) {
        toolBar = new JToolBar();
        toolBar.setBackground(UIUtilities.BACKGROUND_COLOR);
        toolBar.setBorder(null);
        toolBar.setFloatable(false);
        Iterator<JButton> b = toolBarActions.iterator();
        while (b.hasNext())
            toolBar.add(b.next());
    }
    setBackground(UIUtilities.BACKGROUND);
}

From source file:org.openscience.jmol.app.Jmol.java

/**
 * Create the toolbar.  By default this reads the
 * resource file for the definition of the toolbars.
 * @return The toolbar/*from   w  w w.  j av  a2  s . c om*/
 */
private Component createToolbar() {

    toolbar = new JToolBar();
    String[] tool1Keys = tokenize(JmolResourceHandler.getStringX("toolbar"));
    for (int i = 0; i < tool1Keys.length; i++) {
        if (tool1Keys[i].equals("-")) {
            toolbar.addSeparator();
        } else {
            toolbar.add(createTool(tool1Keys[i]));
        }
    }

    //Action handler implementation would go here.
    toolbar.add(Box.createHorizontalGlue());

    return toolbar;
}

From source file:org.orbisgis.sqlconsole.ui.SQLConsolePanel.java

private JToolBar getStatusToolBar() {
    if (infoToolBar == null) {
        infoToolBar = new JToolBar();
        infoToolBar.setTransferHandler(new ScriptPanelTransferHandler(scriptPanel, dataSource));
        statusMessage = new JLabel();
        infoToolBar.add(statusMessage);//from   ww  w  .j av  a2 s. com
        infoToolBar.setFloatable(false);

        messageCleanTimer = new Timer(5000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setStatusMessage("");
            }
        });
        messageCleanTimer.setRepeats(false);
        setStatusMessage("");
    }

    return infoToolBar;
}

From source file:org.orbisgis.view.map.MapEditor.java

private JToolBar createToolBar() {
    JToolBar toolBar = new JToolBar();
    createActions();
    actions.registerContainer(toolBar);
    return toolBar;
}

From source file:org.orbisgis.view.sqlconsole.ui.SQLConsolePanel.java

private JToolBar getStatusToolBar() {

    if (infoToolBar == null) {
        infoToolBar = new JToolBar();
        statusMessage = new JLabel();
        infoToolBar.add(statusMessage);//from ww  w.  ja va2s .co  m
        infoToolBar.setFloatable(false);

        messageCleanTimer = new Timer(5000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setStatusMessage("");
            }
        });
        messageCleanTimer.setRepeats(false);
    }

    return infoToolBar;
}