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

The following examples show how to use com.intellij.ui.treeStructure.treetable.TreeTable. 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: AbstractRefactoringPanel.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
public AbstractRefactoringPanel(@NotNull AnalysisScope scope,
                                String detectIndicatorStatusTextKey,
                                RefactoringType refactoringType,
                                AbstractTreeTableModel model,
                                int refactorDepth) {
    this.scope = scope;
    this.scopeChooserCombo = new ScopeChooserCombo(scope.getProject());
    this.detectIndicatorStatusTextKey = detectIndicatorStatusTextKey;
    this.refactoringType = refactoringType;
    this.model = model;
    this.treeTable = new TreeTable(model);
    this.refactorDepth = refactorDepth;
    refreshLabel.setForeground(JBColor.GRAY);
    setLayout(new BorderLayout());
    setupGUI();
}
 
Example #2
Source File: CellEditor.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    JTextField stringEditor = (JTextField) getComponent();
    final NoSqlTreeNode jsonNode = (NoSqlTreeNode) ((TreeTable) table).getTree().
            getPathForRow(row).getLastPathComponent();

    stringEditor.setText(String.valueOf(jsonNode.getDescriptor().getValue()));

    return stringEditor;
}
 
Example #3
Source File: EditSourceOnDoubleClickHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void install(final TreeTable treeTable) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (treeTable.getTree().getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(treeTable);
      Project project = dataContext.getData(CommonDataKeys.PROJECT);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(treeTable);
}
 
Example #4
Source File: PopupTableAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public JScrollPane createScrollPane() {
  if (myTable instanceof TreeTable) {
    TreeUtil.expandAll(((TreeTable)myTable).getTree());
  }

  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);

  scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

  if (myTable.getSelectedRow() == -1) {
    myTable.getSelectionModel().setSelectionInterval(0, 0);
  }

  if (myTable.getRowCount() >= 20) {
    scrollPane.getViewport().setPreferredSize(new Dimension(myTable.getPreferredScrollableViewportSize().width, 300));
  }
  else {
    scrollPane.getViewport().setPreferredSize(myTable.getPreferredSize());
  }

  if (myBuilder.isAutoselectOnMouseMove()) {
    myTable.addMouseMotionListener(new MouseMotionAdapter() {
      boolean myIsEngaged = false;

      @Override
      public void mouseMoved(MouseEvent e) {
        if (myIsEngaged) {
          int index = myTable.rowAtPoint(e.getPoint());
          myTable.getSelectionModel().setSelectionInterval(index, index);
        }
        else {
          myIsEngaged = true;
        }
      }
    });
  }

  return scrollPane;
}
 
Example #5
Source File: BaseTreeNodeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Object sourceComponent = getSourceComponent(e);
  if (sourceComponent instanceof JTree) {
    performOn((JTree)sourceComponent);
  }
  else if (sourceComponent instanceof TreeTable) {
    performOn(((TreeTable)sourceComponent).getTree());
  }
}
 
Example #6
Source File: BaseTreeNodeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean enabledOn(Object sourceComponent) {
  if (sourceComponent instanceof JTree) {
    return true;
  }
  if (sourceComponent instanceof TreeTable) {
    return true;
  }
  return false;
}
 
Example #7
Source File: FlutterTreeTableModel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
FlutterTreeTableModel(@NotNull TreeTable treeTable) {
  model = treeTable.getModel();
}
 
Example #8
Source File: FlutterLogTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void init(TreeTable table) {
  treeTable = table;
  tableColumns = Collections.list(table.getColumnModel().getColumns());
}
 
Example #9
Source File: FlutterTreeTableModel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
FlutterTreeTableModel(@NotNull TreeTable treeTable) {
  model = treeTable.getModel();
}
 
Example #10
Source File: FlutterLogTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void init(TreeTable table) {
  treeTable = table;
  tableColumns = Collections.list(table.getColumnModel().getColumns());
}
 
Example #11
Source File: TreeTableSpeedSearch.java    From consulo with Apache License 2.0 4 votes vote down vote up
public TreeTableSpeedSearch(TreeTable tree, Convertor<TreePath, String> toStringConvertor) {
  super(tree);
  myToStringConvertor = toStringConvertor;
}
 
Example #12
Source File: TreeTableSpeedSearch.java    From consulo with Apache License 2.0 4 votes vote down vote up
public TreeTableSpeedSearch(TreeTable tree) {
  this(tree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING);
}
 
