com.intellij.ui.table.TableView Java Examples

The following examples show how to use com.intellij.ui.table.TableView. 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: TargetExpressionListUi.java    From intellij with Apache License 2.0 7 votes vote down vote up
public TargetExpressionListUi(Project project) {
  this.project = project;

  listModel = new ListTableModel<>(new TargetColumn());
  tableView = new TableView<>(listModel);
  tableView.getEmptyText().setText("Choose some targets");
  tableView.setPreferredScrollableViewportSize(new Dimension(200, tableView.getRowHeight() * 4));

  setLayout(new BorderLayout());
  add(
      ToolbarDecorator.createDecorator(tableView)
          .setAddAction(button -> addTarget())
          .setRemoveAction(button -> removeTarget())
          .disableUpDownActions()
          .createPanel(),
      BorderLayout.CENTER);
}
 
Example #2
Source File: LatteCustomMacroSettingsDialog.java    From intellij-latte with MIT License 6 votes vote down vote up
public LatteCustomMacroSettingsDialog(TableView<LatteTagSettings> tableView, Project project, LatteTagSettings latteTagSettings) {
    this(tableView, project);

    this.latteTagSettings = latteTagSettings;
    this.textVarName.setText(latteTagSettings.getMacroName());
    this.macroType.getModel().setSelectedItem(latteTagSettings.getMacroType());
    this.argumentsTextField.setText(latteTagSettings.getArguments());
    this.checkBoxAllowedModifiers.setSelected(latteTagSettings.isAllowedModifiers());
    this.multiLineOnlyUsedCheckBox.setSelected(latteTagSettings.isMultiLine());
    this.deprecatedCheckBox.setSelected(latteTagSettings.isDeprecated());
    this.deprecatedMessageTextField.setText(latteTagSettings.getDeprecatedMessage());

    deprecatedMessageTextField.setEnabled(latteTagSettings.isDeprecated());

    attachComboBoxValues();
}
 
Example #3
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private AnActionButtonRunnable getRemoveAction(final TableView<XQueryRunVariable> variablesTable) {
    return new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            TableUtil.stopEditing(variablesTable);
            final int[] selected = variablesTable.getSelectedRows();
            if (selected == null || selected.length == 0) return;
            for (int i = selected.length - 1; i >= 0; i--) {
                variablesModel.removeRow(selected[i]);
            }
            for (int i = selected.length - 1; i >= 0; i--) {
                int idx = selected[i];
                variablesModel.fireTableRowsDeleted(idx, idx);
            }
            int selection = selected[0];
            if (selection >= variablesModel.getRowCount()) {
                selection = variablesModel.getRowCount() - 1;
            }
            if (selection >= 0) {
                variablesTable.setRowSelectionInterval(selection, selection);
            }
            variablesTable.requestFocus();
        }
    };
}
 
Example #4
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private AnActionButtonRunnable getAddAction(final TableView<XQueryRunVariable> variablesTable) {
    return new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            XQueryRunVariable newVariable = new XQueryRunVariable();
            if (showEditorDialog(newVariable)) {
                ArrayList<XQueryRunVariable> newList = new ArrayList<XQueryRunVariable>(variablesModel
                        .getItems());
                newList.add(newVariable);
                variablesModel.setItems(newList);
                int index = variablesModel.getRowCount() - 1;
                variablesModel.fireTableRowsInserted(index, index);
                variablesTable.setRowSelectionInterval(index, index);
            }
        }
    };
}
 
Example #5
Source File: CompareWithSelectedRevisionAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static JPanel createCommentsPanel(final TableView<VcsFileRevision> table) {
  final JTextArea textArea = createTextArea();
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      final VcsFileRevision revision = table.getSelectedObject();
      if (revision == null) {
        textArea.setText("");
      } else {
        textArea.setText(revision.getCommitMessage());
        textArea.select(0, 0);
      }
    }
  });

  JPanel jPanel = new JPanel(new BorderLayout());
  final JScrollPane textScrollPane = ScrollPaneFactory.createScrollPane(textArea);
  textScrollPane.setBorder(IdeBorderFactory.createTitledBorder(VcsBundle.message("border.selected.revision.commit.message"), false
  ));
  jPanel.add(textScrollPane, BorderLayout.SOUTH);

  jPanel.setPreferredSize(new Dimension(300, 100));
  return jPanel;
}
 
