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());
}
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);
}
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;
}
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());
}
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);
}
Aggregations