01: package org.enhydra.kelp.eclipse.ui.launcher;
02:
03: import org.eclipse.core.runtime.CoreException;
04: import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
05: import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
06: import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
07: import org.enhydra.tool.ToolBoxInfo;
08:
09: import org.eclipse.core.runtime.Path;
10: import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
11: import org.eclipse.jdt.launching.JavaRuntime;
12:
13: import java.io.File;
14: import java.util.ArrayList;
15: import java.util.List;
16:
17: /**
18: * @author Administrator
19: *
20: * To change this generated comment edit the template variable "typecomment":
21: * Window>Preferences>Java>Templates.
22: * To enable and disable the creation of type comments go to
23: * Window>Preferences>Java>Code Generation.
24: */
25: public class EnhydraClasspathTab extends JavaClasspathTab {
26:
27: /**
28: * Constructor for EnhydraArgumentsTab.
29: */
30: public EnhydraClasspathTab() {
31: super ();
32: }
33:
34: /**
35: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
36: */
37: public void setDefaults(
38: ILaunchConfigurationWorkingCopy configuration) {
39: super .setDefaults(configuration);
40: try {
41: List classpath = new ArrayList();
42:
43: IRuntimeClasspathEntry[] myClasspath = createMyClasspaths();
44: if (myClasspath != null) {
45: for (int i = 0; i < myClasspath.length; i++) {
46: classpath.add(myClasspath[i].getMemento());
47: }
48: }
49:
50: IRuntimeClasspathEntry[] entries = JavaRuntime
51: .computeUnresolvedRuntimeClasspath(configuration);
52: if (entries != null) {
53: for (int i = 0; i < entries.length; i++) {
54: if (entries[i].getClasspathProperty() != entries[i].USER_CLASSES) {
55: classpath.add(entries[i].getMemento());
56: }
57: }
58: }
59:
60: configuration.setAttribute(
61: IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
62: classpath);
63: configuration
64: .setAttribute(
65: IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
66: false);
67: } catch (CoreException e) {
68: }
69: }
70:
71: public IRuntimeClasspathEntry[] createMyClasspaths() {
72:
73: File path = new File(ToolBoxInfo.getEnhydraRoot());
74: path = path.getParentFile();
75: String enhydraRoot = path.getAbsolutePath();
76:
77: final int jarFileElements = 2;
78:
79: IRuntimeClasspathEntry[] myClasspaths = new IRuntimeClasspathEntry[jarFileElements];
80:
81: int i = 0;
82: myClasspaths[i] = JavaRuntime
83: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
84: + "/bin/bootstrap.jar"));
85: myClasspaths[i]
86: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
87:
88: i++;
89: myClasspaths[i] = JavaRuntime
90: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
91: + "/conf"));
92: myClasspaths[i]
93: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
94:
95: return myClasspaths;
96:
97: }
98:
99: }
|