1 package net.sourceforge.phpeclipse.example.outline;
3 import org.eclipse.core.resources.*;
4 import net.sourceforge.phpdt.core.*;
5 import org.eclipse.jface.action.*;
6 import org.eclipse.jface.viewers.*;
7 import org.eclipse.ui.*;
9 public class Import2Console implements IObjectActionDelegate {
11 private IWorkbenchPartSite myPartSite = null;
13 private IWorkspace myWorkspace = null;
15 private IWorkbenchPart myWorkbenchPart = null;
17 private IImportDeclaration myType = null;
19 public Import2Console() {
20 // this(new PackageSelector());
23 // public CreateMock(IPackageSelector aPackageSelector) {
24 // myPackageSelector = aPackageSelector;
28 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
30 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
31 myWorkspace = ResourcesPlugin.getWorkspace();
32 myWorkbenchPart = targetPart;
36 * @see IActionDelegate#run(IAction)
38 public void run(IAction action) {
40 String actionId = action.getId();
41 showSourceInConsole(actionId);
42 } catch (Exception e) {
48 * @see IActionDelegate#selectionChanged(IAction, ISelection)
50 public void selectionChanged(IAction action, ISelection selection) {
51 if (selection instanceof IStructuredSelection) {
52 Object item = ((IStructuredSelection) selection).getFirstElement();
53 myType = (IImportDeclaration) item; // this plugin only reacts to IImportDeclaration's
57 private void showSourceInConsole(String actionId) throws Exception {
59 String src = myType.getSource();
60 System.out.println(actionId);
61 System.out.println("Source :"+src);