1 package org.enhydra.kelp.eclipse.actions; 2 3 import java.awt.Frame ; 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 22 public class DeployAction implements IWorkbenchWindowActionDelegate { 23 26 public DeployAction() { 27 } 28 29 33 public void run(IAction action) { 34 IProject project = null; 35 String prjName = null; 36 String 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 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 65 AntDeployTool.main(new String []{prjPath}); 66 }else 67 System.err.println("Fail to start Deployer, no project is selected!"); 68 } 69 70 74 public void selectionChanged(IAction action, ISelection selection) { 75 } 76 77 81 public void dispose() { 82 } 83 84 88 public void init(IWorkbenchWindow window) { 89 } 90 } 91 | Popular Tags |