KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > eclipse > actions > DeployAction


1 package org.enhydra.kelp.eclipse.actions;
2
3 import java.awt.Frame JavaDoc;
4
5 import org.eclipse.core.resources.IProject;
6 import org.eclipse.core.resources.IResource;
7 import org.eclipse.jdt.core.IJavaElement;
8 import org.eclipse.jface.action.IAction;
9 import org.eclipse.jface.viewers.ISelection;
10 import org.eclipse.jface.viewers.IStructuredSelection;
11 import org.eclipse.ui.IWorkbenchPage;
12 import org.eclipse.ui.IWorkbenchWindow;
13 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
14 import org.enhydra.kelp.ant.deployer.AntDeployTool;
15 import org.enhydra.kelp.ant.node.AntProject;
16 import org.enhydra.kelp.eclipse.KelpPlugin;
17
18 /**
19  * Insert the type's description here.
20  * @see IWorkbenchWindowActionDelegate
21  */

22 public class DeployAction implements IWorkbenchWindowActionDelegate {
23     /**
24      * The constructor.
25      */

26     public DeployAction() {
27     }
28
29     /**
30      * Insert the method's description here.
31      * @see IWorkbenchWindowActionDelegate#run
32      */

33     public void run(IAction action) {
34         IProject project = null;
35         String JavaDoc prjName = null;
36         String JavaDoc prjPath = null;
37
38         IWorkbenchPage page = KelpPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
39         if (page != null) {
40             ISelection selection = page.getSelection();
41             if (selection instanceof IStructuredSelection) {
42                 IStructuredSelection ss = (IStructuredSelection)selection;
43                 if (!ss.isEmpty()) {
44                     Object JavaDoc obj = ss.getFirstElement();
45                     if (obj instanceof IJavaElement) {
46                         IResource res =((IJavaElement)obj).getResource();
47                         if (res == null)
48                             project = ((IJavaElement)obj).getJavaProject().getProject();
49                         else
50                             project = res.getProject();
51                             
52                     }
53                     if (obj instanceof IResource) {
54                             project = ((IResource)obj).getProject();
55                     }
56                 }
57             }
58         }
59         if (project != null) {
60             prjName = project.getName();
61             prjPath = project.getLocation().toString();
62         
63 //---------------------Dacha---------------------------------
64

65             AntDeployTool.main(new String JavaDoc[]{prjPath});
66         }else
67             System.err.println("Fail to start Deployer, no project is selected!");
68     }
69
70     /**
71      * Insert the method's description here.
72      * @see IWorkbenchWindowActionDelegate#selectionChanged
73      */

74     public void selectionChanged(IAction action, ISelection selection) {
75     }
76
77     /**
78      * Insert the method's description here.
79      * @see IWorkbenchWindowActionDelegate#dispose
80      */

81     public void dispose() {
82     }
83
84     /**
85      * Insert the method's description here.
86      * @see IWorkbenchWindowActionDelegate#init
87      */

88     public void init(IWorkbenchWindow window) {
89     }
90 }
91
Popular Tags