Java Code Examples for com.intellij.ui.table.JBTable#setModel()
The following examples show how to use
com.intellij.ui.table.JBTable#setModel() .
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: RevisionsList.java From consulo with Apache License 2.0 | 6 votes |
public RevisionsList(SelectionListener l) { table = new JBTable(); table.setModel(new MyModel(Collections.<RevisionItem>emptyList(), Collections.<RevisionItem, Period>emptyMap())); table.setTableHeader(null); table.setShowGrid(false); table.setRowMargin(0); table.getColumnModel().setColumnMargin(0); table.resetDefaultFocusTraversalKeys(); table.setDefaultRenderer(Object.class, new MyCellRenderer(table)); table.getEmptyText().setText(VcsBundle.message("history.empty")); addSelectionListener(l); }
Example 2
Source File: IgnoreSettingsPanel.java From idea-gitignore with MIT License | 5 votes |
/** Create UI components. */ private void createUIComponents() { templatesListPanel = new TemplatesListPanel(); editorPanel = new EditorPanel(); editorPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 200)); templatesSplitter = new Splitter(false, 0.3f); templatesSplitter.setFirstComponent(templatesListPanel); templatesSplitter.setSecondComponent(editorPanel); languagesTable = new JBTable(); languagesTable.setModel(new LanguagesTableModel()); languagesTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); languagesTable.setColumnSelectionAllowed(false); languagesTable.setRowHeight(22); languagesTable.getColumnModel().getColumn(2).setCellRenderer(new BooleanTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSel, boolean hasFocus, int row, int column) { boolean editable = table.isCellEditable(row, column); Object newValue = editable ? value : null; return super.getTableCellRendererComponent(table, newValue, isSel, hasFocus, row, column); } }); languagesTable.setPreferredScrollableViewportSize( new Dimension(-1, languagesTable.getRowHeight() * IgnoreBundle.LANGUAGES.size() / 2) ); languagesTable.setStriped(true); languagesTable.setShowGrid(false); languagesTable.setBorder(JBUI.Borders.empty()); languagesTable.setDragEnabled(false); languagesPanel = ScrollPaneFactory.createScrollPane(languagesTable); }
Example 3
Source File: PerGroupDependencyTableModel.java From intellij-spring-assistant with MIT License | 4 votes |
PerGroupDependencyTableModel(JBTable perGroupDependencyTable, @NotNull ProjectCreationRequest request, @NotNull DependencyGroup dependencyGroup, @NotNull Version bootVersion, @NotNull Map<DependencyGroup, List<Dependency>> filteredGroupAndDependencies) { this.perGroupDependencyTable = perGroupDependencyTable; this.request = request; this.dependencyGroup = dependencyGroup; this.bootVersion = bootVersion; this.filteredGroupAndDependencies = filteredGroupAndDependencies; reindex(); perGroupDependencyTable.setModel(this); resetTableLookAndFeelToSingleSelect(perGroupDependencyTable); TableColumnModel columnModel = perGroupDependencyTable.getColumnModel(); columnModel.setColumnMargin(0); TableColumn checkBoxColumn = columnModel.getColumn(CHECKBOX_COL_INDEX); TableUtil.setupCheckboxColumn(checkBoxColumn); checkBoxColumn.setCellRenderer(new BooleanTableCellRenderer()); TableColumn dependencyColumn = columnModel.getColumn(DEPENDENCY_NAME_COL_INDEX); dependencyColumn.setCellRenderer(new ColoredTableCellRenderer() { @Override protected void customizeCellRenderer(JTable table, @Nullable Object value, boolean selected, boolean hasFocus, int row, int column) { if (value != null) { Dependency dependency = Dependency.class.cast(value); boolean selectable = isCellEditable(row, CHECKBOX_COL_INDEX); if (selectable) { append(dependency.getName()); } else { append(dependency.getName(), GRAY_ATTRIBUTES); } } // Enable search highlighting. This in conjunction with TableSpeedSearch(below) enables type to search capability of intellij applySpeedSearchHighlighting(table, this, true, selected); } }); new TableSpeedSearch(perGroupDependencyTable, value -> { if (value instanceof Dependency) { return Dependency.class.cast(value).getName(); } return ""; }); // Add listeners // Allow user to select via keyboard perGroupDependencyTable.getActionMap().put("select_deselect_dependency", new AbstractAction() { public void actionPerformed(ActionEvent e) { toggleSelectionIfApplicable(perGroupDependencyTable.getSelectedRow()); } }); perGroupDependencyTable.getInputMap() .put(getKeyStroke(VK_SPACE, 0), "select_deselect_dependency"); // Allow user to toggle via double click perGroupDependencyTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if (event.getButton() == BUTTON1) { int columIndex = perGroupDependencyTable.columnAtPoint(event.getPoint()); if (columIndex == DEPENDENCY_NAME_COL_INDEX) { int rowIndex = perGroupDependencyTable.rowAtPoint(event.getPoint()); if (event.getClickCount() == 2) { toggleSelectionIfApplicable(rowIndex); } } } } }); perGroupDependencyTable.getSelectionModel().addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { int selectedRow = perGroupDependencyTable.getSelectedRow(); if (selectedRow != -1) { selectionListeners .forEach(listener -> listener.onDependencySelected(getDependencyAt(selectedRow))); } else { selectionListeners.forEach(listener -> listener.onDependencySelected(null)); } } }); }
Example 4
Source File: PatternFilterEditor.java From KodeBeagle with Apache License 2.0 | 4 votes |
public PatternFilterEditor(final Project project, final String patternsHelpId) { super(new BorderLayout()); myPatternsHelpId = patternsHelpId; myTable = new JBTable(); myProject = project; final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable); decorator.addExtraAction(new AnActionButton(getAddPatternButtonText(), getAddPatternButtonIcon()) { @Override public void actionPerformed(final AnActionEvent e) { addPatternFilter(); } }); add(decorator.setRemoveAction(new AnActionButtonRunnable() { @Override public void run(final AnActionButton button) { TableUtil.removeSelectedItems(myTable); } }).setButtonComparator(getAddPatternButtonText(), "Remove") .disableUpDownActions().createPanel(), BorderLayout.CENTER); myTableModel = new FilterTableModel(); myTable.setModel(myTableModel); myTable.setShowGrid(false); myTable.setShowGrid(false); myTable.setIntercellSpacing(new Dimension(0, 0)); myTable.setTableHeader(null); myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); myTable.setColumnSelectionAllowed(false); myTable.setPreferredScrollableViewportSize(new Dimension(WIDTH, myTable.getRowHeight() * PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS)); TableColumnModel columnModel = myTable.getColumnModel(); TableColumn column = columnModel.getColumn(FilterTableModel.CHECK_MARK); TableUtil.setupCheckboxColumn(column); column.setCellRenderer(new EnabledCellRenderer(myTable.getDefaultRenderer(Boolean.class))); columnModel.getColumn(FilterTableModel.FILTER).setCellRenderer(new FilterCellRenderer()); getEmptyText().setText(EMPTY_PATTERNS); }