mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
provide information about a place where we are
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.structureView.impl.java;
|
||||
|
||||
import com.intellij.ide.actions.ViewStructureAction;
|
||||
import com.intellij.ide.structureView.StructureViewModel;
|
||||
import com.intellij.ide.structureView.StructureViewTreeElement;
|
||||
import com.intellij.ide.structureView.TextEditorBasedStructureViewModel;
|
||||
@@ -23,15 +24,17 @@ import com.intellij.ide.util.treeView.smartTree.Grouper;
|
||||
import com.intellij.ide.util.treeView.smartTree.NodeProvider;
|
||||
import com.intellij.ide.util.treeView.smartTree.Sorter;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.ui.PlaceHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class JavaFileTreeModel extends TextEditorBasedStructureViewModel implements StructureViewModel.ElementInfoProvider {
|
||||
public class JavaFileTreeModel extends TextEditorBasedStructureViewModel implements StructureViewModel.ElementInfoProvider, PlaceHolder<String> {
|
||||
private static final Collection<NodeProvider> NODE_PROVIDERS = Arrays.<NodeProvider>asList(new JavaInheritedMembersNodeProvider(),
|
||||
new JavaAnonymousClassesNodeProvider());
|
||||
private final PsiJavaFile myFile;
|
||||
private String myPlace;
|
||||
|
||||
public JavaFileTreeModel(@NotNull PsiJavaFile file) {
|
||||
super(file);
|
||||
@@ -65,7 +68,11 @@ public class JavaFileTreeModel extends TextEditorBasedStructureViewModel impleme
|
||||
|
||||
@NotNull
|
||||
public Sorter[] getSorters() {
|
||||
return new Sorter[]{KindSorter.INSTANCE, VisibilitySorter.INSTANCE, AnonymousClassesSorter.INSTANCE, Sorter.ALPHA_SORTER};
|
||||
return new Sorter[] {
|
||||
ViewStructureAction.isInStructureViewPopup(this) ? KindSorter.POPUP_INSTANCE : KindSorter.INSTANCE,
|
||||
VisibilitySorter.INSTANCE,
|
||||
AnonymousClassesSorter.INSTANCE,
|
||||
Sorter.ALPHA_SORTER};
|
||||
}
|
||||
|
||||
protected PsiFile getPsiFile() {
|
||||
@@ -110,4 +117,14 @@ public class JavaFileTreeModel extends TextEditorBasedStructureViewModel impleme
|
||||
protected Class[] getSuitableClasses() {
|
||||
return new Class[]{PsiClass.class, PsiMethod.class, PsiField.class, PsiJavaFile.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlace(String place) {
|
||||
myPlace = place;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlace() {
|
||||
return myPlace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,13 @@ import java.util.Comparator;
|
||||
|
||||
public class KindSorter implements Sorter {
|
||||
public static final Sorter INSTANCE = new KindSorter();
|
||||
public static final Sorter POPUP_INSTANCE = new KindSorter(){{isPopup = true;}};
|
||||
|
||||
|
||||
@NonNls public static final String ID = "KIND";
|
||||
private static final Comparator COMPARATOR = new Comparator() {
|
||||
boolean isPopup = false;
|
||||
|
||||
private final Comparator COMPARATOR = new Comparator() {
|
||||
public int compare(final Object o1, final Object o2) {
|
||||
return getWeight(o1) - getWeight(o2);
|
||||
}
|
||||
@@ -37,7 +41,7 @@ public class KindSorter implements Sorter {
|
||||
return 55;
|
||||
}
|
||||
if (value instanceof JavaClassTreeElement) {
|
||||
return 10;
|
||||
return isPopup ? 53 : 10;
|
||||
}
|
||||
if (value instanceof ClassInitializerTreeElement) {
|
||||
return 15;
|
||||
|
||||
Reference in New Issue
Block a user