Search in sources :

Example 1 with Table

use of com.intellij.util.ui.Table in project intellij-community by JetBrains.

the class GenerateAntBuildDialog method initChunksPanel.

private void initChunksPanel() {
    List<Chunk<Module>> chunks = getCycleChunks();
    if (chunks.isEmpty()) {
        return;
    }
    myChunksPanel.setLayout(new BorderLayout());
    myChunksPanel.setBorder(IdeBorderFactory.createTitledBorder(CompilerBundle.message("generate.ant.build.dialog.cyclic.modules.table.title"), true));
    JLabel textLabel = new JLabel(CompilerBundle.message("generate.ant.build.dialog.cyclic.modules.table.description"));
    textLabel.setUI(new MultiLineLabelUI());
    textLabel.setBorder(IdeBorderFactory.createEmptyBorder(4, 4, 6, 4));
    myChunksPanel.add(textLabel, BorderLayout.NORTH);
    myTableModel = new MyTableModel(chunks);
    myTable = new Table(myTableModel);
    final MyTableCellRenderer cellRenderer = new MyTableCellRenderer();
    final TableColumn nameColumn = myTable.getColumnModel().getColumn(MyTableModel.NAME_COLUMN);
    nameColumn.setCellEditor(ComboBoxTableCellEditor.INSTANCE);
    nameColumn.setCellRenderer(cellRenderer);
    final TableColumn labelColumn = myTable.getColumnModel().getColumn(MyTableModel.NUMBER_COLUMN);
    labelColumn.setCellRenderer(cellRenderer);
    final Dimension preferredSize = new Dimension(myTable.getPreferredSize());
    preferredSize.height = (myTableModel.getRowCount() + 2) * myTable.getRowHeight() + myTable.getTableHeader().getHeight();
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
    scrollPane.setPreferredSize(preferredSize);
    myChunksPanel.add(scrollPane, BorderLayout.CENTER);
}
Also used : MultiLineLabelUI(com.intellij.openapi.ui.MultiLineLabelUI) Table(com.intellij.util.ui.Table) Chunk(com.intellij.util.Chunk) TableColumn(javax.swing.table.TableColumn)

Example 2 with Table

use of com.intellij.util.ui.Table in project intellij-community by JetBrains.

the class OverridingMethodsDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 0));
    final MyTableModel tableModel = new MyTableModel();
    myTable = new Table(tableModel);
    myTable.setShowGrid(false);
    TableColumnModel columnModel = myTable.getColumnModel();
    //    columnModel.getColumn(DISPLAY_NAME_COLUMN).setCellRenderer(new MemberSelectionTable.MyTableRenderer());
    TableColumn checkboxColumn = columnModel.getColumn(CHECK_COLUMN);
    TableUtil.setupCheckboxColumn(checkboxColumn);
    checkboxColumn.setCellRenderer(new BooleanTableCellRenderer());
    // make SPACE check/uncheck selected rows
    @NonNls InputMap inputMap = myTable.getInputMap();
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
    @NonNls final ActionMap actionMap = myTable.getActionMap();
    actionMap.put("enable_disable", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            if (myTable.isEditing())
                return;
            int[] rows = myTable.getSelectedRows();
            if (rows.length > 0) {
                boolean valueToBeSet = false;
                for (int row : rows) {
                    if (!myChecked[row]) {
                        valueToBeSet = true;
                        break;
                    }
                }
                for (int row : rows) {
                    myChecked[row] = valueToBeSet;
                }
                tableModel.updateData();
            }
        }
    });
    /*Border titledBorder = IdeBorderFactory.createBoldTitledBorder("Select methods");
    Border emptyBorder = BorderFactory.createEmptyBorder(0, 5, 5, 5);
    Border border = BorderFactory.createCompoundBorder(titledBorder, emptyBorder);
    panel.setBorder(border);*/
    panel.setLayout(new BorderLayout());
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
    panel.add(scrollPane, BorderLayout.CENTER);
    ListSelectionListener selectionListener = new ListSelectionListener() {

        public void valueChanged(final ListSelectionEvent e) {
            int index = myTable.getSelectionModel().getLeadSelectionIndex();
            if (index != -1) {
                UsageInfo usageInfo = myOverridingMethods.get(index);
                myUsagePreviewPanel.updateLayout(Collections.singletonList(usageInfo));
            } else {
                myUsagePreviewPanel.updateLayout(null);
            }
        }
    };
    myTable.getSelectionModel().addListSelectionListener(selectionListener);
    final Splitter splitter = new Splitter(true, 0.3f);
    splitter.setFirstComponent(panel);
    splitter.setSecondComponent(myUsagePreviewPanel);
    myUsagePreviewPanel.updateLayout(null);
    Disposer.register(myDisposable, new Disposable() {

        public void dispose() {
            splitter.dispose();
        }
    });
    if (tableModel.getRowCount() != 0) {
        myTable.getSelectionModel().addSelectionInterval(0, 0);
    }
    return splitter;
}
Also used : Disposable(com.intellij.openapi.Disposable) NonNls(org.jetbrains.annotations.NonNls) Table(com.intellij.util.ui.Table) Splitter(com.intellij.openapi.ui.Splitter) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn) ListSelectionListener(javax.swing.event.ListSelectionListener) BooleanTableCellRenderer(com.intellij.ui.BooleanTableCellRenderer) UsageInfo(com.intellij.usageView.UsageInfo) SafeDeleteOverridingMethodUsageInfo(com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteOverridingMethodUsageInfo)

Aggregations

Table (com.intellij.util.ui.Table)2 TableColumn (javax.swing.table.TableColumn)2 Disposable (com.intellij.openapi.Disposable)1 MultiLineLabelUI (com.intellij.openapi.ui.MultiLineLabelUI)1 Splitter (com.intellij.openapi.ui.Splitter)1 SafeDeleteOverridingMethodUsageInfo (com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteOverridingMethodUsageInfo)1 BooleanTableCellRenderer (com.intellij.ui.BooleanTableCellRenderer)1 UsageInfo (com.intellij.usageView.UsageInfo)1 Chunk (com.intellij.util.Chunk)1 ActionEvent (java.awt.event.ActionEvent)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 TableColumnModel (javax.swing.table.TableColumnModel)1 NonNls (org.jetbrains.annotations.NonNls)1