Search in sources :

Example 1 with VerticalLayout

use of org.jdesktop.swingx.VerticalLayout 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 2 with VerticalLayout

use of org.jdesktop.swingx.VerticalLayout in project com.revolsys.open by revolsys.

the class FieldCalculator method initFieldPanel.

@Override
protected JPanel initFieldPanel() {
    final FieldDefinition fieldDefinition = this.getFieldDefinition();
    final String fieldName = fieldDefinition.getName();
    final JPanel fieldPanel = new JPanel(new VerticalLayout());
    final ToolBar toolBar = new ToolBar();
    fieldPanel.add(toolBar);
    this.expressionField = new TextArea("script", 8, 1);
    fieldPanel.add(new JScrollPane(this.expressionField));
    this.expressionField.getDocument().addDocumentListener(this);
    final AbstractRecordLayer layer = getLayer();
    final List<String> fieldNames = layer.getFieldNames();
    final ComboBox<String> fieldNamesField = ComboBox.newComboBox("fieldNames", fieldNames, (final Object name) -> {
        return layer.getFieldTitle((String) name);
    });
    toolBar.addComponent("fieldName", fieldNamesField);
    toolBar.add(fieldNamesField);
    fieldNamesField.setMaximumSize(new Dimension(250, 30));
    final Runnable addFieldAction = () -> {
        final String selectedFieldName = fieldNamesField.getFieldValue();
        insertText(selectedFieldName);
    };
    toolBar.addButton("fieldName", "Add field name", "add", addFieldAction);
    for (final String text : Arrays.asList("+", "-", "*", "/")) {
        addTextButton("operators", toolBar, text, text);
    }
    addTextButton("condition", toolBar, "if", "if (expression) {\n  newValue;\n} else {\n  " + fieldName + ";\n}");
    addTextButton("codeTable", toolBar, "Code ID", "codeId('codeFieldName', codeValue)");
    addTextButton("codeTable", toolBar, "Code Value", "codeValue('codeFieldName', codeValue)");
    return fieldPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) TextArea(com.revolsys.swing.field.TextArea) JTextArea(javax.swing.JTextArea) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Dimension(java.awt.Dimension) ToolBar(com.revolsys.swing.toolbar.ToolBar) VerticalLayout(org.jdesktop.swingx.VerticalLayout) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer)

Example 3 with VerticalLayout

use of org.jdesktop.swingx.VerticalLayout 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 VerticalLayout

use of org.jdesktop.swingx.VerticalLayout in project zaproxy by zaproxy.

the class OptionsProxiesPanel method getScrollPanel.

private JPanel getScrollPanel() {
    if (scrollPanel == null) {
        scrollPanel = new JPanel(new VerticalLayout());
        scrollPanel.add(getMainProxyPanel());
        scrollPanel.add(getSecurityProtocolsPanel());
        scrollPanel.add(getProxiesOptionsPanel());
    }
    return scrollPanel;
}
Also used : JPanel(javax.swing.JPanel) VerticalLayout(org.jdesktop.swingx.VerticalLayout)

Example 5 with VerticalLayout

use of org.jdesktop.swingx.VerticalLayout in project kotlin by JetBrains.

the class ChoosePathDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setGap(3);
    JPanel panel = new JPanel(verticalLayout);
    if (description != null) {
        panel.add(new JLabel(description));
    }
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    FileTextField field = FileChooserFactory.getInstance().createFileTextField(descriptor, myDisposable);
    field.getField().setColumns(25);
    myPathField = new TextFieldWithBrowseButton(field.getField());
    myPathField.addBrowseFolderListener("Choose Destination Folder", "Choose folder", myProject, descriptor);
    myPathField.setText(defaultPath);
    panel.add(myPathField);
    return panel;
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) VerticalLayout(org.jdesktop.swingx.VerticalLayout) FileTextField(com.intellij.openapi.fileChooser.FileTextField)

Aggregations

VerticalLayout (org.jdesktop.swingx.VerticalLayout)13 JPanel (javax.swing.JPanel)9 JLabel (javax.swing.JLabel)5 BasePanel (com.revolsys.swing.component.BasePanel)4 BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 JScrollPane (javax.swing.JScrollPane)3 ToolBar (com.revolsys.swing.toolbar.ToolBar)2 FlowLayout (java.awt.FlowLayout)2 Rectangle (java.awt.Rectangle)2 Window (java.awt.Window)2 JButton (javax.swing.JButton)2 JDialog (javax.swing.JDialog)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 FileTextField (com.intellij.openapi.fileChooser.FileTextField)1 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)1 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1