fix issue with using single child of the file as new root for structure view popup

This commit is contained in:
Maxim.Mossienko
2011-04-18 16:02:21 +04:00
parent 913a226690
commit c5fd9dccdb
3 changed files with 13 additions and 1 deletions
@@ -77,7 +77,7 @@ public abstract class AbstractListBuilder {
final Object rootElement = myTreeStructure.getRootElement();
final Object[] rootChildren = myTreeStructure.getChildElements(rootElement);
if (!showRoot && rootChildren.length == 1) {
if (!showRoot && rootChildren.length == 1 && shouldEnterSingleTopLevelElement(rootChildren[0])) {
myShownRoot = (AbstractTreeNode)rootChildren[0];
}
else {
@@ -85,6 +85,8 @@ public abstract class AbstractListBuilder {
}
}
protected abstract boolean shouldEnterSingleTopLevelElement(Object rootChild);
public final void setParentTitle(final JLabel parentTitle) {
myParentTitle = parentTitle;
}
@@ -74,6 +74,11 @@ public class ProjectListBuilder extends AbstractListBuilder {
}
}
@Override
protected boolean shouldEnterSingleTopLevelElement(Object rootChild) {
return true;
}
protected boolean nodeIsAcceptableForElement(AbstractTreeNode node, Object element) {
return Comparing.equal(node.getValue(), element);
}
@@ -183,6 +183,11 @@ public class FileStructureDialog extends DialogWrapper {
PsiFile psiFile = getPsiFile(myProject);
boolean showRoot = isShowRoot(psiFile);
ProjectListBuilder projectListBuilder = new ProjectListBuilder(myProject, myCommanderPanel, myTreeStructure, null, showRoot) {
@Override
protected boolean shouldEnterSingleTopLevelElement(Object rootChild) {
return myBaseTreeModel.shouldEnterElement(((StructureViewTreeElement)((AbstractTreeNode)rootChild).getValue()).getValue());
}
protected boolean nodeIsAcceptableForElement(AbstractTreeNode node, Object element) {
return Comparing.equal(((StructureViewTreeElement)node.getValue()).getValue(), element);
}