use of javax.swing.table.JTableHeader in project intellij-plugins by JetBrains.
the class EditableTreeTable method updateColumnSizes.
// copied from TableView
public void updateColumnSizes() {
final JTableHeader header = getTableHeader();
final TableCellRenderer defaultRenderer = header == null ? null : header.getDefaultRenderer();
ColumnInfo[] columns = ((ListTreeTableModelOnColumns) getTableModel()).getColumnInfos();
for (int i = 0; i < columns.length; i++) {
final ColumnInfo columnInfo = columns[i];
final TableColumn column = getColumnModel().getColumn(i);
final Component headerComponent = defaultRenderer == null ? null : defaultRenderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, 0, 0);
final Dimension headerSize = headerComponent == null ? JBUI.emptySize() : headerComponent.getPreferredSize();
final String maxStringValue;
final String preferredValue;
if (columnInfo.getWidth(this) > 0) {
int width = columnInfo.getWidth(this);
column.setMaxWidth(width);
column.setPreferredWidth(width);
column.setMinWidth(width);
} else if ((maxStringValue = columnInfo.getMaxStringValue()) != null) {
int width = getFontMetrics(getFont()).stringWidth(maxStringValue) + columnInfo.getAdditionalWidth();
width = Math.max(width, headerSize.width);
column.setPreferredWidth(width);
column.setMaxWidth(width);
} else if ((preferredValue = columnInfo.getPreferredStringValue()) != null) {
int width = getFontMetrics(getFont()).stringWidth(preferredValue) + columnInfo.getAdditionalWidth();
width = Math.max(width, headerSize.width);
column.setPreferredWidth(width);
}
}
}
use of javax.swing.table.JTableHeader in project sling by apache.
the class RequestListSelectionListener method valueChanged.
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
int idx = lsm.getMinSelectionIndex();
if (idx >= 0) {
try {
idx = table.getRowSorter().convertRowIndexToModel(idx);
TableModel tm = ((RequestTrackerFile) table.getModel()).getData(idx);
if (dataField == null) {
dataField = new JTable();
dataField.setAutoCreateRowSorter(true);
dataField.setGridColor(Color.GRAY);
dataField.setShowGrid(true);
dataField.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
dataField.setRowSelectionAllowed(true);
dataField.setTableHeader(new JTableHeader(dataField.getColumnModel()));
dataField.setFont(new Font("Monospaced", dataField.getFont().getStyle(), dataField.getFont().getSize()));
dataField.setShowHorizontalLines(false);
// dataField.setIntercellSpacing(new Dimension(3, 5));
JDialog d = new JDialog(this.parent);
d.add(new JScrollPane(dataField));
d.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
dataField = null;
}
});
// setup location and size and ensure updating preferences
Util.setupComponentLocationSize(d, REQUEST_X, REQUEST_Y, REQUEST_WIDTH, REQUEST_HEIGHT, (int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 4, (int) screenSize.getWidth() / 2, (int) screenSize.getHeight() / 2);
d.setVisible(true);
}
dataField.setModel(tm);
Util.setupColumnWidths(dataField.getColumnModel(), REQUEST_COLS);
} catch (IOException e1) {
// ignore
}
}
}
}
use of javax.swing.table.JTableHeader in project knime-core by knime.
the class RankCorrelationComputeNodeView method changeRenderer.
private void changeRenderer(final String renderer) {
TableContentView tcv = m_tableView.getContentTable();
tcv.changeRenderer(DoubleCell.TYPE, renderer);
Component c = m_tableView.getCorner(ScrollPaneConstants.UPPER_LEFT_CORNER);
LegendCornerAll cornerRenderer = null;
if (c instanceof JTableHeader) {
JTableHeader corner = (JTableHeader) c;
TableCellRenderer ren = corner.getDefaultRenderer();
if (ren instanceof LegendCornerAll) {
cornerRenderer = (LegendCornerAll) ren;
}
}
if (cornerRenderer != null) {
if (renderer.equals(ColorRender.DESCRIPTION)) {
cornerRenderer.setPaintLegend(true);
// no need to set column header height, done by label UI
tcv.setColumnWidth(15);
TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
if (r instanceof JLabel) {
((JLabel) r).setUI(new VerticalLabelUI());
}
} else {
cornerRenderer.setPaintLegend(false);
m_tableView.setColumnHeaderViewHeight(16);
tcv.setColumnWidth(75);
TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
if (r instanceof JLabel) {
((JLabel) r).updateUI();
}
}
}
m_currentRendererID = renderer;
}
use of javax.swing.table.JTableHeader in project knime-core by knime.
the class TableContentView method setWrapColumnHeader.
// hiliteSelected()
/**
* Should the column header names be wrapped if they are too long. Default is false.
* @param value New value. If set, it makes sense to also set
* {@link TableView#setColumnHeaderResizingAllowed(boolean)} to true.
* @since 2.8
*/
public final void setWrapColumnHeader(final boolean value) {
if (value != m_isWrapHeader) {
m_isWrapHeader = value;
JTableHeader header = getTableHeader();
if (header == null) {
return;
}
TableCellRenderer r = header.getDefaultRenderer();
if (r instanceof ColumnHeaderRenderer) {
ColumnHeaderRenderer cr = (ColumnHeaderRenderer) r;
cr.setWrapHeader(value);
}
}
}
use of javax.swing.table.JTableHeader in project knime-core by knime.
the class TableContentView method setFont.
/**
* {@inheritDoc}
*/
@Override
public void setFont(final Font font) {
super.setFont(font);
JTableHeader th = getTableHeader();
if (th != null) {
th.setFont(font);
}
}
Aggregations