Search in sources :

Example 31 with TableColumnModel

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));
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel)

Example 32 with TableColumnModel

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);
}
Also used : UndocAlarmTableModel(alma.acsplugins.alarmsystem.gui.undocumented.table.UndocAlarmTableModel) RowSorter(javax.swing.RowSorter) TableRowSorter(javax.swing.table.TableRowSorter) ToolTipManager(javax.swing.ToolTipManager) ArrayList(java.util.ArrayList) TableColumnModel(javax.swing.table.TableColumnModel) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) FontMetrics(java.awt.FontMetrics) AlarmTableColumn(alma.acsplugins.alarmsystem.gui.table.AlarmTableModel.AlarmTableColumn)

Example 33 with TableColumnModel

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());
}
Also used : InfoRenderer(alma.acs.logging.table.renderer.InfoRenderer) TableColumnModel(javax.swing.table.TableColumnModel) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) DateRenderer(alma.acs.logging.table.renderer.DateRenderer) EntryTypeRenderer(alma.acs.logging.table.renderer.EntryTypeRenderer) TableColumn(javax.swing.table.TableColumn)

Example 34 with TableColumnModel

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");
}
Also used : JScrollPane(javax.swing.JScrollPane) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) ListSelectionModel(javax.swing.ListSelectionModel) TableColumnModel(javax.swing.table.TableColumnModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Container(java.awt.Container) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable)

Example 35 with TableColumnModel

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);
    }
}
Also used : Arrays(java.util.Arrays) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) Operator(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Operator) JTableHeader(javax.swing.table.JTableHeader) TableCellRenderer(javax.swing.table.TableCellRenderer) IconManager(org.cytoscape.util.swing.IconManager) Assisted(com.google.inject.assistedinject.Assisted) ComboItem(org.baderlab.csplugins.enrichmentmap.view.util.ComboItem) Map(java.util.Map) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) DEFAULT_SIZE(javax.swing.GroupLayout.DEFAULT_SIZE) Set(java.util.Set) ColorAndValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorAndValueRenderer) Distance(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Distance) Component(java.awt.Component) Collectors(java.util.stream.Collectors) TableRowSorter(javax.swing.table.TableRowSorter) Sets(com.google.common.collect.Sets) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) ColumnHeaderRankOptionRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderRankOptionRenderer) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) JTable(javax.swing.JTable) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) ActionListener(java.awt.event.ActionListener) TableColumnModel(javax.swing.table.TableColumnModel) SortKey(javax.swing.RowSorter.SortKey) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CompletableFuture(java.util.concurrent.CompletableFuture) GradientLegendPanel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.GradientLegendPanel) ArrayList(java.util.ArrayList) SwingUtilities(javax.swing.SwingUtilities) EMStyleBuilder(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder) JButton(javax.swing.JButton) Transform(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform) TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) ActionEvent(java.awt.event.ActionEvent) RankOptionErrorHeader(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader) RankValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValueRenderer) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) ColorRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorRenderer) Comparator(java.util.Comparator) TableCellRenderer(javax.swing.table.TableCellRenderer) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) TableColumn(javax.swing.table.TableColumn) TableRowSorter(javax.swing.table.TableRowSorter)

Aggregations

TableColumnModel (javax.swing.table.TableColumnModel)168 TableColumn (javax.swing.table.TableColumn)66 JTable (javax.swing.JTable)34 JScrollPane (javax.swing.JScrollPane)31 JButton (javax.swing.JButton)30 BoxLayout (javax.swing.BoxLayout)24 TableCellEditor (javax.swing.table.TableCellEditor)23 ButtonEditor (jmri.util.table.ButtonEditor)23 ButtonRenderer (jmri.util.table.ButtonRenderer)23 JLabel (javax.swing.JLabel)22 JPanel (javax.swing.JPanel)22 ActionEvent (java.awt.event.ActionEvent)20 ActionListener (java.awt.event.ActionListener)16 FlowLayout (java.awt.FlowLayout)15 Border (javax.swing.border.Border)13 Iterator (java.util.Iterator)12 Set (java.util.Set)12 JTableHeader (javax.swing.table.JTableHeader)12 TableCellRenderer (javax.swing.table.TableCellRenderer)12 Container (java.awt.Container)10