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);
}
});
}
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;
}
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);
}
}
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> </td><th style=\"text-align:left\">Top:</th><td style=\"text-align:right\">" + DataTypes.toString(boundingBox.getMaximum(1)) + "</td><td> </td></tr><tr>" + "<td><b>Left</b>: " + DataTypes.toString(boundingBox.getMinimum(0)) + "</td><td> </td><td> </td>" + "<td><b>Right</b>: " + DataTypes.toString(boundingBox.getMaximum(0)) + "</td></tr>" + "<tr><td> </td><th>Bottom:</th><td style=\"text-align:right\">" + DataTypes.toString(boundingBox.getMinimum(1)) + "</td><td> </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;
}
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;
}
Aggregations