Java Code Examples for javax.swing.table.TableColumn#setCellEditor()

The following examples show how to use javax.swing.table.TableColumn#setCellEditor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java    From java-swing-tips with MIT License 9 votes vote down vote up
private MainPanel() {
  super(new BorderLayout());

  String[] columnNames = {"Column1", "Column2"};
  Object[][] data = {
    {"colors", makeModel("blue", "violet", "red", "yellow")},
    {"sports", makeModel("basketball", "soccer", "football", "hockey")},
    {"food", makeModel("hot dogs", "pizza", "ravioli", "bananas")},
  };
  TableModel model = new DefaultTableModel(data, columnNames) {
    @Override public Class<?> getColumnClass(int column) {
      return column == 1 ? DefaultComboBoxModel.class : String.class;
    }
  };
  JTable table = new JTable(model);
  table.setRowHeight(24);
  table.setAutoCreateRowSorter(true);

  TableColumn col = table.getColumnModel().getColumn(1);
  col.setCellRenderer(new ComboCellRenderer());
  col.setCellEditor(new ComboCellEditor());

  add(new JScrollPane(table));
  setPreferredSize(new Dimension(320, 240));
}
 
Example 2
Source File: Test6505027.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 3
Source File: PDFDefinitionTableController.java    From OpenDA with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setupPDFDefinitionComboBoxColumn() {

		if (parentController.getMainPanel().getPDFDefinitionTable().getColumnModel() != null) {

			JComboBox comboBox = new JComboBox();
			JComboBox comboBoxRender = new JComboBox();
			this.populateTypeComboBox(comboBox);
			this.populateTypeComboBox(comboBoxRender);

            TableColumn column = parentController.getMainPanel()
						.getPDFDefinitionTable()
						.getColumnModel()
						.getColumn(
								PDFDefinitionTableModel.COLUMN_PDF_TYPE);

			column.setCellEditor(new DefaultCellEditor(comboBox));
			TableRenderer cellRenderer = new TableRenderer(comboBoxRender);
			column.setCellRenderer(cellRenderer);
		}
	}
 
Example 4
Source File: CorrelationTableController.java    From OpenDA with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setupCorrelationComboBoxColumn() {

		if (this.parentController.getMainPanel().getAutoCorrelationTable().getColumnModel() != null) {

			TableColumn column;
			JComboBox comboBox = new JComboBox();
			JComboBox comboBoxRender = new JComboBox();
			this.populateTypeComboBox(comboBox);
			this.populateTypeComboBox(comboBoxRender);

			column = this.parentController.getMainPanel()
						.getAutoCorrelationTable()
						.getColumnModel()
						.getColumn(
								CorrelationTableModel.COLUMN_CORRELATION_TYPE);

			column.setCellEditor(new DefaultCellEditor(comboBox));
			TableRenderer cellRenderer = new TableRenderer(comboBoxRender);
			column.setCellRenderer(cellRenderer);
		}
	}
 
Example 5
Source File: TablePanelController.java    From mae-annotation with GNU General Public License v3.0 6 votes vote down vote up
private void addAttributeColumns(TagType type, JTable table) {
    List<AttributeType> attributes = new ArrayList<>(type.getAttributeTypes());
    TagTableModel model = (TagTableModel) table.getModel();
    for (AttributeType attType : attributes) {
        logger.debug(String.format("adding '%s' attribute column to '%s' tag table.", attType.getName(), type.getName()));
        model.addColumn(attType.getName());
        TableColumn column = new TableColumn(model.getColumnCount()-1);
        if (attType.isFiniteValueset()) {
            logger.debug(String.format("... and it has predefined value set: %s", attType.getValueset()));
            JComboBox valueset = makeValidValuesComboBox(attType);
            column.setCellEditor(new DefaultCellEditor(valueset));
        } else if (attType.isIdRef()) {
            // TODO: 2016-01-07 22:25:00EST add idref here
            // maybe adding a button to pop up to select an argument?
            column.setCellEditor(new DefaultCellEditor(new JTextField()));
        } else {
            column.setCellEditor(new DefaultCellEditor(new JTextField()));
        }
        if (attType.isRequired()) {
            setBoldColumnHeader(column);
        }
        table.addColumn(column);
    }
}
 
