Search in sources :

Example 11 with JXTable

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

the class ExtensionScript method informScriptsNotAdded.

private void informScriptsNotAdded(final List<String[]> scriptsNotAdded) {
    if (!hasView() || scriptsNotAdded.isEmpty()) {
        return;
    }
    final List<Object> optionPaneContents = new ArrayList<>(2);
    optionPaneContents.add(Constant.messages.getString("script.info.scriptsNotAdded.message"));
    JXTable table = new JXTable(new AbstractTableModel() {

        private static final long serialVersionUID = -457689656746030560L;

        @Override
        public String getColumnName(int column) {
            if (column == 0) {
                return Constant.messages.getString("script.info.scriptsNotAdded.table.column.scriptName");
            } else if (column == 1) {
                return Constant.messages.getString("script.info.scriptsNotAdded.table.column.scriptEngine");
            }
            return Constant.messages.getString("script.info.scriptsNotAdded.table.column.errorCause");
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            return scriptsNotAdded.get(rowIndex)[columnIndex];
        }

        @Override
        public int getRowCount() {
            return scriptsNotAdded.size();
        }

        @Override
        public int getColumnCount() {
            return 3;
        }
    });
    table.setColumnControlVisible(true);
    table.setVisibleRowCount(Math.min(scriptsNotAdded.size() + 1, 5));
    table.packAll();
    optionPaneContents.add(new JScrollPane(table));
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            JOptionPane.showMessageDialog(getView().getMainFrame(), optionPaneContents.toArray(), Constant.PROGRAM_NAME, JOptionPane.INFORMATION_MESSAGE);
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JXTable(org.jdesktop.swingx.JXTable) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 12 with JXTable

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

the class HttpSessionsPanel method getHttpSessionsTable.

/**
 * Gets the http sessions table.
 *
 * @return the http sessions table
 */
private JXTable getHttpSessionsTable() {
    if (sessionsTable == null) {
        sessionsTable = new JXTable(sessionsModel);
        sessionsTable.setColumnSelectionAllowed(false);
        sessionsTable.setCellSelectionEnabled(false);
        sessionsTable.setRowSelectionAllowed(true);
        sessionsTable.setAutoCreateRowSorter(true);
        sessionsTable.setColumnControlVisible(true);
        sessionsTable.setAutoCreateColumnsFromModel(false);
        sessionsTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
        sessionsTable.getColumnExt(0).setHighlighters(new ActiveSessionIconHighlighter(0));
        this.setSessionsTableColumnSizes();
        sessionsTable.setName(PANEL_NAME);
        sessionsTable.setDoubleBuffered(true);
        sessionsTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        sessionsTable.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) {
                if (e.isPopupTrigger()) {
                    // Select table item
                    int row = sessionsTable.rowAtPoint(e.getPoint());
                    if (row < 0 || !sessionsTable.getSelectionModel().isSelectedIndex(row)) {
                        sessionsTable.getSelectionModel().clearSelection();
                        if (row >= 0) {
                            sessionsTable.getSelectionModel().setSelectionInterval(row, row);
                        }
                    }
                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });
    }
    return sessionsTable;
}
Also used : JXTable(org.jdesktop.swingx.JXTable) MappedValue(org.jdesktop.swingx.renderer.MappedValue) DefaultTableRenderer(org.jdesktop.swingx.renderer.DefaultTableRenderer)

Example 13 with JXTable

use of org.jdesktop.swingx.JXTable in project cuba by cuba-platform.

the class DesktopRowsCount method onPrevClick.

private void onPrevClick() {
    if (!(datasource instanceof CollectionDatasource.SupportsPaging)) {
        return;
    }
    CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource;
    int firstResult = ds.getFirstResult();
    int newStart = ds.getFirstResult() - ds.getMaxResults();
    ds.setFirstResult(newStart < 0 ? 0 : newStart);
    if (refreshDatasource(ds)) {
        if (owner instanceof DesktopAbstractTable) {
            JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent();
            table.scrollRowToVisible(0);
        }
    } else {
        ds.setFirstResult(firstResult);
    }
}
Also used : JXTable(org.jdesktop.swingx.JXTable) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource)

Example 14 with JXTable

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

the class AbstractLayer method newPropertiesTabCoordinateSystem.