Example #13
Source File: OptionTableWithPreviewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Component getTableCellRendererComponent(@Nonnull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  myTable = table;
  myRow = row;
  myColumn = column;
  boolean isEnabled = true;
  final DefaultMutableTreeNode node = (DefaultMutableTreeNode)((TreeTable)table).getTree().
          getPathForRow(row).getLastPathComponent();
  Option key = null;
  if (node instanceof MyTreeNode) {
    isEnabled = ((MyTreeNode)node).isEnabled();
    key = ((MyTreeNode)node).getKey();
  }
  if (!table.isEnabled()) {
    isEnabled = false;
  }

  Color background = table.getBackground();
  if (key != null && value != null) {
    JComponent customRenderer = getCustomValueRenderer(key.getOptionName(), value);
    if (customRenderer != null) {
      return customRenderer;
    }
  }
  if (value instanceof Boolean) {
    myCheckBox.setSelected(((Boolean)value).booleanValue());
    myCheckBox.setBackground(background);
    myCheckBox.setEnabled(isEnabled);
    return myCheckBox;
  }
  else if (value instanceof String) {
    myComboBox.setText((String)value);
    myComboBox.setBackground(background);
    myComboBox.setEnabled(isEnabled);
    return myComboBox;
  }
  else if (value instanceof Integer) {
    if (key instanceof IntOption && ((IntOption)key).isDefaultValue(value)) {
      myIntLabel.setText(((IntOption)key).getDefaultValueText());
    }
    else {
      myIntLabel.setText(value.toString());
    }
    return myIntLabel;
  }

  myEmptyLabel.setBackground(background);
  return myEmptyLabel;
}
 
Example #14
Source File: OptionTableWithPreviewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  final DefaultMutableTreeNode defaultNode = (DefaultMutableTreeNode)((TreeTable)table).getTree().
          getPathForRow(row).getLastPathComponent();
  myCurrentEditor = null;
  myCurrentNode = null;
  if (defaultNode instanceof MyTreeNode) {
    MyTreeNode node = (MyTreeNode)defaultNode;
    myCurrentNode = node;
    if (node.getKey() instanceof BooleanOption) {
      myCurrentEditor = myBooleanEditor;
      myBooleanEditor.setSelected(node.getValue() == Boolean.TRUE);
      myBooleanEditor.setEnabled(node.isEnabled());
    }
    else if (node.getKey() instanceof IntOption) {
      IntOption intOption = (IntOption)node.getKey();
      myCurrentEditor = myIntOptionsEditor;
      myIntOptionsEditor.setCanBeEmpty(true);
      myIntOptionsEditor.setMinValue(intOption.getMinValue());
      myIntOptionsEditor.setMaxValue(intOption.getMaxValue());
      myIntOptionsEditor.setDefaultValue(intOption.getDefaultValue());
      myIntOptionsEditor.setValue((Integer)node.getValue());
    }
    else {
      myCurrentEditor = getCustomNodeEditor(node);
    }
    if (myCurrentEditor == null) {
      myCurrentEditor = myOptionsEditor;
      myOptionsEditor.setCell(table, row, column);
      myOptionsEditor.setText(String.valueOf(node.getValue()));
      //noinspection ConfusingArgumentToVarargsMethod
      myOptionsEditor.setOptions(((SelectionOption)node.getKey()).options);
      myOptionsEditor.setDefaultValue(node.getValue());
    }
  }

  if (myCurrentEditor != null) {
    myCurrentEditor.setBackground(table.getBackground());
    if (myCurrentEditor instanceof JTextField) {
      myCurrentEditor.getInputMap().put(ENTER_KEY_STROKE, STOP_CELL_EDIT_ACTION_KEY);
      myCurrentEditor.getActionMap().put(STOP_CELL_EDIT_ACTION_KEY, STOP_CELL_EDIT_ACTION);
    }
  }
  return myCurrentEditor;
}
 
Example #15
Source File: ValueCellRenderer.java    From nosql4idea with Apache License 2.0 3 votes vote down vote up
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {

    TreeTableTree tree = ((TreeTable) table).getTree();
    TreePath pathForRow = tree.getPathForRow(row);

    final NoSqlTreeNode node = (NoSqlTreeNode) pathForRow.getLastPathComponent();

    node.getDescriptor().renderValue(this, tree.isExpanded(pathForRow));
}