com.ibm.jdg2e.jdt
Class AddTraceStatementsEditorAction

java.lang.Object
  extended bycom.ibm.jdg2e.jdt.AddTraceStatementsAction
      extended bycom.ibm.jdg2e.jdt.AddTraceStatementsEditorAction
All Implemented Interfaces:
org.eclipse.ui.IActionDelegate, org.eclipse.ui.IEditorActionDelegate

public class AddTraceStatementsEditorAction
extends AddTraceStatementsAction
implements org.eclipse.ui.IEditorActionDelegate

The purpose of AddTraceStatementEditorAction is to demonstrate how to add simple code modifications ("refactoring") to the Java editor. This action adds System.out.println statements, including all parameters, to the beginning of each method.

See Also:
IBuffer, JavaCore, IWorkingCopyManager, ICompilationUnit

Nested Class Summary
protected static class AddTraceStatementsEditorAction.JavaMethodCollector
          An AST visitor that traverses a compilation unit and gathers all instances of MethodDeclaration, whether they be in the top-level class, inner classes, or anonymous classes.
 
Constructor Summary
AddTraceStatementsEditorAction()
           
 
Method Summary
 void run(org.eclipse.jface.action.IAction action)
          Traverse all the ICompilationUnit's methods using an AST, calculating the position of each, and adding System.out.println for each method parameter.
 void setActiveEditor(org.eclipse.jface.action.IAction action, org.eclipse.ui.IEditorPart targetEditor)
          Instances of IEditorActionDelegate are shared among editors of the same type; this method notifies the action that it now "works" for another editor.
 
Methods inherited from class com.ibm.jdg2e.jdt.AddTraceStatementsAction
addTraceStatement, createTraceStatement, selectionChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IActionDelegate
selectionChanged
 

Constructor Detail

AddTraceStatementsEditorAction

public AddTraceStatementsEditorAction()
Method Detail

run

public void run(org.eclipse.jface.action.IAction action)
Traverse all the ICompilationUnit's methods using an AST, calculating the position of each, and adding System.out.println for each method parameter.

Specified by:
run in interface org.eclipse.ui.IActionDelegate
See Also:
IActionDelegate.run(IAction action)

setActiveEditor

public void setActiveEditor(org.eclipse.jface.action.IAction action,
                            org.eclipse.ui.IEditorPart targetEditor)
Instances of IEditorActionDelegate are shared among editors of the same type; this method notifies the action that it now "works" for another editor. This determines the context for availability of this action and the target of the run method.

Specified by:
setActiveEditor in interface org.eclipse.ui.IEditorActionDelegate