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.debug.ui.launchConfigurations.JavaClasspathTab;
006: import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
007: import org.enhydra.tool.ToolBoxInfo;
008:
009: import org.eclipse.core.runtime.Path;
010: import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
011: import org.eclipse.jdt.launching.JavaRuntime;
012:
013: import java.io.File;
014: import java.util.ArrayList;
015: import java.util.List;
016:
017: /**
018: * @author Administrator
019: *
020: * To change this generated comment edit the template variable "typecomment":
021: * Window>Preferences>Java>Templates.
022: * To enable and disable the creation of type comments go to
023: * Window>Preferences>Java>Code Generation.
024: */
025: public class EnhydraEnterpriseJOnASClasspathTab extends
026: JavaClasspathTab {
027:
028: /**
029: * Constructor for EnhydraEnterpriseJOnASClasspathTab.
030: */
031: public EnhydraEnterpriseJOnASClasspathTab() {
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: List classpath = new ArrayList();
043:
044: IRuntimeClasspathEntry[] myClasspath = createMyClasspaths();
045: if (myClasspath != null) {
046: for (int i = 0; i < myClasspath.length; i++) {
047: classpath.add(myClasspath[i].getMemento());
048: }
049: }
050:
051: IRuntimeClasspathEntry[] entries = JavaRuntime
052: .computeUnresolvedRuntimeClasspath(configuration);
053: if (entries != null) {
054: for (int i = 0; i < entries.length; i++) {
055: if (entries[i].getClasspathProperty() != entries[i].USER_CLASSES) {
056: classpath.add(entries[i].getMemento());
057: }
058: }
059: }
060:
061: configuration.setAttribute(
062: IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
063: classpath);
064: configuration
065: .setAttribute(
066: IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
067: false);
068: } catch (CoreException e) {
069: }
070: }
071:
072: public IRuntimeClasspathEntry[] createMyClasspaths() {
073:
074: File path = new File(ToolBoxInfo.getEnhydraRoot());
075: path = path.getParentFile();
076: String enhydraRoot = path.getAbsolutePath();
077:
078: final int jarFileElements = 2;
079:
080: IRuntimeClasspathEntry[] myClasspaths = new IRuntimeClasspathEntry[jarFileElements];
081:
082: int i = 0;
083: myClasspaths[i] = JavaRuntime
084: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
085: + "/lib/common/ow_jonas_bootstrap.jar"));
086: myClasspaths[i]
087: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
088:
089: i++;
090: myClasspaths[i] = JavaRuntime
091: .newArchiveRuntimeClasspathEntry(new Path(enhydraRoot
092: + "/conf"));
093: myClasspaths[i]
094: .setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
095:
096: return myClasspaths;
097:
098: }
099:
100: }
|