Example #6
Source File: MethodParameterDialog.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public MethodParameterDialog(Project project, TableView<MethodParameterSetting> tableView, MethodParameterSetting methodParameterSetting) {
    this(project, tableView);

    this.textCallTo.setText(methodParameterSetting.getCallTo());
    this.textMethodName.setText(methodParameterSetting.getMethodName());
    this.textIndex.setText(String.valueOf(methodParameterSetting.getIndexParameter()));
    this.textContributorData.setText(methodParameterSetting.getContributorData());
    this.methodParameterSetting = methodParameterSetting;

    if(methodParameterSetting.getReferenceProviderName() != null) {
        this.comboProvider.setSelectedItem(methodParameterSetting.getReferenceProviderName());
    }

    if(methodParameterSetting.getContributorName() != null) {
        this.comboContributor.setSelectedItem(methodParameterSetting.getContributorName());
    }

}
 
Example #7
Source File: UseAliasListForm.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
public UseAliasListForm() {
    this.tableView = new TableView<>();

    this.modelList = new ListTableModel<>(
        new ClassColumn(),
        new AliasColumn(),
        new DisableColumn()
    );

    this.tableView.setModelAndUpdateColumns(this.modelList);

    buttonReset.addActionListener(e -> {
        tableView.getTableViewModel().fireTableDataChanged();
        changed = true;
        resetList();
        try {
            apply();
            ApplicationSettings.getInstance().provideDefaults = false;
            JOptionPane.showMessageDialog(panel, "Default alias applied");
        } catch (ConfigurationException ignored) {
        }
    });

    initList();
}
 
Example #8
Source File: TemplatePathDialog.java    From idea-php-laravel-plugin with MIT License 5 votes vote down vote up
public TemplatePathDialog(Project project, TableView<TemplatePath> tableView, TemplatePath twigPath) {
    this(project, tableView);
    this.name.setText(twigPath.getNamespace());
    this.namespacePath.getTextField().setText(twigPath.getPath());
    //this.namespaceType.getModel().setSelectedItem(twigPath.getNamespaceType().toString());
    this.twigPath = twigPath;
    this.setOkState();
}
 
Example #9
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 #10
Source File: DependencyConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public JComponent createComponent() {
  myDenyRulesModel = new MyTableModel(myProject, new ColumnInfo[]{DENY_USAGES_OF, DENY_USAGES_IN}, true);
  myDenyRulesModel.setSortable(false);

  myAllowRulesModel = new MyTableModel(myProject, new ColumnInfo[]{ALLOW_USAGES_OF, ALLOW_USAGES_ONLY_IN}, false);
  myAllowRulesModel.setSortable(false);

  myDenyTable = new TableView<DependencyRule>(myDenyRulesModel);
  myDenyPanel.add(createRulesPanel(myDenyRulesModel, myDenyTable), BorderLayout.CENTER);
  myAllowTable = new TableView<DependencyRule>(myAllowRulesModel);
  myAllowPanel.add(createRulesPanel(myAllowRulesModel, myAllowTable), BorderLayout.CENTER);
  return myWholePanel;
}
 
Example #11
Source File: FileHistoryColumnWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private String getMaxValue(@Nonnull String columnHeader) {
  TableView table = getDualView().getFlatView();
  if (table.getRowCount() == 0) return null;
  final Enumeration<TableColumn> columns = table.getColumnModel().getColumns();
  int idx = 0;
  while (columns.hasMoreElements()) {
    TableColumn column = columns.nextElement();
    if (columnHeader.equals(column.getHeaderValue())) {
      break;
    }
    ++idx;
  }
  if (idx >= table.getColumnModel().getColumnCount() - 1) return null;
  final FontMetrics fm = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD));
  final Object header = table.getColumnModel().getColumn(idx).getHeaderValue();
  double maxValue = fm.stringWidth((String)header);
  String value = (String)header;
  for (int i = 0; i < table.getRowCount(); i++) {
    final Object at = table.getValueAt(i, idx);
    if (at instanceof String) {
      final int newWidth = fm.stringWidth((String)at);
      if (newWidth > maxValue) {
        maxValue = newWidth;
        value = (String)at;
      }
    }
  }
  return value + "ww";
}
 