protected JPanel newPropertiesTabCoordinateSystem(final TabbedValuePanel tabPanel) {
    final GeometryFactory geometryFactory = getGeometryFactory();
    if (geometryFactory != null) {
        final JPanel panel = new JPanel(new VerticalLayout(5));
        tabPanel.addTab("Spatial", "world", panel);
        final JPanel extentPanel = Panels.titledTransparent("Extent");
        extentPanel.setLayout(new BorderLayout());
        final BoundingBox boundingBox = getBoundingBox();
        if (boundingBox == null || boundingBox.isEmpty()) {
            extentPanel.add(new JLabel("Unknown"), BorderLayout.CENTER);
        } else {
            final JLabel extentLabel = new JLabel("<html><table cellspacing=\"3\" style=\"margin:0px\">" + "<tr><td>&nbsp;</td><th style=\"text-align:left\">Top:</th><td style=\"text-align:right\">" + DataTypes.toString(boundingBox.getMaximum(1)) + "</td><td>&nbsp;</td></tr><tr>" + "<td><b>Left</b>: " + DataTypes.toString(boundingBox.getMinimum(0)) + "</td><td>&nbsp;</td><td>&nbsp;</td>" + "<td><b>Right</b>: " + DataTypes.toString(boundingBox.getMaximum(0)) + "</td></tr>" + "<tr><td>&nbsp;</td><th>Bottom:</th><td style=\"text-align:right\">" + DataTypes.toString(boundingBox.getMinimum(1)) + "</td><td>&nbsp;</td></tr><tr>" + "</tr></table></html>");
            extentLabel.setFont(SwingUtil.FONT);
            extentPanel.add(extentLabel, BorderLayout.CENTER);
            final int boundingBoxAxisCount = boundingBox.getAxisCount();
            final DefaultTableModel boundingBoxTableModel = new DefaultTableModel(new Object[] { "AXIS", "MIN", "MAX" }, 0);
            boundingBoxTableModel.addRow(new Object[] { "X", boundingBox.getMinX(), boundingBox.getMaxY() });
            boundingBoxTableModel.addRow(new Object[] { "Y", boundingBox.getMinY(), boundingBox.getMaxY() });
            if (boundingBoxAxisCount > 2) {
                boundingBoxTableModel.addRow(new Object[] { "Z", boundingBox.getMinZ(), boundingBox.getMaxZ() });
            }
            final JXTable boundingBoxTable = new JXTable(boundingBoxTableModel);
            boundingBoxTable.setVisibleRowCount(3);
            boundingBoxTable.setDefaultEditor(Object.class, null);
            boundingBoxTable.setDefaultRenderer(Object.class, new NumberTableCellRenderer());
            final JScrollPane boundingBoxScroll = new JScrollPane(boundingBoxTable);
            extentPanel.add(boundingBoxScroll, BorderLayout.EAST);
            boundingBoxTable.getColumnExt(0).setMaxWidth(31);
        }
        panel.add(extentPanel);
        final JPanel coordinateSystemPanel = Panels.titledTransparent("Coordinate System");
        final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
        if (coordinateSystem == null) {
            coordinateSystemPanel.add(new JLabel("Unknown"));
        } else {
            final int axisCount = geometryFactory.getAxisCount();
            SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "ID", coordinateSystem.getCoordinateSystemId(), 10);
            SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "axisCount", axisCount, 10);
            final double scaleX = geometryFactory.getScaleX();
            if (scaleX > 0) {
                SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "scaleX", scaleX, 10);
            } else {
                SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "scaleX", "Floating", 10);
            }
            final double scaleY = geometryFactory.getScaleXY();
            if (scaleY > 0) {
                SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "scaleY", scaleY, 10);
            } else {
                SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "scaleY", "Floating", 10);
            }
            if (axisCount > 2) {
                final double scaleZ = geometryFactory.getScaleZ();
                if (scaleZ > 0) {
                    SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "scaleZ", scaleZ, 10);
                } else {
                    SwingUtil.addLabelledReadOnlyTextField(coordinateSystemPanel, "scaleZ", "Floating", 10);
                }
            }
            SwingUtil.addLabel(coordinateSystemPanel, "ESRI WKT");
            final String wktFormatted = geometryFactory.toWktCsFormatted();
            final TextArea wktTextArea = new TextArea(wktFormatted, 10, 80);
            wktTextArea.setEditable(false);
            wktTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
            coordinateSystemPanel.add(wktTextArea);
            GroupLayouts.makeColumns(coordinateSystemPanel, 2, true);
        }
        panel.add(coordinateSystemPanel);
        return panel;
    }
    return null;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) JXTable(org.jdesktop.swingx.JXTable) TextArea(java.awt.TextArea) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) DefaultTableModel(javax.swing.table.DefaultTableModel) JLabel(javax.swing.JLabel) ScrollableSizeHint(org.jdesktop.swingx.ScrollableSizeHint) Font(java.awt.Font) BorderLayout(java.awt.BorderLayout) BoundingBox(com.revolsys.geometry.model.BoundingBox) VerticalLayout(org.jdesktop.swingx.VerticalLayout) NumberTableCellRenderer(com.revolsys.swing.table.NumberTableCellRenderer)