Example 6
Source File: Test6505027.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 7
Source File: Test6505027.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 8
Source File: Test6505027.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 9
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JScrollPane createVariablesTable(final String labelName) {
    variablesTable = new JTable();
    variablesTable.setName(labelName);
    variablesTable.setRowSelectionAllowed(true);
    bindingCtx.bind("variables", new VariablesTableAdapter(variablesTable));
    bindingCtx.bindEnabledState("variables", false, "updateMode", true);
    variablesTable.addMouseListener(createExpressionEditorMouseListener(variablesTable, false));

    final JTableHeader tableHeader = variablesTable.getTableHeader();
    tableHeader.setName(labelName);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(true);

    final TableColumnModel columnModel = variablesTable.getColumnModel();
    columnModel.setColumnSelectionAllowed(false);

    final TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(100);
    nameColumn.setCellRenderer(new TCR());

    final TableColumn expressionColumn = columnModel.getColumn(1);
    expressionColumn.setPreferredWidth(400);
    expressionColumn.setCellRenderer(new TCR());
    final ExprEditor exprEditor = new ExprEditor(false);
    expressionColumn.setCellEditor(exprEditor);
    bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final boolean enabled = Boolean.FALSE.equals(evt.getNewValue());
            exprEditor.button.setEnabled(enabled);
        }
    });

    final JScrollPane scrollPane = new JScrollPane(variablesTable);
    scrollPane.setName(labelName);
    scrollPane.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, 150));

    return scrollPane;
}
 
Example 10
Source File: PanelModuleDetectionVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initModuleTable() {
    Vector<String> colNames = new Vector<String>();
    colNames.add(getMessage("LBL_IW_Module"));
    colNames.add(getMessage("LBL_IW_Type"));
    DefaultTableModel moduleTableModel = new DefaultTableModel(modules, colNames);
    moduleTable.setModel(moduleTableModel);
    TableColumnModel tcm = moduleTable.getColumnModel();
    TableColumn tc = tcm.getColumn(1);
    ModuleTypeRenderer renderer = new ModuleTypeRenderer();
    tc.setCellRenderer(renderer);
    tc.setCellEditor(new ModuleTypeEditor());
    moduleTable.setRowHeight((int) renderer.getPreferredSize().getHeight());
    moduleSP.getViewport().setBackground(moduleTable.getBackground());
}
 
Example 11
Source File: CalendarEditorPanel.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
public JPanel createNonRecurringComponent() {
  AbstractTableAndActionsComponent<CalendarEvent> tableAndActions = createTableComponent(myOneOffModel, GanttLanguage.getInstance().getShortDateFormat(), myUiFacade);
  JPanel result = AbstractTableAndActionsComponent.createDefaultTableAndActions(tableAndActions.getTable(), tableAndActions.getActionsComponent());

  Date today = CalendarFactory.newCalendar().getTime();
  final String hint = GanttLanguage.getInstance().formatText("calendar.editor.dateHint",
      GanttLanguage.getInstance().getMediumDateFormat().format(today), GanttLanguage.getInstance().getShortDateFormat().format(today));

  Pair<JLabel,? extends TableCellEditor> validator = createDateValidatorComponents(hint, GanttLanguage.getInstance().getMediumDateFormat(), GanttLanguage.getInstance().getShortDateFormat());
  TableColumn dateColumn = tableAndActions.getTable().getColumnModel().getColumn(TableModelImpl.Column.DATES.ordinal());
  dateColumn.setCellEditor(validator.second());
  result.add(validator.first(), BorderLayout.SOUTH);
  result.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  return result;
}
 
Example 12
Source File: VariationPerParameterTableController.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
    * Update the PDFDefinition Parameters Table.
    */