Example #12
Source File: FileHistoryPanelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void executeAction(AnActionEvent e) {
  List<TreeNodeOnVcsRevision> sel = getSelection();

  int selectionSize = sel.size();
  if (selectionSize > 1) {
    List<VcsFileRevision> selectedRevisions =
            ContainerUtil.sorted(ContainerUtil.map(sel, TreeNodeOnVcsRevision::getRevision), myRevisionsInOrderComparator);
    VcsFileRevision olderRevision = selectedRevisions.get(0);
    VcsFileRevision newestRevision = selectedRevisions.get(sel.size() - 1);
    myDiffHandler.showDiffForTwo(e.getRequiredData(CommonDataKeys.PROJECT), myFilePath, olderRevision, newestRevision);
  }
  else if (selectionSize == 1) {
    final TableView<TreeNodeOnVcsRevision> flatView = myDualView.getFlatView();
    final int selectedRow = flatView.getSelectedRow();
    VcsFileRevision revision = getFirstSelectedRevision();

    VcsFileRevision previousRevision;
    if (selectedRow == (flatView.getRowCount() - 1)) {
      // no previous
      previousRevision = myBottomRevisionForShowDiff != null ? myBottomRevisionForShowDiff : VcsFileRevision.NULL;
    }
    else {
      previousRevision = flatView.getRow(selectedRow + 1).getRevision();
    }

    if (revision != null) {
      myDiffHandler.showDiffForOne(e, e.getRequiredData(CommonDataKeys.PROJECT), myFilePath, previousRevision, revision);
    }
  }
}
 
Example #13
Source File: FileHistoryPanelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void setupDualView(@Nonnull DefaultActionGroup group) {
  myDualView.setShowGrid(true);
  PopupHandler.installPopupHandler(myDualView.getTreeView(), group, ActionPlaces.UPDATE_POPUP, ActionManager.getInstance());
  PopupHandler.installPopupHandler(myDualView.getFlatView(), group, ActionPlaces.UPDATE_POPUP, ActionManager.getInstance());
  IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myDualView);

  myDualView.addListSelectionListener(e -> updateMessage());

  myDualView.setRootVisible(false);

  myDualView.expandAll();

  final TreeCellRenderer defaultCellRenderer = myDualView.getTree().getCellRenderer();

  final Getter<VcsHistorySession> sessionGetter = () -> myHistorySession;
  myDualView.setTreeCellRenderer(new MyTreeCellRenderer(defaultCellRenderer, sessionGetter));

  myDualView.setCellWrapper(new MyCellWrapper(sessionGetter));

  myDualView.installDoubleClickHandler(new MyDiffAction());

  final TableView flatView = myDualView.getFlatView();
  TableViewModel sortableModel = flatView.getTableViewModel();
  sortableModel.setSortable(true);

  final RowSorter<? extends TableModel> rowSorter = flatView.getRowSorter();
  if (rowSorter != null) {
    rowSorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(0, SortOrder.DESCENDING)));
  }
}
 
Example #14
Source File: TableModelEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * source will be copied, passed list will not be used directly
 *
 * Implement {@link DialogItemEditor} instead of {@link CollectionItemEditor} if you want provide dialog to edit.
 */
public TableModelEditor(@Nonnull List<T> items, @Nonnull ColumnInfo[] columns, @Nonnull CollectionItemEditor<T> itemEditor, @Nonnull String emptyText) {
  super(itemEditor);

  model = new MyListTableModel(columns, new ArrayList<>(items));
  table = new TableView<>(model);
  table.setDefaultEditor(Enum.class, ComboBoxTableCellEditor.INSTANCE);
  table.setStriped(true);
  table.setEnableAntialiasing(true);
  preferredScrollableViewportHeightInRows(JBTable.PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS);
  new TableSpeedSearch(table);
  ColumnInfo firstColumn = columns[0];
  if ((firstColumn.getColumnClass() == boolean.class || firstColumn.getColumnClass() == Boolean.class) && firstColumn.getName().isEmpty()) {
    TableUtil.setupCheckboxColumn(table.getColumnModel().getColumn(0));
  }

 boolean needTableHeader = false;
  for (ColumnInfo column : columns) {
    if (!StringUtil.isEmpty(column.getName())) {
      needTableHeader = true;
      break;
    }
  }

  if (!needTableHeader) {
    table.setTableHeader(null);
  }

  table.getEmptyText().setText(emptyText);
  MyRemoveAction removeAction = new MyRemoveAction();
  toolbarDecorator = ToolbarDecorator.createDecorator(table, this).setRemoveAction(removeAction).setRemoveActionUpdater(removeAction);

  if (itemEditor instanceof DialogItemEditor) {
    addDialogActions();
  }
}
 
Example #15
Source File: TwigNamespaceDialog.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public TwigNamespaceDialog(Project project, TableView<TwigPath> tableView, TwigPath twigPath) {
    this(project, tableView);
    this.name.setText(twigPath.getNamespace());
    this.namespacePath.getTextField().setText(twigPath.getPath());
    this.namespaceType.getModel().setSelectedItem(twigPath.getNamespaceType().toString());
    this.twigPath = twigPath;
    this.setOkState();
}
 
