X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java index 9c08fa7..e310315 100644 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java +++ b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/example/outline/Type2Console.java @@ -1,75 +1,81 @@ package net.sourceforge.phpeclipse.example.outline; - -import org.eclipse.core.resources.*; -import net.sourceforge.phpdt.core.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; +import net.sourceforge.phpdt.core.IMethod; +import net.sourceforge.phpdt.core.IType; + +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; public class Type2Console implements IObjectActionDelegate { - private IWorkbenchPartSite myPartSite = null; - - private IWorkspace myWorkspace = null; - - private IWorkbenchPart myWorkbenchPart = null; - - private IType myType = null; - - private Shell myShell = new Shell(); // TBReplaced with getShell() - - public Type2Console() { - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - myWorkspace = ResourcesPlugin.getWorkspace(); - myWorkbenchPart = targetPart; - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - try { - - String actionId = action.getId(); - showSourceInConsole(actionId); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - if (selection instanceof IStructuredSelection) { - Object item = ((IStructuredSelection) selection).getFirstElement(); - myType = (IType) item; // this plugin only reacts to - // "org.eclipse.jdt.core.IType" objects - } - } - - private void showSourceInConsole(String actionId) throws Exception { - System.out.println(actionId); - if (!(myType.isInterface() || myType.isClass())) { - throw new Exception("incompatible Type"); - } - - IMethod[] methods = myType.getMethods(); - - String fqname = myType.getFullyQualifiedName(); // a.b.c.d.MyClass - System.out.println(fqname + '\n'); - for (int i = 0; i < methods.length; i++) { - System.out.println("Method " + i + ":" - + methods[i].getElementName()); - } - - } + private IWorkbenchPartSite myPartSite = null; + + private IWorkspace myWorkspace = null; + + private IWorkbenchPart myWorkbenchPart = null; + + private IType myType = null; + + private Shell myShell = new Shell(); // TBReplaced with getShell() + + public Type2Console() { + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + myWorkspace = ResourcesPlugin.getWorkspace(); + myWorkbenchPart = targetPart; + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + try { + + String actionId = action.getId(); + showSourceInConsole(actionId); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object item = ((IStructuredSelection) selection).getFirstElement(); + myType = (IType) item; // this plugin only reacts to + // "org.eclipse.jdt.core.IType" objects + } + } + + private void showSourceInConsole(String actionId) throws Exception { + System.out.println(actionId); + if (!(myType.isInterface() || myType.isClass())) { + throw new Exception("incompatible Type"); + } + + IMethod[] methods = myType.getMethods(); + + String fqname = myType.getFullyQualifiedName(); // a.b.c.d.MyClass + System.out.println(fqname + '\n'); + for (int i = 0; i < methods.length; i++) { + System.out.println("Method " + i + ":" + + methods[i].getElementName()); + } + + } }