private void updateVariationFunctionParametersTable() {
	// Populate the correlation model parameters table.
	FunctionParameterTableModel parameterTableModel = new FunctionParameterTableModel(this.currentVariationFunctionContext);

	parentController.getMainPanel().getvariationPerParameterSidePanel().getParametersTable()
	        .setModel(parameterTableModel);

	//setup cell editor.
   	TableColumn columnValue = parentController.getMainPanel().getvariationPerParameterSidePanel()
   	    .getParametersTable().getColumnModel().getColumn(FunctionParameterTableModel.COLUMN_VALUE);
   	columnValue.setCellEditor(new TextCellEditor());
}
 
Example 13
Source File: ResourceAssignmentsPanel.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
private void setUpTasksComboColumn(TableColumn column, final JTable table) {
  final JComboBox comboBox = new JComboBox();
  Task[] tasks = myTaskManager.getTasks();
  for (Task next : tasks) {
    comboBox.addItem(next);
  }
  comboBox.setEditable(false);
  column.setCellEditor(new DefaultCellEditor(comboBox));
}
 
Example 14
Source File: DataPanel.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void modelsChanged() {
    TableColumn col = dataTable.getColumnModel().getColumn(5);
    col.setCellEditor(new ComboBoxCellEditor());

    col = dataTable.getColumnModel().getColumn(6);
    col.setCellEditor(new ComboBoxCellEditor());

    col = dataTable.getColumnModel().getColumn(7);
    col.setCellEditor(new DefaultCellEditor(new JComboBox(options.getPartitionTreeModels().toArray())));
}
 
Example 15
Source File: CRUDMethodParametersPanel.java    From mobile-persistence with MIT License 5 votes vote down vote up
public void createParametersTable(DCMethod method, boolean nameUpdateable) {
      table = new GenericTable(new MethodParamsTableModel(method.getParams(),nameUpdateable));
    table.getSelectionModel().addListSelectionListener(this);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setColumnSelectorAvailable(false);

    //To stop cell editing when user switches to another component without using tab/enter keys
    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

//      TableCellRenderer checkBoxRenderer = new TableCellCheckBoxRenderer();
//      TableCellCheckBoxEditor checkBoxEditor = new TableCellCheckBoxEditor();

      TableColumn tc0 = table.getColumnModel().getColumn(0);
//    tc0.setMinWidth(30);
//    tc0.setMaxWidth(30);
    TableColumn tc1 = table.getColumnModel().getColumn(1);
    JComboBox valueProvider = new JComboBox();
    valueProvider.addItem("");
    for (String value: DCMethodParameter.getValueProviderAllowableValues())
    {
      valueProvider.addItem(value);      
    }
    tc1.setCellEditor(new DefaultCellEditor(valueProvider));
//    tc1.setMinWidth(120);
    TableColumn tc2 = table.getColumnModel().getColumn(2);
    tc2.setCellEditor(new AttributeEditor(method.getParameterValueProviderDataObject()));
//    tc2.setMinWidth(200);
    TableColumn tc3 = table.getColumnModel().getColumn(3);
//    tc3.setMinWidth(200);
    scrollPane.getViewport().setView(table);
  }
 
Example 16
Source File: MappingPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static void setColumn(final JTable table, final int columnIndex, final ArrayList<String> values0) {
    // Copy the list of labels into a String[] with a leading "" as the default "no choice" value.
    final String[] values = new String[values0.size() + 1];
    values[0] = "";
    for (int i = 0; i < values0.size(); i++) {
        values[i + 1] = values0.get(i);
    }

    final TableColumn tcol = table.getColumnModel().getColumn(columnIndex);
    tcol.setCellRenderer(new MappingCellRenderer(values));
    tcol.setCellEditor(new DefaultCellEditor(new JComboBox<>(values)));
}
 
