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 EnhydraEnterpriseJOnASSourceLookupTab extends
027: SourceLookupTab {
028:
029: /**
030: * Constructor for EnhydraEnterpriseJOnASSourceLookupTab.
031: */
032: public EnhydraEnterpriseJOnASSourceLookupTab() {
033: super ();
034: }
035:
036: /**
037: * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
038: */
039: public void setDefaults(
040: ILaunchConfigurationWorkingCopy configuration) {
041: super .setDefaults(configuration);
042: try {
043:
044: List classpath = new ArrayList();
045:
046: IRuntimeClasspathEntry[] myClasspath = createMyClasspaths();
047: if (myClasspath != null) {
048: for (int i = 0; i < myClasspath.length; i++) {
049: classpath.add(myClasspath[i].getMemento());
050: }
051: }
052:
053: //IRuntimeClasspathEntry[] entries= JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
054: IRuntimeClasspathEntry[] entries = JavaRuntime
055: .computeUnresolvedRuntimeClasspath(configuration);
056: if (entries != null) {
057: for (int i = 0; i < entries.length; i++) {
058: classpath.add(entries[i].getMemento());
059: }
060: }
061:
062: configuration.setAttribute(
063: IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH,
064: classpath);
065: configuration
066: .setAttribute(
067: IJavaLaunchConfigurationConstants.ATTR_DEFAULT_SOURCE_PATH,
068: false);
069:
070: } catch (CoreException e) {
071: }
072:
073: }
074:
075: private IRuntimeClasspathEntry[] createMyClasspaths() {
076:
077: File path = new File(ToolBoxInfo.getEnhydraRoot());
078: path = path.getParentFile();
079: String enhydraRoot = path.getAbsolutePath();
080:
081: final int jarFileElements = 2;
082:
083: IRuntimeClasspathEntry[] myClasspaths = new IRuntimeClasspathEntry[jarFileElements];
084:
085: int i = 0;
086: myClasspaths[i] = JavaRuntime
087: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
088: + "/lib/common/ow_jonas_bootstrap.jar"));
089: myClasspaths[i]
090: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
091:
092: i++;
093: myClasspaths[i] = JavaRuntime
094: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
095: + "/conf"));
096: myClasspaths[i]
097: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
098:
099: return myClasspaths;
100:
101: }
102:
103: }
|