mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix issue with using single child of the file as new root for structure view popup
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user