Example usage for javax.swing JSeparator JSeparator

List of usage examples for javax.swing JSeparator JSeparator

Introduction

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

Prototype

public JSeparator() 

Source Link

Document

Creates a new horizontal separator.

Usage

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.PopupMenu.java

/**
 * Populates the menu with the passed actions.
 * //from  ww w  . j  a  va 2s .  com
 * @param actions The list of actions.
 */
void populateOpenWith() {
    openWithMenu.removeAll();
    List<ViewOtherAction> actions = controller.getApplicationActions();
    if (!CollectionUtils.isEmpty(actions)) {
        Iterator<ViewOtherAction> i = actions.iterator();
        while (i.hasNext()) {
            openWithMenu.add(new JMenuItem(i.next()));
        }
        openWithMenu.add(new JSeparator());
    }
    openWithMenu.add(new JMenuItem(controller.getAction(DataBrowserControl.OPEN_WITH)));
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java

/** Builds and lays out the UI. */
private void buildGUI() {
    setLayout(new BorderLayout(0, 0));
    JPanel p = new JPanel();
    p.setBorder(null);/*  w w w .  jav a  2s. co  m*/
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(buildQuotaPane());
    p.add(table);
    tabbedPane.add("Files to import", p);
    tabbedPane.add("Options", buildOptionsPane());

    double[][] tablePanelDesign = { { TableLayout.PREFERRED, 10, 5, TableLayout.FILL },
            { TableLayout.PREFERRED, TableLayout.FILL } };
    JPanel tablePanel = new JPanel(new TableLayout(tablePanelDesign));
    tablePanel.add(table.buildControls(), "0, 1, LEFT, CENTER");
    tablePanel.add(tabbedPane, "2, 1, 3, 1");
    int plugin = ImporterAgent.runAsPlugin();
    JSplitPane pane;
    if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        JLabel label = UIUtilities.setTextFont("Select where to import the image(s).");
        panel.add(UIUtilities.buildComponentPanel(label));
        panel.add(locationDialog.getContentPane());
        pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, tablePanel);
    } else {
        pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chooser, tablePanel);
    }

    JPanel mainPanel = new JPanel();
    double[][] mainPanelDesign = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } };
    mainPanel.setLayout(new TableLayout(mainPanelDesign));
    mainPanel.setBackground(UIUtilities.BACKGROUND);
    mainPanel.add(pane, "0, 1");

    this.add(mainPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel();
    controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS));

    // Lays out the buttons.
    JPanel bar = new JPanel();
    bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS));
    bar.add(buildToolBarLeft());
    bar.add(buildToolBarRight());
    controls.add(new JSeparator());
    controls.add(bar);

    add(controls, BorderLayout.SOUTH);
    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations)
            getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
    }
}

From source file:org.openmicroscopy.shoola.agents.imviewer.util.proj.ProjSavingDialog.java

/**
 * Builds the various panels used to set the parameters of the
 * projection.//from  w w  w .  j  a  v a  2 s. com
 * 
 * @return See above.
 */
private JPanel buildParametersPanel() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(buildRangePanel(zrangeSelection, "Z Range: "));
    p.add(buildRangePanel(timeSelection, "Timepoint: "));

    if (pixelsType != null) {
        p.add(new JSeparator());
        p.add(buildPixelsTypePanel());
    }

    JPanel r = UIUtilities.buildComponentPanel(p);
    r.setBorder(new TitledBorder(""));
    return r;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java

/** 
 * Builds and lays out the UI.//from w  w w.  j  av  a 2s . co m
 * 
 * @param components The components to lay out.
 */