Example #16
Source File: LatteCustomModifierSettingsDialog.java    From intellij-latte with MIT License 5 votes vote down vote up
public LatteCustomModifierSettingsDialog(TableView<LatteFilterSettings> tableView, Project project, LatteFilterSettings latteCustomModifierSettings) {
    this(tableView, project);

    this.textName.setText(latteCustomModifierSettings.getModifierName());
    this.textHelp.setText(latteCustomModifierSettings.getModifierHelp());
    this.textDescription.setText(latteCustomModifierSettings.getModifierDescription());
    this.textInsert.setText(latteCustomModifierSettings.getModifierInsert());
    this.latteCustomModifierSettings = latteCustomModifierSettings;
}
 
Example #17
Source File: LatteCustomFunctionSettingsDialog.java    From intellij-latte with MIT License 5 votes vote down vote up
public LatteCustomFunctionSettingsDialog(TableView<LatteFunctionSettings> tableView, Project project, LatteFunctionSettings latteFunctionSettings) {
    this(tableView, project);

    this.textName.setText(latteFunctionSettings.getFunctionName());
    this.textReturnType.setText(latteFunctionSettings.getFunctionReturnType());
    this.textHelp.setText(latteFunctionSettings.getFunctionHelp());
    this.textDescription.setText(latteFunctionSettings.getFunctionDescription());
    this.latteFunctionSettings = latteFunctionSettings;
}
 
Example #18
Source File: LatteVariableSettingsDialog.java    From intellij-latte with MIT License 5 votes vote down vote up
public LatteVariableSettingsDialog(TableView<LatteVariableSettings> tableView, Project project, LatteVariableSettings latteVariableSettings) {
    this(tableView, project);

    this.textVarName.setText(latteVariableSettings.getVarName());
    this.textVarType.setText(latteVariableSettings.getVarType());
    this.latteVariableSettings = latteVariableSettings;

}
 
Example #19
Source File: CSharpChangeSignatureDialog.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
protected void customizeParametersTable(TableView<CSharpParameterTableModelItem> table)
{
	final JTable t = table.getComponent();
	final TableColumn defaultValue = t.getColumnModel().getColumn(2);
	final TableColumn varArg = t.getColumnModel().getColumn(3);
	t.removeColumn(defaultValue);
	t.removeColumn(varArg);
	t.getModel().addTableModelListener(new TableModelListener()
	{
		@Override
		public void tableChanged(TableModelEvent e)
		{
			if(e.getType() == TableModelEvent.INSERT)
			{
				t.getModel().removeTableModelListener(this);
				final TableColumnAnimator animator = new TableColumnAnimator(t);
				animator.setStep(48);
				animator.addColumn(defaultValue, (t.getWidth() - 48) / 3);
				animator.addColumn(varArg, 48);
				animator.startAndDoWhenDone(new Runnable()
				{
					@Override
					public void run()
					{
						t.editCellAt(t.getRowCount() - 1, 0);
					}
				});
				animator.start();
			}
		}
	});
}
 
Example #20
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private AnActionButtonRunnable getUpdateAction(final TableView<XQueryRunVariable> variablesTable) {
    return new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            final int selectedRow = variablesTable.getSelectedRow();
            final XQueryRunVariable selectedVariable = variablesTable.getSelectedObject();
            showEditorDialog(selectedVariable);
            variablesModel.fireTableDataChanged();
            variablesTable.setRowSelectionInterval(selectedRow, selectedRow);
        }
    };
}
 
Example #21
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private TableView<XQueryRunVariable> prepareVariablesTable() {
    TableView<XQueryRunVariable> variablesTable = new TableView<XQueryRunVariable>(variablesModel);
    variablesTable.getEmptyText().setText("No variables defined");
    variablesTable.setColumnSelectionAllowed(false);
    variablesTable.setShowGrid(false);
    variablesTable.setDragEnabled(false);
    variablesTable.setShowHorizontalLines(false);
    variablesTable.setShowVerticalLines(false);
    variablesTable.setIntercellSpacing(new Dimension(0, 0));
    return variablesTable;
}
 
Example #22
Source File: MethodSignatureTypeDialog.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public MethodSignatureTypeDialog(Project project, TableView<MethodSignatureSetting> tableView, MethodSignatureSetting methodParameterSetting) {
    this(project, tableView);

    this.textCallTo.setText(methodParameterSetting.getCallTo());
    this.textMethodName.setText(methodParameterSetting.getMethodName());
    this.textIndex.setText(String.valueOf(methodParameterSetting.getIndexParameter()));
    this.methodParameterSetting = methodParameterSetting;

    if(methodParameterSetting.getReferenceProviderName() != null) {
        this.comboProvider.setSelectedItem(methodParameterSetting.getReferenceProviderName());
    }

}
 
