use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class ProjectFrame method newMenuTools.
protected MenuFactory newMenuTools() {
final MenuFactory tools = new MenuFactory("Tools");
final MapPanel map = getMapPanel();
final MeasureOverlay measureOverlay = map.getMapOverlay(MeasureOverlay.class);
tools.addCheckboxMenuItem("map", new RunnableAction("Measure Length", Icons.getIcon("ruler_line"), () -> measureOverlay.toggleMeasureMode(DataTypes.LINE_STRING)), new ObjectPropertyEnableCheck(measureOverlay, "measureDataType", DataTypes.LINE_STRING));
tools.addCheckboxMenuItem("map", new RunnableAction("Measure Area", Icons.getIcon("ruler_polygon"), () -> measureOverlay.toggleMeasureMode(DataTypes.POLYGON)), new ObjectPropertyEnableCheck(measureOverlay, "measureDataType", DataTypes.POLYGON));
tools.addMenuItem("script", "Run Script...", "script_go", this::actionRunScript);
return tools;
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class SwingUtil method addAction.
static void addAction(final JComponent component, final KeyStroke keyStroke, final String actionKey, final Runnable runnable) {
final InputMap inputMap = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(keyStroke, actionKey);
final ActionMap actionMap = component.getActionMap();
final RunnableAction action = new RunnableAction(actionKey, runnable);
actionMap.put(actionKey, action);
if (component instanceof JComboBox) {
final JComboBox comboBox = (JComboBox) component;
final JComponent editorComponent = (JComponent) comboBox.getEditor().getEditorComponent();
addAction(editorComponent, keyStroke, actionKey, runnable);
}
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class TreeItemScaleMenu method addScaleMenuItem.
protected void addScaleMenuItem(final long layerScale, final JMenu menu, final T object, final long scale) {
final String label;
if (scale <= 0) {
label = "Unlimited";
} else {
label = MapScale.formatScale(scale);
}
final RunnableAction action = new RunnableAction(label, () -> this.setScaleFunction.accept(object, scale));
final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(action);
final boolean selected = scale == layerScale;
menuItem.setSelected(selected);
menuItem.setPreferredSize(new Dimension(140, 22));
menuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
menu.add(menuItem);
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class LayerRecordMenu method addMenuItem.
public static <V extends Record> RunnableAction addMenuItem(final MenuFactory menu, final String groupName, final int index, final CharSequence name, final String toolTip, final String iconName, final EnableCheck enableCheck, final Consumer<V> consumer) {
final Icon icon = Icons.getIcon(iconName);
final RunnableAction action = MenuFactory.newMenuItem(name, toolTip, icon, enableCheck, () -> {
final V record = getEventRecord();
if (record != null && consumer != null) {
consumer.accept(record);
}
});
menu.addComponentFactory(groupName, index, action);
return action;
}
use of com.revolsys.swing.action.RunnableAction in project com.revolsys.open by revolsys.
the class TreeNodes method addMenuItem.
static <V extends BaseTreeNode> RunnableAction addMenuItem(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 = enableCheck(enabledFilter);
final RunnableAction action = new RunnableAction(name, name.toString(), icon, true, () -> {
final V object = BaseTree.getMenuNode();
consumer.accept(object);
});
action.setEnableCheck(enableCheck);
menu.addMenuItem(groupName, action);
return action;
}
Aggregations