Example 17
Source File: ConfigDialog.java    From lizzie with GNU General Public License v3.0 4 votes vote down vote up
private void readDefaultTheme() {
  spnWinrateStrokeWidth.setValue(Lizzie.config.uiConfig.optInt("winrate-stroke-width", 3));
  spnMinimumBlunderBarWidth.setValue(
      Lizzie.config.uiConfig.optInt("minimum-blunder-bar-width", 3));
  spnShadowSize.setValue(Lizzie.config.uiConfig.optInt("shadow-size", 100));
  cmbFontName.setSelectedItem(Lizzie.config.uiConfig.optString("font-name", null));
  cmbUiFontName.setSelectedItem(Lizzie.config.uiConfig.optString("ui-font-name", null));
  cmbWinrateFontName.setSelectedItem(Lizzie.config.uiConfig.optString("winrate-font-name", null));
  txtBackgroundPath.setEnabled(false);
  btnBackgroundPath.setEnabled(false);
  txtBackgroundPath.setText("/assets/background.jpg");
  txtBoardPath.setEnabled(false);
  btnBoardPath.setEnabled(false);
  txtBoardPath.setText("/assets/board.png");
  txtBlackStonePath.setEnabled(false);
  btnBlackStonePath.setEnabled(false);
  txtBlackStonePath.setText("/assets/black0.png");
  txtWhiteStonePath.setEnabled(false);
  btnWhiteStonePath.setEnabled(false);
  txtWhiteStonePath.setText("/assets/white0.png");
  lblWinrateLineColor.setColor(
      Theme.array2Color(Lizzie.config.uiConfig.optJSONArray("winrate-line-color"), Color.green));
  lblWinrateMissLineColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("winrate-miss-line-color"), Color.blue.darker()));
  lblBlunderBarColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("blunder-bar-color"), new Color(255, 0, 0, 150)));
  lblScoreMeanLineColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("scoremean-line-color"), Color.magenta.brighter()));
  setStoneIndicatorType(Lizzie.config.uiConfig.optInt("stone-indicator-type", 1));
  chkShowCommentNodeColor.setSelected(
      Lizzie.config.uiConfig.optBoolean("show-comment-node-color"));
  lblCommentNodeColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("comment-node-color"), Color.BLUE.brighter()));
  lblCommentBackgroundColor.setColor(
      Theme.array2Color(
          Lizzie.config.uiConfig.optJSONArray("comment-background-color"),
          new Color(0, 0, 0, 200)));
  lblCommentFontColor.setColor(
      Theme.array2Color(Lizzie.config.uiConfig.optJSONArray("comment-font-color"), Color.WHITE));
  txtCommentFontSize.setText(
      String.valueOf(Lizzie.config.uiConfig.optInt("comment-font-size", 3)));
  Theme defTheme = new Theme("");
  tblBlunderNodes.setModel(
      new BlunderNodeTableModel(
          defTheme.blunderWinrateThresholds().orElse(null),
          defTheme.blunderNodeColors().orElse(null),
          columsBlunderNodes));
  TableColumn colorCol = tblBlunderNodes.getColumnModel().getColumn(1);
  colorCol.setCellRenderer(new ColorRenderer(false));
  colorCol.setCellEditor(new ColorEditor(this));
}
 
Example 18
Source File: ScrDeclensionSetup.java    From PolyGlot with MIT License 4 votes vote down vote up
private void setupDimTable() {
    DefaultTableModel dimTableModel = new javax.swing.table.DefaultTableModel(
            new Object[][][]{},
            new String[]{
                "Dimension", "ID"
            }
    ) {
        Class[] types =  {
            java.lang.String.class, java.lang.Boolean.class, java.lang.Integer.class
        };

        @Override
        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }
    };

    tblDimensions.setModel(dimTableModel);

    tblDimensions.setColumnSelectionAllowed(true);
    tblDimensions.setMinimumSize(new java.awt.Dimension(0, 0));
    tblDimensions.getTableHeader().setReorderingAllowed(false);
    tblDimensions.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    tblDimensions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (tblDimensions.getColumnModel().getColumnCount() > 0) {
        tblDimensions.getColumnModel().getColumn(0).setMinWidth(0);
        tblDimensions.removeColumn(tblDimensions.getColumn(tblDimensions.getColumnName(1)));
    }

    TableColumn column = tblDimensions.getColumnModel().getColumn(0);
    column.setCellEditor(new PCellEditor(false, core));

    // disable tab/arrow selection
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_DOWN_MASK), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_DOWN_MASK), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "none");
    tblDimensions.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
            put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_DOWN_MASK), "none");
}
 
