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 EnhydraEnterpriseJBossClasspathTab extends
26: JavaClasspathTab {
27:
28: /**
29: * Constructor for EnhydraEnterpriseJBossClasspathTab.
30: */
31: public EnhydraEnterpriseJBossClasspathTab() {
32: super ();
33: }
34:
35: /**
36: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
37: */
38: public void setDefaults(
39: ILaunchConfigurationWorkingCopy configuration) {
40: super .setDefaults(configuration);
41: try {
42: List classpath = new ArrayList();
43:
44: IRuntimeClasspathEntry[] myClasspath = createMyClasspaths();
45: if (myClasspath != null) {
46: for (int i = 0; i < myClasspath.length; i++) {
47: classpath.add(myClasspath[i].getMemento());
48: }
49: }
50:
51: IRuntimeClasspathEntry[] entries = JavaRuntime
52: .computeUnresolvedRuntimeClasspath(configuration);
53: if (entries != null) {
54: for (int i = 0; i < entries.length; i++) {
55: if (entries[i].getClasspathProperty() != entries[i].USER_CLASSES) {
56: classpath.add(entries[i].getMemento());
57: }
58: }
59: }
60:
61: configuration.setAttribute(
62: IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
63: classpath);
64: configuration
65: .setAttribute(
66: IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
67: false);
68: } catch (CoreException e) {
69: }
70: }
71:
72: public IRuntimeClasspathEntry[] createMyClasspaths() {
73:
74: File path = new File(ToolBoxInfo.getEnhydraRoot());
75: path = path.getParentFile();
76: String enhydraRoot = path.getAbsolutePath();
77:
78: final int jarFileElements = 1;
79:
80: IRuntimeClasspathEntry[] myClasspaths = new IRuntimeClasspathEntry[jarFileElements];
81:
82: int i = 0;
83: myClasspaths[i] = JavaRuntime
84: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
85: + "/bin/run.jar"));
86: myClasspaths[i]
87: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
88:
89: return myClasspaths;
90:
91: }
92:
93: }
|