01: package org.enhydra.kelp.eclipse.actions;
02:
03: import java.io.File;
04: import java.io.IOException;
05:
06: import javax.swing.JFileChooser;
07: import javax.swing.JOptionPane;
08:
09: import org.eclipse.core.resources.IProject;
10: import org.eclipse.core.resources.IResource;
11: import org.eclipse.core.runtime.CoreException;
12: import org.eclipse.debug.internal.ui.DebugUIPlugin;
13: import org.eclipse.debug.ui.DebugUITools;
14: import org.eclipse.jface.action.IAction;
15: import org.eclipse.jface.viewers.ISelection;
16: import org.eclipse.swt.widgets.Shell;
17: import org.eclipse.ui.IWorkbenchWindow;
18: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
19:
20: public class PathAction implements IWorkbenchWindowActionDelegate {
21:
22: public void dispose() {
23: // TODO Auto-generated method stub
24: }
25:
26: public void init(IWorkbenchWindow arg0) {
27: // TODO Auto-generated method stub
28: }
29:
30: public void run(IAction arg0) {
31: JFileChooser chooser = new JFileChooser();
32: chooser.setCurrentDirectory(new File("/"));
33: chooser.setDialogTitle("Choose TAS Root!");
34: chooser.setApproveButtonText("Configure");
35: chooser.setApproveButtonToolTipText("Select TAS Root folder");
36: chooser.setFileSelectionMode(chooser.DIRECTORIES_ONLY);
37: int returnVal = chooser.showOpenDialog(null);
38: while (returnVal == JFileChooser.APPROVE_OPTION) {
39: try {
40: String eafJarPath = chooser.getSelectedFile()
41: .getAbsolutePath()
42: + File.separator
43: + "enhydra"
44: + File.separator
45: + "lib" + File.separator + "eaf.jar";
46: File eafJar = new File(eafJarPath);
47: File tasRoot = new File(chooser.getSelectedFile()
48: .getAbsolutePath());
49: if (eafJar.exists()) {
50: addEnhydraRoot(tasRoot);
51: break;
52: } else {
53: JOptionPane.showMessageDialog(null,
54: "Invalid TAS Directory", "TAS Root Error",
55: JOptionPane.ERROR_MESSAGE);
56: returnVal = chooser.showOpenDialog(null);
57: }
58: } catch (Exception e) {
59: JOptionPane.showMessageDialog(null,
60: "Invalid TAS Directory", "TAS Root Error",
61: JOptionPane.ERROR_MESSAGE);
62: }
63: }
64: }
65:
66: private void addEnhydraRoot(File tasRoot) {
67: try {
68: String[] params = new String[1];
69: params[0] = tasRoot.getAbsolutePath() + "/enhydra";
70: org.enhydra.tool.InitEnhydraRoot.main(params);
71: JOptionPane.showMessageDialog(null,
72: "TAS Root Set Successfully", "TAS Path is Set",
73: JOptionPane.INFORMATION_MESSAGE);
74: } catch (Exception e) {
75: JOptionPane.showMessageDialog(null,
76: "Invalid TAS Directory", "TAS Root Error",
77: JOptionPane.ERROR_MESSAGE);
78: }
79: }
80:
81: protected Shell getShell() {
82: return DebugUIPlugin.getShell();
83: }
84:
85: public void selectionChanged(IAction arg0, ISelection arg1) {
86: // TODO Auto-generated method stub
87:
88: }
89: }
|