com.intellij.ide.structureView
Class TextEditorBasedStructureViewModel

java.lang.Object
  extended by com.intellij.ide.structureView.TextEditorBasedStructureViewModel
All Implemented Interfaces:
StructureViewModel, TreeModel

public abstract class TextEditorBasedStructureViewModel
extends java.lang.Object
implements StructureViewModel

The standard StructureViewModel implementation which is linked to a text editor.

See Also:
TreeBasedStructureViewBuilder.createStructureViewModel()

Constructor Summary
protected TextEditorBasedStructureViewModel(Editor editor)
          Creates a structure view model instance linked to the specified text editor.
protected TextEditorBasedStructureViewModel(PsiFile psiFile)
          Creates a structure view model instance linked to a text editor displaying the specified file.
 
Method Summary
 void addEditorPositionListener(FileEditorPositionListener listener)
          Adds a listener which gets notified when the selection in the editor linked to the structure view moves to a different element visible in the structure view.
 void addModelListener(ModelListener modelListener)
          Adds a listener which gets notified when the data represented by the structure view is changed and the structure view needs to be rebuilt.
 void dispose()
          Disposes of the model.
 java.lang.Object getCurrentEditorElement()
          Returns the element currently selected in the editor linked to the structure view.
protected  Editor getEditor()
           
protected abstract  PsiFile getPsiFile()
           
protected abstract  java.lang.Class[] getSuitableClasses()
          Returns the list of PSI element classes which are shown as structure view elements.
protected  boolean isSuitable(PsiElement element)
           
 void removeEditorPositionListener(FileEditorPositionListener listener)
          Removes a listener which gets notified when the selection in the editor linked to the structure view moves to a different element visible in the structure view.
 void removeModelListener(ModelListener modelListener)
          Removes a listener which gets notified when the data represented by the structure view is changed and the structure view needs to be rebuilt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.intellij.ide.structureView.StructureViewModel
getRoot
 
Methods inherited from interface com.intellij.ide.util.treeView.smartTree.TreeModel
getFilters, getGroupers, getSorters
 

Constructor Detail

TextEditorBasedStructureViewModel

protected TextEditorBasedStructureViewModel(@NotNull
                                            PsiFile psiFile)
Creates a structure view model instance linked to a text editor displaying the specified file.

Parameters:
psiFile - the file for which the structure view model is requested.

TextEditorBasedStructureViewModel

protected TextEditorBasedStructureViewModel(Editor editor)
Creates a structure view model instance linked to the specified text editor.

Parameters:
editor - the editor for which the structure view model is requested.
Method Detail

addEditorPositionListener

public final void addEditorPositionListener(FileEditorPositionListener listener)
Description copied from interface: StructureViewModel
Adds a listener which gets notified when the selection in the editor linked to the structure view moves to a different element visible in the structure view.

Specified by:
addEditorPositionListener in interface StructureViewModel
Parameters:
listener - the listener to add.

removeEditorPositionListener

public final void removeEditorPositionListener(FileEditorPositionListener listener)
Description copied from interface: StructureViewModel
Removes a listener which gets notified when the selection in the editor linked to the structure view moves to a different element visible in the structure view.

Specified by:
removeEditorPositionListener in interface StructureViewModel
Parameters:
listener - the listener to remove.

dispose

public void dispose()
Description copied from interface: StructureViewModel
Disposes of the model.

Specified by:
dispose in interface StructureViewModel

getCurrentEditorElement

public java.lang.Object getCurrentEditorElement()
Description copied from interface: StructureViewModel
Returns the element currently selected in the editor linked to the structure view.

Specified by:
getCurrentEditorElement in interface StructureViewModel
Returns:
the selected element, or null if the current editor position does not correspond to any element that can be shown in the structure view.

getPsiFile

protected abstract PsiFile getPsiFile()

isSuitable

protected boolean isSuitable(PsiElement element)

addModelListener

public void addModelListener(ModelListener modelListener)
Description copied from interface: StructureViewModel
Adds a listener which gets notified when the data represented by the structure view is changed and the structure view needs to be rebuilt.

Specified by:
addModelListener in interface StructureViewModel
Parameters:
modelListener - the listener to add.

removeModelListener

public void removeModelListener(ModelListener modelListener)
Description copied from interface: StructureViewModel
Removes a listener which gets notified when the data represented by the structure view is changed and the structure view needs to be rebuilt.

Specified by:
removeModelListener in interface StructureViewModel
Parameters:
modelListener - the listener to remove.

getSuitableClasses

@NotNull
protected abstract java.lang.Class[] getSuitableClasses()
Returns the list of PSI element classes which are shown as structure view elements. When determining the current editor element, the PSI tree is walked up until an element matching one of these classes is found.

Returns:
the list of classes

getEditor

protected Editor getEditor()