An
JavaElementSelectoris an interface which implementations are used to find selected Java element from
a view.
The implementation of
JavaElementSelectorhas to be public class with a default public construct so that
the new instance be created by calling Class.newInstance().
Each view can have one or more implementations of
ElementSelectorto find currently selected Java element.
The
ElementSelectors should be registered in extension.xml within
java-selector-hookelement.
Example - CodeEditorElementSelector should be able to find selected Java element from CodeEditor view:
<java-selector-hook xmlns="http://xmlns.oracle.com/ide/extension">
<viewJavaElementSelector
selector-class="oracle.jdevimpl.java.editing.CodeEditorElementSelector"
view-class="oracle.ide.ceditor.CodeEditor"/>
</java-selector-hook>
To force usage of concrete ElementSelector for only once withouth any registration the
JavaElementSelectorcan
be set as a propery of the Context. Look at the constant
SOURCE_ELEMENT_SELECTOR.
When implementing method
#getCurrentElement(Context,T)try to return the most detail source element which
is currently selected, for example the caret is within the element code.
The
JavaElementSelector.SelectedElementto return can be created either by method
createSelectedSourceElement(SourceElement)or
createSelectedJavaPackage(JavaPackage)
The
JavaElementSelectoris used by module refactoring-java to refactor or find usages of Java elements.
It is supposed that each view which wants to refactoring any Java element which is currently selected can supply
this element using
JavaElementSelector.