Refine search
setEditable(original.isEditable()); setHeaderValue(original.getHeaderValue()); // no need to copy setTitle(); setToolTipText(original.getToolTipText()); setIdentifier(original.getIdentifier()); setMaxWidth(original.getMaxWidth()); setMinWidth(original.getMinWidth()); setPreferredWidth(original.getPreferredWidth()); setPrototypeValue(original.getPrototypeValue()); setResizable(original.isResizable); setVisible(original.isVisible()); setSortable(original.isSortable()); setComparator(original.getComparator()); copyClientPropertiesFrom(original); setHighlighters(original.getHighlighters());
/** * Instantiates a new table view column with all properties copied from the * given original. * * @param columnExt the column to copy properties from * @see #copyFrom(TableColumnExt) */ public TableColumnExt(TableColumnExt columnExt) { this(columnExt.getModelIndex(), columnExt.getWidth(), columnExt .getCellRenderer(), columnExt.getCellEditor()); copyFrom(columnExt); }
/** * Creates a table column with modelIndex. * <p> * The factory's column creation is passed through this method, so * subclasses can override to return custom column types. * * @param modelIndex column index in model coordinates * @return a TableColumnExt with <code>modelIndex</code> * * @see #createAndConfigureTableColumn(TableModel, int) * */ public TableColumnExt createTableColumn(int modelIndex) { return new TableColumnExt(modelIndex); }
/** * Sets the visible property. This property controls whether or not * this view column is currently visible in the table. * * @param visible boolean indicating whether or not this view column is * visible in the table * @see #setVisible */ public void setVisible(boolean visible) { boolean oldVisible = isVisible(); this.visible = visible; firePropertyChange("visible", oldVisible, isVisible()); }
/** * Sets the hideable property. This property controls whether the column can * be hidden. This is a bound property. If the column's visibilty is affected, * listeners are notified about that change as well.. * <p> * * The default value is true. * * @param hideable */ public void setHideable(boolean hideable) { boolean old = isHideable(); boolean oldVisible = isVisible(); this.hideable = hideable; firePropertyChange("visible", oldVisible, isVisible()); firePropertyChange("hideable", old, isHideable()); }
if (!columnExt.isVisible()) throw new IllegalStateException("column must be visible to pack"); int column = table.convertColumnIndexToView(columnExt.getModelIndex()); int width = 0; TableCellRenderer headerRenderer = getHeaderRenderer(table, columnExt); if (headerRenderer != null) { Component comp = headerRenderer.getTableCellRendererComponent(table, columnExt.getHeaderValue(), false, false, 0, column); width = comp.getPreferredSize().width; TableCellRenderer renderer = getCellRenderer(table, columnExt); for (int r = 0; r < getRowCount(table); r++) { Component comp = table.prepareRenderer(renderer, r, column); width = max; columnExt.setPreferredWidth(width);
public void columnPropertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { updateEditingAfterColumnChanged((TableColumn) event.getSource(), (Boolean) event.getNewValue()); } else if (event.getPropertyName().equals("sortable")) { updateSortableAfterColumnChanged((TableColumn) event.getSource(), (Boolean) event.getNewValue()); } else if (event.getPropertyName().equals("comparator")) { updateComparatorAfterColumnChanged((TableColumn) event.getSource(), (Comparator<?>) event.getNewValue()); } else if (event.getPropertyName().equals("cellRenderer")) { Rectangle r = getCellRect(0, convertColumnIndexToView(column .getModelIndex()), true); r.height = getHeight(); repaint(r);
/** * Returns the cell renderer to use for measuring. Delegates to * JXTable for visible columns, duplicates table logic for hidden * columns. <p> * * @param table the table which provides the renderer * @param columnExt the TableColumn to configure * * @return returns a cell renderer for measuring. */ protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) { int viewIndex = table.convertColumnIndexToView(columnExt .getModelIndex()); if (viewIndex >= 0) { // JW: ok to not guard against rowCount < 0? // technically, the index should be a valid coordinate return table.getCellRenderer(0, viewIndex); } // hidden column - need api on JXTable to access renderer for hidden? // here we duplicate JXTable api ... maybe by-passing the strategy // implemented there TableCellRenderer renderer = columnExt.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex())); } return renderer; }
int prefWidth = 75 - table.getColumnMargin(); int prototypeWidth = calcPrototypeWidth(table, columnExt); if (prototypeWidth > 0) { prefWidth = prototypeWidth; int headerWidth = calcHeaderWidth(table, columnExt); prefWidth = Math.max(prefWidth, headerWidth); prefWidth += table.getColumnModel().getColumnMargin(); columnExt.setPreferredWidth(prefWidth);
filterPanel.add(filterEdit); JXTable table = new JXTable(tableModel); table.getSelectionMapper().setEnabled(false); table.setSelectionModel(selectionModel); table.setColumnControlVisible(true); table.getColumnExt(3).setComparator(new IssueStateComparator()); EventListJXTableSorting eventListJXTableSorting = EventListJXTableSorting.install(table, sortedIssues); eventListJXTableSorting.setMultipleColumnSort(true);
/** * {@inheritDoc} * * Listens to column property changes. * */ public void columnPropertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { updateEditingAfterColumnChanged((TableColumn) event.getSource(), (Boolean) event.getNewValue()); } else if (event.getPropertyName().equals("sortable")) { updateSortingAfterColumnChanged((TableColumn) event.getSource(), (Boolean) event.getNewValue()); } else if (event.getPropertyName().startsWith("highlighter")) { if (event.getSource() instanceof TableColumnExt && getRowCount() > 0) { TableColumnExt column = (TableColumnExt) event.getSource(); Rectangle r = getCellRect(0, convertColumnIndexToView(column .getModelIndex()), true); r.height = getHeight(); repaint(r); } else { repaint(); } } }
/** * {@inheritDoc} <p> * * Overridden to update internals related to column visibility. */ @Override public void removeColumn(TableColumn column) { boolean oldVisible = true; //remove the visibility listener if appropriate if (column instanceof TableColumnExt) { oldVisible = ((TableColumnExt) column).isVisible(); ((TableColumnExt) column).setVisible(true); ((TableColumnExt)column).removePropertyChangeListener(visibilityListener); } currentColumns.remove(column); initialColumns.remove(column); //let the superclass handle notification etc super.removeColumn(column); if (column instanceof TableColumnExt) { ((TableColumnExt) column).setVisible(oldVisible); } }
public DataDrivenNodesMultipleOptionsPanel(StructuralNodeModifiersTableModel model) { super(model); getTable().getColumnExt(0).setPreferredWidth(50); getTable().getColumnExt(1).setPreferredWidth(50); getTable().getColumnExt(2).setPreferredWidth(200); getTable().setSortOrder(1, SortOrder.ASCENDING); }
public void setIssues(List<IssueFilter> filters, RadarIssue... issues) { attacher.detachAnnotations(); IssuesTableModel model = (IssuesTableModel) issuesTable.getModel(); model.setIssues(issues); StringBuilder builder = new StringBuilder(); filters.forEach((filter) -> { if (builder.length() > 0) { builder.append(", "); } builder.append(filter.getDescription()); }); if (builder.length() > 0) { builder.append(". "); } builder.append( "Number of issues:"); builder.append(issues.length); title.setText(builder.toString()); issuesTable.getColumnExt("Rule").setVisible(true); issuesTable.getColumnExt("Severity").setVisible(false); issuesTable.getColumnExt( "Project Key").setVisible(false); issuesTable.getColumnExt("Full Path").setVisible(false); showIssuesCount(); filterText.setText(""); if(isEditorAnnotationsEnabled()) { attacher.attachAnnotations(issues); } }
public GlobalExcludeURLMultipleOptionsPanel(OptionsGlobalExcludeURLTableModel model) { super(model); this.model = model; getTable().getColumnExt(0).setPreferredWidth(25); // checkbox column should be tiny getTable().getColumnExt(1).setPreferredWidth(350); // wide Desc Col getTable().getColumnExt(2).setPreferredWidth(300); // less wide Regex Column getTable().setHorizontalScrollEnabled(true); // descriptions / regexs are very wide, so turn on horiz scroll getTable().setAutoCreateRowSorter(true); getTable().setSortOrder(1, SortOrder.ASCENDING); // sort by description by default /* XXX For some reason, sorting isn't accurate in the table. The getColumnClass correctly returns String for the Description, but sort order might be: "Ext - MS Word, ExtParam - Bla bla, Ext - PDF." It is like string.compare for the column sort ignores the space and dash. Really unsure as to why. As a work-around, start some descriptions with "Extension" instead of the shorter "Ext" */ }
protected <R> TableColumnExt addColumnToModel(TableColumnModel model, TableCellEditor editor, TableCellRenderer renderer, ColumnIdentifier<R> identifier) { TableColumnExt col = new TableColumnExt(model.getColumnCount()); col.setCellEditor(editor); col.setCellRenderer(renderer); String label = t(identifier.getHeaderI18nKey()); col.setHeaderValue(label); String tip = t(identifier.getHeaderTipI18nKey()); col.setToolTipText(tip); col.setIdentifier(identifier); model.addColumn(col); // by default no column is sortable, must specify it col.setSortable(false); return col; }
public UsersMultipleOptionsPanel(ExtensionUserManagement extension, UsersTableModel model, int contextId) { super(model); this.extension = extension; getTable().getColumnExt(0).setPreferredWidth(40); getTable().getColumnExt(1).setPreferredWidth(30); getTable().getColumnExt(1).setMaxWidth(50); getTable().setSortOrder(2, SortOrder.ASCENDING); }
public void setVisibleColumns(final int min, final int max) { // Note: The loop starts in the top and goes down, this is because the // getColumnExt() index is affected directly, when setting a column as // invisible! for (int i = getColumnCount(); i > 0; i--) { if (i >= min && i <= max) { getColumnExt(i - 1).setVisible(true); } else { getColumnExt(i - 1).setVisible(false); } } }
@Override public void actionPerformed(ActionEvent actionEvent) { List<String> colNames = columnLayout.getColumns(); LOGGER.debug(String.format("Retrieved %d col names: <<%s>>", colNames.size(), colNames.toString())); List<TableColumns> visCols = new ArrayList<>(); Map<String, TableColumns> colNameToEnum = new HashMap<>(); for (TableColumns tcEnum : TableColumns.values()) { colNameToEnum.put(tcEnum.getName(), tcEnum); } for (TableColumn tableColumn : table.getColumns()) { Object o = tableColumn.getIdentifier(); if (!(o instanceof TableColumns)) { LOGGER.error("TableColumn identifier of unexpected type: " + tableColumn.getIdentifier().getClass().getName()); return; } TableColumns tcs = (TableColumns) o; table.getColumnExt(tcs).setVisible(false); } visCols.addAll(colNames.stream().map(colNameToEnum::get).collect(Collectors.toList())); TablesUtils.showOnlyThisColumns(table, visCols.toArray(new TableColumns[visCols.size()])); TablesUtils.sortColumnsInOrder(columnLayout, table); LOGGER.debug("Column changes applied"); } }
public static void showOnlyThisColumns(JXTable table, Object[] columns) { for (Object tableColumns : columns) { table.getColumnExt(tableColumns).setVisible(true); } // updateColumnsSize(); } }