Search in sources :

Example 11 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project jabref by JabRef.

the class OpenOfficePanel method showSettingsPopup.

private void showSettingsPopup() {
    JPopupMenu menu = new JPopupMenu();
    final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(Localization.lang("Automatically sync bibliography when inserting citations"), preferences.syncWhenCiting());
    final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem(Localization.lang("Look up BibTeX entries in the active tab only"));
    final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem(Localization.lang("Look up BibTeX entries in all open libraries"));
    final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(useActiveBase);
    bg.add(useAllBases);
    if (preferences.useAllDatabases()) {
        useAllBases.setSelected(true);
    } else {
        useActiveBase.setSelected(true);
    }
    autoSync.addActionListener(e -> preferences.setSyncWhenCiting(autoSync.isSelected()));
    useAllBases.addActionListener(e -> preferences.setUseAllDatabases(useAllBases.isSelected()));
    useActiveBase.addActionListener(e -> preferences.setUseAllDatabases(!useActiveBase.isSelected()));
    clearConnectionSettings.addActionListener(e -> frame.output(preferences.clearConnectionSettings()));
    menu.add(autoSync);
    menu.addSeparator();
    menu.add(useActiveBase);
    menu.add(useAllBases);
    menu.addSeparator();
    menu.add(clearConnectionSettings);
    menu.show(settingsB, 0, settingsB.getHeight());
}
Also used : ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 12 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project JMRI by JMRI.

the class Editor method setShowTooltipMenu.

/**
     * Add a checkbox to display a tooltip for the Positionable item and if
     * showable, provide a dialog menu to edit it.
     *
     * @param p     the item to set the menu for
     * @param popup the menu to add for p
     */
public void setShowTooltipMenu(Positionable p, JPopupMenu popup) {
    if (p.getDisplayLevel() == BKG) {
        return;
    }
    JMenu edit = new JMenu(Bundle.getMessage("EditTooltip"));
    JCheckBoxMenuItem showTooltipItem = new JCheckBoxMenuItem(Bundle.getMessage("ShowTooltip"));
    showTooltipItem.setSelected(p.showTooltip());
    showTooltipItem.addActionListener(new ActionListener() {

        Positionable comp;

        JCheckBoxMenuItem checkBox;

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            comp.setShowTooltip(checkBox.isSelected());
        }

        ActionListener init(Positionable pos, JCheckBoxMenuItem cb) {
            comp = pos;
            checkBox = cb;
            return this;
        }
    }.init(p, showTooltipItem));
    edit.add(showTooltipItem);
    edit.add(CoordinateEdit.getTooltipEditAction(p));
    jmri.NamedBean bean = p.getNamedBean();
    if (bean != null) {
        edit.add(new AbstractAction(Bundle.getMessage("SetSysNameTooltip")) {

            Positionable comp;

            jmri.NamedBean bean;

            @Override
            public void actionPerformed(ActionEvent e) {
                ToolTip tip = comp.getTooltip();
                if (tip != null) {
                    String uName = bean.getUserName();
                    String sName = bean.getSystemName();
                    if (uName != null && uName.length() > 0) {
                        sName = uName + "(" + sName + ")";
                    }
                    tip.setText(sName);
                }
            }

            AbstractAction init(Positionable pos, jmri.NamedBean b) {
                comp = pos;
                bean = b;
                return this;
            }
        }.init(p, bean));
    }
    popup.add(edit);
}
Also used : NamedBean(jmri.NamedBean) ActionListener(java.awt.event.ActionListener) NamedBean(jmri.NamedBean) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 13 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project JMRI by JMRI.

the class PositionablePopupUtil method newStyleMenuItem.

protected JMenuItem newStyleMenuItem(AbstractAction a, int mask) {
    // next two lines needed because JCheckBoxMenuItem(AbstractAction) not in 1.1.8
    JCheckBoxMenuItem c = new JCheckBoxMenuItem((String) a.getValue(AbstractAction.NAME));
    c.addActionListener(a);
    if (log.isDebugEnabled()) {
        // Avoid action lookup unless needed
        log.debug("When creating style item {} mask was {} state was {}", ((String) a.getValue(AbstractAction.NAME)), mask, _textComponent.getFont().getStyle());
    }
    if ((mask & _textComponent.getFont().getStyle()) == mask) {
        c.setSelected(true);
    }
    return c;
}
Also used : JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 14 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project JMRI by JMRI.

the class RosterTable method showTableHeaderPopup.

protected void showTableHeaderPopup(MouseEvent e) {
    JPopupMenu popupMenu = new JPopupMenu();
    for (int i = 0; i < columnModel.getColumnCount(false); i++) {
        TableColumn tc = columnModel.getColumnByModelIndex(i);
        JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(dataTable.getModel().getColumnName(i), columnModel.isColumnVisible(tc));
        menuItem.addActionListener(new headerActionListener(tc));
        popupMenu.add(menuItem);
    }
    popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
Also used : TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 15 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project JMRI by JMRI.

the class Editor method setHiddenMenu.

/**
     * Add a menu entry to set visibility of the Positionable item
     *
     * @param p     the item
     * @param popup the menu to add the entry to
     */
public void setHiddenMenu(Positionable p, JPopupMenu popup) {
    if (p.getDisplayLevel() == BKG) {
        return;
    }
    JCheckBoxMenuItem hideItem = new JCheckBoxMenuItem(Bundle.getMessage("SetHidden"));
    hideItem.setSelected(p.isHidden());
    hideItem.addActionListener(new ActionListener() {

        Positionable comp;

        JCheckBoxMenuItem checkBox;

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            comp.setHidden(checkBox.isSelected());
            setSelectionsHidden(checkBox.isSelected(), comp);
        }

        ActionListener init(Positionable pos, JCheckBoxMenuItem cb) {
            comp = pos;
            checkBox = cb;
            return this;
        }
    }.init(p, hideItem));
    popup.add(hideItem);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Aggregations

JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)48 ActionEvent (java.awt.event.ActionEvent)21 JMenuItem (javax.swing.JMenuItem)21 ActionListener (java.awt.event.ActionListener)18 JMenu (javax.swing.JMenu)17 JPopupMenu (javax.swing.JPopupMenu)12 AbstractAction (javax.swing.AbstractAction)8 JMenuBar (javax.swing.JMenuBar)6 JSeparator (javax.swing.JSeparator)5 JSpinner (javax.swing.JSpinner)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 JTableHeader (javax.swing.table.JTableHeader)4 TableColumn (javax.swing.table.TableColumn)4 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)3 Component (java.awt.Component)2 ItemEvent (java.awt.event.ItemEvent)2 HashMap (java.util.HashMap)2 Action (javax.swing.Action)2 ButtonGroup (javax.swing.ButtonGroup)2