use of com.revolsys.swing.component.BasePanel in project com.revolsys.open by revolsys.
the class AbstractLayer method newPanelComponent.
@Override
public Component newPanelComponent(final Map<String, Object> config) {
if (isInitialized()) {
if (isExists()) {
return newTableViewComponent(config);
} else {
return new BasePanel(new BorderLayout());
}
} else {
final BasePanel basePanel = new BasePanel(new BorderLayout());
addPropertyChangeListener("initialized", (event) -> {
if (isExists()) {
Invoke.later(() -> {
final Component tableViewComponent = newTableViewComponent(config);
if (tableViewComponent != null) {
basePanel.add(tableViewComponent, BorderLayout.CENTER);
removePropertyChangeListener("initialized", this);
}
});
}
});
if (isInitialized()) {
firePropertyChange("initialized", false, true);
}
return basePanel;
}
}
use of com.revolsys.swing.component.BasePanel in project com.revolsys.open by revolsys.
the class RecordLayerErrors method showErrorDialog.
public boolean showErrorDialog() {
if (this.records.isEmpty()) {
return true;
} else {
Invoke.later(() -> {
final RecordLayerErrorsTableModel tableModel = new RecordLayerErrorsTableModel(this.layer, this.records, this.messages, this.exceptions, this.fieldNames);
final String layerPath = this.layer.getPath();
final BasePanel panel = new BasePanel(new VerticalLayout(), new JLabel("<html><p><b style=\"color:red\">Error " + this.title + " for layer:</b></p><p>" + layerPath + "</p>"), tableModel.newPanel());
final Rectangle screenBounds = SwingUtil.getScreenBounds();
panel.setPreferredSize(new Dimension(screenBounds.width - 300, tableModel.getRowCount() * 22 + 75));
final Window window = SwingUtil.getActiveWindow();
final JOptionPane pane = new JOptionPane(panel, JOptionPane.ERROR_MESSAGE, JOptionPane.DEFAULT_OPTION, null, null, null);
pane.setComponentOrientation(window.getComponentOrientation());
final JDialog dialog = pane.createDialog(window, "Error " + this.title + ": " + layerPath);
dialog.pack();
SwingUtil.setLocationCentre(screenBounds, dialog);
dialog.setVisible(true);
SwingUtil.dispose(dialog);
});
return false;
}
}
use of com.revolsys.swing.component.BasePanel in project com.revolsys.open by revolsys.
the class RecordValidationDialog method showErrorDialog.
private void showErrorDialog(final String title, final Consumer<RecordValidationDialog> successAction, final Consumer<RecordValidationDialog> cancelAction) {
Invoke.later(() -> {
final String layerPath = this.layer.getPath();
final Window window = SwingUtil.getActiveWindow();
final JDialog dialog = new JDialog(window, "Error " + title + " for " + layerPath, ModalityType.APPLICATION_MODAL);
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
dialog.setLayout(new BorderLayout());
final ToolBar toolBar = new ToolBar();
toolBar.addButtonTitleIcon("default", "Cancel " + title, "table_cancel", () -> {
dialog.setVisible(false);
cancelAction.accept(this);
});
toolBar.addButtonTitleIcon("default", "Save valid records", "table_save", () -> {
dialog.setVisible(false);
validateRecords(this.invalidRecords, true);
successAction.accept(this);
});
final TablePanel invalidRecordsTablePanel = newInvalidRecordsTablePanel();
final JLabel message = new JLabel("<html><b style=\"color:red\">Edit the invalid fields (red background) for the invalid records.</b><br />" + " Valid records will have a green background when edited.</html>");
message.setBorder(BorderFactory.createTitledBorder(layerPath));
final BasePanel panel = new //
BasePanel(//
new VerticalLayout(), //
toolBar, //
message, //
invalidRecordsTablePanel);
panel.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6));
if (!this.validRecords.isEmpty()) {
final TablePanel validRecordsTablePanel = newValidRecordsTablePanel();
panel.add(validRecordsTablePanel);
}
dialog.add(panel, BorderLayout.NORTH);
final Rectangle screenBounds = SwingUtil.getScreenBounds();
dialog.pack();
dialog.setSize(screenBounds.width - 50, dialog.getPreferredSize().height);
SwingUtil.setLocationCentre(screenBounds, dialog);
dialog.setVisible(true);
SwingUtil.dispose(dialog);
});
}
use of com.revolsys.swing.component.BasePanel in project com.revolsys.open by revolsys.
the class MapPanel method promptCoordinateSystem.
/**
* Prompt for a coordinate system if the geometry factory does not have a coordinate system.
* @author Paul Austin <paul.austin@revolsys.com>
* @param geometryFactoryProxy
* @param action
*/
public static <GFP extends GeometryFactoryProxy> void promptCoordinateSystem(final String title, final GFP geometryFactoryProxy, final Consumer<GeometryFactory> action) {
if (geometryFactoryProxy.isHasCoordinateSystem()) {
final GeometryFactory geometryFactory = geometryFactoryProxy.getGeometryFactory();
action.accept(geometryFactory);
} else {
Invoke.later(() -> {
final Project project = Project.get();
final MapPanel mapPanel = project.getMapPanel();
final int mapCoordinateSystemId = mapPanel.getCoordinateSystemId();
final CoordinateSystemField coordinateSystemField = new CoordinateSystemField("coordinateSystem");
coordinateSystemField.setSelectedItem(mapCoordinateSystemId);
final JPanel fieldPanel = new BasePanel(new JLabel("Coordinate System"), coordinateSystemField);
GroupLayouts.makeColumns(fieldPanel, 2, true);
final ValueField valueField = new ValueField(fieldPanel);
valueField.add(fieldPanel);
valueField.showDialog();
if (valueField.isSaved()) {
final GeometryFactory geometryFactory = coordinateSystemField.getGeometryFactory();
if (geometryFactory.isHasCoordinateSystem()) {
Invoke.background(title, () -> action.accept(geometryFactory));
}
}
});
}
}
use of com.revolsys.swing.component.BasePanel in project com.revolsys.open by revolsys.
the class AbstractLayer method newPropertiesTabGeneral.
protected BasePanel newPropertiesTabGeneral(final TabbedValuePanel tabPanel) {
final BasePanel generalPanel = new BasePanel(new VerticalLayout(5));
generalPanel.setScrollableHeightHint(ScrollableSizeHint.FIT);
tabPanel.addTab("General", generalPanel);
newPropertiesTabGeneralPanelGeneral(generalPanel);
final ValueField sourcePanel = newPropertiesTabGeneralPanelSource(generalPanel);
if (sourcePanel.getComponentCount() == 0) {
generalPanel.remove(sourcePanel);
}
return generalPanel;
}
Aggregations