JTree (boolean dndAware) { Tree tree; if (dndAware) { tree = new DnDAwareTree() { @Override public void addNotify() { super.addNotify(); myRefreshAction.registerShortcutOn(this); } @Override public void removeNotify() { super.removeNotify(); myRefreshAction.unregisterCustomShortcutSet(this); } @Override public boolean isFileColorsEnabled() { return ProjectViewTree.isFileColorsEnabledFor(this); } @Override public Color getFileColorFor(Object object) { return getFileColorForNode(object); } }; if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { DnDManager.getInstance().registerSource(new DnDSource() { @Override public boolean canStartDragging(DnDAction action, @NotNull Point dragOrigin) { return getSelectedElements().length > 0; } @Override public DnDDragStartBean startDragging(DnDAction action, @NotNull Point dragOrigin) { return new DnDDragStartBean(new TransferableWrapper() { @Override public TreeNode[] getTreeNodes() { return tree.getSelectedNodes(TreeNode.class, null); } @Override public PsiElement[] getPsiElements() { return getSelectedElements(); } @Override public List<File> asFileList() { return PsiCopyPasteManager.asFileList(getPsiElements()); } }); } }, tree); } } else { tree = new Tree() { @Override public void addNotify() { super.addNotify(); myRefreshAction.registerShortcutOn(this); } @Override public void removeNotify() { super.removeNotify(); myRefreshAction.unregisterCustomShortcutSet(this); } @Override public boolean isFileColorsEnabled() { return ProjectViewTree.isFileColorsEnabledFor(this); } @Override public Color getFileColorFor(Object object) { return getFileColorForNode(object); } }; } HintUpdateSupply.installDataContextHintUpdateSupply(tree); configureTree(tree); EditSourceOnDoubleClickHandler.install(tree); EditSourceOnEnterKeyHandler.install(tree); return tree; }