1 package net.sourceforge.phpeclipse.example.outline;
3 import net.sourceforge.phpdt.core.IImportDeclaration;
5 import org.eclipse.core.resources.IWorkspace;
6 import org.eclipse.core.resources.ResourcesPlugin;
7 import org.eclipse.jface.action.IAction;
8 import org.eclipse.jface.viewers.ISelection;
9 import org.eclipse.jface.viewers.IStructuredSelection;
10 import org.eclipse.ui.IActionDelegate;
11 import org.eclipse.ui.IObjectActionDelegate;
12 import org.eclipse.ui.IWorkbenchPart;
13 import org.eclipse.ui.IWorkbenchPartSite;
15 public class Import2Console implements IObjectActionDelegate {
17 private IWorkbenchPartSite myPartSite = null;
19 private IWorkspace myWorkspace = null;
21 private IWorkbenchPart myWorkbenchPart = null;
23 private IImportDeclaration myType = null;
25 public Import2Console() {
26 // this(new PackageSelector());
29 // public CreateMock(IPackageSelector aPackageSelector) {
30 // myPackageSelector = aPackageSelector;
34 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
36 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
37 myWorkspace = ResourcesPlugin.getWorkspace();
38 myWorkbenchPart = targetPart;
42 * @see IActionDelegate#run(IAction)
44 public void run(IAction action) {
46 String actionId = action.getId();
47 showSourceInConsole(actionId);
48 } catch (Exception e) {
54 * @see IActionDelegate#selectionChanged(IAction, ISelection)
56 public void selectionChanged(IAction action, ISelection selection) {
57 if (selection instanceof IStructuredSelection) {
58 Object item = ((IStructuredSelection) selection).getFirstElement();
59 myType = (IImportDeclaration) item; // this plugin only reacts to
60 // IImportDeclaration's
64 private void showSourceInConsole(String actionId) throws Exception {
66 String src = myType.getSource();
67 System.out.println(actionId);
68 System.out.println("Source :" + src);