com.intellij.ui.BooleanTableCellRenderer Java Examples
The following examples show how to use
com.intellij.ui.BooleanTableCellRenderer.
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: QuarkusExtensionsStep.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
private ExtensionsTable() { setShowGrid(false); setShowVerticalLines(false); this.setCellSelectionEnabled(false); this.setRowSelectionAllowed(true); this.setSelectionMode(0); this.setTableHeader(null); setModel(new Model(new ArrayList<>())); TableColumn selectedColumn = columnModel.getColumn(0); TableUtil.setupCheckboxColumn(this, 0); selectedColumn.setCellRenderer(new BooleanTableCellRenderer()); TableColumn extensionColumn = columnModel.getColumn(1); extensionColumn.setCellRenderer(new ColoredTableCellRenderer() { @Override protected void customizeCellRenderer(JTable table, @Nullable Object value, boolean b, boolean b1, int i, int i1) { QuarkusExtension extension = (QuarkusExtension) value; append(extension.getName(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, null)); append(" "); append(extension.asLabel(false), new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, null)); } }); }
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: PluginAdvertiserPluginModel.java From consulo with Apache License 2.0 | 5 votes |
@Override public TableCellRenderer getRenderer(final PluginDescriptor ideaPluginDescriptor) { return new BooleanTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return super.getTableCellRendererComponent(table, value == null ? Boolean.TRUE : value, isSelected, hasFocus, row, column); } }; }
Example #4
Source File: InstalledPluginsTableModel.java From consulo with Apache License 2.0 | 5 votes |
@Override public TableCellRenderer getRenderer(final PluginDescriptor ideaPluginDescriptor) { return new BooleanTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return super.getTableCellRendererComponent(table, value == null ? Boolean.TRUE : value, isSelected, hasFocus, row, column); } }; }
Example #5
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 #6
Source File: SearchSelectPanel.java From p4ic4idea with Apache License 2.0 | 4 votes |
public SearchSelectPanel(@NotNull P4CommandRunner.QueryAnswer<? extends Collection<T>> query, @Nullable final SelectionChangedListener listener, @NotNull List<ColumnInfo<T, ?>> columns) { super(new BorderLayout()); Runnable onSelectionChange = () -> { if (listener == null) { return; } int count = 0; synchronized (itemSync) { for (SelectedItem<T> item : items) { if (item.selected) { count++; } } } listener.selectionCount(count); }; ColumnInfo[] columnArray = new ColumnInfo[columns.size() + 1]; columnArray[0] = new BooleanColumnInfo<SelectedItem<T>>(P4Bundle.getString("search-select.column.selected"), true) { @Override protected boolean booleanValue(SelectedItem<T> o) { return o.selected; } @Override protected void setBooleanValue(SelectedItem<T> o, boolean value) { o.selected = value; onSelectionChange.run(); } }; this.searchableColumns = new ArrayList<>(columns.size()); for (int i = 0; i < columns.size(); i++) { ColumnInfo<T, ?> column = columns.get(i); columnArray[i + 1] = proxyColumnInfo(column, onSelectionChange); if (String.class.equals(column.getColumnClass())) { //noinspection unchecked searchableColumns.add((ColumnInfo<T, String>) column); } } tableModel = new ListTableModel<>(columnArray); final JBTable table = new JBTable(tableModel); table.getColumnModel().getColumn(0).setCellEditor(new BooleanTableCellEditor(false, SwingConstants.CENTER)); table.getColumnModel().getColumn(0).setCellRenderer(new BooleanTableCellRenderer(SwingConstants.CENTER)); this.add(new JBScrollPane(table), BorderLayout.CENTER); this.add(table.getTableHeader(), BorderLayout.NORTH); table.getEmptyText().setText(P4Bundle.getString("search-select.status.loading")); final FilterComponent filterComponent = new FilterComponent("search-select", 10, true) { @Override public void filter() { String text = getFilter(); filterTable(text); } }; this.add(filterComponent, BorderLayout.SOUTH); query .whenCompleted((tValues) -> { table.getEmptyText().setText(P4Bundle.getString("search-select.status.empty")); synchronized (itemSync) { items.clear(); tValues.forEach(t -> items.add(new SelectedItem<>(t))); } filterTable(filterComponent.getFilter()); }) .whenServerError(e -> { table.getEmptyText().setText(P4Bundle.message("search-select.status.error", e.getLocalizedMessage())); synchronized (itemSync) { items.clear(); } if (listener != null) { listener.selectionCount(-1); } }); }
Example #7
Source File: AbstractParameterTablePanel.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Override public TableCellRenderer getRenderer(AbstractVariableData data) { return new BooleanTableCellRenderer(); }