com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns Java Examples

The following examples show how to use com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns. 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: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
PropertiesPanel(FlutterApp flutterApp, InspectorService inspectorService) {
  super(new ListTreeTableModelOnColumns(
    new DefaultMutableTreeNode(),
    new ColumnInfo[]{
      new PropertyNameColumnInfo("Property"),
      new PropertyValueColumnInfo("Value")
    }
  ));
  this.flutterApp = flutterApp;
  this.groups = new InspectorObjectGroupManager(inspectorService, "panel");
  setRootVisible(false);

  setStriped(true);
  setRowHeight(getRowHeight() + JBUI.scale(4));

  final JTableHeader tableHeader = getTableHeader();
  tableHeader.setPreferredSize(new Dimension(0, getRowHeight()));

  getColumnModel().getColumn(0).setPreferredWidth(120);
  getColumnModel().getColumn(1).setPreferredWidth(200);
}
 
Example #2
Source File: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
PropertiesPanel(FlutterApp flutterApp, InspectorService inspectorService) {
  super(new ListTreeTableModelOnColumns(
    new DefaultMutableTreeNode(),
    new ColumnInfo[]{
      new PropertyNameColumnInfo("Property"),
      new PropertyValueColumnInfo("Value")
    }
  ));
  this.flutterApp = flutterApp;
  this.groups = new InspectorObjectGroupManager(inspectorService, "panel");
  setRootVisible(false);

  setStriped(true);
  setRowHeight(getRowHeight() + JBUI.scale(4));

  final JTableHeader tableHeader = getTableHeader();
  tableHeader.setPreferredSize(new Dimension(0, getRowHeight()));

  getColumnModel().getColumn(0).setPreferredWidth(120);
  getColumnModel().getColumn(1).setPreferredWidth(200);
}
 
Example #3
Source File: QueryPlanPanel.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 6 votes vote down vote up
private void initTreeCellRenderer(ListTreeTableModelOnColumns model) {
    ((TreeTableCellRenderer) treeTable.getDefaultRenderer(TreeTableModel.class))
            .setCellRenderer(new TreeCellRenderer() {
                private final TreeCellRenderer myBaseRenderer = new HighlightableCellRenderer();

                @Override
                @SuppressWarnings("unchecked")
                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                                                              boolean expanded, boolean leaf, int row,
                                                              boolean hasFocus) {
                    Object transformedValue = Stream.of(model.getColumns())
                            .filter(col -> TreeTableModel.class == col.getColumnClass())
                            .findAny()
                            .map(col -> col.valueOf(value))
                            .orElseThrow(() ->
                                    new ShouldNeverHappenException("Sergey Ishchenko",
                                            "columns are statically defined, and each column set should contain "
                                                    + "operator column"));

                    JComponent result = (JComponent) myBaseRenderer.getTreeCellRendererComponent(tree,
                            transformedValue, selected, expanded, leaf, row, hasFocus);
                    result.setOpaque(!selected);
                    return result;
                }
            });
}
 
Example #4
Source File: JsonTreeTableView.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
public JsonTreeTableView(TreeNode rootNode, ColumnInfo[] columnInfos) {
    super(new ListTreeTableModelOnColumns(rootNode, columnInfos));
    this.columns = columnInfos;

    final TreeTableTree tree = getTree();

    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    UIUtil.setLineStyleAngled(tree);
    setTreeCellRenderer(new KeyCellRenderer());

    TreeUtil.expand(tree, 2);

    new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
        @Override
        public String convert(final TreePath path) {
            final NoSqlTreeNode node = (NoSqlTreeNode) path.getLastPathComponent();
            NodeDescriptor descriptor = node.getDescriptor();
            return descriptor.getFormattedKey();
        }
    });
}
 
Example #5
Source File: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void setModelFromProperties(ArrayList<DiagnosticsNode> properties) {
  final ListTreeTableModelOnColumns model = getTreeModel();
  final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
  for (DiagnosticsNode property : properties) {
    if (property.getLevel() != DiagnosticLevel.hidden) {
      root.add(new DefaultMutableTreeNode(property));
    }
  }
  getEmptyText().setText(FlutterBundle.message("app.inspector.all_properties_hidden"));
  model.setRoot(root);
}
 
Example #6
Source File: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void setModelFromProperties(ArrayList<DiagnosticsNode> properties) {
  final ListTreeTableModelOnColumns model = getTreeModel();
  final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
  for (DiagnosticsNode property : properties) {
    if (property.getLevel() != DiagnosticLevel.hidden) {
      root.add(new DefaultMutableTreeNode(property));
    }
  }
  getEmptyText().setText(FlutterBundle.message("app.inspector.all_properties_hidden"));
  model.setRoot(root);
}
 
