use of com.revolsys.swing.table.TableRowCount in project com.revolsys.open by revolsys.
the class RecordLayerTablePanel method newToolBar.
protected void newToolBar(final Map<String, Object> pluginConfig) {
final ToolBar toolBar = getToolBar();
final RecordDefinition recordDefinition = getRecordDefinition();
final boolean hasGeometry = recordDefinition.hasGeometryField();
final MenuFactory layerMenuFactory = MenuFactory.findMenu(this.layer);
if (layerMenuFactory != null) {
toolBar.addButtonTitleIcon("menu", "Layer Menu", "menu", () -> layerMenuFactory.showMenu(this.layer, this, 10, 10));
}
if (hasGeometry) {
final EnableCheck hasSelectedRecords = new ObjectPropertyEnableCheck(this.layer, "hasSelectedRecords");
toolBar.addButton("layer", "Zoom to Selected", "magnifier_zoom_selected", hasSelectedRecords, this.layer::zoomToSelected);
toolBar.addButton("layer", "Pan to Selected", "pan_selected", hasSelectedRecords, this.layer::panToSelected);
}
final RecordLayerTable table = getTable();
final TableRowCount tableRowCount = new TableRowCount(table);
toolBar.addComponent("count", tableRowCount);
toolBar.addButtonTitleIcon("table", "Refresh", "table_refresh", this.layer::refresh);
toolBar.addButtonTitleIcon("table", "Export Records", "table_save", new ObjectPropertyEnableCheck(tableRowCount, "rowCount", 0, true), () -> actionExportRecords());
this.fieldSetsButton = toolBar.addButtonTitleIcon("table", "Field Sets", "fields_filter", () -> actionShowFieldSetsMenu());
this.fieldFilterPanel = new FieldFilterPanel(this, this.tableModel, pluginConfig);
if (this.fieldFilterPanel.isVisible()) {
toolBar.addComponent("search", this.fieldFilterPanel);
toolBar.addButtonTitleIcon("search", "Advanced Search", "filter_edits", this.fieldFilterPanel::showAdvancedFilter);
final EnableCheck hasFilter = new ObjectPropertyEnableCheck(this.tableModel, "hasFilter");
toolBar.addButton("search", "Clear Search", "filter_delete", hasFilter, this.fieldFilterPanel::clear);
final EnableCheck hasFilterHistory = new ObjectPropertyEnableCheck(this.tableModel, "hasFilterHistory");
toolBar.addButton("search", ConsumerAction.action("Search History", Icons.getIconWithBadge("book", "filter"), hasFilterHistory, (event) -> {
final Object source = event.getSource();
Component component = null;
if (source instanceof Component) {
component = (Component) source;
}
final BaseJPopupMenu menu = new BaseJPopupMenu();
for (final Condition filter : this.tableModel.getFilterHistory()) {
menu.addMenuItem(filter.toString(), () -> this.fieldFilterPanel.setFilter(filter));
}
menu.showMenu(component, 0, 20);
}));
}
// Filter buttons
boolean first = true;
for (final TableRecordsMode fieldFilterMode : this.tableModel.getFieldFilterModes()) {
final String key = fieldFilterMode.getKey();
final String title = fieldFilterMode.getTitle();
final Icon icon = fieldFilterMode.getIcon();
final EnableCheck enableCheck = fieldFilterMode.getEnableCheck();
final JToggleButton button = toolBar.addToggleButton(FILTER_FIELD, -1, null, title, icon, enableCheck, () -> {
if (this.tableModel != null) {
this.tableModel.setTableRecordsMode(fieldFilterMode);
}
});
this.buttonByMode.put(FILTER_FIELD + "_" + key, button);
if (first) {
button.doClick();
first = false;
}
}
if (hasGeometry) {
final JToggleButton showAllGeometries = addGeometryFilterToggleButton(toolBar, -1, "Show All Records ", "world_filter", "all", null);
showAllGeometries.doClick();
addGeometryFilterToggleButton(toolBar, -1, "Show Records on Map", "map_filter", "boundingBox", new ObjectPropertyEnableCheck(this.tableModel, "filterByBoundingBoxSupported"));
}
}
Aggregations