Java Code Examples for com.intellij.ui.table.TableView#setPreferredScrollableViewportSize()

The following examples show how to use com.intellij.ui.table.TableView#setPreferredScrollableViewportSize() . 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: DependencyConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JPanel createRulesPanel(MyTableModel model, TableView<DependencyRule> table) {
  table.setSurrendersFocusOnKeystroke(true);
  table.setPreferredScrollableViewportSize(new Dimension(300, 150));
  table.setShowGrid(true);
  table.setRowHeight(new PackageSetChooserCombo(myProject, null).getPreferredSize().height);

  return ToolbarDecorator.createDecorator(table).createPanel();
}
 
Example 2
Source File: BuckSettingsUI.java    From buck with Apache License 2.0 4 votes vote down vote up
private JPanel initBuckCellSection() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.setBorder(IdeBorderFactory.createTitledBorder("Cells", true));
  cellTableModel = new ListTableModel<>(CELL_NAME_COLUMN, ROOT_COLUMN, BUILD_FILENAME_COLUMN);
  cellTableModel.setItems(buckCellSettingsProvider.getCells());
  TableView<BuckCell> cellTable = new TableView<>(cellTableModel);
  cellTable.setPreferredScrollableViewportSize(
      new Dimension(
          cellTable.getPreferredScrollableViewportSize().width, 8 * cellTable.getRowHeight()));
  ToolbarDecorator decorator =
      ToolbarDecorator.createDecorator(cellTable)
          .setAddAction(
              (AnActionButton button) -> {
                final FileChooserDescriptor dirChooser =
                    FileChooserDescriptorFactory.createSingleFolderDescriptor()
                        .withTitle("Select root directory of buck cell");
                Project project = buckProjectSettingsProvider.getProject();
                FileChooser.chooseFile(
                    dirChooser,
                    project,
                    BuckSettingsUI.this,
                    project.getBaseDir(),
                    file -> {
                      BuckCell buckCell = new BuckCell();
                      buckCell.setName(file.getName());
                      buckCell.setRoot(file.getPath());
                      cellTableModel.addRow(buckCell);
                    });
              })
          .addExtraAction(
              new AnActionButton("Automatically discover cells", Actions.Find) {
                @Override
                public void actionPerformed(AnActionEvent anActionEvent) {
                  discoverCells();
                }
              });
  JBLabel label = new JBLabel("By default, commands take place in the topmost cell");
  panel.add(label, BorderLayout.NORTH);
  panel.add(decorator.createPanel(), BorderLayout.CENTER);
  return panel;
}