Example 15 with JXTable

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

the class SingleRecordTableCellRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, int rowIndex, int columnIndex) {
    if (table instanceof JXTable) {
        final JXTable jxTable = (JXTable) table;
        rowIndex = jxTable.convertRowIndexToModel(rowIndex);
        columnIndex = jxTable.convertColumnIndexToModel(columnIndex);
    }
    final AbstractSingleRecordTableModel model = (AbstractSingleRecordTableModel) table.getModel();
    final RecordDefinition recordDefinition = model.getRecordDefinition();
    JComponent component = null;
    final String name = model.getColumnFieldName(rowIndex, columnIndex);
    final boolean required = recordDefinition.isFieldRequired(name);
    this.valueComponent.setBorder(new EmptyBorder(1, 2, 1, 2));
    if (columnIndex == 0) {
        this.valueComponent.setText(String.valueOf(rowIndex + 1));
        this.valueComponent.setHorizontalAlignment(SwingConstants.RIGHT);
        this.valueComponent.setHorizontalTextPosition(SwingConstants.RIGHT);
        component = this.valueComponent;
    } else if (columnIndex == 1) {
        final String title = model.getFieldTitle(name);
        this.labelComponent.setText(title);
        this.labelComponent.setBorder(new EmptyBorder(1, 2, 1, 2));
        component = this.labelComponent;
    } else {
        final String text = model.toDisplayValue(rowIndex, rowIndex, value);
        this.valueComponent.setText(text);
        if (BigDecimals.isNumber(text)) {
            this.valueComponent.setHorizontalAlignment(SwingConstants.RIGHT);
            this.valueComponent.setHorizontalTextPosition(SwingConstants.RIGHT);
        } else {
            this.valueComponent.setHorizontalAlignment(SwingConstants.LEFT);
            this.valueComponent.setHorizontalTextPosition(SwingConstants.LEFT);
        }
        component = this.valueComponent;
    }
    if (required && model.getObjectValue(rowIndex, columnIndex) == null) {
        component.setBackground(new Color(255, 0, 0, 100));
        component.setForeground(table.getForeground());
    }
    component.setToolTipText(null);
    return component;
}
Also used : JXTable(org.jdesktop.swingx.JXTable) Color(java.awt.Color) JComponent(javax.swing.JComponent) AbstractSingleRecordTableModel(com.revolsys.swing.table.record.model.AbstractSingleRecordTableModel) EmptyBorder(javax.swing.border.EmptyBorder) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

JXTable (org.jdesktop.swingx.JXTable)25 JScrollPane (javax.swing.JScrollPane)13 JPanel (javax.swing.JPanel)11 JLabel (javax.swing.JLabel)10 Rectangle (java.awt.Rectangle)6 ArrayList (java.util.ArrayList)6 BorderLayout (java.awt.BorderLayout)5 JButton (javax.swing.JButton)5 TableFilterHeader (net.coderazzi.filters.gui.TableFilterHeader)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 JComboBox (javax.swing.JComboBox)4 MagicEdition (org.magic.api.beans.MagicEdition)4 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)3 Component (java.awt.Component)3 SQLException (java.sql.SQLException)3 List (java.util.List)3 JSpinner (javax.swing.JSpinner)3 JSplitPane (javax.swing.JSplitPane)3 JTabbedPane (javax.swing.JTabbedPane)3 SpinnerNumberModel (javax.swing.SpinnerNumberModel)3