CVS test
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / example / outline / Import2Console.java
1 package net.sourceforge.example.outline;
2
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.*;
8
9 public class Import2Console implements IObjectActionDelegate {
10
11     private IWorkbenchPartSite myPartSite = null;
12
13     private IWorkspace myWorkspace = null;
14
15     private IWorkbenchPart myWorkbenchPart = null;
16
17     private IImportDeclaration myType = null;
18
19     public Import2Console() {
20         //              this(new PackageSelector());
21     }
22
23     //  public CreateMock(IPackageSelector aPackageSelector) {
24     //          myPackageSelector = aPackageSelector;
25     //  }
26
27     /**
28      * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
29      */
30     public void setActivePart(IAction action, IWorkbenchPart targetPart) {
31         myWorkspace = ResourcesPlugin.getWorkspace();
32         myWorkbenchPart = targetPart;
33     }
34
35     /**
36      * @see IActionDelegate#run(IAction)
37      */
38     public void run(IAction action) {
39         try {
40             String actionId = action.getId();
41             showSourceInConsole(actionId);
42         } catch (Exception e) {
43             e.printStackTrace();
44         }
45     }
46
47     /**
48      * @see IActionDelegate#selectionChanged(IAction, ISelection)
49      */
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
54         }
55     }
56
57     private void showSourceInConsole(String actionId) throws Exception {
58
59         String src = myType.getSource();
60         System.out.println("Source :"+src);
61         
62     }
63
64 }