01: package org.enhydra.kelp.eclipse.actions;
02:
03: import org.eclipse.core.resources.IProject;
04: import org.eclipse.core.resources.IResource;
05: import org.eclipse.core.runtime.CoreException;
06: import org.eclipse.jface.action.IAction;
07: import org.eclipse.jface.viewers.ISelection;
08: import org.eclipse.ui.IWorkbenchWindow;
09: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
10: import org.enhydra.kelp.ant.deployer.AntDeployTool;
11: import org.eclipse.debug.ui.DebugUITools;
12: import org.eclipse.debug.internal.ui.DebugUIPlugin;
13: import org.eclipse.swt.widgets.Shell;
14:
15: /**
16: * Insert the type's description here.
17: * @see IWorkbenchWindowActionDelegate
18: */
19: public class DeployAction implements IWorkbenchWindowActionDelegate {
20: /**
21: * The constructor.
22: */
23: public DeployAction() {
24: }
25:
26: /**
27: * Insert the method's description here.
28: * @see IWorkbenchWindowActionDelegate#run
29: */
30: public void run(IAction action) {
31: IProject project = null;
32: String prjPath = null;
33:
34: IResource res = DebugUITools.getSelectedResource();
35: project = res.getProject();
36:
37: if (project != null) {
38: prjPath = project.getLocation().toString();
39:
40: AntDeployTool.main(new String[] { prjPath });
41: // Refresh project, so the generated files could be visible
42: try {
43: project.refreshLocal(IResource.DEPTH_INFINITE, null);
44: } catch (CoreException ce) {
45: DebugUIPlugin
46: .errorDialog(
47: getShell(),
48: "Error refreshing application project",
49: "Please, sellect valid application project before starting this action!",
50: ce);
51: }
52: } else
53: //System.err.println("Fail to start Deployer, no project is selected!");
54: DebugUIPlugin
55: .errorDialog(
56: getShell(),
57: "Error getting application project",
58: "Please, sellect valid application project before starting this action!",
59: new Exception("Project is null!"));
60: }
61:
62: protected Shell getShell() {
63: return DebugUIPlugin.getShell();
64: }
65:
66: /**
67: * Insert the method's description here.
68: * @see IWorkbenchWindowActionDelegate#selectionChanged
69: */
70: public void selectionChanged(IAction action, ISelection selection) {
71: }
72:
73: /**
74: * Insert the method's description here.
75: * @see IWorkbenchWindowActionDelegate#dispose
76: */
77: public void dispose() {
78: }
79:
80: /**
81: * Insert the method's description here.
82: * @see IWorkbenchWindowActionDelegate#init
83: */
84: public void init(IWorkbenchWindow window) {
85: }
86: }
|