use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class LayerRecordForm method deleteRecord.
public void deleteRecord() {
final LayerRecord record = getRecord();
if (record != null) {
final AbstractRecordLayer layer = getLayer();
layer.deleteRecord(record);
}
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class LayerRecordForm method addToolBar.
protected ToolBar addToolBar(final AbstractRecordLayer layer) {
this.toolBar = new ToolBar();
add(this.toolBar, BorderLayout.NORTH);
final RecordDefinition recordDefinition = getRecordDefinition();
final FieldDefinition geometryField = recordDefinition.getGeometryField();
final boolean hasGeometry = geometryField != null;
final EnableCheck editable = new ObjectPropertyEnableCheck(this, "editable");
if (layer != null) {
final MenuFactory menuFactory = MenuFactory.findMenu(layer);
if (menuFactory != null) {
this.toolBar.addButtonTitleIcon("menu", "Layer Menu", "menu", () -> menuFactory.showMenu(layer, this, 10, 10));
}
}
final EnableCheck deletableEnableCheck = editable.and(new ObjectPropertyEnableCheck(this, "deletable"));
this.toolBar.addButton("record", "Delete Record", "table_row_delete", deletableEnableCheck, this::deleteRecord);
// Cut, Copy Paste
this.toolBar.addButton("dnd", "Copy Record", "page_copy", (EnableCheck) null, this::dataTransferCopy);
if (hasGeometry) {
this.toolBar.addButton("dnd", "Copy Geometry", "geometry_copy", (EnableCheck) null, this::copyGeometry);
}
this.toolBar.addButton("dnd", "Paste Record", "paste_plain", editable, this::dataTransferPaste);
if (hasGeometry) {
this.toolBar.addButton("dnd", "Paste Geometry", "geometry_paste", editable, this::pasteGeometry);
}
final EnableCheck canUndo = new ObjectPropertyEnableCheck(this.undoManager, "canUndo");
final EnableCheck canRedo = new ObjectPropertyEnableCheck(this.undoManager, "canRedo");
final EnableCheck modifiedOrDeleted = new ObjectPropertyEnableCheck(this, "modifiedOrDeleted");
this.toolBar.addButton("changes", "Revert Record", "arrow_revert", modifiedOrDeleted, this::revertChanges);
this.toolBar.addButton("changes", "Revert Empty Fields", "field_empty_revert", new ObjectPropertyEnableCheck(this, "hasModifiedEmptyFields"), this::revertEmptyFields);
this.toolBar.addButton("changes", "Undo", "arrow_undo", canUndo, this.undoManager::undo);
this.toolBar.addButton("changes", "Redo", "arrow_redo", canRedo, this.undoManager::redo);
if (hasGeometry) {
this.toolBar.addButtonTitleIcon("zoom", "Zoom to Record", "magnifier_zoom_selected", () -> {
final LayerRecord record = getRecord();
layer.zoomToRecord(record);
});
this.toolBar.addButtonTitleIcon("zoom", "Pan to Record", "pan_selected", () -> {
final LayerRecord record = getRecord();
final MapPanel mapPanel = layer.getMapPanel();
if (mapPanel != null) {
mapPanel.panToRecord(record);
}
});
}
// Geometry manipulation
if (hasGeometry) {
final DataType geometryDataType = geometryField.getDataType();
if (geometryDataType == DataTypes.LINE_STRING || geometryDataType == DataTypes.MULTI_LINE_STRING) {
if (DirectionalFields.getProperty(recordDefinition).hasDirectionalFields()) {
this.toolBar.addButton("geometry", FLIP_RECORD_NAME, FLIP_RECORD_ICON, editable, this::flipRecordOrientation);
this.toolBar.addButton("geometry", FLIP_LINE_ORIENTATION_NAME, FLIP_LINE_ORIENTATION_ICON, editable, this::flipLineOrientation);
this.toolBar.addButton("geometry", FLIP_FIELDS_NAME, FLIP_FIELDS_ICON, editable, this::flipFields);
} else {
this.toolBar.addButton("geometry", "Flip Line Orientation", "flip_line", editable, this::flipLineOrientation);
}
}
}
return this.toolBar;
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordLayerTable method addModifiedRecordHighlighter.
@Override
protected void addModifiedRecordHighlighter() {
final RecordLayerTableModel model = getModel();
final HighlightPredicate predicate = (renderer, adapter) -> {
try {
final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
final LayerRecord record = model.getRecord(rowIndex);
final AbstractRecordLayer layer = model.getLayer();
return layer.isModified(record);
} catch (final Throwable e) {
return false;
}
};
addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LimeGreen, 127), WebColors.Black, WebColors.newAlpha(WebColors.DarkGreen, 191), Color.WHITE));
addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.LimeGreen, WebColors.Black, WebColors.DarkGreen, Color.WHITE));
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordLayerTable method editCellAt.
@Override
public boolean editCellAt(final int row, final int column, final EventObject e) {
final LayerRecord record = getRecord(row);
LayerRecordMenu.setEventRecord(record);
return super.editCellAt(row, column, e);
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class RecordLayerTable method addNewRecordHighlighter.
@Override
protected void addNewRecordHighlighter() {
final RecordLayerTableModel model = getModel();
final HighlightPredicate predicate = (renderer, adapter) -> {
try {
final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
final LayerRecord record = model.getRecord(rowIndex);
final AbstractRecordLayer layer = model.getLayer();
return layer.isNew(record);
} catch (final Throwable e) {
return false;
}
};
addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LightSkyBlue, 127), WebColors.Black, WebColors.newAlpha(WebColors.RoyalBlue, 191), Color.WHITE));
addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.LightSkyBlue, WebColors.Black, WebColors.RoyalBlue, Color.WHITE));
}
Aggregations