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.xmlc.AntXMLCTool;
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 XMLCAction implements IWorkbenchWindowActionDelegate {
20: /**
21: * The constructor.
22: */
23: public XMLCAction() {
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: AntXMLCTool.main(new String[] { prjPath });
41:
42: // Refresh project, so the generated files could be visible
43: try {
44: project.refreshLocal(IResource.DEPTH_INFINITE, null);
45: } catch (CoreException ce) {
46: DebugUIPlugin
47: .errorDialog(
48: getShell(),
49: "Error refreshing application project",
50: "Please, sellect valid application project before starting this action!",
51: ce);
52: }
53: } else
54: //System.err.println("Fail to start XML Compiler, no project is selected!");
55: DebugUIPlugin
56: .errorDialog(
57: getShell(),
58: "Error getting application project",
59: "Please, sellect valid application project before starting this action!",
60: new Exception("Project is null!"));
61: }
62:
63: protected Shell getShell() {
64: return DebugUIPlugin.getShell();
65: }
66:
67: /**
68: * Insert the method's description here.
69: * @see IWorkbenchWindowActionDelegate#selectionChanged
70: */
71: public void selectionChanged(IAction action, ISelection selection) {
72: }
73:
74: /**
75: * Insert the method's description here.
76: * @see IWorkbenchWindowActionDelegate#dispose
77: */
78: public void dispose() {
79: }
80:
81: /**
82: * Insert the method's description here.
83: * @see IWorkbenchWindowActionDelegate#init
84: */
85: public void init(IWorkbenchWindow window) {
86: }
87: }
|