Java Code Examples for com.intellij.util.ui.UIUtil#setLineStyleAngled()

The following examples show how to use com.intellij.util.ui.UIUtil#setLineStyleAngled() . 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: 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 2
Source File: ModulesDependenciesPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void initTree(Tree tree, boolean isRightTree) {
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setCellRenderer(new MyTreeCellRenderer());
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      return o.getLastPathComponent().toString();
    }
  }, true);
  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree, tree), ActionManager.getInstance());
}
 
Example 3
Source File: FileTemplateTabAsTree.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected FileTemplateTabAsTree(String title) {
  super(title);
  myRoot = initModel();
  myTreeModel = new MyTreeModel(myRoot);
  myTree = new Tree(myTreeModel);
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(myTree);

  myTree.expandPath(TreeUtil.getPathFromRoot(myRoot));
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myTree.setCellRenderer(new MyTreeCellRenderer());
  myTree.expandRow(0);

  myTree.addTreeSelectionListener(e -> onTemplateSelected());
  new TreeSpeedSearch(myTree);
}
 
Example 4
Source File: InspectionTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
public InspectionTree(@Nonnull Project project, @Nonnull GlobalInspectionContextImpl context) {
  super(new InspectionRootNode(project));
  myContext = context;

  setCellRenderer(new CellRenderer());
  setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(this);
  addTreeWillExpandListener(new ExpandListener());

  myExpandedUserObjects = new HashSet<Object>();
  myExpandedUserObjects.add(project);

  TreeUtil.installActions(this);
  new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      return InspectionsConfigTreeComparator.getDisplayTextToSort(o.getLastPathComponent().toString());
    }
  });

  addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      TreePath newSelection = e.getNewLeadSelectionPath();
      if (newSelection != null) {
        mySelectionPath = new SelectionPath(newSelection);
      }
    }
  });
}
 
Example 5
Source File: PsiViewerDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void initTree(JTree tree) {
  UIUtil.setLineStyleAngled(tree);
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.updateUI();
  ToolTipManager.sharedInstance().registerComponent(tree);
  TreeUtil.installActions(tree);
  new TreeSpeedSearch(tree);
}
 
Example 6
Source File: AbstractFileTreeTable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public TreeTableCellRenderer createTableRenderer(TreeTableModel treeTableModel) {
  TreeTableCellRenderer tableRenderer = super.createTableRenderer(treeTableModel);
  UIUtil.setLineStyleAngled(tableRenderer);
  tableRenderer.setRootVisible(false);
  tableRenderer.setShowsRootHandles(true);

  return tableRenderer;
}
 
Example 7
Source File: DependenciesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initTree(final MyTree tree, boolean isRightTree) {
  tree.setCellRenderer(new MyTreeCellRenderer());
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  SmartExpander.installOn(tree);
  EditSourceOnDoubleClickHandler.install(tree);
  new TreeSpeedSearch(tree);

  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree), ActionManager.getInstance());


}
 
Example 8
Source File: HierarchyBrowserBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void configureTree(@Nonnull Tree tree) {
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  tree.setToggleClickCount(-1);
  tree.setCellRenderer(new HierarchyNodeRenderer());
  UIUtil.setLineStyleAngled(tree);
  new TreeSpeedSearch(tree);
  TreeUtil.installActions(tree);
  myAutoScrollToSourceHandler.install(tree);
}
 
Example 9
Source File: AbstractProjectViewPSIPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initTree() {
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  UIUtil.setLineStyleAngled(myTree);
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.expandPath(new TreePath(myTree.getModel().getRoot()));

  EditSourceOnDoubleClickHandler.install(myTree);

  ToolTipManager.sharedInstance().registerComponent(myTree);
  TreeUtil.installActions(myTree);

  new MySpeedSearch(myTree);

  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (KeyEvent.VK_ENTER == e.getKeyCode()) {
        TreePath path = getSelectedPath();
        if (path != null && !myTree.getModel().isLeaf(path.getLastPathComponent())) {
          return;
        }

        DataContext dataContext = DataManager.getInstance().getDataContext(myTree);
        OpenSourceUtil.openSourcesFrom(dataContext, ScreenReader.isActive());
      }
      else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
        if (e.isConsumed()) return;
        PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
        boolean[] isCopied = new boolean[1];
        if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
          copyPasteManager.clear();
          e.consume();
        }
      }
    }
  });
  CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
 
