void () { myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); myTree.getSelectionModel().addTreeSelectionListener(e -> onSelectionChanged()); myTree.addFocusListener(new FocusListener() { void updateIfMultipleSelection() { if (myTree != null && myTree.getSelectionCount() > 1) { onSelectionChanged(); } } @Override public void focusGained(FocusEvent e) { updateIfMultipleSelection(); } @Override public void focusLost(FocusEvent e) { updateIfMultipleSelection(); } }); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.expandPath(new TreePath(myTree.getModel().getRoot())); EditSourceOnDoubleClickHandler.install(myTree); EditSourceOnEnterKeyHandler.install(myTree); ToolTipManager.sharedInstance().registerComponent(myTree); TreeUtil.installActions(myTree); MySpeedSearch.installOn(myTree); myTree.addKeyListener(new PsiCopyPasteManager.EscapeHandler()); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP); }