use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class TreeNodes method addMenuItemNodeValue.
static <V> void addMenuItemNodeValue(final MenuFactory menu, final String groupName, final int index, final CharSequence name, final String iconName, final Predicate<V> enabledFilter, final Consumer<V> consumer) {
final Icon icon = Icons.getIcon(iconName);
final EnableCheck enableCheck = enableCheckNodeValue(enabledFilter);
final RunnableAction action = new RunnableAction(name, name.toString(), icon, true, () -> {
final BaseTreeNode node = BaseTree.getMenuNode();
if (node != null) {
@SuppressWarnings("unchecked") final V value = (V) node.getUserObject();
if (value != null) {
consumer.accept(value);
}
}
});
action.setEnableCheck(enableCheck);
menu.addMenuItem(groupName, index, action);
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class ToolBar method addToggleButton.
public JToggleButton addToggleButton(final String groupName, final int index, final String name, final String title, final Icon icon, final EnableCheck enableCheck, final Runnable runnable) {
final RunnableAction action = new RunnableAction(name, title, icon, runnable);
action.setEnableCheck(enableCheck);
final JToggleButton button = action.newToggleButton();
button.setBorderPainted(true);
this.groups.addComponent(this, groupName, index, button);
final ButtonGroup buttonGroup = getButtonGroup(groupName);
buttonGroup.add(button);
return button;
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class ToolBar method addButton.
public JButton addButton(final String groupName, final int index, final String name, final String title, final Icon icon, final EnableCheck enableCheck, final Runnable runnable) {
final RunnableAction action = new RunnableAction(name, title, icon, runnable);
action.setEnableCheck(enableCheck);
final JButton button = action.newButton();
button.setBorderPainted(false);
this.groups.addComponent(this, groupName, index, button);
return button;
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class UndoManager method addKeyMap.
public void addKeyMap(final Component component) {
if (component instanceof JComponent) {
final JComponent jcomponent = (JComponent) component;
if (jcomponent instanceof JTextComponent) {
final JTextComponent textComponent = (JTextComponent) jcomponent;
textComponent.getDocument().addUndoableEditListener(this);
}
final InputMap inputMap = jcomponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
final ActionMap actionMap = jcomponent.getActionMap();
int modifiers;
if (OS.isMac()) {
modifiers = Event.META_MASK;
} else {
modifiers = Event.CTRL_MASK;
}
final KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, modifiers);
final RunnableAction undoAction = new RunnableAction("Undo", this::undo);
actionMap.put("undo", undoAction);
inputMap.put(undoKey, "undo");
final KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Y, modifiers);
final RunnableAction redoAction = new RunnableAction("Redo", this::redo);
actionMap.put("redo", redoAction);
inputMap.put(redoKey, "redo");
}
}
Aggregations