use of com.revolsys.swing.action.enablecheck.EnableCheck in project com.revolsys.open by revolsys.
the class SetRecordsFieldValue method addMenuItem.
public static void addMenuItem(final MenuFactory headerMenu) {
final EnableCheck enableCheck = newEnableCheck();
headerMenu.addMenuItem("field", "Set Field Value", "table_fill_down", enableCheck, SetRecordsFieldValue::showDialog);
}
use of com.revolsys.swing.action.enablecheck.EnableCheck in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method initRecordMenu.
protected LayerRecordMenu initRecordMenu() {
final LayerRecordMenu menu = new LayerRecordMenu(this);
this.recordMenu = menu;
if (this.recordDefinition != null) {
final RecordDefinition recordDefinition = getRecordDefinition();
final boolean hasGeometry = recordDefinition.hasGeometryField();
final Predicate<LayerRecord> modified = LayerRecord::isModified;
final Predicate<LayerRecord> notDeleted = ((Predicate<LayerRecord>) this::isDeleted).negate();
final Predicate<LayerRecord> modifiedOrDeleted = modified.or(LayerRecord::isDeleted);
final EnableCheck editableEnableCheck = this::isEditable;
menu.addGroup(0, "default");
menu.addGroup(1, "record");
menu.addGroup(2, "dnd");
final MenuFactory layerMenuFactory = MenuFactory.findMenu(this);
if (layerMenuFactory != null) {
menu.addComponentFactory("default", 0, new WrappedMenuFactory("Layer", layerMenuFactory));
}
menu.addMenuItem("record", "View/Edit Record", "table_edit", notDeleted, this::showForm);
if (hasGeometry) {
menu.addMenuItem("record", "Zoom to Record", "magnifier_zoom_selected", notDeleted, this::zoomToRecord);
menu.addMenuItem("record", "Pan to Record", "pan_selected", notDeleted, (record) -> {
final MapPanel mapPanel = getMapPanel();
if (mapPanel != null) {
mapPanel.panToRecord(record);
}
});
final MenuFactory editMenu = new MenuFactory("Edit Record Operations");
editMenu.setEnableCheck(LayerRecordMenu.enableCheck(notDeleted));
final DataType geometryDataType = recordDefinition.getGeometryField().getDataType();
if (geometryDataType == DataTypes.LINE_STRING || geometryDataType == DataTypes.MULTI_LINE_STRING) {
if (DirectionalFields.getProperty(recordDefinition).hasDirectionalFields()) {
LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_RECORD_NAME, LayerRecordForm.FLIP_RECORD_ICON, editableEnableCheck, this::actionFlipRecordOrientation);
LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_LINE_ORIENTATION_NAME, LayerRecordForm.FLIP_LINE_ORIENTATION_ICON, editableEnableCheck, this::actionFlipLineOrientation);
LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_FIELDS_NAME, LayerRecordForm.FLIP_FIELDS_ICON, editableEnableCheck, this::actionFlipFields);
} else {
LayerRecordMenu.addMenuItem(editMenu, "geometry", "Flip Line Orientation", "flip_line", editableEnableCheck, this::actionFlipLineOrientation);
}
}
menu.addComponentFactory("record", editMenu);
}
menu.addMenuItem("record", "Delete Record", "table_row_delete", LayerRecord::isDeletable, this::deleteRecord);
menu.addMenuItem("record", "Revert Record", "arrow_revert", modifiedOrDeleted, LayerRecord::revertChanges);
final Predicate<LayerRecord> hasModifiedEmptyFields = LayerRecord::isHasModifiedEmptyFields;
menu.addMenuItem("record", "Revert Empty Fields", "field_empty_revert", hasModifiedEmptyFields, LayerRecord::revertEmptyFields);
menu.addMenuItem("dnd", "Copy Record", "page_copy", this::copyRecordToClipboard);
if (hasGeometry) {
menu.addMenuItem("dnd", "Paste Geometry", "geometry_paste", this::canPasteRecordGeometry, this::pasteRecordGeometry);
}
}
return menu;
}
use of com.revolsys.swing.action.enablecheck.EnableCheck 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;
}
use of com.revolsys.swing.action.enablecheck.EnableCheck 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);
}
Aggregations