Example 19
Source File: SymbolPanel.java    From ghidra with Apache License 2.0 4 votes vote down vote up
SymbolPanel(SymbolProvider provider, SymbolTableModel model, SymbolRenderer renderer,
		final PluginTool tool, GoToService gotoService) {

	super(new BorderLayout());

	this.symProvider = provider;
	this.tableModel = model;

	threadedTablePanel = new GhidraThreadedTablePanel<>(model);

	this.listener = e -> symProvider.updateTitle();

	symTable = threadedTablePanel.getTable();
	symTable.setAutoLookupColumn(SymbolTableModel.LABEL_COL);
	symTable.setName("SymbolTable");//used by JUnit...
	symTable.setRowSelectionAllowed(true);
	symTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	symTable.getModel().addTableModelListener(listener);
	symTable.getSelectionModel().addListSelectionListener(e -> {
		if (!e.getValueIsAdjusting()) {
			handleTableSelection();
			tool.contextChanged(symProvider);
		}
	});

	GoToService goToService = tool.getService(GoToService.class);
	symTable.installNavigation(goToService, goToService.getDefaultNavigatable());

	for (int i = 0; i < symTable.getColumnCount(); i++) {
		TableColumn column = symTable.getColumnModel().getColumn(i);
		column.setCellRenderer(renderer);
		if (column.getModelIndex() == SymbolTableModel.LABEL_COL) {
			column.setCellEditor(new SymbolEditor());
		}
	}

	add(threadedTablePanel, BorderLayout.CENTER);
	add(createFilterFieldPanel(), BorderLayout.SOUTH);

	filterDialog = new FilterDialog(tool);
}
 
Example 20
Source File: TraceTreeTable.java    From pega-tracerviewer with Apache License 2.0 2 votes vote down vote up
@Override
protected void setTreeTableColumnModel() {

    TreeTableModelAdapter model = (TreeTableModelAdapter) getModel();
    TableColumnModel tableColumnModel = new DefaultTableColumnModel();

    for (int i = 0; i < model.getColumnCount(); i++) {

        TableColumn tableColumn = new TableColumn(i);

        TreeTableColumn treeTableColumn = model.getColumn(i);

        String text = treeTableColumn.getDisplayName();

        Class<?> columnClass = treeTableColumn.getColumnClass();

        int preferredWidth = treeTableColumn.getPrefColumnWidth();

        tableColumn.setHeaderValue(text);
        tableColumn.setPreferredWidth(preferredWidth);

        TableCellRenderer tcr = null;

        if (TreeTableColumn.TREE_COLUMN_CLASS.equals(columnClass)) {

            DefaultTreeTableTree treeTableTree = getTree();
            tcr = treeTableTree;
            tableColumn.setCellEditor(new TreeTableCellEditor(treeTableTree));
        } else {

            TraceTreeTableCellRenderer ltcr = new TraceTreeTableCellRenderer();
            ltcr.setBorder(new EmptyBorder(1, 3, 1, 1));
            ltcr.setHorizontalAlignment(treeTableColumn.getHorizontalAlignment());

            tableColumn.setCellEditor(new TreeTableCellEditor(ltcr));

            tcr = ltcr;
        }

        tableColumn.setCellRenderer(tcr);

        tableColumn.setResizable(true);

        tableColumnModel.addColumn(tableColumn);
    }

    setColumnModel(tableColumnModel);
}