Example #23
Source File: ServiceArgumentSelectionDialog.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
private void createUIComponents() {
    mainPanel = new JPanel();

    mainPanel.setLayout(new GridLayout(0, 1));

    this.modelList = new ListTableModel<>(
        new IconColumn(),
        new NamespaceColumn(),
        new ServiceColumn()
    );

    for (Map.Entry<String, Set<String>> entry : this.arguments.entrySet()) {
        this.modelList.addRow(new ServiceParameter(entry.getKey(), entry.getValue()));
    }

    this.tableView = new TableView<>();
    this.tableView.setModelAndUpdateColumns(this.modelList);

    mainPanel.add(ToolbarDecorator.createDecorator(this.tableView)
            .disableAddAction()
            .disableDownAction()
            .disableRemoveAction()
            .disableUpDownActions()
            .createPanel()
    );

}
 
Example #24
Source File: TableViewSpeedSearch.java    From consulo with Apache License 2.0 4 votes vote down vote up
public TableViewSpeedSearch(TableView<Item> component) {
  super(component);
  setComparator(new SpeedSearchComparator(false));
}
 
Example #25
Source File: ListTableWithButtons.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public TableView<T> getTableView() {
  return myTableView;
}
 
Example #26
Source File: ShowFeatureUsageStatisticsDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected JComponent createCenterPanel() {
  Splitter splitter = new Splitter(true);
  splitter.setShowDividerControls(true);

  ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
  ArrayList<FeatureDescriptor> features = new ArrayList<FeatureDescriptor>();
  for (String id : registry.getFeatureIds()) {
    features.add(registry.getFeatureDescriptor(id));
  }
  final TableView table = new TableView<FeatureDescriptor>(new ListTableModel<FeatureDescriptor>(COLUMNS, features, 0));
  new TableViewSpeedSearch<FeatureDescriptor>(table) {
    @Override
    protected String getItemText(@Nonnull FeatureDescriptor element) {
      return element.getDisplayName();
    }
  };

  JPanel controlsPanel = new JPanel(new VerticalFlowLayout());


  Application app = ApplicationManager.getApplication();
  long uptime = System.currentTimeMillis() - app.getStartTime();
  long idleTime = app.getIdleTime();

  final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime",
                                                         ApplicationNamesInfo.getInstance().getFullProductName(),
                                                         DateFormatUtil.formatDuration(uptime));

  final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time",
                                                           DateFormatUtil.formatDuration(idleTime));

  String labelText = uptimeS + ", " + idleTimeS;
  CompletionStatistics stats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getCompletionStatistics();
  if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
    String total = formatCharacterCount(stats.sparedCharacters, true);
    String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
    labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) +
                 " (~" + perDay + " per working day)";
  }

  CumulativeStatistics fstats = ((FeatureUsageTrackerImpl)FeatureUsageTracker.getInstance()).getFixesStats();
  if (fstats.dayCount > 0 && fstats.invocations > 0) {
    labelText +=
      "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) +
      " (~" + fstats.invocations / fstats.dayCount + " per working day)";
  }

  controlsPanel.add(new JLabel("<html><body>" + labelText + "</body></html>"), BorderLayout.NORTH);

  JPanel topPanel = new JPanel(new BorderLayout());
  topPanel.add(controlsPanel, BorderLayout.NORTH);
  topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);

  splitter.setFirstComponent(topPanel);

  final JEditorPane browser = new JEditorPane(UIUtil.HTML_MIME, "");
  browser.setEditable(false);
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));

  table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      Collection selection = table.getSelection();
      try {
        if (selection.isEmpty()) {
          browser.read(new StringReader(""), null);
        }
        else {
          FeatureDescriptor feature = (FeatureDescriptor)selection.iterator().next();
          TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
        }
      }
      catch (IOException ex) {
        LOG.info(ex);
      }
    }
  });

  return splitter;
}
 
Example #27
Source File: DualView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public TableView getFlatView() {
  return myFlatView;
}
 
Example #28
Source File: ToolbarDecorator.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static <T> ToolbarDecorator createDecorator(@Nonnull TableView<T> table, @Nullable ElementProducer<T> producer) {
  return new TableToolbarDecorator(table, producer).initPosition();
}
 
Example #29
Source File: StatisticsPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void createUIComponents() {
  myStatisticsTableView = new TableView<SMTestProxy>();
}
 
Example #30
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;
}