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