private void buildGUI(Map<String, List<String>> components) {
    //Now lay out the elements
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    String key;
    List<String> l;
    Entry<String, List<String>> entry;
    Iterator<Entry<String, List<String>>> i = components.entrySet().iterator();
    JPanel row;
    JLabel label;
    p.add(new JSeparator());
    while (i.hasNext()) {
        entry = i.next();
        key = entry.getKey();
        l = entry.getValue();
        if (!CollectionUtils.isEmpty(l)) {
            label = UIUtilities.setTextFont(key);
            label.setBackground(UIUtilities.BACKGROUND_COLOR);
            row = UIUtilities.buildComponentPanel(label);
            row.setBackground(UIUtilities.BACKGROUND_COLOR);
            p.add(row);
            p.add(createTable(l));
        }
    }
    removeAll();
    add(toolBar, BorderLayout.NORTH);
    add(p, BorderLayout.CENTER);
    revalidate();
    repaint();
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java

/** Builds and lays out the UI. */
private void buildGUI() {
    JPanel bars = new JPanel();
    bars.setBackground(UIUtilities.BACKGROUND_COLOR);
    bars.setLayout(new BoxLayout(bars, BoxLayout.X_AXIS));
    bars.add(buildGeneralBar());//from   w w  w. j  a  v a2 s  . c  o m
    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    JPanel pp = UIUtilities.buildComponentPanel(bars);
    pp.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(pp);
    pp = UIUtilities.buildComponentPanelRight(busyLabel);
    pp.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(pp);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBackground(UIUtilities.BACKGROUND_COLOR);
    add(p);
    add(new JSeparator());
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java

/** 
 * Builds the menu displaying the available scripts.
 * //from w  ww  . ja  va  2  s  .  c o m
 * @return See above.
 */
private JPopupMenu getScriptsMenu() {
    JPopupMenu menu = new JPopupMenu();

    Collection<ScriptObject> scripts = model.getScripts();
    //Scripts are sorted.
    if (scripts == null || scripts.size() == 0)
        return menu;
    IconManager icons = IconManager.getInstance();
    JMenuItem refresh = new JMenuItem(icons.getIcon(IconManager.REFRESH));
    refresh.setText("Reload Scripts");
    refresh.setToolTipText("Reloads the existing scripts.");
    refresh.addActionListener(controller);
    refresh.setActionCommand("" + EditorControl.RELOAD_SCRIPT);
    menu.add(refresh);
    menu.add(new JSeparator());

    Iterator<ScriptObject> i = scripts.iterator();
    ScriptObject so;
    Map<String, ScriptSubMenu> menus = new HashMap<String, ScriptSubMenu>();
    String path;
    ScriptSubMenu subMenu;
    List<ScriptSubMenu> others = new ArrayList<ScriptSubMenu>();
    List<String> formattedName = new ArrayList<String>();
    while (i.hasNext()) {
        so = i.next();
        setScriptIcon(so);
        path = so.getPath();
        subMenu = menus.get(path);
        if (subMenu == null) {
            subMenu = new ScriptSubMenu(path, formattedName);
            //formattedName.add(subMenu.getUnformattedText());
            menus.put(path, subMenu);
            if (so.isOfficialScript())
                menu.add(subMenu);
            else
                others.add(subMenu);
        }
        //if (!ScriptMenuItem.isScriptWithUI(so.getScriptLabel()))
        subMenu.addScript(so).addActionListener(controller);
    }
    if (others.size() > 0) {
        menu.add(new JSeparator());
        JMenu uploadedMenu = new JMenu("User Scripts");
        menu.add(uploadedMenu);
        Iterator<ScriptSubMenu> j = others.iterator();
        while (j.hasNext())
            uploadedMenu.add(j.next());
    }
    return menu;
}

From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java

/** 
 * Builds hosting the various sliders//from w  ww .  j  a  v a  2 s  . c  o m
 * 
 * @return See above.
 */
private JPanel buildGeneralPane() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridy = 0;
    c.gridx = 0;
    if (model.isGeneralIndex()) {
        content.add(previewToolBar, c);
        c.gridy++;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.HORIZONTAL;
        content.add(new JSeparator(), c);
        c.gridy++;
    }
    content.add(controlsBar, c);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;

    Iterator<ChannelSlider> i = sliders.iterator();
    while (i.hasNext()) {
        c.gridy++;
        content.add(i.next(), c);
    }
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    content.add(viewedBy, c);
    JPanel p = UIUtilities.buildComponentPanel(content);
    p.setBackground(content.getBackground());
    return p;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/** Helper method to create the menu bar. */
private void createMenuBars() {
    rightMenuBar = new JToolBar();
    rightMenuBar.setBorder(null);//from   w ww  . j  a v a 2  s .c o  m
    rightMenuBar.setRollover(true);
    rightMenuBar.setFloatable(false);

    JButton button;
    leftMenuBar = new JToolBar();
    leftMenuBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    leftMenuBar.setRollover(true);
    leftMenuBar.setFloatable(false);
    BrowserManageAction a;
    int type = model.getBrowserType();
    switch (type) {
    case Browser.PROJECTS_EXPLORER:
    case Browser.SCREENS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_CONTAINER);
        button = new JButton(a);
        button.setName("new container button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.ADMIN_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_ADMIN);
        button = new JButton(a);
        button.setName("new group or user button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.TAGS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_TAG);
        button = new JButton(a);
        button.setName("new tag button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
    }
    button = new JButton(controller.getAction(BrowserControl.CUT));
    button.setName("cut button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.COPY));
    button.setName("copy button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.PASTE));
    button.setName("paste button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.DELETE));
    button.setName("delete button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.REFRESH));
    button.setName("refresh button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);

    if (type == Browser.ADMIN_EXPLORER) {
        button = new JButton(controller.getAction(BrowserControl.RESET_PASSWORD));
        button.setBorderPainted(false);
        rightMenuBar.add(button);
    } else {
        button = new JButton(controller.getAction(BrowserControl.IMPORT));
        button.setBorderPainted(false);
        //rightMenuBar.add(button);
    }
    rightMenuBar.add(Box.createHorizontalStrut(6));
    rightMenuBar.add(new JSeparator());
    rightMenuBar.add(Box.createHorizontalStrut(6));
    ButtonGroup group = new ButtonGroup();
    JToggleButton b = new JToggleButton();
    group.add(b);
    b.setBorderPainted(true);
    b.setSelected(true);
    b.setAction(controller.getAction(BrowserControl.SORT));

    rightMenuBar.add(b);
    b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE));
    b.setBorderPainted(true);
    group.add(b);
    rightMenuBar.add(b);

    partialButton = new JToggleButton(controller.getAction(BrowserControl.PARTIAL_NAME));
    partialButton.setBorderPainted(true);
    rightMenuBar.add(partialButton);
    rightMenuBar.add(new JSeparator(JSeparator.VERTICAL));
    button = new JButton(controller.getAction(BrowserControl.COLLAPSE));
    button.setBorderPainted(false);
    rightMenuBar.add(button);
}

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

/**
 * Creates the menu displaying the groups and users.
 * //from  ww  w.j  a v  a 2s.c o m
 * @param source The invoker.
 * @param p The location of the mouse clicked.
 */
private void createGroupsAndUsersMenu(Component source, Point p) {
    if (!source.isEnabled())
        return;
    Collection groups = model.getGroups();
    if (CollectionUtils.isEmpty(groups))
        return;
    popupMenu.removeAll();
    GroupData group;
    List sortedGroups = sorter.sort(groups);

    //Determine the group already displayed.
    Browser browser = model.getBrowser(Browser.PROJECTS_EXPLORER);
    List<TreeImageDisplay> nodes;
    ExperimenterVisitor visitor;
    //Find the user already added to the selected group.
    visitor = new ExperimenterVisitor(browser, -1);
    browser.accept(visitor);
    nodes = visitor.getNodes();
    Iterator<TreeImageDisplay> k = nodes.iterator();
    List<Long> groupIds = new ArrayList<Long>();
    long id;
    while (k.hasNext()) {
        id = k.next().getUserObjectId();
        if (id >= 0)
            groupIds.add(id);
    }

    //Create the group menu.
    Iterator i = sortedGroups.iterator();
    int size = sortedGroups.size();
    long userID = model.getExperimenter().getId();

    //First add item to toggle between users and group display
    DataMenuItem data = new DataMenuItem(DataMenuItem.USERS_TEXT, null);
    data.setSelected(model.getDisplayMode() == LookupNames.EXPERIMENTER_DISPLAY);
    data.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (DataMenuItem.ITEM_SELECTED_PROPERTY.equals(name)) {
                DataMenuItem data = (DataMenuItem) evt.getNewValue();
                handleSelectionDisplay(data.isSelected());
            }
        }
    });
    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    panel.setBorder(null);
    IconManager icons = IconManager.getInstance();
    panel.add(new JLabel(icons.getIcon(IconManager.TRANSPARENT)));
    panel.add(data);
    popupMenu.add(panel);
    popupMenu.add(new JSeparator());
    GroupItem item;
    GroupItem allGroup = null;
    //First add option to add all the groups.
    if (size > 1) {
        item = new GroupItem(false);
        item.setUserID(userID);
        createGroupMenu(item, 0);
        popupMenu.add(item);
        popupMenu.add(new JSeparator());
        allGroup = item;
    }

    boolean selected;
    int count = 0;
    while (i.hasNext()) {
        group = (GroupData) i.next();
        boolean b = groupIds.contains(group.getId());
        item = new GroupItem(group, b, size > 1);
        item.setUserID(userID);
        selected = createGroupMenu(item, size);
        popupMenu.add(item);
        if (selected)
            count++;
    }
    if (allGroup != null) {
        allGroup.setMenuSelected(count == sortedGroups.size(), false);
    }
    popupMenu.show(source, p.x, p.y);
}

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

/**
 * Brings up the <code>Available Scripts</code> on top of the specified
 * component at the specified location./*from   w w w . ja  v  a 2 s.c  o  m*/
 * 
 * @param c The component that requested the pop-pup menu.
 * @param p The point at which to display the menu, relative to the
 *          <code>component</code>'s coordinates.
 */
void showAvailableScriptsMenu(Component c, Point p) {
    if (p == null)
        return;
    if (c == null) {
        c = scriptButton;
    }
    IconManager icons = IconManager.getInstance();
    Collection<ScriptObject> scripts = model.getAvailableScripts();
    if (CollectionUtils.isEmpty(scripts))
        return;
    if (scriptsMenu == null) {
        scriptsMenu = new JPopupMenu();
        JMenuItem refresh = new JMenuItem(icons.getIcon(IconManager.REFRESH));
        refresh.setText("Reload Scripts");
        refresh.setToolTipText("Reloads the existing scripts.");
        refresh.addMouseListener(new MouseAdapter() {

            /**
             * Launches the dialog when the user releases the mouse.
             * MouseAdapter#mouseReleased(MouseEvent)
             */
            public void mouseReleased(MouseEvent e) {
                model.setAvailableScripts(null);
                scriptsMenu = null;
                controller.reloadAvailableScripts(e.getPoint());
            }
        });
        scriptsMenu.add(refresh);
        scriptsMenu.add(new JSeparator());

        ScriptObject so;
        Map<String, JMenu> menus = new HashMap<String, JMenu>();
        String path;

        Icon icon = icons.getIcon(IconManager.ANALYSIS);
        Icon largeIcon = icons.getIcon(IconManager.ANALYSIS_48);
        ActionListener listener = new ActionListener() {

            /** 
             * Listens to the selection of a script.
             * @see ActionListener#actionPerformed(ActionEvent)
             */
            public void actionPerformed(ActionEvent e) {
                ScriptMenuItem item = (ScriptMenuItem) e.getSource();
                controller.handleScriptSelection(item.getScript());
            }
        };
        String name = "";
        //loop twice to check if we need to add the first element
        String refString = null;
        int count = 0;
        Iterator<ScriptObject> i = scripts.iterator();
        String sep;
        String[] values;
        String value;
        while (i.hasNext()) {
            so = i.next();
            value = "";
            path = so.getPath();
            if (path != null) {
                sep = FilenameUtils.getPrefix(path);
                if (path.startsWith(sep))
                    path = path.substring(1, path.length());
                values = UIUtilities.splitString(path);
                if (values != null && values.length > 0)
                    value = values[0];
            }

            if (refString == null) {
                refString = value;
                count++;
            } else if (refString.equals(value))
                count++;
        }
        int index = 0;
        if (scripts.size() == count)
            index++;
        i = scripts.iterator();
        List<JMenuItem> topMenus = new ArrayList<JMenuItem>();
        JMenu ref = null;
        while (i.hasNext()) {
            so = i.next();
            path = so.getPath();
            if (path != null) {
                sep = FilenameUtils.getPrefix(path);
                if (path.startsWith(sep))
                    path = path.substring(1, path.length());
                values = UIUtilities.splitString(path);
                if (values != null) {
                    for (int j = index; j < values.length; j++) {
                        value = values[j];
                        JMenu v;
                        String text = name + value;
                        if (menus.containsKey(text)) {
                            v = menus.get(text);
                        } else {
                            value = value.replace(ScriptObject.PARAMETER_SEPARATOR,
                                    ScriptObject.PARAMETER_UI_SEPARATOR);
                            v = new JMenu(value);
                        }
                        if (ref == null)
                            topMenus.add(v);
                        else
                            ref.add(v);
                        ref = v;
                        name += values[j];
                        menus.put(name, v);
                    }
                }
            }
            ScriptMenuItem item = new ScriptMenuItem(so);
            item.addActionListener(listener);
            if (ref != null)
                ref.add(item);
            else
                topMenus.add(item);
            name = "";
            ref = null;
            if (so.getIcon() == null) {
                so.setIcon(icon);
                so.setIconLarge(largeIcon);
            }
        }
        Iterator<JMenuItem> j = topMenus.iterator();
        while (j.hasNext()) {
            scriptsMenu.add(j.next());
        }
    }
    scriptsMenu.show(c, p.x, p.y);
}