use of javax.swing.table.TableColumnModel in project otapij by FellowTraveler.
the class BasketTableModel method removeCols.
public static void removeCols(JTable basketTable) {
TableColumnModel tcm = basketTable.getColumnModel();
System.out.println("getColumnCount:" + tcm.getColumnCount());
if (tcm.getColumnCount() == 2) {
basketTable.removeColumn(tcm.getColumn(1));
}
}
use of javax.swing.table.TableColumnModel in project ACS by ACS-Community.
the class AlarmTable method initGUI.
/**
* Init the GUI
*/
private void initGUI() {
setShowHorizontalLines(true);
// Build and set the selection model
selectionModel = new DefaultListSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
setSelectionModel(selectionModel);
this.setOpaque(false);
sorter = new TableRowSorter<AlarmTableModel>(model);
this.setRowSorter(sorter);
sorter.setMaxSortKeys(2);
sorter.setSortsOnUpdates(true);
// Initially sort by timestamp
List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
sortKeys.add(new RowSorter.SortKey(AlarmTableColumn.PRIORITY.ordinal(), SortOrder.ASCENDING));
sortKeys.add(new RowSorter.SortKey(AlarmTableColumn.TIME.ordinal(), SortOrder.DESCENDING));
sorter.setSortKeys(sortKeys);
// Remove all the columns not visible at startup
TableColumnModel colModel = getColumnModel();
columns = new TableColumn[colModel.getColumnCount()];
for (int t = 0; t < columns.length; t++) {
columns[t] = colModel.getColumn(t);
columns[t].setIdentifier(AlarmTableColumn.values()[t]);
if (columns[t].getIdentifier() == AlarmTableColumn.ICON || columns[t].getIdentifier() == AlarmTableColumn.IS_CHILD || columns[t].getIdentifier() == AlarmTableColumn.IS_PARENT) {
columns[t].setWidth(20);
columns[t].setResizable(false);
columns[t].setPreferredWidth(20);
columns[t].setMaxWidth(20);
columns[t].setMinWidth(20);
} else if (columns[t].getIdentifier() == AlarmTableColumn.PRIORITY) {
BufferedImage bImg = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2D = bImg.createGraphics();
FontMetrics fm = g2D.getFontMetrics();
int sz = fm.stringWidth(PriorityLabel.VERY_HIGH.description);
columns[t].setPreferredWidth(sz + 6);
columns[t].setMaxWidth(sz + 8);
}
}
for (AlarmTableColumn col : AlarmTableColumn.values()) {
if (!col.visibleAtStartup) {
colModel.removeColumn(columns[col.ordinal()]);
}
}
buildPopupMenu();
addMouseListener(mouseAdapter);
getTableHeader().addMouseListener(new AlarmHeaderMouseAdapter());
// Set the tooltip
ToolTipManager ttm = ToolTipManager.sharedInstance();
ttm.setDismissDelay(Integer.MAX_VALUE);
ttm.setLightWeightPopupEnabled(true);
}
use of javax.swing.table.TableColumnModel in project ACS by ACS-Community.
the class LogEntryTable method initialize.
/**
* Setup the table
*
* @param shortDateFormat The format to show the date (if <code>true</code> is short, otherwise complete)
* @param logTypeformat The way to show the log type (if <code>true</code> the description is shown)
*/
private void initialize(boolean shortDateFormat, boolean logTypeformat) {
createDefaultColumnsFromModel();
setShowHorizontalLines(false);
TableColumnModel tcm = getColumnModel();
// Setup the first col
TableColumn tc;
// Setup the first col
tc = tcm.getColumn(0);
tc.setCellRenderer(new InfoRenderer());
tc.setWidth(18);
tc.setMaxWidth(18);
tc.setResizable(false);
tc = tcm.getColumn(LogField.ENTRYTYPE.ordinal() + 1);
logTypeRenderer = new EntryTypeRenderer(logTypeformat);
tc.setCellRenderer(logTypeRenderer);
tc = tcm.getColumn(LogField.TIMESTAMP.ordinal() + 1);
dateRenderer = new DateRenderer(shortDateFormat);
tc.setCellRenderer(dateRenderer);
int n = tcm.getColumnCount();
columnsList = new TableColumn[n];
visibleColumns = new boolean[n];
for (int i = 0; i < n; i++) {
columnsList[i] = tcm.getColumn(i);
visibleColumns[i] = true;
if (i == LogField.LOGMESSAGE.ordinal() + 1) {
columnsList[i].setPreferredWidth(250);
}
}
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
sizeColumnsToFit(JTable.AUTO_RESIZE_OFF);
// Hide some columns (default at startup)
hideColumn(LogField.LINE.ordinal() + 1);
hideColumn(LogField.ROUTINE.ordinal() + 1);
hideColumn(LogField.HOST.ordinal() + 1);
hideColumn(LogField.PROCESS.ordinal() + 1);
hideColumn(LogField.CONTEXT.ordinal() + 1);
hideColumn(LogField.THREAD.ordinal() + 1);
hideColumn(LogField.LOGID.ordinal() + 1);
hideColumn(LogField.PRIORITY.ordinal() + 1);
hideColumn(LogField.URI.ordinal() + 1);
hideColumn(LogField.STACKID.ordinal() + 1);
hideColumn(LogField.FILE.ordinal() + 1);
hideColumn(LogField.STACKLEVEL.ordinal() + 1);
hideColumn(LogField.AUDIENCE.ordinal() + 1);
hideColumn(LogField.ARRAY.ordinal() + 1);
hideColumn(LogField.ANTENNA.ordinal() + 1);
// Build and set the selection model
selectionModel = new DefaultListSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
setSelectionModel(selectionModel);
addMouseListener(new TableMouseAdapter());
}
use of javax.swing.table.TableColumnModel in project ACS by ACS-Community.
the class JDynAct method buildWindow.
/** Build the GUI
*
*/
private void buildWindow() {
Container rootCnt = getContentPane();
rootCnt.setLayout(new BorderLayout());
// The container with labels and combo boxes
Container firstCnt = new Container();
firstCnt.setLayout(new GridLayout(4, 2));
firstCnt.add(new JLabel("Name"));
nameCB = new JComboBox();
nameCB.setEditable(true);
nameCB.addItem("*");
nameCB.addItem("PIPPO");
nameCB.addItem("PLUTO");
firstCnt.add(nameCB);
firstCnt.add(new JLabel("IDL interface"));
idlCB = new JComboBox();
idlCB.addItem("*");
idlCB.addItem("IDL:alma/acsexmplLamp/Lamp:1.0");
idlCB.addItem("IDL:alma/MOUNT_ACS/Mount:1.0");
idlCB.addItem("IDL:alma/demo/HelloDemo:1.0");
idlCB.setEditable(true);
firstCnt.add(idlCB);
firstCnt.add(new JLabel("Implementation"));
implCB = new JComboBox();
implCB.addItem("*");
implCB.addItem("acsexmplLampImpl");
implCB.addItem("acsexmplMountImpl");
implCB.addItem("alma.demo.HelloDemoImpl.HelloDemoHelper");
implCB.addItem("demoImpl.HelloDemo");
implCB.addItem("acsexmplHelloWorldClient");
implCB.setEditable(true);
firstCnt.add(implCB);
firstCnt.add(new JLabel("Container"));
containerCB = new JComboBox();
containerCB.addItem("*");
containerCB.addItem("bilboContainer");
containerCB.addItem("frodoContainer");
containerCB.addItem("aragornContainer");
containerCB.setEditable(true);
firstCnt.add(containerCB);
// The container with the activate button
Container secondCnt = new Container();
secondCnt.setLayout(new FlowLayout());
JButton activateB = new JButton("Activate");
activateB.addActionListener(this);
secondCnt.add(activateB, "Center");
// The container with activated container
MyTableModel tableModel = new MyTableModel();
activatedT = new JTable(tableModel);
activatedT.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = activatedT.getSelectionModel();
JScrollPane scrollP = new JScrollPane(activatedT);
activatedT.setPreferredScrollableViewportSize(new Dimension(400, 90));
MyCellRendererr cellR = new MyCellRendererr();
TableColumnModel tcm = activatedT.getColumnModel();
TableColumn tc = tcm.getColumn(2);
tc.setCellRenderer(cellR);
MyCellEditor cellE = new MyCellEditor(this);
tc.setCellEditor(cellE);
Container thirdCnt = new Container();
thirdCnt.setLayout(new FlowLayout());
thirdCnt.add(scrollP, "North");
// Add the container to the main container
rootCnt.add(firstCnt, "North");
rootCnt.add(secondCnt, "Center");
rootCnt.add(thirdCnt, "South");
}
use of javax.swing.table.TableColumnModel in project EnrichmentMapApp by BaderLab.
the class HeatMapMainPanel method createTableHeader.
private void createTableHeader(int expressionColumnWidth) {
JTableHeader header = table.getTableHeader();
header.setReorderingAllowed(false);
HeatMapTableModel tableModel = (HeatMapTableModel) table.getModel();
TableColumnModel columnModel = table.getColumnModel();
TableCellRenderer vertRenderer = new ColumnHeaderVerticalRenderer();
TableCellRenderer vertRendererPheno1 = new ColumnHeaderVerticalRenderer(EMStyleBuilder.Colors.LIGHTEST_PHENOTYPE_1);
TableCellRenderer vertRendererPheno2 = new ColumnHeaderVerticalRenderer(EMStyleBuilder.Colors.LIGHTEST_PHENOTYPE_2);
TableColumn rankColumn = columnModel.getColumn(HeatMapTableModel.RANK_COL);
rankColumn.setHeaderRenderer(columnHeaderRankOptionRendererFactory.create(this, HeatMapTableModel.RANK_COL));
rankColumn.setPreferredWidth(100);
((TableRowSorter<?>) table.getRowSorter()).setSortable(HeatMapTableModel.RANK_COL, false);
int colCount = tableModel.getColumnCount();
for (int col = HeatMapTableModel.DESC_COL_COUNT; col < colCount; col++) {
EMDataSet dataset = tableModel.getDataSet(col);
String pheno1 = dataset.getEnrichments().getPhenotype1();
String pheno2 = dataset.getEnrichments().getPhenotype2();
Optional<String> pheno = tableModel.getPhenotype(col);
TableCellRenderer renderer;
if (pheno.filter(p -> p.equals(pheno1)).isPresent())
renderer = vertRendererPheno1;
else if (pheno.filter(p -> p.equals(pheno2)).isPresent())
renderer = vertRendererPheno2;
else
renderer = vertRenderer;
TableColumn column = columnModel.getColumn(col);
column.setHeaderRenderer(renderer);
column.setPreferredWidth(expressionColumnWidth);
}
}
Aggregations