From 115f47f184406904b06a5f67d0e083c8d10d5e5a Mon Sep 17 00:00:00 2001 From: Olesya Smirnova Date: Tue, 1 Mar 2005 14:52:57 +0300 Subject: [PATCH] Structure view under project view fixed --- .../ide/projectView/impl/ProjectViewImpl.java | 7 +++++-- .../StructureViewComponent.java | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/source/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/source/com/intellij/ide/projectView/impl/ProjectViewImpl.java index 208070a45a0d..a417b935ca5e 100644 --- a/source/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/source/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -534,8 +534,11 @@ public final class ProjectViewImpl extends ProjectView implements JDOMExternaliz if (toShow) { VirtualFile[] files = FileEditorManager.getInstance(myProject).getSelectedFiles(); - PsiFile psiFile = files.length != 0 ? PsiManager.getInstance(myProject).findFile(files[0]) : null; - myStructureViewWrapper.setFileEditor(null); + if (files.length != 0) { + myStructureViewWrapper.setFileEditor(FileEditorManager.getInstance(myProject).getSelectedEditor(files[0])); + } else { + myStructureViewWrapper.setFileEditor(null); + } } } diff --git a/source/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/source/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index c6ddbd13a10b..ce0fc40fe8c3 100644 --- a/source/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/source/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java @@ -134,6 +134,11 @@ public class StructureViewComponent extends JPanel implements TreeActionsOwner, return convertPathsToValues(getTree().getSelectionPaths()); } + private Object[] getSelectedTreeElements() { + return convertPathsToTreeElements(getTree().getSelectionPaths()); + } + + private Object[] convertPathsToValues(TreePath[] selectionPaths) { if (selectionPaths != null) { Object[] result = new Object[selectionPaths.length]; @@ -153,6 +158,20 @@ public class StructureViewComponent extends JPanel implements TreeActionsOwner, } } + private Object[] convertPathsToTreeElements(TreePath[] selectionPaths) { + if (selectionPaths != null) { + Object[] result = new Object[selectionPaths.length]; + + for (int i = 0; i < selectionPaths.length; i++) { + result[i] = ((AbstractTreeNode)((DefaultMutableTreeNode)selectionPaths[i].getLastPathComponent()).getUserObject()).getValue(); + } + return result; + } + else { + return null; + } + } + private void addTreeMouseListeners() { EditSourceOnDoubleClickHandler.install(getTree()); ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_STRUCTURE_VIEW_POPUP); @@ -619,7 +638,7 @@ public class StructureViewComponent extends JPanel implements TreeActionsOwner, return myCopyPasteDelegator.getPasteProvider(); } else if (DataConstantsEx.NAVIGATABLE.equals(dataId)) { - Object[] selectedElements = getSelectedElements(); + Object[] selectedElements = getSelectedTreeElements(); if (selectedElements == null || selectedElements.length == 0) { return null;