001: package org.enhydra.kelp.eclipse.ui.launcher;
002:
003: import org.eclipse.core.runtime.CoreException;
004: import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
005: import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
006: import org.enhydra.tool.ToolBoxInfo;
007:
008: import org.eclipse.core.runtime.Path;
009: import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
010: import org.eclipse.jdt.launching.JavaRuntime;
011:
012: import java.io.File;
013: import java.util.ArrayList;
014: import java.util.List;
015:
016: import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
017:
018: /**
019: * @author Administrator
020: *
021: * To change this generated comment edit the template variable "typecomment":
022: * Window>Preferences>Java>Templates.
023: * To enable and disable the creation of type comments go to
024: * Window>Preferences>Java>Code Generation.
025: */
026: public class EnhydraSourceLookupTab extends SourceLookupTab {
027:
028: /**
029: * Constructor for EnhydraArgumentsTab.
030: */
031: public EnhydraSourceLookupTab() {
032: super ();
033: }
034:
035: /**
036: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
037: */
038: public void setDefaults(
039: ILaunchConfigurationWorkingCopy configuration) {
040: super .setDefaults(configuration);
041: try {
042:
043: List classpath = new ArrayList();
044:
045: IRuntimeClasspathEntry[] myClasspath = createMyClasspaths();
046: if (myClasspath != null) {
047: for (int i = 0; i < myClasspath.length; i++) {
048: classpath.add(myClasspath[i].getMemento());
049: }
050: }
051:
052: //IRuntimeClasspathEntry[] entries= JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
053: IRuntimeClasspathEntry[] entries = JavaRuntime
054: .computeUnresolvedRuntimeClasspath(configuration);
055: if (entries != null) {
056: for (int i = 0; i < entries.length; i++) {
057: classpath.add(entries[i].getMemento());
058: }
059: }
060:
061: configuration.setAttribute(
062: IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH,
063: classpath);
064: configuration
065: .setAttribute(
066: IJavaLaunchConfigurationConstants.ATTR_DEFAULT_SOURCE_PATH,
067: false);
068:
069: } catch (CoreException e) {
070: }
071:
072: }
073:
074: private IRuntimeClasspathEntry[] createMyClasspaths() {
075:
076: File path = new File(ToolBoxInfo.getEnhydraRoot());
077: path = path.getParentFile();
078: String enhydraRoot = path.getAbsolutePath();
079:
080: final int jarFileElements = 2;
081:
082: IRuntimeClasspathEntry[] myClasspaths = new IRuntimeClasspathEntry[jarFileElements];
083:
084: int i = 0;
085: myClasspaths[i] = JavaRuntime
086: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
087: + "/bin/bootstrap.jar"));
088: myClasspaths[i]
089: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
090:
091: i++;
092: myClasspaths[i] = JavaRuntime
093: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
094: + "/conf"));
095: myClasspaths[i]
096: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
097:
098: return myClasspaths;
099:
100: }
101:
102: }
|