mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-25231 Resource Editor: Remember Group node foldings + arrows in properties structure
This commit is contained in:
+14
-5
@@ -21,7 +21,10 @@ import com.intellij.ide.structureView.ModelListener;
|
||||
import com.intellij.ide.structureView.StructureViewModel;
|
||||
import com.intellij.ide.structureView.StructureViewTreeElement;
|
||||
import com.intellij.ide.util.treeView.*;
|
||||
import com.intellij.ide.util.treeView.smartTree.Group;
|
||||
import com.intellij.ide.util.treeView.smartTree.GroupWrapper;
|
||||
import com.intellij.ide.util.treeView.smartTree.SmartTreeStructure;
|
||||
import com.intellij.ide.util.treeView.smartTree.TreeElement;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
@@ -99,15 +102,21 @@ public class StructureTreeBuilder extends AbstractTreeBuilder {
|
||||
if (model instanceof StructureViewModel.ExpandInfoProvider) {
|
||||
StructureViewModel.ExpandInfoProvider provider = (StructureViewModel.ExpandInfoProvider)model;
|
||||
Object element = nodeDescriptor.getElement();
|
||||
StructureViewTreeElement value = null;
|
||||
if (element instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
|
||||
StructureViewComponent.StructureViewTreeElementWrapper wrapper = (StructureViewComponent.StructureViewTreeElementWrapper)element;
|
||||
if (wrapper.getValue() instanceof StructureViewTreeElement) {
|
||||
value = (StructureViewTreeElement)wrapper.getValue();
|
||||
final StructureViewTreeElement value = (StructureViewTreeElement)wrapper.getValue();
|
||||
if (value != null) {
|
||||
return provider.isAutoExpand(value);
|
||||
}
|
||||
}
|
||||
} else if (element instanceof GroupWrapper) {
|
||||
final Group group = ((GroupWrapper)element).getValue();
|
||||
for (TreeElement treeElement : group.getChildren()) {
|
||||
if (treeElement instanceof StructureViewTreeElement && !provider.isAutoExpand((StructureViewTreeElement)treeElement)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value != null) {
|
||||
return provider.isAutoExpand(value);
|
||||
}
|
||||
}
|
||||
// expand root node & its immediate children
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import com.intellij.ide.structureView.StructureViewModel;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public interface PropertiesGroupingStructureViewModel extends StructureViewModel {
|
||||
public interface PropertiesGroupingStructureViewModel extends StructureViewModel.ElementInfoProvider {
|
||||
void setSeparator(String separator);
|
||||
|
||||
String getSeparator();
|
||||
|
||||
+25
-4
@@ -17,6 +17,7 @@ package com.intellij.lang.properties.editor;
|
||||
|
||||
import com.intellij.ide.structureView.FileEditorPositionListener;
|
||||
import com.intellij.ide.structureView.ModelListener;
|
||||
import com.intellij.ide.structureView.StructureViewModel;
|
||||
import com.intellij.ide.structureView.StructureViewTreeElement;
|
||||
import com.intellij.ide.util.treeView.smartTree.Filter;
|
||||
import com.intellij.ide.util.treeView.smartTree.Grouper;
|
||||
@@ -30,16 +31,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ResourceBundleStructureViewModel implements PropertiesGroupingStructureViewModel {
|
||||
private final Project myProject;
|
||||
public class ResourceBundleStructureViewModel implements PropertiesGroupingStructureViewModel, StructureViewModel.ExpandInfoProvider {
|
||||
private final ResourceBundle myResourceBundle;
|
||||
private final GroupByWordPrefixes myGroupByWordPrefixes;
|
||||
private final StructureViewTreeElement myRoot;
|
||||
|
||||
public ResourceBundleStructureViewModel(final Project project, ResourceBundle root) {
|
||||
myProject = project;
|
||||
myResourceBundle = root;
|
||||
String separator = PropertiesSeparatorManager.getInstance().getSeparator(project, new ResourceBundleAsVirtualFile(myResourceBundle));
|
||||
myGroupByWordPrefixes = new GroupByWordPrefixes(separator);
|
||||
myRoot = new ResourceBundleFileStructureViewElement(project, myResourceBundle);
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
@@ -53,7 +54,7 @@ public class ResourceBundleStructureViewModel implements PropertiesGroupingStruc
|
||||
|
||||
@NotNull
|
||||
public StructureViewTreeElement getRoot() {
|
||||
return new ResourceBundleFileStructureViewElement(myProject, myResourceBundle);
|
||||
return myRoot;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -98,4 +99,24 @@ public class ResourceBundleStructureViewModel implements PropertiesGroupingStruc
|
||||
public boolean shouldEnterElement(final Object element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysShowsPlus(final StructureViewTreeElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysLeaf(final StructureViewTreeElement element) {
|
||||
return element instanceof ResourceBundlePropertyStructureViewElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoExpand(@NotNull StructureViewTreeElement element) {
|
||||
return getRoot() == element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSmartExpand() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -106,4 +106,14 @@ public class PropertiesFileStructureViewModel extends TextEditorBasedStructureVi
|
||||
protected Class[] getSuitableClasses() {
|
||||
return new Class[] {Property.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysLeaf(StructureViewTreeElement element) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user