Search in sources :

Example 1 with BasePanel

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;
    }
}
Also used : BasePanel(com.revolsys.swing.component.BasePanel) BorderLayout(java.awt.BorderLayout) Component(java.awt.Component)

Example 2 with 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;
    }
}
Also used : Window(java.awt.Window) BasePanel(com.revolsys.swing.component.BasePanel) Rectangle(java.awt.Rectangle) VerticalLayout(org.jdesktop.swingx.VerticalLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 3 with BasePanel

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);
    });
}
Also used : Window(java.awt.Window) BasePanel(com.revolsys.swing.component.BasePanel) BorderLayout(java.awt.BorderLayout) ToolBar(com.revolsys.swing.toolbar.ToolBar) Rectangle(java.awt.Rectangle) JLabel(javax.swing.JLabel) VerticalLayout(org.jdesktop.swingx.VerticalLayout) JDialog(javax.swing.JDialog) TablePanel(com.revolsys.swing.table.TablePanel)

Example 4 with BasePanel

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));
                }
            }
        });
    }
}
Also used : Project(com.revolsys.swing.map.layer.Project) JPanel(javax.swing.JPanel) BasePanel(com.revolsys.swing.component.BasePanel) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) CoordinateSystemField(com.revolsys.swing.map.component.CoordinateSystemField) JLabel(javax.swing.JLabel) Point(com.revolsys.geometry.model.Point) ValueField(com.revolsys.swing.component.ValueField)

Example 5 with BasePanel

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;
}
Also used : BasePanel(com.revolsys.swing.component.BasePanel) VerticalLayout(org.jdesktop.swingx.VerticalLayout) ValueField(com.revolsys.swing.component.ValueField)

Aggregations

BasePanel (com.revolsys.swing.component.BasePanel)8 BorderLayout (java.awt.BorderLayout)4 VerticalLayout (org.jdesktop.swingx.VerticalLayout)4 Dimension (java.awt.Dimension)3 JLabel (javax.swing.JLabel)3 ValueField (com.revolsys.swing.component.ValueField)2 Rectangle (java.awt.Rectangle)2 Window (java.awt.Window)2 JDialog (javax.swing.JDialog)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Point (com.revolsys.geometry.model.Point)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 CoordinateSystemField (com.revolsys.swing.map.component.CoordinateSystemField)1 Project (com.revolsys.swing.map.layer.Project)1 BaseJTable (com.revolsys.swing.table.BaseJTable)1 TablePanel (com.revolsys.swing.table.TablePanel)1 ToolBar (com.revolsys.swing.toolbar.ToolBar)1 Component (java.awt.Component)1