use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class SignalMastIcon method showPopUp.
/**
* Pop-up just displays the name
*/
@Override
public boolean showPopUp(JPopupMenu popup) {
if (isEditable()) {
JMenu clickMenu = new JMenu(Bundle.getMessage("WhenClicked"));
ButtonGroup clickButtonGroup = new ButtonGroup();
JRadioButtonMenuItem r;
r = new JRadioButtonMenuItem(Bundle.getMessage("ChangeAspect"));
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setClickMode(0);
}
});
clickButtonGroup.add(r);
if (clickMode == 0) {
r.setSelected(true);
} else {
r.setSelected(false);
}
clickMenu.add(r);
r = new JRadioButtonMenuItem(Bundle.getMessage("AlternateLit"));
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setClickMode(1);
}
});
clickButtonGroup.add(r);
if (clickMode == 1) {
r.setSelected(true);
} else {
r.setSelected(false);
}
clickMenu.add(r);
r = new JRadioButtonMenuItem(Bundle.getMessage("AlternateHeld"));
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setClickMode(2);
}
});
clickButtonGroup.add(r);
if (clickMode == 2) {
r.setSelected(true);
} else {
r.setSelected(false);
}
clickMenu.add(r);
popup.add(clickMenu);
// add menu to select handling of lit parameter
JMenu litMenu = new JMenu(Bundle.getMessage("WhenNotLit"));
litButtonGroup = new ButtonGroup();
r = new JRadioButtonMenuItem(Bundle.getMessage("ShowAppearance"));
r.setIconTextGap(10);
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setLitMode(false);
displayState(mastState());
}
});
litButtonGroup.add(r);
if (!litMode) {
r.setSelected(true);
} else {
r.setSelected(false);
}
litMenu.add(r);
r = new JRadioButtonMenuItem(Bundle.getMessage("ShowDarkIcon"));
r.setIconTextGap(10);
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setLitMode(true);
displayState(mastState());
}
});
litButtonGroup.add(r);
if (litMode) {
r.setSelected(true);
} else {
r.setSelected(false);
}
litMenu.add(r);
popup.add(litMenu);
java.util.Enumeration<String> en = getSignalMast().getSignalSystem().getImageTypeList();
if (en.hasMoreElements()) {
JMenu iconSetMenu = new JMenu(Bundle.getMessage("SignalMastIconSet"));
ButtonGroup iconTypeGroup = new ButtonGroup();
setImageTypeList(iconTypeGroup, iconSetMenu, "default");
while (en.hasMoreElements()) {
setImageTypeList(iconTypeGroup, iconSetMenu, en.nextElement());
}
popup.add(iconSetMenu);
}
popup.add(new jmri.jmrit.signalling.SignallingSourceAction(Bundle.getMessage("SignalMastLogic"), getSignalMast()));
JMenu aspect = new JMenu(Bundle.getMessage("ChangeAspect"));
final java.util.Vector<String> aspects = getSignalMast().getValidAspects();
for (int i = 0; i < aspects.size(); i++) {
final int index = i;
aspect.add(new AbstractAction(aspects.elementAt(index)) {
@Override
public void actionPerformed(ActionEvent e) {
getSignalMast().setAspect(aspects.elementAt(index));
}
});
}
popup.add(aspect);
addTransitPopup(popup);
} else {
final java.util.Vector<String> aspects = getSignalMast().getValidAspects();
for (int i = 0; i < aspects.size(); i++) {
final int index = i;
popup.add(new AbstractAction(aspects.elementAt(index)) {
@Override
public void actionPerformed(ActionEvent e) {
getSignalMast().setAspect(aspects.elementAt(index));
}
});
}
}
return true;
}
use of javax.swing.JRadioButtonMenuItem in project knime-core by knime.
the class Axis method createPopupMenu.
private JPopupMenu createPopupMenu() {
if (getCoordinate() == null) {
return null;
}
m_currFormat = NORMAL;
JPopupMenu popupMenu = new JPopupMenu();
createNotationMenu(popupMenu);
// policies
if (m_coordinate != null) {
List<PolicyStrategy> strategies = new LinkedList<PolicyStrategy>();
Set<PolicyStrategy> policies = m_coordinate.getCompatiblePolicies();
if (policies != null) {
strategies.addAll(policies);
Collections.sort(strategies, new Comparator<PolicyStrategy>() {
/**
* {@inheritDoc}
*/
@Override
public int compare(final PolicyStrategy o1, final PolicyStrategy o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
}
JMenu tickPolicyMenu = new JMenu("Tick policies");
ButtonGroup tickPolicyButtons = new ButtonGroup();
if (strategies.size() > 0) {
popupMenu.add(tickPolicyMenu);
for (PolicyStrategy strategy : strategies) {
final PolicyStrategy tempStrategy = strategy;
JRadioButtonMenuItem tickPolicy = new JRadioButtonMenuItem(strategy.getDisplayName());
tickPolicyButtons.add(tickPolicy);
tickPolicyMenu.add(tickPolicy);
if (strategy.equals(m_coordinate.getCurrentPolicy())) {
tickPolicy.setSelected(true);
}
tickPolicy.addItemListener(new ItemListener() {
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setPolicy(tempStrategy);
// recreate popup menu
setComponentPopupMenu(createPopupMenu());
if (tempStrategy.isMappingAllowed()) {
m_mappingMethodMenu.setEnabled(true);
m_notationsMenu.setEnabled(true);
} else {
// hide mapping methods
m_mappingMethodMenu.setEnabled(false);
m_notationsMenu.setEnabled(false);
if (getCoordinate() != null) {
getCoordinate().setActiveMappingMethod(null);
}
}
notifyChangeListeners();
}
}
});
}
}
// add strategies
Set<MappingMethod> mappingMethods = m_coordinate.getCompatibleMappingMethods();
m_mappingMethodMenu = new JMenu("Mapping Methods");
if (mappingMethods != null && mappingMethods.size() > 0) {
popupMenu.add(m_mappingMethodMenu);
ButtonGroup buttons = new ButtonGroup();
final Map<MappingMethod, JRadioButtonMenuItem> checkboxes = new HashMap<MappingMethod, JRadioButtonMenuItem>();
JRadioButtonMenuItem none = new JRadioButtonMenuItem("none", true);
buttons.add(none);
none.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setActiveMappingMethod(null);
notifyChangeListeners();
}
}
});
m_mappingMethodMenu.add(none);
for (MappingMethod method : mappingMethods) {
// final needed
final MappingMethod tempMethod = method;
JRadioButtonMenuItem checkbox = new JRadioButtonMenuItem(method.getDisplayName(), false);
checkbox.setEnabled(method.isCompatibleWithDomain(getCoordinate().getDomain()));
checkboxes.put(method, checkbox);
buttons.add(checkbox);
if (method.equals(m_coordinate.getActiveMappingMethod())) {
checkbox.setSelected(true);
}
checkbox.addItemListener(new ItemListener() {
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setActiveMappingMethod(tempMethod);
}
notifyChangeListeners();
}
});
m_mappingMethodMenu.add(checkbox);
}
for (Map.Entry<MappingMethod, JRadioButtonMenuItem> entry : checkboxes.entrySet()) {
if (entry.getKey().isCompatibleWithDomain(getCoordinate().getDomain())) {
entry.getValue().setEnabled(true);
}
}
}
}
if (popupMenu.getComponentCount() < 1) {
return null;
}
return popupMenu;
}
use of javax.swing.JRadioButtonMenuItem in project knime-core by knime.
the class SotaTreeViewPropsPanel method createZoomMenu.
/**
* @return a JMenu entry handling the zooming ability
*/
public JMenu createZoomMenu() {
JMenu menu = new JMenu("View");
menu.setMnemonic('Z');
ActionListener actL = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (e.getActionCommand().equals(ENABLE_ZOOM)) {
JMenuItem item = (JMenuItem) e.getSource();
if (!item.isSelected()) {
m_pane.setZooming(true);
if (m_zoomOut != null && m_zoomIn != null) {
m_zoomIn.setEnabled(true);
m_zoomOut.setEnabled(true);
}
} else {
m_pane.setZooming(false);
if (m_zoomOut != null && m_zoomIn != null) {
m_zoomIn.setEnabled(false);
m_zoomOut.setEnabled(false);
}
}
}
}
};
JMenuItem item = new JRadioButtonMenuItem(ENABLE_ZOOM);
item.setToolTipText("Click to disable zooming and fit tree to " + "frame size.");
item.addActionListener(actL);
item.setMnemonic('E');
item.setSelected(!m_pane.isZooming());
menu.add(item);
return menu;
}
use of javax.swing.JRadioButtonMenuItem in project knime-core by knime.
the class ParallelCoordinatesViewPanel method createViewTypeMenu.
/**
* @return - a JMenu entry handling the view type.
*/
public JMenu createViewTypeMenu() {
JMenu menu = new JMenu("View Type");
menu.setMnemonic('V');
ActionListener actL = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
if (e.getActionCommand().equals(POPUP_ALL_VISIBLE)) {
// set view to ALL VISIBLE
setViewType(ALL_VISIBLE);
((JRadioButtonMenuItem) e.getSource()).firePropertyChange(POPUP_ALL_VISIBLE, false, true);
repaint();
} else if (e.getActionCommand().equals(POPUP_HIDE_UNHILITED)) {
// set view to HIDE_UNHILITED
setViewType(HIDE_UNHILITED);
unselectUnhilited();
((JRadioButtonMenuItem) e.getSource()).firePropertyChange(POPUP_HIDE_UNHILITED, false, true);
repaint();
} else if (e.getActionCommand().equals(POPUP_FADE_UNHILITED)) {
// set view to FADE_UNHILITED
setViewType(FADE_UNHILITED);
unselectUnhilited();
((JRadioButtonMenuItem) e.getSource()).firePropertyChange(POPUP_FADE_UNHILITED, false, true);
repaint();
}
}
};
ButtonGroup group = new ButtonGroup();
// JMenuItem item
JMenuItem item = new JRadioButtonMenuItem(POPUP_ALL_VISIBLE);
item.setSelected(m_viewType == ALL_VISIBLE);
item.addActionListener(actL);
item.setMnemonic('A');
item.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent e) {
((JRadioButtonMenuItem) e.getSource()).setSelected(m_viewType == ALL_VISIBLE);
}
});
group.add(item);
menu.add(item);
item = new JRadioButtonMenuItem(POPUP_HIDE_UNHILITED);
item.setSelected(m_viewType == HIDE_UNHILITED);
item.addActionListener(actL);
item.setMnemonic('H');
item.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent e) {
((JRadioButtonMenuItem) e.getSource()).setSelected(m_viewType == HIDE_UNHILITED);
}
});
group.add(item);
menu.add(item);
item = new JRadioButtonMenuItem(POPUP_FADE_UNHILITED);
item.setSelected(m_viewType == FADE_UNHILITED);
item.addActionListener(actL);
item.setMnemonic('F');
item.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent e) {
((JRadioButtonMenuItem) e.getSource()).setSelected(m_viewType == FADE_UNHILITED);
}
});
group.add(item);
menu.add(item);
return menu;
}
use of javax.swing.JRadioButtonMenuItem in project knime-core by knime.
the class ScatterPlotter method fillPopupMenu.
/**
* {@inheritDoc}
*/
@Override
protected void fillPopupMenu(final JPopupMenu menu) {
if (m_hiliteMenu == null) {
m_hiliteMenu = getHiLiteMenu();
}
boolean dotsSelected;
if ((getScatterPlotterDrawingPane().getSelectedSet() != null) && (getScatterPlotterDrawingPane().getSelectedSet().size() > 0)) {
dotsSelected = true;
} else {
dotsSelected = false;
}
String selCnt = "Selected: " + getScatterPlotterDrawingPane().getSelectedSet().size();
boolean clearPossible = m_hiliteHdlr.getHiLitKeys().size() > 0;
String hilite = POPUP_HILITE_SELECTED;
if (m_hiliteHdlr == null) {
hilite = "<no hilit hdl>";
dotsSelected = false;
}
String unhilite = POPUP_UNHILITE_SELECTED;
if (m_hiliteHdlr == null) {
unhilite = "<no hilit hdl>";
dotsSelected = false;
}
String clearhilite = POPUP_CLEAR_HILITED;
JMenuItem item;
/* --- "Selected: xxx" --- */
item = new JMenuItem(selCnt);
item.setEnabled(false);
menu.add(item);
menu.addSeparator();
/* --- "hilite selected" --- */
item = new JMenuItem(hilite);
item.setEnabled(dotsSelected);
item.addActionListener(this);
menu.add(item);
/* --- "unhilite selected" --- */
item = new JMenuItem(unhilite);
item.setEnabled(dotsSelected && clearPossible);
item.addActionListener(this);
menu.add(item);
/* --- "clear hilite" --- */
item = new JMenuItem(clearhilite);
item.setEnabled(clearPossible);
item.addActionListener(this);
menu.add(item);
/* ------------------------------ */
menu.addSeparator();
ButtonGroup group = new ButtonGroup();
/* --- "[ ] show unhilited" --- */
item = new JRadioButtonMenuItem(POPUP_SHOW, (!getFadeUnHiLited() && !isHideUnHiLited()));
item.addActionListener(this);
group.add(item);
menu.add(item);
/* --- "[ ] fade unhilited" --- */
item = new JRadioButtonMenuItem(POPUP_FADE, getFadeUnHiLited());
item.addActionListener(this);
group.add(item);
menu.add(item);
/* --- "[ ] hide unhilited" --- */
item = new JRadioButtonMenuItem(POPUP_HIDE, isHideUnHiLited());
item.addActionListener(this);
group.add(item);
menu.add(item);
}
Aggregations