Example #7
Source File: QueryPlanPanel.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 5 votes vote down vote up
public void initialize(Container container) {
    JTextArea queryLabel = new JTextArea(originalQuery);
    queryLabel.setRows(3);
    queryLabel.setEditable(false);

    GraphQueryPlan graphQueryPlan = result.getPlan()
            .orElseThrow(() ->
                    new ShouldNeverHappenException("Sergey Ishchenko",
                            "GraphQueryPanel is initialized when explain or profile queries are executed"));

    ListTreeTableModelOnColumns model = createModel(graphQueryPlan, result.isProfilePlan());

    treeTable = new TreeTableView(model);
    treeTable.setAutoCreateColumnsFromModel(true);
    treeTable.setRootVisible(true);
    treeTable.setCellSelectionEnabled(false);
    treeTable.setRowSelectionAllowed(true);
    treeTable.setAutoResizeMode(TreeTableView.AUTO_RESIZE_OFF);

    treeTable.getTree().setShowsRootHandles(true);

    DefaultTreeExpander expander = new DefaultTreeExpander(treeTable.getTree());
    expander.expandAll();
    initTreeCellRenderer(model);

    JBLabel infoLabel = new JBLabel(getStatusText(result));
    infoLabel.setHorizontalAlignment(SwingConstants.LEFT);

    container.add(new JBScrollPane(queryLabel), BorderLayout.NORTH);
    // scroll pane is needed to correctly fit all the tree content and to show table header
    container.add(new JBScrollPane(treeTable, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    container.add(infoLabel, BorderLayout.SOUTH);

    new ColumnResizer(treeTable).resize();
}
 
Example #8
Source File: QueryPlanPanel.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 5 votes vote down vote up
private ListTreeTableModelOnColumns createModel(GraphQueryPlan plan, boolean isProfilePlan) {
    MutableTreeNode rootNode = new DefaultMutableTreeNode(plan);
    addChildrenPlansToModel(plan, rootNode);

    return new ListTreeTableModelOnColumns(rootNode,
            isProfilePlan ? getProfileQueryPlanColumns() : getQueryPlanColumns());
}
 
Example #9
Source File: DualView.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Component createTreeComponent(DualViewColumnInfo[] columns, TreeNode root) {
  myTreeView = new TreeTableView(new ListTreeTableModelOnColumns(root, createTreeColumns(columns))) {
    public TableCellRenderer getCellRenderer(int row, int column) {
      return createWrappedRenderer(super.getCellRenderer(row, column));
    }
  };
  myTreeView.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  JPanel result = new JPanel(new BorderLayout());
  result.add(ScrollPaneFactory.createScrollPane(myTreeView), BorderLayout.CENTER);
  return result;
}
 
Example #10
Source File: DualView.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void changeColumnSet(DualViewColumnInfo[] columns) {
  myTreeView.setTableModel(new ListTreeTableModelOnColumns((TreeNode)myTreeView.getTreeViewModel().getRoot(),
                                                           createTreeColumns(columns)));
  myFlatView.setModelAndUpdateColumns(new ListTableModel(columns));
  if (myTreeCellRenderer != null) myTreeView.setTreeCellRenderer(myTreeCellRenderer);
  setRootVisible(myRootVisible);

  refreshFlatModel();

  addWidthListenersTo(myTreeView);
  addWidthListenersTo(myFlatView);
}
 
Example #11
Source File: CompareWithSelectedRevisionAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void showTreePopup(final List<TreeItem<VcsFileRevision>> roots, final VirtualFile file, final Project project, final DiffProvider diffProvider) {
  final TreeTableView treeTable = new TreeTableView(new ListTreeTableModelOnColumns(new TreeNodeAdapter(null, null, roots),
                                                                                    new ColumnInfo[]{BRANCH_COLUMN, REVISION_COLUMN,
                                                                                    DATE_COLUMN, AUTHOR_COLUMN}));
  Runnable runnable = new Runnable() {
    public void run() {
      int index = treeTable.getSelectionModel().getMinSelectionIndex();
      if (index == -1) {
        return;
      }
      VcsFileRevision revision = getRevisionAt(treeTable, index);
      if (revision != null) {
        DiffActionExecutor.showDiff(diffProvider, revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH);
      }
    }
  };

  treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  new PopupChooserBuilder(treeTable).
    setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")).
    setItemChoosenCallback(runnable).
    setSouthComponent(createCommentsPanel(treeTable)).
    setResizable(true).
    setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup").
    createPopup().
    showCenteredInCurrentWindow(project);
}
 
Example #12
Source File: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
ListTreeTableModelOnColumns getTreeModel() {
  return (ListTreeTableModelOnColumns)getTableModel();
}
 
Example #13
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
ListTreeTableModelOnColumns getTreeModel() {
  return (ListTreeTableModelOnColumns)getTableModel();
}
 
Example #14
Source File: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
ListTreeTableModelOnColumns getTreeModel() {
  return (ListTreeTableModelOnColumns)getTableModel();
}
 
Example #15
Source File: WidgetPerfTable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
ListTreeTableModelOnColumns getTreeModel() {
  return (ListTreeTableModelOnColumns)getTableModel();
}
 
Example #16
Source File: CheckboxTreeTable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CheckboxTreeTable(CheckedTreeNode root, CheckboxTree.CheckboxTreeCellRenderer renderer, final ColumnInfo[] columns) {
  super(new ListTreeTableModelOnColumns(root, columns));
  initTree(getTree(), renderer);
}