Example 10
Source File: MemberChooser.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected Tree createTree() {
  final Tree tree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode()));

  tree.setCellRenderer(getTreeCellRenderer());
  UIUtil.setLineStyleAngled(tree);
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.addKeyListener(new TreeKeyListener());
  tree.addTreeSelectionListener(new MyTreeSelectionListener());

  if (!myAllowMultiSelection) {
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  }

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
        doOKAction();
        return true;
      }
      return false;
    }
  }.installOn(tree);

  TreeUtil.installActions(tree);
  return tree;
}
 
Example 11
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initTree() {
  myTree.setCellRenderer(new MyTreeCellRenderer());
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(myTree);
  TreeUtil.installActions(myTree);
  EditSourceOnDoubleClickHandler.install(myTree);
  new TreeSpeedSearch(myTree);
  myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) {
    @Override
    @Nonnull
    protected PsiElement[] getSelectedElements() {
      return getSelectedPsiElements();
    }
  };
  myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject);
  final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject);
  for (ScopeTreeStructureExpander expander : extensions) {
    myTree.addTreeWillExpandListener(expander);
  }
  if (extensions.length == 0) {
    myTree.addTreeWillExpandListener(new SortingExpandListener());
  }
  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (KeyEvent.VK_ENTER == e.getKeyCode()) {
        final Object component = myTree.getLastSelectedPathComponent();
        if (component instanceof DefaultMutableTreeNode) {
          final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component;
          if (selectedNode.isLeaf()) {
            OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false);
          }
        }
      }
    }
  });
  CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
 
Example 12
Source File: NewErrorTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) {
  myProject = project;
  myHelpId = helpId;
  myConfiguration = ErrorTreeViewConfiguration.getInstance(project);
  setLayout(new BorderLayout());

  myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() {
    @Override
    protected boolean isAutoScrollMode() {
      return myConfiguration.isAutoscrollToSource();
    }

    @Override
    protected void setAutoScrollMode(boolean state) {
      myConfiguration.setAutoscrollToSource(state);
    }
  };

  myMessagePanel = new JPanel(new BorderLayout());

  myErrorViewStructure = new ErrorViewStructure(project, canHideWarningsOrInfos());
  DefaultMutableTreeNode root = new DefaultMutableTreeNode();
  root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null));
  final DefaultTreeModel treeModel = new DefaultTreeModel(root);
  myTree = new Tree(treeModel) {
    @Override
    public void setRowHeight(int i) {
      super.setRowHeight(0);
      // this is needed in order to make UI calculate the height for each particular row
    }
  };
  myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure);

  myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure);
  myOccurenceNavigatorSupport = new MyOccurenceNavigatorSupport(myTree);

  myAutoScrollToSourceHandler.install(myTree);
  TreeUtil.installActions(myTree);
  UIUtil.setLineStyleAngled(myTree);
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.setLargeModel(true);

  JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree);
  scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
  myMessagePanel.add(scrollPane, BorderLayout.CENTER);

  if (createToolbar) {
    add(createToolbarPanel(rerunAction), BorderLayout.WEST);
  }

  add(myMessagePanel, BorderLayout.CENTER);

  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        navigateToSource(false);
      }
    }
  });

  myTree.addMouseListener(new PopupHandler() {
    @Override
    public void invokePopup(Component comp, int x, int y) {
      popupInvoked(comp, x, y);
    }
  });

  EditSourceOnDoubleClickHandler.install(myTree);
}