public abstract class JavaRefactoringActionDelegate extends Object
Usage:
Implement this class to provide a RefactoringUI for your refactoring.
Include a static method on your implementation which instantiates an
instance of your JavaRefactoringActionDelegate and passes it to
JavaRefactoringActionDelegate.createAction()
.
Register an action in your module‘s XML Layer, in the folder for
the menu (toolbar button, keybinding, etc.) where you want it to appear -
typically Menu/Refactorings
. Set the
instanceCreate
attribute to the fully qualified path to the
static method you created (which should return javax.swing.Action
.
Example Registration
<filesystem> <folder name="Menu"> <folder name="Refactoring"> <file name="MyRefactoring.shadow"> <attr name="originalFile" stringvalue="Actions/Refactoring/MyRefactoring.instance"/> </file> </folder> </folder> <folder name="Actions"> <folder name="Refactoring"> <file name="MyRefactoring.instance"> <attr name="instanceCreate" methodvalue="com.foo.MyClass.myStaticMethod"/> </file> </folder> </folder> </filesystem>
Modifier | Constructor and Description |
---|---|
protected |
JavaRefactoringActionDelegate(String name)
Create a new refactoring action delegate which does not require a
text selection, with the passed name.
|
protected |
JavaRefactoringActionDelegate(String name,
boolean requiresSelection)
Create a new refactoring action delegate which may require a
text selection, with the passed name.
|
Modifier and Type | Method and Description |
---|---|
static Action |
createAction(JavaRefactoringActionDelegate delegate)
Create an Action which should appear in menus to invoke this refactoring.
|
abstract RefactoringUI |
createRefactoringUI(TreePathHandle selectedElement,
int startOffset,
int endOffset,
CompilationInfo info)
Create the refactoring UI which will be used to configure and invoke
the refactoring.
|
String |
getErrorMessage()
Get an error message to be shown to the user if the creaetRefactoringUI()
has just returned null.
|
protected boolean |
isEnabled(Lookup context)
Determine if the action should be enabled.
|
protected JavaRefactoringActionDelegate(String name)
name
- The display name of the actionprotected JavaRefactoringActionDelegate(String name, boolean requiresSelection)
name
- The display name of the actionrequiresSelection
- if true, isEnabled() will return false unless
there is a text selection in the editorpublic abstract RefactoringUI createRefactoringUI(TreePathHandle selectedElement, int startOffset, int endOffset, CompilationInfo info)
public String getErrorMessage()
public static Action createAction(JavaRefactoringActionDelegate delegate)
delegate
- An instance of JavaRefactoringActionDelegate which the
resulting action will call to create the refactoring ui.protected boolean isEnabled(Lookup context)
requiresSelection
was passed to the constructor, it also depends on a text selection in that
editor being present.context
- A Lookup containing either an EditorCookie or one or more
Nodes whose lookup contains an EditorCookie