An
JavaElementSelector
is an interface which implementations are used to find selected Java element from
a view.
The implementation of
JavaElementSelector
has 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
ElementSelector
to find currently selected Java element.
The
ElementSelector
s should be registered in extension.xml within
java-selector-hook
element.
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
JavaElementSelector
can
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.SelectedElement
to return can be created either by method
createSelectedSourceElement(SourceElement)
or
createSelectedJavaPackage(JavaPackage)
The
JavaElementSelector
is 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
.