Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 79685 Details for
Bug 201758
Breaking change in IVMInstall.getInstallLocation()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
ee-update-oct3.patch (text/plain), 154.92 KB, created by
Darin Wright
on 2007-10-03 18:11:47 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2007-10-03 18:11:47 EDT
Size:
154.92 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.launching >Index: launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java,v >retrieving revision 1.23 >diff -u -r1.23 LaunchingMessages.java >--- launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java 24 Aug 2007 17:52:38 -0000 1.23 >+++ launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java 3 Oct 2007 22:11:06 -0000 >@@ -40,6 +40,10 @@ > > public static String EEVMType_1; > >+ public static String EEVMType_2; >+ >+ public static String EEVMType_3; >+ > public static String JavaLocalApplicationLaunchConfigurationDelegate_Verifying_launch_attributes____1; > public static String JavaLocalApplicationLaunchConfigurationDelegate_Creating_source_locator____2; > public static String JavaLocalApplicationLaunchConfigurationDelegate_0; >@@ -53,6 +57,8 @@ > public static String JavaRemoteApplicationLaunchConfigurationDelegate_Verifying_launch_attributes____1; > public static String JavaRemoteApplicationLaunchConfigurationDelegate_Creating_source_locator____2; > >+ public static String JavaRuntime_24; >+ > public static String JavaRuntime_25; > > public static String JavaRuntime_badFormat; >Index: launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java,v >retrieving revision 1.53 >diff -u -r1.53 StandardVMRunner.java >--- launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java 30 Jul 2007 18:57:47 -0000 1.53 >+++ launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java 3 Oct 2007 22:11:06 -0000 >@@ -171,11 +171,17 @@ > > // If no java command was specified, use default executable > if (command == null) { >- File exe = StandardVMType.findJavaExecutable(fVMInstance.getInstallLocation()); >+ File exe = null; >+ if (fVMInstance instanceof StandardVM) { >+ exe = ((StandardVM)fVMInstance).getJavaExecutable(); >+ } else { >+ exe = StandardVMType.findJavaExecutable(fVMInstance.getInstallLocation()); >+ } > if (exe == null) { > abort(MessageFormat.format(LaunchingMessages.StandardVMRunner_Unable_to_locate_executable_for__0__1, new String[]{fVMInstance.getName()}), null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR); >+ } else { >+ return exe.getAbsolutePath(); > } >- return exe.getAbsolutePath(); > } > > // Build the path to the java executable. First try 'bin', and if that >Index: launching/org/eclipse/jdt/internal/launching/StandardVM.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVM.java,v >retrieving revision 1.8 >diff -u -r1.8 StandardVM.java >--- launching/org/eclipse/jdt/internal/launching/StandardVM.java 10 Aug 2007 20:00:35 -0000 1.8 >+++ launching/org/eclipse/jdt/internal/launching/StandardVM.java 3 Oct 2007 22:11:06 -0000 >@@ -41,10 +41,7 @@ > StandardVMType installType = (StandardVMType) getVMInstallType(); > File installLocation = getInstallLocation(); > if (installLocation != null) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getJavaVersion(installLocation); >- } >- File executable = StandardVMType.findJavaExecutable(installLocation); >+ File executable = getJavaExecutable(); > if (executable != null) { > String vmVersion = installType.getVMVersion(installLocation, executable); > // strip off extra info >@@ -64,4 +61,19 @@ > } > return null; > } >+ >+ /** >+ * Returns the java executable for this VM or <code>null</code> if cannot be found >+ * >+ * @return executable for this VM or <code>null</code> if none >+ */ >+ File getJavaExecutable() { >+ File installLocation = getInstallLocation(); >+ if (installLocation != null) { >+ return StandardVMType.findJavaExecutable(installLocation); >+ } >+ return null; >+ } >+ >+ > } >Index: launching/org/eclipse/jdt/internal/launching/EEVMType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/EEVMType.java,v >retrieving revision 1.1 >diff -u -r1.1 EEVMType.java >--- launching/org/eclipse/jdt/internal/launching/EEVMType.java 10 Aug 2007 20:00:35 -0000 1.1 >+++ launching/org/eclipse/jdt/internal/launching/EEVMType.java 3 Oct 2007 22:11:06 -0000 >@@ -28,6 +28,9 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.launching.AbstractVMInstall; >+import org.eclipse.jdt.launching.AbstractVMInstallType; >+import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.LibraryLocation; > > import com.ibm.icu.text.MessageFormat; >@@ -38,7 +41,12 @@ > * > * @since 3.4 > */ >-public class EEVMType { >+public class EEVMType extends AbstractVMInstallType { >+ >+ /** >+ * VM Type id >+ */ >+ public static final String ID_EE_VM_TYPE = "org.eclipse.jdt.launching.EEVMType"; //$NON-NLS-1$ > > /** > * Map of {EE File -> {Map of {PropertyName -> PropertyValue}} >@@ -58,55 +66,43 @@ > public static final String PROP_CLASS_LIB_LEVEL = "-Dee.class.library.level"; //$NON-NLS-1$ > public static final String PROP_EXECUTABLE = "-Dee.executable"; //$NON-NLS-1$ > public static final String PROP_EXECUTABLE_CONSOLE = "-Dee.executable.console"; //$NON-NLS-1$ >+ public static final String PROP_JAVA_HOME = "-Djava.home"; //$NON-NLS-1$ > >- private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL}; >- >+ private static final String[] REQUIRED_PROPERTIES = new String[]{PROP_EXECUTABLE, PROP_BOOT_CLASS_PATH, PROP_LANGUAGE_LEVEL, PROP_JAVA_HOME}; >+ > /** >- * Returns whether the given install location corresponds to an .ee file. >+ * Returns the library locations defined in the given definition file. > * >- * @param installLocation >- * @return whether the given install location corresponds to an .ee file. >+ * @param eeFile definition file >+ * @return library locations defined in the file or an empty collection if none > */ >- public static boolean isEEInstall(File installLocation) { >- if (installLocation.isFile()) { >- String name = installLocation.getName(); >- if (name.endsWith(".ee")) { //$NON-NLS-1$ >- return true; >- } >- } >- return false; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) >- */ >- public static LibraryLocation[] getDefaultLibraryLocations(File installLocation) { >+ public static LibraryLocation[] getLibraryLocations(File eeFile) { > >- Map properties = getProperties(installLocation); >+ Map properties = getProperties(eeFile); > if (properties == null) { > return new LibraryLocation[]{}; > } > > List allLibs = new ArrayList(); > >- String dirs = getProperty(PROP_ENDORSED_DIRS, installLocation); >+ String dirs = getProperty(PROP_ENDORSED_DIRS, eeFile); > if (dirs != null) { > // Add all endorsed libraries - they are first, as they replace >- allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation))); >+ allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile))); > } > > // next is the bootpath libraries >- dirs = getProperty(PROP_BOOT_CLASS_PATH, installLocation); >+ dirs = getProperty(PROP_BOOT_CLASS_PATH, eeFile); > if (dirs != null) { >- String[] bootpath = resolvePaths(dirs, installLocation); >+ String[] bootpath = resolvePaths(dirs, eeFile); > List boot = new ArrayList(bootpath.length); >- URL url = getDefaultJavadocLocation(installLocation); >+ URL url = getJavadocLocation(eeFile); > for (int i = 0; i < bootpath.length; i++) { > IPath path = new Path(bootpath[i]); > File lib = path.toFile(); > if (lib.exists() && lib.isFile()) { > LibraryLocation libraryLocation = new LibraryLocation(path, >- getDefaultSourceLocation(installLocation), >+ getDefaultSourceLocation(eeFile), > Path.EMPTY, > url); > boot.add(libraryLocation); >@@ -116,9 +112,9 @@ > } > > // Add all extension libraries >- dirs = getProperty(PROP_EXTENSION_DIRS, installLocation); >+ dirs = getProperty(PROP_EXTENSION_DIRS, eeFile); > if (dirs != null) { >- allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, installLocation))); >+ allLibs.addAll(StandardVMType.gatherAllLibraries(resolvePaths(dirs, eeFile))); > } > > >@@ -135,24 +131,50 @@ > return (LibraryLocation[])allLibs.toArray(new LibraryLocation[allLibs.size()]); > } > >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File) >+ >+ /** >+ * Returns the javadoc location specified in the definition file or <code>null</code> >+ * if none. >+ * >+ * @param eeFile definition file >+ * @return javadoc location specified in the definition file or <code>null</code> if none > */ >- public static URL getDefaultJavadocLocation(File installLocation) { >- String version = getProperty(PROP_LANGUAGE_LEVEL, installLocation); >+ public static URL getJavadocLocation(File eeFile) { >+ String version = getProperty(PROP_LANGUAGE_LEVEL, eeFile); > if (version != null) { > return StandardVMType.getDefaultJavadocLocation(version); > } > return null; > } > >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File) >+ /** >+ * Returns the definition file associated with the given VM or <code>null</code> >+ * if none. >+ * >+ * @param vm VM install >+ * @return definition file or <code>null</code> if none. The file may/may not exist. >+ */ >+ public static File getDefinitionFile(IVMInstall vm) { >+ if (vm instanceof AbstractVMInstall) { >+ AbstractVMInstall avm = (AbstractVMInstall) vm; >+ String path = avm.getAttribute(EEVMInstall.ATTR_DEFINITION_FILE); >+ if (path != null) { >+ return new File(path); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Returns VM arguments defined in the given definition file or <code>null</code> if none. >+ * >+ * @param eeFile definition file >+ * @return VM arguments or <code>null</code> if none > */ >- public static String getDefaultVMArguments(File installLocation) { >- Map properties = getProperties(installLocation); >+ public static String getVMArguments(File eeFile) { >+ Map properties = getProperties(eeFile); > if (properties != null) { >- List args = (List) fgArguments.get(installLocation); >+ List args = (List) fgArguments.get(eeFile); > StringBuffer buf = new StringBuffer(); > Iterator iterator = args.iterator(); > while (iterator.hasNext()) { >@@ -185,20 +207,23 @@ > return Path.EMPTY; > } > >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) >+ /** >+ * Returns a status indicating if the given definition file is valid. >+ * >+ * @param eeFile definition file >+ * @return status indicating if the given definition file is valid > */ >- public static IStatus validateInstallLocation(File installLocation) { >- Map properties = getProperties(installLocation); >+ public static IStatus validateDefinitionFile(File eeFile) { >+ Map properties = getProperties(eeFile); > if (properties == null) { >- return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{installLocation.getName()} )); >+ return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_0, new String[]{eeFile.getName()} )); > } > // validate required properties > for (int i = 0; i < REQUIRED_PROPERTIES.length; i++) { > String key = REQUIRED_PROPERTIES[i]; > String property = (String) properties.get(key); > if (property == null) { >- return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{installLocation.getName(), key} )); >+ return new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), MessageFormat.format(LaunchingMessages.EEVMType_1, new String[]{eeFile.getName(), key} )); > } > } > return Status.OK_STATUS; >@@ -209,7 +234,7 @@ > * is considered first. > * > * @param installLocation ee file >- * @return standard executable >+ * @return standard executable or <code>null</code> if none > */ > public static File getExecutable(File installLocation) { > String property = getProperty(PROP_EXECUTABLE, installLocation); >@@ -320,4 +345,48 @@ > } > return null; > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.AbstractVMInstallType#doCreateVMInstall(java.lang.String) >+ */ >+ protected IVMInstall doCreateVMInstall(String id) { >+ return new EEVMInstall(this, id); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#detectInstallLocation() >+ */ >+ public File detectInstallLocation() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) >+ */ >+ public LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile) { >+ return new LibraryLocation[0]; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#getName() >+ */ >+ public String getName() { >+ return LaunchingMessages.EEVMType_2; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) >+ */ >+ public IStatus validateInstallLocation(File installLocationOrDefinitionFile) { >+ return new Status(IStatus.INFO, LaunchingPlugin.getUniqueIdentifier(), LaunchingMessages.EEVMType_3); >+ } >+ >+ /** >+ * Clears any cached properties for the given file. >+ * >+ * @param eeFile >+ */ >+ public synchronized static void clearProperties(File eeFile) { >+ fgProperites.remove(eeFile); >+ } > } >Index: launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties,v >retrieving revision 1.95 >diff -u -r1.95 LaunchingMessages.properties >--- launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties 24 Aug 2007 17:52:38 -0000 1.95 >+++ launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties 3 Oct 2007 22:11:06 -0000 >@@ -49,6 +49,7 @@ > JavaRuntime_Could_not_resolve_classpath_container___0__1=Could not resolve classpath container: {0} > JavaRuntime_Classpath_references_non_existant_project___0__3=The project: {0} which is referenced by the classpath, does not exist. > JavaRuntime_Classpath_references_non_existant_archive___0__4=The archive: {0} which is referenced by the classpath, does not exist. >+JavaRuntime_24=Failed to create installed JRE > JavaRuntime_26=Referenced classpath provider does not exist: {0} > JavaRuntime_27=Referenced source lookup provider does not exist: {0} > JavaRuntime_28=Launch configuration {0} references closed project {1} >@@ -177,6 +178,8 @@ > PackageFragmentRootSourceContainerTypeDelegate_8=Missing required <packageFragmentRoot> attribute > EEVMType_0={0} is not a valid .ee property file > EEVMType_1={0} missing required property ''{1}'' >+EEVMType_2=Execution Environment Description >+EEVMType_3=Unable to validate install location. > VMDefinitionsContainer_0=Installed JRE ''{0}'' removed due to missing VM type extension. > VMDefinitionsContainer_2=Installed JRE of type ''{0}'' removed due to missing VM type extension. > VMDefinitionsContainer_3=Installed JRE of type ''{0}'' removed due to missing install path and name. >Index: launching/org/eclipse/jdt/internal/launching/StandardVMType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMType.java,v >retrieving revision 1.73 >diff -u -r1.73 StandardVMType.java >--- launching/org/eclipse/jdt/internal/launching/StandardVMType.java 10 Aug 2007 20:00:35 -0000 1.73 >+++ launching/org/eclipse/jdt/internal/launching/StandardVMType.java 3 Oct 2007 22:11:06 -0000 >@@ -79,9 +79,6 @@ > * <code>null</code>. > */ > public static File findJavaExecutable(File vmInstallLocation) { >- if (EEVMType.isEEInstall(vmInstallLocation)) { >- return EEVMType.getExecutable(vmInstallLocation); >- } > // Try each candidate in order. The first one found wins. Thus, the order > // of fgCandidateJavaLocations and fgCandidateJavaFiles is significant. > for (int i = 0; i < fgCandidateJavaFiles.length; i++) { >@@ -282,10 +279,6 @@ > * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(File) > */ > public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getDefaultLibraryLocations(installLocation); >- } >- > // Determine the java executable that corresponds to the specified install location > // and use this to generate library information. If no java executable was found, > // the 'standard' libraries will be returned. >@@ -446,9 +439,6 @@ > * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) > */ > public IStatus validateInstallLocation(File javaHome) { >- if (EEVMType.isEEInstall(javaHome)) { >- return EEVMType.validateInstallLocation(javaHome); >- } > IStatus status = null; > if (Platform.getOS().equals(Constants.OS_MACOSX)) { > status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_Standard_VM_not_supported_on_MacOS__1, null); >@@ -602,29 +592,15 @@ > * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultJavadocLocation(java.io.File) > */ > public URL getDefaultJavadocLocation(File installLocation) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getDefaultJavadocLocation(installLocation); >- } else { >- File javaExecutable = findJavaExecutable(installLocation); >- if (javaExecutable != null) { >- LibraryInfo libInfo = getLibraryInfo(installLocation, javaExecutable); >- if (libInfo != null) { >- String version = libInfo.getVersion(); >- return getDefaultJavadocLocation(version); >- } >+ File javaExecutable = findJavaExecutable(installLocation); >+ if (javaExecutable != null) { >+ LibraryInfo libInfo = getLibraryInfo(installLocation, javaExecutable); >+ if (libInfo != null) { >+ String version = libInfo.getVersion(); >+ return getDefaultJavadocLocation(version); > } >- return null; > } >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jdt.launching.AbstractVMInstallType#getDefaultVMArguments(java.io.File) >- */ >- public String getDefaultVMArguments(File installLocation) { >- if (EEVMType.isEEInstall(installLocation)) { >- return EEVMType.getDefaultVMArguments(installLocation); >- } >- return super.getDefaultVMArguments(installLocation); >+ return null; > } > > /** >Index: launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java,v >retrieving revision 1.34 >diff -u -r1.34 VMDefinitionsContainer.java >--- launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java 27 Jun 2007 20:03:57 -0000 1.34 >+++ launching/org/eclipse/jdt/internal/launching/VMDefinitionsContainer.java 3 Oct 2007 22:11:07 -0000 >@@ -23,6 +23,7 @@ > import java.util.List; > import java.util.Map; > import java.util.Set; >+import java.util.Map.Entry; > > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.DocumentBuilderFactory; >@@ -35,6 +36,7 @@ > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; > import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.jdt.launching.AbstractVMInstall; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstall2; > import org.eclipse.jdt.launching.IVMInstallType; >@@ -130,7 +132,7 @@ > } > vmList.add(vm); > File installLocation = vm.getInstallLocation(); >- if (installLocation == null || !vmInstallType.validateInstallLocation(installLocation).isOK()) { >+ if (installLocation == null || vmInstallType.validateInstallLocation(installLocation).getSeverity() == IStatus.ERROR) { > fInvalidVMList.add(vm); > } > fVMList.add(vm); >@@ -344,6 +346,23 @@ > } > } > >+ // vm attributes >+ if (vm instanceof AbstractVMInstall) { >+ Map attributes = ((AbstractVMInstall)vm).getAttributes(); >+ if (!attributes.isEmpty()) { >+ Element attrElement = doc.createElement("attributeMap"); //$NON-NLS-1$ >+ Iterator iterator = attributes.entrySet().iterator(); >+ while (iterator.hasNext()) { >+ Entry entry = (Entry) iterator.next(); >+ Element entryElement = doc.createElement("entry"); //$NON-NLS-1$ >+ entryElement.setAttribute("key", (String)entry.getKey()); //$NON-NLS-1$ >+ entryElement.setAttribute("value", (String)entry.getValue()); //$NON-NLS-1$ >+ attrElement.appendChild(entryElement); >+ } >+ element.appendChild(attrElement); >+ } >+ } >+ > return element; > } > >@@ -534,10 +553,21 @@ > if (subElementName.equals("libraryLocation")) { //$NON-NLS-1$ > LibraryLocation loc = getLibraryLocation(subElement); > vmStandin.setLibraryLocations(new LibraryLocation[]{loc}); >- break; > } else if (subElementName.equals("libraryLocations")) { //$NON-NLS-1$ > setLibraryLocations(vmStandin, subElement); >- break; >+ } else if (subElementName.equals("attributeMap")) { //$NON-NLS-1$ >+ NodeList entries = subElement.getElementsByTagName("entry"); //$NON-NLS-1$ >+ for (int j = 0; j < entries.getLength(); j++) { >+ Node entryNode = entries.item(j); >+ if (entryNode instanceof Element) { >+ Element entryElement = (Element) entryNode; >+ String key = entryElement.getAttribute("key"); //$NON-NLS-1$ >+ String value = entryElement.getAttribute("value"); //$NON-NLS-1$ >+ if (key != null && value != null) { >+ vmStandin.setAttribute(key, value); >+ } >+ } >+ } > } > } > } >Index: launching/org/eclipse/jdt/launching/AbstractVMInstall.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractVMInstall.java,v >retrieving revision 1.30 >diff -u -r1.30 AbstractVMInstall.java >--- launching/org/eclipse/jdt/launching/AbstractVMInstall.java 16 May 2006 20:16:41 -0000 1.30 >+++ launching/org/eclipse/jdt/launching/AbstractVMInstall.java 3 Oct 2007 22:11:07 -0000 >@@ -55,6 +55,12 @@ > private LibraryLocation[] fSystemLibraryDescriptions; > private URL fJavadocLocation; > private String fVMArgs; >+ /** >+ * Map VM specific attributes that are persisted restored with a VM install. >+ * @since 3.4 >+ */ >+ private Map fAttributeMap = new HashMap(); >+ > // system properties are cached in user preferences prefixed with this key, followed > // by vm type, vm id, and system property name > private static final String PREF_VM_INSTALL_SYSTEM_PROPERTY = "PREF_VM_INSTALL_SYSTEM_PROPERTY"; //$NON-NLS-1$ >@@ -484,5 +490,56 @@ > throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin > .getUniqueIdentifier(), code, message, exception)); > } >+ >+ /** >+ * Sets a VM specific attribute. Attributes are persisted and restored with VM installs. >+ * Specifying a value of <code>null</code> as a value removes the attribute. Change >+ * notification is provided to {@link IVMInstallChangedListener} for VM attributes. >+ * >+ * @param key attribute key, cannot be <code>null</code> >+ * @param value attribute value or <code>null</code> to remove the attribute >+ * @since 3.4 >+ */ >+ public void setAttribute(String key, String value) { >+ String prevValue = (String) fAttributeMap.remove(key); >+ boolean notify = false; >+ if (value == null) { >+ if (prevValue != null && fNotify) { >+ notify = true; >+ } >+ } else { >+ fAttributeMap.put(key, value); >+ if (fNotify && (prevValue == null || !prevValue.equals(value))) { >+ notify = true; >+ } >+ } >+ if (notify) { >+ PropertyChangeEvent event = new PropertyChangeEvent(this, key, prevValue, value); >+ JavaRuntime.fireVMChanged(event); >+ } >+ } > >+ /** >+ * Returns a VM specific attribute associated with the given key or <code>null</code> >+ * if none. >+ * >+ * @param key attribute key, cannot be <code>null</code> >+ * @return attribute value, or <code>null</code> if none >+ * @since 3.4 >+ */ >+ public String getAttribute(String key) { >+ return (String) fAttributeMap.get(key); >+ } >+ >+ /** >+ * Returns a map of VM specific attributes stored with this VM install. Keys >+ * and values are strings. Modifying the map does not modify the attributes >+ * associated with this VM install. >+ * >+ * @return map of VM attributes >+ * @since 3.4 >+ */ >+ public Map getAttributes() { >+ return new HashMap(fAttributeMap); >+ } > } >Index: launching/org/eclipse/jdt/launching/IVMInstall.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/IVMInstall.java,v >retrieving revision 1.22 >diff -u -r1.22 IVMInstall.java >--- launching/org/eclipse/jdt/launching/IVMInstall.java 10 Aug 2007 20:00:35 -0000 1.22 >+++ launching/org/eclipse/jdt/launching/IVMInstall.java 3 Oct 2007 22:11:07 -0000 >@@ -68,28 +68,17 @@ > void setName(String name); > /** > * Returns the root directory of the install location of this VM. >- * <p> >- * Since 3.4, this may also be a file describing a VM install. >- * For example, the standard VM installs support execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >+ * > * @return the root directory of this VM installation. May > * return <code>null</code>. > */ > File getInstallLocation(); > /** > * Sets the root directory of the install location of this VM. >- * <p> >- * Since 3.4, this may also be a file describing a VM install. >- * For example, the standard VM installs support execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * @param installLocationOrDefinitionFile the root directory or definition file for >- * this VM installation >+ * >+ * @param installLocation the root directory of this VM installation > */ >- void setInstallLocation(File installLocationOrDefinitionFile); >+ void setInstallLocation(File installLocation); > > /** > * Returns the VM type of this VM. >Index: launching/org/eclipse/jdt/launching/IVMInstallType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/IVMInstallType.java,v >retrieving revision 1.16 >diff -u -r1.16 IVMInstallType.java >--- launching/org/eclipse/jdt/launching/IVMInstallType.java 10 Aug 2007 20:00:35 -0000 1.16 >+++ launching/org/eclipse/jdt/launching/IVMInstallType.java 3 Oct 2007 22:11:07 -0000 >@@ -88,20 +88,15 @@ > /** > * Validates the given location of a VM installation. > * <p> >- * Since 3.4, the given installLocation may be a file (rather than a home >- * directory). For example, the standard VM install type accepts execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * <p> > * For example, an implementation might check whether the VM executable > * is present. > * </p> >- * @param installLocationOrDefinitionFile the root directory of a potential installation for >- * this type of VM or since 3.4, a file describing an installation >+ * >+ * @param installLocation the root directory of a potential installation for >+ * this type of VM > * @return a status object describing whether the install location is valid > */ >- IStatus validateInstallLocation(File installLocationOrDefinitionFile); >+ IStatus validateInstallLocation(File installLocation); > > /** > * Tries to detect an installed VM that matches this VM install type. >@@ -120,19 +115,13 @@ > * at the given <code>installLocation</code>. > * The returned <code>LibraryLocation</code>s may not exist if the > * <code>installLocation</code> is not a valid install location. >- * <p> >- * Since 3.4, the given installLocation may be a file (rather than a home >- * directory). For example, the standard VM install type accepts execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * @param installLocationOrDefinitionFile home directory or since 3.4, a file >- * describing an installation >+ * >+ * @param installLocation home location > * @see LibraryLocation > * @see IVMInstallType#validateInstallLocation(File) > * > * @return default library locations based on the given <code>installLocation</code>. > * @since 2.0 > */ >- LibraryLocation[] getDefaultLibraryLocations(File installLocationOrDefinitionFile); >+ LibraryLocation[] getDefaultLibraryLocations(File installLocation); > } >Index: launching/org/eclipse/jdt/launching/JavaRuntime.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java,v >retrieving revision 1.194 >diff -u -r1.194 JavaRuntime.java >--- launching/org/eclipse/jdt/launching/JavaRuntime.java 15 Aug 2007 16:01:00 -0000 1.194 >+++ launching/org/eclipse/jdt/launching/JavaRuntime.java 3 Oct 2007 22:11:08 -0000 >@@ -59,6 +59,8 @@ > import org.eclipse.jdt.internal.launching.CompositeId; > import org.eclipse.jdt.internal.launching.DefaultEntryResolver; > import org.eclipse.jdt.internal.launching.DefaultProjectClasspathEntry; >+import org.eclipse.jdt.internal.launching.EEVMInstall; >+import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.internal.launching.JREContainerInitializer; > import org.eclipse.jdt.internal.launching.JavaSourceLookupUtil; > import org.eclipse.jdt.internal.launching.LaunchingMessages; >@@ -1465,8 +1467,7 @@ > } > String javadoc = element.getAttribute("javadocURL"); //$NON-NLS-1$ > String vmArgs = element.getAttribute("vmArgs"); //$NON-NLS-1$ >- VMStandin standin = new VMStandin(installType, id); >- standin.setName(name); >+ VMStandin standin = null; > home = substitute(home); > File homeDir = new File(home); > if (homeDir.exists()) { >@@ -1477,67 +1478,73 @@ > } catch (IOException e) { > } > } >- IStatus status = installType.validateInstallLocation(homeDir); >- if (!status.isOK()) { >- abort(MessageFormat.format("Illegal install location {0} for vmInstall {1} contributed by {2}: {3}", //$NON-NLS-1$ >- new String[]{home, id, element.getContributor().getName(), status.getMessage()}), null); >- } >- standin.setInstallLocation(homeDir); >- if (javadoc != null) { >- try { >- standin.setJavadocLocation(new URL(javadoc)); >- } catch (MalformedURLException e) { >- abort(MessageFormat.format("Illegal javadocURL attribute for vmInstall {0} contributed by {1}", //$NON-NLS-1$ >- new String[]{id, element.getContributor().getName()}), e); >+ if (EEVMType.ID_EE_VM_TYPE.equals(installType.getId())) { >+ standin = createVMFromDefinitionFile(homeDir, name, id); >+ } else { >+ standin = new VMStandin(installType, id); >+ standin.setName(name); >+ IStatus status = installType.validateInstallLocation(homeDir); >+ if (!status.isOK()) { >+ abort(MessageFormat.format("Illegal install location {0} for vmInstall {1} contributed by {2}: {3}", //$NON-NLS-1$ >+ new String[]{home, id, element.getContributor().getName(), status.getMessage()}), null); >+ } >+ standin.setInstallLocation(homeDir); >+ if (javadoc != null) { >+ try { >+ standin.setJavadocLocation(new URL(javadoc)); >+ } catch (MalformedURLException e) { >+ abort(MessageFormat.format("Illegal javadocURL attribute for vmInstall {0} contributed by {1}", //$NON-NLS-1$ >+ new String[]{id, element.getContributor().getName()}), e); >+ } > } >- } >- // allow default arguments to be specified by vm install type if no explicit arguments >- if (vmArgs == null) { >- if (installType instanceof AbstractVMInstallType) { >- AbstractVMInstallType type = (AbstractVMInstallType) installType; >- vmArgs = type.getDefaultVMArguments(homeDir); >+ // allow default arguments to be specified by vm install type if no explicit arguments >+ if (vmArgs == null) { >+ if (installType instanceof AbstractVMInstallType) { >+ AbstractVMInstallType type = (AbstractVMInstallType) installType; >+ vmArgs = type.getDefaultVMArguments(homeDir); >+ } > } >+ if (vmArgs != null) { >+ standin.setVMArgs(vmArgs); >+ } >+ IConfigurationElement[] libraries = element.getChildren("library"); //$NON-NLS-1$ >+ LibraryLocation[] locations = null; >+ if (libraries.length > 0) { >+ locations = new LibraryLocation[libraries.length]; >+ for (int j = 0; j < libraries.length; j++) { >+ IConfigurationElement library = libraries[j]; >+ String libPathStr = library.getAttribute("path"); //$NON-NLS-1$ >+ if (libPathStr == null) { >+ abort(MessageFormat.format("library for vmInstall {0} contributed by {1} missing required attribute libPath", //$NON-NLS-1$ >+ new String[]{id, element.getContributor().getName()}), null); >+ } >+ String sourcePathStr = library.getAttribute("sourcePath"); //$NON-NLS-1$ >+ String packageRootStr = library.getAttribute("packageRootPath"); //$NON-NLS-1$ >+ String javadocOverride = library.getAttribute("javadocURL"); //$NON-NLS-1$ >+ URL url = null; >+ if (javadocOverride != null) { >+ try { >+ url = new URL(javadocOverride); >+ } catch (MalformedURLException e) { >+ abort(MessageFormat.format("Illegal javadocURL attribute specified for library {0} for vmInstall {1} contributed by {2}" //$NON-NLS-1$ >+ ,new String[]{libPathStr, id, element.getContributor().getName()}), e); >+ } >+ } >+ IPath homePath = new Path(home); >+ IPath libPath = homePath.append(substitute(libPathStr)); >+ IPath sourcePath = Path.EMPTY; >+ if (sourcePathStr != null) { >+ sourcePath = homePath.append(substitute(sourcePathStr)); >+ } >+ IPath packageRootPath = Path.EMPTY; >+ if (packageRootStr != null) { >+ packageRootPath = new Path(substitute(packageRootStr)); >+ } >+ locations[j] = new LibraryLocation(libPath, sourcePath, packageRootPath, url); >+ } >+ } >+ standin.setLibraryLocations(locations); > } >- if (vmArgs != null) { >- standin.setVMArgs(vmArgs); >- } >- IConfigurationElement[] libraries = element.getChildren("library"); //$NON-NLS-1$ >- LibraryLocation[] locations = null; >- if (libraries.length > 0) { >- locations = new LibraryLocation[libraries.length]; >- for (int j = 0; j < libraries.length; j++) { >- IConfigurationElement library = libraries[j]; >- String libPathStr = library.getAttribute("path"); //$NON-NLS-1$ >- if (libPathStr == null) { >- abort(MessageFormat.format("library for vmInstall {0} contributed by {1} missing required attribute libPath", //$NON-NLS-1$ >- new String[]{id, element.getContributor().getName()}), null); >- } >- String sourcePathStr = library.getAttribute("sourcePath"); //$NON-NLS-1$ >- String packageRootStr = library.getAttribute("packageRootPath"); //$NON-NLS-1$ >- String javadocOverride = library.getAttribute("javadocURL"); //$NON-NLS-1$ >- URL url = null; >- if (javadocOverride != null) { >- try { >- url = new URL(javadocOverride); >- } catch (MalformedURLException e) { >- abort(MessageFormat.format("Illegal javadocURL attribute specified for library {0} for vmInstall {1} contributed by {2}" //$NON-NLS-1$ >- ,new String[]{libPathStr, id, element.getContributor().getName()}), e); >- } >- } >- IPath homePath = new Path(home); >- IPath libPath = homePath.append(substitute(libPathStr)); >- IPath sourcePath = Path.EMPTY; >- if (sourcePathStr != null) { >- sourcePath = homePath.append(substitute(sourcePathStr)); >- } >- IPath packageRootPath = Path.EMPTY; >- if (packageRootStr != null) { >- packageRootPath = new Path(substitute(packageRootStr)); >- } >- locations[j] = new LibraryLocation(libPath, sourcePath, packageRootPath, url); >- } >- } >- standin.setLibraryLocations(locations); > // in case the contributed JRE attributes changed, remove it first, then add > vmDefs.removeVM(standin); > vmDefs.addVM(standin); >@@ -1592,7 +1599,11 @@ > LibraryLocation[] locations= vm.getLibraryLocations(); > if (locations == null) { > URL defJavaDocLocation = vm.getJavadocLocation(); >- LibraryLocation[] dflts= vm.getVMInstallType().getDefaultLibraryLocations(vm.getInstallLocation()); >+ File installLocation = vm.getInstallLocation(); >+ if (installLocation == null) { >+ return new LibraryLocation[0]; >+ } >+ LibraryLocation[] dflts= vm.getVMInstallType().getDefaultLibraryLocations(installLocation); > libraryPaths = new IPath[dflts.length]; > sourcePaths = new IPath[dflts.length]; > sourceRootPaths = new IPath[dflts.length]; >@@ -2654,5 +2665,45 @@ > } > } > } >+ >+ /** >+ * Creates a new VM based on the attributes specified in the given execution >+ * environment description file. The format of the file is defined by >+ * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >+ * >+ * @param eeFile VM definition file >+ * @param name name for the VM >+ * @param id id to assign to the new VM >+ * @return VM standin >+ * @exception CoreException if unable to create a VM from the given definition file >+ * @since 3.4 >+ */ >+ public static VMStandin createVMFromDefinitionFile(File eeFile, String name, String id) throws CoreException { >+ IStatus status = EEVMType.validateDefinitionFile(eeFile); >+ if (status.isOK()) { >+ VMStandin standin = new VMStandin(getVMInstallType(EEVMType.ID_EE_VM_TYPE), id); >+ standin.setName(name); >+ String home = EEVMType.getProperty(EEVMType.PROP_JAVA_HOME, eeFile); >+ standin.setInstallLocation(new File(home)); >+ standin.setLibraryLocations(EEVMType.getLibraryLocations(eeFile)); >+ standin.setVMArgs(EEVMType.getVMArguments(eeFile)); >+ standin.setJavadocLocation(EEVMType.getJavadocLocation(eeFile)); >+ standin.setAttribute(EEVMInstall.ATTR_EXECUTION_ENVIRONMENT_ID, EEVMType.getProperty(EEVMType.PROP_CLASS_LIB_LEVEL, eeFile)); >+ File exe = EEVMType.getExecutable(eeFile); >+ if (exe != null) { >+ try { >+ standin.setAttribute(EEVMInstall.ATTR_JAVA_EXE, exe.getCanonicalPath()); >+ } catch (IOException e) { >+ throw new CoreException(new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), >+ LaunchingMessages.JavaRuntime_24, e)); >+ } >+ } >+ standin.setAttribute(EEVMInstall.ATTR_JAVA_VERSION, EEVMType.getJavaVersion(eeFile)); >+ standin.setAttribute(EEVMInstall.ATTR_DEFINITION_FILE, eeFile.getPath()); >+ return standin; >+ } else { >+ throw new CoreException(status); >+ } >+ } > > } >Index: launching/org/eclipse/jdt/launching/AbstractVMInstallType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/AbstractVMInstallType.java,v >retrieving revision 1.21 >diff -u -r1.21 AbstractVMInstallType.java >--- launching/org/eclipse/jdt/launching/AbstractVMInstallType.java 10 Aug 2007 20:00:35 -0000 1.21 >+++ launching/org/eclipse/jdt/launching/AbstractVMInstallType.java 3 Oct 2007 22:11:07 -0000 >@@ -157,29 +157,23 @@ > * implementation returns <code>null</code>, subclasses must override as > * appropriate. > * <p> >- * Since 3.4, the argument may also be a file describing a VM install. >- * For example, the standard VM installs support execution >- * environment description files, as described by >- * <code>http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions</code>. >- * </p> >- * <p> > * Note, this method would ideally be added to <code>IVMInstallType</code>, > * but it would have been a breaking API change between 2.0 and 2.1. Thus, > * it has been added to the abstract base class that VM install types should > * subclass. > * </p> > * >- * @param installLocationOrDefinitionFile home location or since 3.4, a definition file >+ * @param installLocationOrDefinitionFile home location > * @return default javadoc location or <code>null</code> > * @since 2.1 > */ >- public URL getDefaultJavadocLocation(File installLocationOrDefinitionFile) { >+ public URL getDefaultJavadocLocation(File installLocation) { > return null; > } > > /** > * Returns a string of default VM arguments for a VM installed at the >- * given home location or definition file, or <code>null</code> if none. >+ * given home location, or <code>null</code> if none. > * The default implementation returns <code>null</code>, subclasses must override > * as appropriate. > * <p> >@@ -188,11 +182,11 @@ > * it has been added to the abstract base class that VM install types should > * subclass. > * </p> >- * @param installLocationOrDefinitionFile home location or definition file >+ * @param installLocation home location > * @return default VM arguments or <code>null</code> if none > * @since 3.4 > */ >- public String getDefaultVMArguments(File installLocationOrDefinitionFile) { >+ public String getDefaultVMArguments(File installLocation) { > return null; > } > } >Index: launching/org/eclipse/jdt/launching/VMStandin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/VMStandin.java,v >retrieving revision 1.16 >diff -u -r1.16 VMStandin.java >--- launching/org/eclipse/jdt/launching/VMStandin.java 8 May 2006 20:39:12 -0000 1.16 >+++ launching/org/eclipse/jdt/launching/VMStandin.java 3 Oct 2007 22:11:08 -0000 >@@ -10,6 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.launching; > >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Map.Entry; >+ > > > /** >@@ -93,6 +97,15 @@ > setVMArguments(realVM.getVMArguments()); > fJavaVersion = null; > } >+ if (realVM instanceof AbstractVMInstall) { >+ AbstractVMInstall vm2 = (AbstractVMInstall) realVM; >+ Map attributes = vm2.getAttributes(); >+ Iterator iterator = attributes.entrySet().iterator(); >+ while (iterator.hasNext()) { >+ Entry entry = (Entry) iterator.next(); >+ setAttribute((String)entry.getKey(), (String)entry.getValue()); >+ } >+ } > } > > /** >@@ -126,7 +139,13 @@ > } > > if (realVM instanceof AbstractVMInstall) { >- ((AbstractVMInstall)realVM).setNotify(true); >+ AbstractVMInstall avm = (AbstractVMInstall) realVM; >+ Iterator iterator = getAttributes().entrySet().iterator(); >+ while (iterator.hasNext()) { >+ Entry entry = (Entry) iterator.next(); >+ avm.setAttribute((String)entry.getKey(), (String)entry.getValue()); >+ } >+ avm.setNotify(true); > } > if (!notify) { > JavaRuntime.fireVMAdded(realVM); >Index: launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java,v >retrieving revision 1.2 >diff -u -r1.2 ExecutionEnvironmentAnalyzer.java >--- launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java 10 Aug 2007 20:00:35 -0000 1.2 >+++ launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironmentAnalyzer.java 3 Oct 2007 22:11:07 -0000 >@@ -18,6 +18,7 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jdt.internal.launching.EEVMInstall; > import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstall2; >@@ -72,8 +73,8 @@ > return new CompatibleEnvironment[0]; > IVMInstall2 vm2 = (IVMInstall2) vm; > List types = null; >- if (EEVMType.isEEInstall(vm.getInstallLocation())) { >- String eeId = EEVMType.getProperty(EEVMType.PROP_CLASS_LIB_LEVEL, vm.getInstallLocation()); >+ if (EEVMType.ID_EE_VM_TYPE.equals(vm.getVMInstallType().getId())) { >+ String eeId = ((EEVMInstall)vm).getAttribute(EEVMInstall.ATTR_EXECUTION_ENVIRONMENT_ID); > if (eeId != null) { > types = getTypes(eeId); > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/plugin.xml,v >retrieving revision 1.69 >diff -u -r1.69 plugin.xml >--- plugin.xml 24 Aug 2007 17:52:38 -0000 1.69 >+++ plugin.xml 3 Oct 2007 22:11:06 -0000 >@@ -23,6 +23,10 @@ > class="org.eclipse.jdt.internal.launching.Standard11xVMType" > id="org.eclipse.jdt.launching.Standard11xVMType"> > </vmInstallType> >+ <vmInstallType >+ class="org.eclipse.jdt.internal.launching.EEVMType" >+ id="org.eclipse.jdt.launching.EEVMType"> >+ </vmInstallType> > </extension> > <extension > point="org.eclipse.debug.core.launchConfigurationTypes"> >Index: schema/vmInstallTypes.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/schema/vmInstallTypes.exsd,v >retrieving revision 1.7 >diff -u -r1.7 vmInstallTypes.exsd >--- schema/vmInstallTypes.exsd 23 Feb 2005 16:57:03 -0000 1.7 >+++ schema/vmInstallTypes.exsd 3 Oct 2007 22:11:08 -0000 >@@ -65,6 +65,7 @@ > </complexType> > </element> > >+ > <annotation> > <appInfo> > <meta.section type="examples"/> >@@ -85,13 +86,14 @@ > </documentation> > </annotation> > >+ > <annotation> > <appInfo> > <meta.section type="implementation"/> > </appInfo> > <documentation> > Abstract implementations of IVMInstall and IVMInstallType are provided. The Java Development Tools Launching Support plug-in defines a VM >-install type for the standard 1.1.* and 1.2/1.3/1.4 level <b>JRE</b>. >+install type for the standard 1.1.* level JRE, and an install type for JREs conforming to standard command line options (1.2, 1.3, 1.4, 5.0, 6.0, and 7.0 level JREs). As well an install type is provided for JREs defined by an <a href=" http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions">execution environment description</a> file. > </documentation> > </annotation> > >Index: schema/vmInstalls.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.launching/schema/vmInstalls.exsd,v >retrieving revision 1.3 >diff -u -r1.3 vmInstalls.exsd >--- schema/vmInstalls.exsd 15 Aug 2007 16:01:00 -0000 1.3 >+++ schema/vmInstalls.exsd 3 Oct 2007 22:11:08 -0000 >@@ -71,7 +71,7 @@ > <attribute name="home" type="string" use="required"> > <annotation> > <documentation> >- Path to the home installation directory for this VM install. Paths must be absolute and may use string substitution variables such as ${eclipse_home}. Since 3.4, this attribute may reference a VM definition file in addition to a home directory. The standard VM type included with the SDK supports <a href=" http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions">execution environment descriptions</a>. >+ Path to the home installation directory for this VM install. Paths must be absolute and may use string substitution variables such as ${eclipse_home}. Since 3.4, this attribute may reference a VM definition file in addition to a home directory. The Execution Environment VM type included with the SDK supports <a href=" http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions">execution environment descriptions</a>. When an execution environment description file is specified, any library elements are ignored. In this case, libraries are defined by the execution environment description file. > </documentation> > </annotation> > </attribute> >@@ -151,6 +151,20 @@ > </extension> > </pre> > </p> >+<p> >+The following example will create a JRE definition based on the contents of the specified execution environment description file. When an execution environment description file is provided as the home location the "Execution Environment Description" VM type must be specified for the <code>vmInstallType</code> attribute. >+</p> >+<p> >+<pre> >+<extension point="org.eclipse.jdt.launching.vmInstalls"> >+ <vmInstall >+ home="${eclipse_home}/jre-def.ee" >+ id="com.example.ee.id" >+ name="Default JRE" >+ vmInstallType="org.eclipse.jdt.launching.EEVMType"/> >+</extension> >+</pre> >+</p> > </documentation> > </annotation> > >Index: launching/org/eclipse/jdt/internal/launching/EEVMInstall.java >=================================================================== >RCS file: launching/org/eclipse/jdt/internal/launching/EEVMInstall.java >diff -N launching/org/eclipse/jdt/internal/launching/EEVMInstall.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ launching/org/eclipse/jdt/internal/launching/EEVMInstall.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.launching; >+ >+import java.io.File; >+ >+import org.eclipse.jdt.launching.IVMInstallType; >+ >+/** >+ * A VM install created from an execution environment description file. >+ * >+ * @since 3.4 >+ */ >+public class EEVMInstall extends StandardVM { >+ >+ /** >+ * Attribute key for Java version property >+ */ >+ public static final String ATTR_JAVA_VERSION = "ATTR_JAVA_VERSION"; //$NON-NLS-1$ >+ >+ /** >+ * Attribute key for supported execution environment by this runtime >+ */ >+ public static final String ATTR_EXECUTION_ENVIRONMENT_ID = "ATTR_EXECUTION_ENVIRONMENT_ID"; //$NON-NLS-1$ >+ >+ /** >+ * Attribute key for Java executable used by this VM >+ */ >+ public static final String ATTR_JAVA_EXE = "ATTR_JAVA_EXE"; //$NON-NLS-1$ >+ >+ /** >+ * Path to file used to define the JRE >+ */ >+ public static final String ATTR_DEFINITION_FILE = "ATTR_DEFINITION_FILE"; //$NON-NLS-1$ >+ >+ /** >+ * Constructs a VM install. >+ * >+ * @param type vm type >+ * @param id unique id >+ */ >+ EEVMInstall(IVMInstallType type, String id) { >+ super(type, id); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.StandardVM#getJavaVersion() >+ */ >+ public String getJavaVersion() { >+ return getAttribute(ATTR_JAVA_VERSION); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.launching.StandardVM#getJavaExecutable() >+ */ >+ File getJavaExecutable() { >+ String exe = getAttribute(ATTR_JAVA_EXE); >+ if (exe != null) { >+ return new File(exe); >+ } >+ return null; >+ } >+ >+ >+ >+} >#P org.eclipse.jdt.debug >Index: buildnotes_jdt-debug.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug/buildnotes_jdt-debug.html,v >retrieving revision 1.2115 >diff -u -r1.2115 buildnotes_jdt-debug.html >--- buildnotes_jdt-debug.html 2 Oct 2007 17:46:35 -0000 1.2115 >+++ buildnotes_jdt-debug.html 3 Oct 2007 22:11:10 -0000 >@@ -42,21 +42,15 @@ > > <h3>Support for Execution Environment Descriptions</h3> > <p>An installed JRE can be defined by an <a href="http://wiki.eclipse.org/index.php/Execution_Environment_Descriptions">execution >- environment description file</a>. The API for <code>IVMInstallType</code> and >- <code>IVMInstall</code> have been augmented to allow for a file to be specified >- for an install location in addition to a home directory. The 'Standard VM Install >- Type' shipped with the Eclipse SDK supports standard ".ee" files.</p> >-<p>This change effects the following methods in <code>IVMInstallType</code>, which >- now accept the location of a description file as well as a home directory.</p> >+ environment description file</a>. A new 'Execution Environment Description' >+ VM install type shipped with the Eclipse SDK supports standard ".ee" >+ files.</p> >+<p>API has been added to <code>JavaRuntime</code> to create a VM from an execution >+ environment description file. A name and unique identifier must be provided >+ to create a new JRE.</p> > <ul> >- <li><code>public IStatus validateInstallLocation(File installLocation)</code></li> >- <li><code>public LibraryLocation[] getDefaultLibraryLocations(File installLocation)</code></li> >-</ul> >-<p>This change effects the following methods in <code>IVMInstall</code>, which >- can now accept/return a file as well as home directory.</p> >-<ul> >- <li><code>public File getInstallLocation()</code></li> >- <li><code>public void setInstallLocation(File installLocation)</code></li> >+ <li><code>public VMStandin createVMFromDefinitionFile(File eeFile, String name, >+ String id)</code></li> > </ul> > <p>A new method has been added to <code>AbstractVMInstallType</code> to allow > default arguments to be provided for newly created VM installs. Ideally, this >@@ -68,11 +62,13 @@ > <ul> > <li><code>public String getDefaultVMArguments(File installLocation)</code></li> > </ul> >-<p>As well, the specification of the following method in <code>AbstractVMInstallType</code> >- has been changed to allow a file to be supplied as an argument.</p> >-<ul> >- <li><code>public URL getDefaultJavadocLocation(File installLocation)</code></li> >-</ul> >+<h3>Support for custom wizard pages used to edit VM installs</h3> >+<p>An new extension point (<code>org.eclipse.jdt.debug.ui.vmInstallPages</code>) >+ allows a wizard page to be contributed for editing the properties of an <code>IVMInstall</code>. >+ The page is used when adding or editing an installed JRE via user preference. >+ A standard page is provided based on the <code>IVMInstallType</code> and <code>IVMInstall</code> >+ interfaces. JDT contributes a page for editing a JRE based on an execution environment >+ description file.</p> > <h3>Support for setting a range of values in array objects</h3> > <p>API has been added to <code>IJavaArray</code> to support setting ranges of > values in the arrays. It is more efficient to set a range of values at once >#P org.eclipse.jdt.debug.tests >#P org.eclipse.jdt.debug.ui >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/LibraryContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/LibraryContentProvider.java,v >retrieving revision 1.5 >diff -u -r1.5 LibraryContentProvider.java >--- ui/org/eclipse/jdt/internal/debug/ui/jres/LibraryContentProvider.java 27 Mar 2007 02:35:58 -0000 1.5 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/LibraryContentProvider.java 3 Oct 2007 22:11:14 -0000 >@@ -142,7 +142,9 @@ > for (int i = 0; i < libs.length; i++) { > fLibraries[i] = new LibraryStandin(libs[i]); > } >- fViewer.refresh(); >+ if (fViewer != null) { >+ fViewer.refresh(); >+ } > } > > /** >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties,v >retrieving revision 1.57 >diff -u -r1.57 JREMessages.properties >--- ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties 28 Sep 2007 16:10:48 -0000 1.57 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties 3 Oct 2007 22:11:14 -0000 >@@ -15,6 +15,7 @@ > AbstractJavaCommandTab_4=&Alternate > AbstractJavaCommandTab_Java_executable_must_be_specified_5=Java executable must be specified > >+AddVMInstallWizard_0=Add JRE > BuildJREDescriptor_0=Workspace &default JRE ({0}) > > InstalledJREsBlock_0=Name >@@ -46,6 +47,9 @@ > JREsComboBlock_0=No JREs defined in workspace > JREsComboBlock_4=E&xecution Environment: > JREsComboBlock_5=No execution environments defined in workspace >+StandardVMPage_0=Add Standard VM >+StandardVMPage_1=JRE Definition >+StandardVMPage_2=Specify attributes for a JRE > JREContainerWizardPage_JRE_System_Library_1=JRE System Library > JREContainerWizardPage_4=Select JRE for the project build path. > JREContainerWizardPage_3=System library >@@ -58,17 +62,18 @@ > JREsPreferencePage_14=Conflicting compliance settings can be changed on the <a>Compiler</a> page. > > addVMDialog_duplicateName=The JRE name is already in use. >-addVMDialog_enterLocation=Enter the location of the JRE. >+addVMDialog_enterLocation=Enter the home directory of the JRE. > addVMDialog_enterName=Enter a name for the JRE. >-addVMDialog_jreHome=&JRE location: >+EditVMInstallWizard_0=Edit JRE >+addVMDialog_jreHome=&JRE home: > addVMDialog_jreName=JRE &name: > addVMDialog_jreType=JRE &type: >-addVMDialog_locationNotExists=The location does not exist. >+addVMDialog_locationNotExists=The home directory does not exist. > addVMDialog_pickJRERootDialog_message=Select the root directory of the JRE installation: > AddVMDialog_JRE_system_libraries__1=JRE system libraries: > AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1=JRE name must be a valid file name: {0} > AddVMDialog_21=Definition &File... >-AddVMDialog_22=H&ome Directory... >+AddVMDialog_22=Direct&ory... > AddVMDialog_23=Default &VM Arguments: > > JREsUpdater_0=Save VM Definitions >@@ -76,7 +81,7 @@ > VMLibraryBlock_1=(none) > VMLibraryBlock_10=Jar Selection > VMDetailsDialog_0=JRE Details >-VMLibraryBlock_2=Javadoc location: >+VMLibraryBlock_2=JRE System Libraries > VMLibraryBlock_11=Source &Attachment... > VMLibraryBlock_16=Select to add an external JAR to the list > VMLibraryBlock_17=Select to add a JavaDoc location to the selected library >@@ -101,3 +106,14 @@ > MacVMSearch_0=Searching for installed JREs > MacVMSearch_1=JVM {0} (MacOS X Default) > MacVMSearch_2=JVM {0} >+EEVMPage_0=Add EE VM >+EEVMPage_1=&Definition File: >+EEVMPage_2=F&ile... >+EEVMPage_4=Enter definition file >+EEVMPage_5=Definition file does not exist >+EEVMPage_6=JRE Definition >+EEVMPage_7=Specify attributes for a JRE >+VMTypePage_0=Select JRE Type >+VMTypePage_1=Select the type of JRE to add to the workspace. >+VMTypePage_2=JRE Type >+VMTypePage_3=Installed JRE &Types: >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java,v >retrieving revision 1.29 >diff -u -r1.29 JREMessages.java >--- ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java 28 Sep 2007 16:10:47 -0000 1.29 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java 3 Oct 2007 22:11:14 -0000 >@@ -25,6 +25,8 @@ > > public static String AddVMDialog_22; > >+ public static String AddVMInstallWizard_0; >+ > public static String BuildJREDescriptor_0; > > public static String InstalledJREsBlock_0; >@@ -70,6 +72,8 @@ > public static String addVMDialog_duplicateName; > public static String addVMDialog_enterLocation; > public static String addVMDialog_enterName; >+ >+ public static String EditVMInstallWizard_0; > public static String addVMDialog_jreHome; > public static String addVMDialog_jreName; > public static String addVMDialog_jreType; >@@ -100,8 +104,31 @@ > public static String VMLibraryBlock_18; > > public static String JREsUpdater_0; >+ >+ public static String EEVMPage_0; >+ >+ public static String EEVMPage_1; >+ >+ public static String EEVMPage_2; >+ >+ public static String EEVMPage_4; >+ >+ public static String EEVMPage_5; >+ >+ public static String EEVMPage_6; >+ >+ public static String EEVMPage_7; >+ >+ public static String VMTypePage_0; >+ >+ public static String VMTypePage_1; >+ >+ public static String VMTypePage_2; >+ >+ public static String VMTypePage_3; > public static String VMLibraryBlock_0; > public static String VMLibraryBlock_1; >+ > public static String VMLibraryBlock_2; > public static String VMLibraryBlock_3; > public static String VMLibraryBlock_4; >@@ -123,6 +150,12 @@ > > public static String JREsComboBlock_5; > >+ public static String StandardVMPage_0; >+ >+ public static String StandardVMPage_1; >+ >+ public static String StandardVMPage_2; >+ > public static String JREProfilesPreferencePage_0; > > public static String JREProfilesPreferencePage_1; >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java,v >retrieving revision 1.45 >diff -u -r1.45 InstalledJREsBlock.java >--- ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java 10 Aug 2007 20:00:37 -0000 1.45 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java 3 Oct 2007 22:11:14 -0000 >@@ -56,6 +56,7 @@ > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerComparator; > import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.WizardDialog; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.KeyAdapter; > import org.eclipse.swt.events.KeyEvent; >@@ -129,6 +130,11 @@ > // happen very quickly > private static String fgLastUsedID; > >+ /** >+ * VM install type id for OSX VMs >+ */ >+ public static final String MACOSX_VM_TYPE_ID = "org.eclipse.jdt.internal.launching.macosx.MacOSXType"; //$NON-NLS-1$ >+ > /** > * Content provider to show a list of JREs > */ >@@ -357,17 +363,20 @@ > ArrayList newEntries = new ArrayList(); > while (it.hasNext()) { > IVMInstall selectedVM = (IVMInstall) it.next(); >- > // duplicate & add vm > VMStandin standin = new VMStandin(selectedVM, createUniqueId(selectedVM.getVMInstallType())); > standin.setName(generateName(selectedVM.getName())); >- AddVMDialog dialog = new AddVMDialog(this, getShell(), JavaRuntime.getVMInstallTypes(), standin); >- dialog.setTitle(JREMessages.InstalledJREsBlock_18); >- if (dialog.open() != Window.OK) { >- return; >- } >- newEntries.add(standin); >- fVMs.add(standin); >+ EditVMInstallWizard wizard = new EditVMInstallWizard(standin, (IVMInstall[]) fVMs.toArray(new IVMInstall[fVMs.size()])); >+ WizardDialog dialog = new WizardDialog(getShell(), wizard); >+ if (dialog.open() == Window.OK) { >+ VMStandin result = wizard.getResult(); >+ if (result != null) { >+ // add the new VM >+ fVMs.add(result); >+ fVMList.refresh(); >+ fVMList.setSelection(new StructuredSelection(result)); >+ } >+ } > } > fVMList.refresh(); > fVMList.setSelection(new StructuredSelection(newEntries.toArray())); >@@ -543,15 +552,19 @@ > } > > /** >- * Bring up a dialog that lets the user create a new VM definition. >+ * Bring up a wizard that lets the user create a new VM definition. > */ > private void addVM() { >- AddVMDialog dialog= new AddVMDialog(this, getShell(), JavaRuntime.getVMInstallTypes(), null); >- dialog.setTitle(JREMessages.InstalledJREsBlock_7); >- if (dialog.open() != Window.OK) { >- return; >+ AddVMInstallWizard wizard = new AddVMInstallWizard((IVMInstall[]) fVMs.toArray(new IVMInstall[fVMs.size()])); >+ WizardDialog dialog = new WizardDialog(getShell(), wizard); >+ if (dialog.open() == Window.OK) { >+ VMStandin result = wizard.getResult(); >+ if (result != null) { >+ fVMs.add(result); >+ fVMList.refresh(); >+ fVMList.setSelection(new StructuredSelection(result)); >+ } > } >- fVMList.refresh(); > } > > /** >@@ -580,7 +593,7 @@ > */ > private void editVM() { > IStructuredSelection selection= (IStructuredSelection)fVMList.getSelection(); >- IVMInstall vm= (IVMInstall)selection.getFirstElement(); >+ VMStandin vm= (VMStandin)selection.getFirstElement(); > if (vm == null) { > return; > } >@@ -588,13 +601,22 @@ > VMDetailsDialog dialog= new VMDetailsDialog(getShell(), vm); > dialog.open(); > } else { >- AddVMDialog dialog= new AddVMDialog(this, getShell(), JavaRuntime.getVMInstallTypes(), vm); >- dialog.setTitle(JREMessages.InstalledJREsBlock_8); >- if (dialog.open() != Window.OK) { >- return; >+ EditVMInstallWizard wizard = new EditVMInstallWizard(vm, (IVMInstall[]) fVMs.toArray(new IVMInstall[fVMs.size()])); >+ WizardDialog dialog = new WizardDialog(getShell(), wizard); >+ if (dialog.open() == Window.OK) { >+ VMStandin result = wizard.getResult(); >+ if (result != null) { >+ // replace with the edited VM >+ int index = fVMs.indexOf(vm); >+ fVMs.remove(index); >+ fVMs.add(index, result); >+ fVMList.refresh(); >+ fVMList.setSelection(new StructuredSelection(result)); >+ } > } >- fVMList.refresh(vm); > } >+ >+ > } > > /** >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/MacVMSearch.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/MacVMSearch.java,v >retrieving revision 1.2 >diff -u -r1.2 MacVMSearch.java >--- ui/org/eclipse/jdt/internal/debug/ui/jres/MacVMSearch.java 10 Aug 2007 20:00:37 -0000 1.2 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/MacVMSearch.java 3 Oct 2007 22:11:14 -0000 >@@ -91,7 +91,7 @@ > IVMInstallType[] types = JavaRuntime.getVMInstallTypes(); > for (int i = 0; i < types.length; i++) { > IVMInstallType installType = types[i]; >- if (installType.getId().equals(AddVMDialog.MACOSX_VM_TYPE_ID)) { >+ if (installType.getId().equals(InstalledJREsBlock.MACOSX_VM_TYPE_ID)) { > return installType; > } > } >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMDialog.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMDialog.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMDialog.java >--- ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMDialog.java 10 Aug 2007 20:00:37 -0000 1.40 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,659 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jdt.internal.debug.ui.jres; >- >- >-import java.io.File; >-import java.io.IOException; >-import java.net.URL; >-import java.util.Arrays; >-import java.util.Comparator; >- >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.debug.core.DebugPlugin; >-import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; >-import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >-import org.eclipse.jdt.internal.debug.ui.SWTFactory; >-import org.eclipse.jdt.internal.debug.ui.StatusInfo; >-import org.eclipse.jdt.internal.launching.StandardVMType; >-import org.eclipse.jdt.launching.AbstractVMInstallType; >-import org.eclipse.jdt.launching.IVMInstall; >-import org.eclipse.jdt.launching.IVMInstall2; >-import org.eclipse.jdt.launching.IVMInstallType; >-import org.eclipse.jdt.launching.VMStandin; >-import org.eclipse.jface.dialogs.IDialogConstants; >-import org.eclipse.jface.dialogs.IDialogSettings; >-import org.eclipse.jface.dialogs.StatusDialog; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.SelectionListener; >-import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Combo; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.DirectoryDialog; >-import org.eclipse.swt.widgets.FileDialog; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.Text; >-import org.eclipse.ui.PlatformUI; >- >-import com.ibm.icu.text.MessageFormat; >- >-/** >- * Provides the Add VM dialog >- */ >-public class AddVMDialog extends StatusDialog { >- >- /** >- * VM install type id for OSX VMs >- */ >- public static final String MACOSX_VM_TYPE_ID = "org.eclipse.jdt.internal.launching.macosx.MacOSXType"; //$NON-NLS-1$ >- >- private IAddVMDialogRequestor fRequestor; >- private IVMInstall fEditedVM; >- private IVMInstallType[] fVMTypes; >- private IVMInstallType fSelectedVMType; >- private Combo fVMCombo; >- private Text fVMName; >- private Text fVMArgs; >- private Text fJRERoot; >- private Button fFileButton; >- private VMLibraryBlock fLibraryBlock; >-// the VM install's javadoc location >- private URL fJavadocLocation = null; >- private boolean fAutoDetectAttributes = false; >- private IStatus[] fStatus; >- private int fPrevIndex = -1; >- >- /** >- * Constructor >- * @param requestor dialog validation requester >- * @param shell the parent shell >- * @param vmInstallTypes the types of VM installs >- * @param editedVM the editedVM >- */ >- public AddVMDialog(IAddVMDialogRequestor requestor, Shell shell, IVMInstallType[] vmInstallTypes, IVMInstall editedVM) { >- super(shell); >- setShellStyle(getShellStyle() | SWT.RESIZE); >- fRequestor = requestor; >- fStatus = new IStatus[5]; >- for (int i= 0; i < fStatus.length; i++) { >- fStatus[i] = new StatusInfo(); >- } >- fVMTypes = vmInstallTypes; >- sortVMTypes(); >- int typeIndex = 0; >- if (Platform.OS_MACOSX.equals(Platform.getOS())) { >- // select OSX VM type by default >- for (int i = 0; i < fVMTypes.length; i++) { >- IVMInstallType type = fVMTypes[i]; >- if (type.getId().equals(MACOSX_VM_TYPE_ID)) { >- typeIndex = i; >- break; >- } >- } >- } >- fSelectedVMType = editedVM != null ? editedVM.getVMInstallType() : vmInstallTypes[typeIndex]; >- fEditedVM = editedVM; >- //only detect the javadoc location if not already set >- fAutoDetectAttributes = fEditedVM == null || fEditedVM.getJavadocLocation() == null; >- } >- >- /** >- * This method is used to sort the array of VM install types, placing >- * the 'Standard VM' type first, if it exists >- * >- * @since 3.3.0 >- */ >- private void sortVMTypes() { >- Comparator compare = new Comparator() { >- public int compare(Object o1, Object o2) { >- if(o1 instanceof IVMInstallType && o2 instanceof IVMInstallType) { >- return ((IVMInstallType) o1).getName().compareTo(((IVMInstallType) o2).getName()); >- } >- return 0; >- } >- }; >- //first find the 'Standard VM' and set it at position 0 >- for(int i = 0; i < fVMTypes.length; i++) { >- if(fVMTypes[i].getId().equals("org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")) { //$NON-NLS-1$ >- if(i > 0) { >- IVMInstallType tmp = fVMTypes[0]; >- fVMTypes[0] = fVMTypes[i]; >- fVMTypes[i] = tmp; >- break; >- } >- else { >- break; >- } >- } >- } >- if(fVMTypes[0].getId().equals("org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")) { //$NON-NLS-1$ >- Arrays.sort(fVMTypes, 1, fVMTypes.length, compare); >- } >- else { >- Arrays.sort(fVMTypes, compare); >- } >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.StatusDialog#configureShell(org.eclipse.swt.widgets.Shell) >- */ >- protected void configureShell(Shell newShell) { >- super.configureShell(newShell); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaDebugHelpContextIds.EDIT_JRE_DIALOG); >- } >- >- /** >- * Returns the VM name from the text control >- * @return >- */ >- protected String getVMName() { >- return fVMName.getText(); >- } >- >- /** >- * Returns the installation location as a file from the JRE root text control >- * @return the installation location as a file >- */ >- protected File getInstallLocation() { >- return new File(fJRERoot.getText()); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >- */ >- protected Control createDialogArea(Composite ancestor) { >- Composite parent = (Composite)super.createDialogArea(ancestor); >- ((GridLayout)parent.getLayout()).numColumns = 3; >- //VM type >- SWTFactory.createLabel(parent, JREMessages.addVMDialog_jreType, 1); >- fVMCombo = SWTFactory.createCombo(parent, SWT.READ_ONLY, 2, getVMTypeNames()); >- // VM location >- SWTFactory.createLabel(parent, JREMessages.addVMDialog_jreHome, 1); >- fJRERoot = SWTFactory.createSingleText(parent, 2); >- Composite buttons = SWTFactory.createComposite(parent, parent.getFont(), 2, 4, GridData.HORIZONTAL_ALIGN_END, 0, 0); >- Button folders = SWTFactory.createPushButton(buttons, JREMessages.AddVMDialog_22, null); >- GridData data = (GridData) folders.getLayoutData(); >- data.horizontalAlignment = GridData.END; >- fFileButton = SWTFactory.createPushButton(buttons, JREMessages.AddVMDialog_21, null); >- data = (GridData) fFileButton.getLayoutData(); >- data.horizontalAlignment = GridData.END; >- //VM name >- SWTFactory.createLabel(parent, JREMessages.addVMDialog_jreName, 1); >- fVMName = SWTFactory.createSingleText(parent, 2); >- //VM arguments >- SWTFactory.createLabel(parent, JREMessages.AddVMDialog_23, 1); >- fVMArgs = SWTFactory.createSingleText(parent, 2); >- //VM libraries block >- SWTFactory.createLabel(parent, JREMessages.AddVMDialog_JRE_system_libraries__1, 3); >- fLibraryBlock = new VMLibraryBlock(this); >- Control block = fLibraryBlock.createControl(parent); >- GridData gd = new GridData(GridData.FILL_BOTH); >- gd.horizontalSpan = 3; >- block.setLayoutData(gd); >- >- //initialize the fields >- initializeFields(); >- >- //add the listeners now to prevent them from monkeying with initialized settings >- fVMCombo.addSelectionListener(new SelectionListener() { >- public void widgetDefaultSelected(SelectionEvent e) {} >- public void widgetSelected(SelectionEvent e) { >- updateVMType(); >- } >- }); >- fVMName.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- validateVMName(); >- updateStatusLine(); >- } >- }); >- fJRERoot.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- validateJRELocation(); >- updateStatusLine(); >- } >- }); >- folders.addSelectionListener(new SelectionListener() { >- public void widgetDefaultSelected(SelectionEvent e) {} >- public void widgetSelected(SelectionEvent e) { >- DirectoryDialog dialog = new DirectoryDialog(getShell()); >- File file = new File(fJRERoot.getText()); >- String text = fJRERoot.getText(); >- if (file.isFile()) { >- text = file.getParentFile().getAbsolutePath(); >- } >- dialog.setFilterPath(text); >- dialog.setMessage(JREMessages.addVMDialog_pickJRERootDialog_message); >- String newPath = dialog.open(); >- if (newPath != null) { >- fJRERoot.setText(newPath); >- } >- } >- }); >- fFileButton.addSelectionListener(new SelectionListener() { >- public void widgetDefaultSelected(SelectionEvent e) {} >- public void widgetSelected(SelectionEvent e) { >- FileDialog dialog = new FileDialog(getShell()); >- dialog.setFilterExtensions(new String[]{"*.ee"}); //$NON-NLS-1$ >- dialog.setFilterPath(fJRERoot.getText()); >- String newPath = dialog.open(); >- if (newPath != null) { >- fJRERoot.setText(newPath); >- } >- } >- }); >- applyDialogFont(parent); >- return parent; >- } >- >- /** >- * Updates the JRE location status and initializes the library block >- */ >- private void updateVMType() { >- int selIndex = fVMCombo.getSelectionIndex(); >- if (selIndex == fPrevIndex) { >- return; >- } >- fPrevIndex = selIndex; >- if (selIndex >= 0 && selIndex < fVMTypes.length) { >- fSelectedVMType= fVMTypes[selIndex]; >- } >- validateJRELocation(); >- fLibraryBlock.initializeFrom(fEditedVM, fSelectedVMType); >- updateFileButton(); >- updateStatusLine(); >- } >- >- /** >- * Updates enabled state of the "Definition File..." button. >- */ >- private void updateFileButton() { >- fFileButton.setEnabled(fSelectedVMType.getId().equals(StandardVMType.ID_STANDARD_VM_TYPE)); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.StatusDialog#create() >- */ >- public void create() { >- super.create(); >- if (fJRERoot.getText().length() == 0) { >- fJRERoot.setFocus(); >- } else { >- fVMName.setFocus(); >- } >- selectVMType(); >- } >- >- /** >- * Returns the VM type names >- * @return an array of strings with the names of the applicable VMs >- */ >- private String[] getVMTypeNames() { >- String[] names = new String[fVMTypes.length]; >- for (int i = 0; i < fVMTypes.length; i++) { >- names[i]= fVMTypes[i].getName(); >- } >- return names; >- } >- >- /** >- * Selects the corresponding VM for fSelectedVMType >- */ >- private void selectVMType() { >- for (int i= 0; i < fVMTypes.length; i++) { >- if (fSelectedVMType == fVMTypes[i]) { >- if(i < fVMCombo.getItemCount()) { >- fVMCombo.select(i); >- return; >- } >- } >- } >- } >- >- /** >- * Initialize the dialogs fields >- */ >- private void initializeFields() { >- if (fEditedVM == null) { >- fVMName.setText(""); //$NON-NLS-1$ >- fJRERoot.setText(""); //$NON-NLS-1$ >- fLibraryBlock.initializeFrom(null, fSelectedVMType); >- fVMArgs.setText(""); //$NON-NLS-1$ >- } else { >- fVMCombo.setEnabled(false); >- fVMName.setText(fEditedVM.getName()); >- fJRERoot.setText(fEditedVM.getInstallLocation().getAbsolutePath()); >- fLibraryBlock.initializeFrom(fEditedVM, fSelectedVMType); >- if (fEditedVM instanceof IVMInstall2) { >- IVMInstall2 vm2 = (IVMInstall2) fEditedVM; >- String vmArgs = vm2.getVMArgs(); >- if (vmArgs != null) { >- fVMArgs.setText(vmArgs); >- } >- } else { >- String[] vmArgs = fEditedVM.getVMArguments(); >- if (vmArgs != null) { >- StringBuffer buffer = new StringBuffer(); >- int length= vmArgs.length; >- if (length > 0) { >- buffer.append(vmArgs[0]); >- for (int i = 1; i < length; i++) { >- buffer.append(' ').append(vmArgs[i]); >- } >- } >- fVMArgs.setText(buffer.toString()); >- } >- } >- } >- updateFileButton(); >- validateVMName(); >- updateStatusLine(); >- } >- >- /** >- * Validates the JRE location >- * @return the status after validating the JRE location >- */ >- private IStatus validateJRELocation() { >- String locationName = fJRERoot.getText(); >- IStatus s = null; >- File file = null; >- if (locationName.length() == 0) { >- s = new StatusInfo(IStatus.INFO, JREMessages.addVMDialog_enterLocation); >- } >- else { >- file = new File(locationName); >- if (!file.exists()) { >- s = new StatusInfo(IStatus.ERROR, JREMessages.addVMDialog_locationNotExists); >- } >- else { >- final IStatus[] temp = new IStatus[1]; >- final File tempFile = file; >- Runnable r = new Runnable() { >- public void run() { >- temp[0] = fSelectedVMType.validateInstallLocation(tempFile); >- } >- }; >- BusyIndicator.showWhile(getShell().getDisplay(), r); >- s = temp[0]; >- } >- } >- if (s.isOK()) { >- fLibraryBlock.setHomeDirectory(file); >- String name = fVMName.getText(); >- if (name == null || name.trim().length() == 0) { >- // auto-generate VM name >- if (file.isFile()) { >- String fileName = file.getName(); >- int index = fileName.lastIndexOf(".ee"); //$NON-NLS-1$ >- if (index > 0) { >- fileName = fileName.substring(0, index); >- } >- fVMName.setText(fileName); >- } else { >- try { >- String genName = null; >- IPath path = new Path(file.getCanonicalPath()); >- int segs = path.segmentCount(); >- if (segs == 1) { >- genName = path.segment(0); >- } >- else if (segs >= 2) { >- String last = path.lastSegment(); >- if ("jre".equalsIgnoreCase(last)) { //$NON-NLS-1$ >- genName = path.segment(segs - 2); >- } >- else { >- genName = last; >- } >- } >- if (genName != null) { >- fVMName.setText(genName); >- } >- } catch (IOException e) {} >- } >- } >- } else { >- fLibraryBlock.setHomeDirectory(null); >- } >- fLibraryBlock.restoreDefaultLibraries(); >- detectJavadocLocation(); >- fStatus[1] = s; >- return s; >- } >- >- /** >- * Auto-detects the default javadoc location >- */ >- private void detectJavadocLocation() { >- if (fAutoDetectAttributes) { >- if (fSelectedVMType instanceof AbstractVMInstallType) { >- AbstractVMInstallType type = (AbstractVMInstallType)fSelectedVMType; >- fJavadocLocation = type.getDefaultJavadocLocation(getInstallLocation()); >- String args = type.getDefaultVMArguments(getInstallLocation()); >- if (args != null) { >- fVMArgs.setText(args); >- } >- } >- } else { >- fJavadocLocation = fEditedVM.getJavadocLocation(); >- } >- } >- >- /** >- * Validates the entered name of the VM >- * @return the status of the name validation >- */ >- private IStatus validateVMName() { >- StatusInfo status= new StatusInfo(); >- String name= fVMName.getText(); >- if (name == null || name.trim().length() == 0) { >- status.setInfo(JREMessages.addVMDialog_enterName); >- } else { >- if (fRequestor.isDuplicateName(name) && (fEditedVM == null || !name.equals(fEditedVM.getName()))) { >- status.setError(JREMessages.addVMDialog_duplicateName); >- } else { >- IStatus s = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE); >- if (!s.isOK()) { >- status.setError(MessageFormat.format(JREMessages.AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1, new String[]{s.getMessage()})); >- } >- } >- } >- fStatus[0] = status; >- return status; >- } >- >- /** >- * Updates the status line to show/hide messages to the user >- */ >- protected void updateStatusLine() { >- IStatus max= null; >- for (int i = 0; i < fStatus.length; i++) { >- IStatus curr = fStatus[i]; >- if (curr.matches(IStatus.ERROR)) { >- updateStatus(curr); >- return; >- } >- if (max == null || curr.getSeverity() > max.getSeverity()) { >- max = curr; >- } >- } >- updateStatus(max); >- } >- >- /** >- * Returns the URL for the javadoc location >- * @return the URL for the javadoc location >- */ >- protected URL getURL() { >- return fJavadocLocation; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#okPressed() >- */ >- protected void okPressed() { >- if (fEditedVM == null) { >- IVMInstall vm = new VMStandin(fSelectedVMType, createUniqueId(fSelectedVMType)); >- setFieldValuesToVM(vm); >- fRequestor.vmAdded(vm); >- } else { >- setFieldValuesToVM(fEditedVM); >- } >- super.okPressed(); >- } >- >- /** >- * Creates a unique name for the VMInstallType >- * @param vmType the vm install type >- * @return a unique name >- */ >- private String createUniqueId(IVMInstallType vmType) { >- String id = null; >- do { >- id = String.valueOf(System.currentTimeMillis()); >- } while (vmType.findVMInstall(id) != null); >- return id; >- } >- >- /** >- * initialize fields to the specified VM >- * @param vm the VM to initialize from >- */ >- protected void setFieldValuesToVM(IVMInstall vm) { >- File dir = new File(fJRERoot.getText()); >- try { >- vm.setInstallLocation(dir.getCanonicalFile()); >- } >- catch (IOException e) { >- vm.setInstallLocation(dir.getAbsoluteFile()); >- } >- vm.setName(fVMName.getText()); >- vm.setJavadocLocation(getURL()); >- >- String argString = fVMArgs.getText().trim(); >- if (vm instanceof IVMInstall2) { >- IVMInstall2 vm2 = (IVMInstall2) vm; >- if (argString != null && argString.length() > 0) { >- vm2.setVMArgs(argString); >- } >- else { >- vm2.setVMArgs(null); >- } >- } >- else { >- if (argString != null && argString.length() > 0) { >- vm.setVMArguments(DebugPlugin.parseArguments(argString)); >- } >- else { >- vm.setVMArguments(null); >- } >- } >- fLibraryBlock.performApply(vm); >- } >- >- /** >- * returns an absolute file or an empty file if the path is either null or zero length >- * @param path the path to the file >- * @return a new file >- */ >- protected File getAbsoluteFileOrEmpty(String path) { >- if (path == null || path.length() == 0) { >- return new File(""); //$NON-NLS-1$ >- } >- return new File(path).getAbsoluteFile(); >- } >- >- /** >- * @return the status of the system library >- */ >- protected IStatus getSystemLibraryStatus() { >- return fStatus[3]; >- } >- >- /** >- * Allows the VM page to set the status of the current system library >- * @param status the specified status >- */ >- protected void setSystemLibraryStatus(IStatus status) { >- fStatus[3] = status; >- } >- >- /** >- * Updates the status of the OK button to reflect the given status. >- * Subclasses may override this method to update additional buttons. >- * @param status the status. >- */ >- protected void updateButtonsEnableState(IStatus status) { >- Button ok = getButton(IDialogConstants.OK_ID); >- if (ok != null && !ok.isDisposed()) >- ok.setEnabled(status.getSeverity() == IStatus.OK); >- } >- >- /** >- * Returns the name of the section that this dialog stores its settings in >- * >- * @return String >- */ >- protected String getDialogSettingsSectionName() { >- return "ADD_VM_DIALOG_SECTION"; //$NON-NLS-1$ >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() >- */ >- protected IDialogSettings getDialogBoundsSettings() { >- IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings(); >- IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); >- if (section == null) { >- section = settings.addNewSection(getDialogSettingsSectionName()); >- } >- return section; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() >- */ >- protected Point getInitialSize() { >- IDialogSettings settings = getDialogBoundsSettings(); >- if(settings != null) { >- try { >- int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$ >- int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$ >- if(width > 0 & height > 0) { >- return new Point(width, height); >- } >- } >- catch (NumberFormatException nfe) { >- return new Point(500, 570); >- } >- } >- return new Point(500, 570); >- } >- >- protected void setButtonLayoutData(Button button) { >- super.setButtonLayoutData(button); >- } >- >-} >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/VMLibraryBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/VMLibraryBlock.java,v >retrieving revision 1.32 >diff -u -r1.32 VMLibraryBlock.java >--- ui/org/eclipse/jdt/internal/debug/ui/jres/VMLibraryBlock.java 19 Jul 2007 19:47:04 -0000 1.32 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/VMLibraryBlock.java 3 Oct 2007 22:11:14 -0000 >@@ -21,14 +21,16 @@ > import org.eclipse.core.runtime.Status; > import org.eclipse.jdt.core.IClasspathEntry; > import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants; >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; > import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; > import org.eclipse.jdt.internal.debug.ui.SWTFactory; > import org.eclipse.jdt.internal.debug.ui.jres.LibraryContentProvider.SubElement; >+import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.launching.IRuntimeClasspathEntry; > import org.eclipse.jdt.launching.IVMInstall; >-import org.eclipse.jdt.launching.IVMInstallType; > import org.eclipse.jdt.launching.JavaRuntime; > import org.eclipse.jdt.launching.LibraryLocation; >+import org.eclipse.jdt.launching.VMStandin; > import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; > import org.eclipse.jface.dialogs.IDialogSettings; > import org.eclipse.jface.viewers.DoubleClickEvent; >@@ -44,14 +46,13 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.FileDialog; > > /** > * Control used to edit the libraries associated with a VM install > */ >-public class VMLibraryBlock implements SelectionListener, ISelectionChangedListener { >- >+public class VMLibraryBlock extends AbstractVMInstallPage implements SelectionListener, ISelectionChangedListener { >+ > /** > * Attribute name for the last path used to open a file/directory chooser > * dialog. >@@ -64,13 +65,10 @@ > protected static final String DIALOG_SETTINGS_PREFIX = "VMLibraryBlock"; //$NON-NLS-1$ > > protected boolean fInCallback = false; >- protected IVMInstall fVmInstall; >- protected IVMInstallType fVmInstallType; >- protected File fHome; >+ protected VMStandin fVmInstall; > > //widgets > protected LibraryContentProvider fLibraryContentProvider; >- protected AddVMDialog fDialog = null; > protected TreeViewer fLibraryViewer; > private Button fUpButton; > private Button fDownButton; >@@ -80,19 +78,22 @@ > private Button fSourceButton; > protected Button fDefaultButton; > >+ private IStatus[] fLibStatus; >+ > /** >- * Constructor for VMLibraryBlock. >+ * Constructs a new wizard page with the given name. >+ * >+ * @param pageName page name > */ >- public VMLibraryBlock(AddVMDialog dialog) { >- fDialog = dialog; >- } >+ VMLibraryBlock() { >+ super(JREMessages.VMLibraryBlock_2); >+ fLibStatus = new IStatus[]{Status.OK_STATUS}; >+ } > >- /** >- * Creates and returns the source lookup control. >- * >- * @param parent the parent widget of this control >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) > */ >- public Control createControl(Composite parent) { >+ public void createControl(Composite parent) { > Font font = parent.getFont(); > > Composite comp = SWTFactory.createComposite(parent, font, 2, 1, GridData.FILL_BOTH, 0, 0); >@@ -132,62 +133,43 @@ > fDefaultButton = SWTFactory.createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_9, JREMessages.VMLibraryBlock_15, null); > fDefaultButton.addSelectionListener(this); > >- return comp; >+ setControl(comp); > } > > /** > * The "default" button has been toggled > */ >- public void restoreDefaultLibraries() { >+ private void restoreDefaultLibraries() { > LibraryLocation[] libs = null; >- File installLocation = getHomeDirectory(); >- if (installLocation == null) { >- libs = new LibraryLocation[0]; >- } else { >- libs = getVMInstallType().getDefaultLibraryLocations(installLocation); >+ File installLocation = null; >+ if (fVmInstall != null) { >+ if (EEVMType.ID_EE_VM_TYPE.equals(fVmInstall.getVMInstallType().getId())) { >+ File definitionFile = EEVMType.getDefinitionFile(fVmInstall); >+ if (definitionFile != null) { >+ libs = EEVMType.getLibraryLocations(definitionFile); >+ } else { >+ libs = new LibraryLocation[0]; >+ } >+ } else { >+ installLocation = fVmInstall.getInstallLocation(); >+ if (installLocation == null) { >+ libs = new LibraryLocation[0]; >+ } else { >+ libs = fVmInstall.getVMInstallType().getDefaultLibraryLocations(installLocation); >+ } >+ } > } > fLibraryContentProvider.setLibraries(libs); > update(); > } > > /** >- * Initializes this control based on the settings in the given >- * vm install and type. >- * >- * @param vm vm or <code>null</code> if none >- * @param type type of vm install >- */ >- public void initializeFrom(IVMInstall vm, IVMInstallType type) { >- fVmInstall = vm; >- fVmInstallType = type; >- if (vm != null) { >- setHomeDirectory(vm.getInstallLocation()); >- fLibraryContentProvider.setLibraries(JavaRuntime.getLibraryLocations(getVMInstall())); >- } >- update(); >- } >- >- /** >- * Sets the home directory of the VM Install the user has chosen >- */ >- public void setHomeDirectory(File file) { >- fHome = file; >- } >- >- /** >- * Returns the home directory >- */ >- protected File getHomeDirectory() { >- return fHome; >- } >- >- /** > * Updates buttons and status based on current libraries > */ >- public void update() { >+ private void update() { > updateButtons(); > IStatus status = Status.OK_STATUS; >- if (fLibraryContentProvider.getLibraries().length == 0) { // && !isDefaultSystemLibrary()) { >+ if (fLibraryContentProvider.getLibraries().length == 0) { > status = new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR, "Libraries cannot be empty.", null); //$NON-NLS-1$ > } > LibraryStandin[] standins = fLibraryContentProvider.getStandins(); >@@ -198,21 +180,20 @@ > break; > } > } >- fDialog.setSystemLibraryStatus(status); >- fDialog.updateStatusLine(); >- } >- >- /** >- * Saves settings in the given working copy >- */ >- public void performApply(IVMInstall vm) { >- if (isDefaultLocations(vm)) { >- vm.setLibraryLocations(null); >+ fLibStatus[0] = status; >+ if (status.isOK()) { >+ setErrorMessage(null); >+ setPageComplete(true); > } else { >- LibraryLocation[] libs = fLibraryContentProvider.getLibraries(); >- vm.setLibraryLocations(libs); >- } >- } >+ setErrorMessage(status.getMessage()); >+ setPageComplete(false); >+ } >+ // must force since this page is a 'sub-page' and may not be considered the current page >+ if (getContainer().getCurrentPage() != this) { >+ getContainer().updateMessage(); >+ getContainer().updateButtons(); >+ } >+ } > > /** > * Determines if the current libraries displayed to the user are the default location >@@ -228,7 +209,7 @@ > } > File installLocation = vm.getInstallLocation(); > if (installLocation != null) { >- LibraryLocation[] def = getVMInstallType().getDefaultLibraryLocations(installLocation); >+ LibraryLocation[] def = vm.getVMInstallType().getDefaultLibraryLocations(installLocation); > if (def.length == libraryLocations.length) { > for (int i = 0; i < def.length; i++) { > if (!def[i].equals(libraryLocations[i])) { >@@ -240,24 +221,6 @@ > } > return false; > } >- >- /** >- * Returns the vm install associated with this library block. >- * >- * @return vm install >- */ >- protected IVMInstall getVMInstall() { >- return fVmInstall; >- } >- >- /** >- * Returns the vm install type associated with this library block. >- * >- * @return vm install >- */ >- protected IVMInstallType getVMInstallType() { >- return fVmInstallType; >- } > > /* (non-Javadoc) > * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >@@ -409,4 +372,49 @@ > fJavadocButton.setEnabled(!selection.isEmpty() && (allJavadoc || allRoots)); > fSourceButton.setEnabled(!selection.isEmpty() && (allSource || allRoots)); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#finish() >+ */ >+ public boolean finish() { >+ if (fVmInstall != null) { >+ if (isDefaultLocations(fVmInstall)) { >+ fVmInstall.setLibraryLocations(null); >+ } else { >+ LibraryLocation[] libs = fLibraryContentProvider.getLibraries(); >+ fVmInstall.setLibraryLocations(libs); >+ } >+ } >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#getSelection() >+ */ >+ public VMStandin getSelection() { >+ return fVmInstall; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#setSelection(org.eclipse.jdt.launching.VMStandin) >+ */ >+ public void setSelection(VMStandin vm) { >+ super.setSelection(vm); >+ LibraryLocation[] libraryLocations = null; >+ if (vm == null) { >+ libraryLocations = new LibraryLocation[0]; >+ } else { >+ libraryLocations = JavaRuntime.getLibraryLocations(vm); >+ } >+ fVmInstall = vm; >+ fLibraryContentProvider.setLibraries(libraryLocations); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#getVMStatus() >+ */ >+ protected IStatus[] getVMStatus() { >+ return fLibStatus; >+ } >+ > } >Index: ui/org/eclipse/jdt/debug/ui/IJavaDebugUIConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/IJavaDebugUIConstants.java,v >retrieving revision 1.22 >diff -u -r1.22 IJavaDebugUIConstants.java >--- ui/org/eclipse/jdt/debug/ui/IJavaDebugUIConstants.java 12 Sep 2006 14:58:47 -0000 1.22 >+++ ui/org/eclipse/jdt/debug/ui/IJavaDebugUIConstants.java 3 Oct 2007 22:11:14 -0000 >@@ -32,6 +32,14 @@ > public static final String EXTENSION_POINT_VM_INSTALL_TYPE_PAGE = "vmInstallTypePage"; //$NON-NLS-1$ > > /** >+ * Extension point identifier for contributions of a wizard page that for a VMInstallType >+ * (value <code>"vmInstallPages"</code>). >+ * >+ * @since 3.4 >+ */ >+ public static final String EXTENSION_POINT_VM_INSTALL_PAGES = "vmInstallPages"; //$NON-NLS-1$ >+ >+ /** > * Display view identifier (value <code>"org.eclipse.jdt.debug.ui.DisplayView"</code>). > */ > public static final String ID_DISPLAY_VIEW= PLUGIN_ID + ".DisplayView"; //$NON-NLS-1$ >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.xml,v >retrieving revision 1.464 >diff -u -r1.464 plugin.xml >--- plugin.xml 10 Sep 2007 15:00:43 -0000 1.464 >+++ plugin.xml 3 Oct 2007 22:11:14 -0000 >@@ -5,6 +5,7 @@ > > <!-- Extensions Points --> > <extension-point id="vmInstallTypePage" name="%vmInstallTypePage" schema="schema/vmInstallTypePage.exsd"/> >+ <extension-point id="vmInstallPages" name="VM Install Page" schema="schema/vmInstallPages.exsd"/> > > <!-- Extensions --> > <extension >@@ -3369,4 +3370,11 @@ > targetId="org.eclipse.jdt.ui.javaCode"> > </hyperlinkDetector> > </extension> >+ <extension >+ point="org.eclipse.jdt.debug.ui.vmInstallPages"> >+ <vmInstallPage >+ class="org.eclipse.jdt.internal.debug.ui.jres.EEVMPage" >+ vmInstallType="org.eclipse.jdt.launching.EEVMType"> >+ </vmInstallPage> >+ </extension> > </plugin> >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/VMTypePage.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/VMTypePage.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/VMTypePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/VMTypePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,164 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.jres; >+ >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.Set; >+ >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.internal.debug.ui.JavaDebugImages; >+import org.eclipse.jdt.internal.debug.ui.SWTFactory; >+import org.eclipse.jdt.internal.launching.StandardVMType; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.ViewerComparator; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+ >+/** >+ * Wizard page used to select a VM type. >+ * >+ * @since 3.4 >+ */ >+public class VMTypePage extends WizardPage { >+ >+ private CheckboxTableViewer fTypesViewer; >+ >+ private AbstractVMInstallPage fNextPage; >+ >+ /** >+ * Keep track of pages created, so we can dispose of them. >+ */ >+ private Set fPages = new HashSet(); >+ >+ /** >+ * Label provider for VM types >+ */ >+ private class TypeLabelProvider extends LabelProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ if (element instanceof IVMInstallType) { >+ IVMInstallType type = (IVMInstallType) element; >+ return type.getName(); >+ } >+ return super.getText(element); >+ } >+ >+ } >+ >+ /** >+ * Constructs a VM type selection page >+ */ >+ public VMTypePage() { >+ super(JREMessages.VMTypePage_0); >+ setDescription(JREMessages.VMTypePage_1); >+ setTitle(JREMessages.VMTypePage_2); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#dispose() >+ */ >+ public void dispose() { >+ super.dispose(); >+ Iterator iterator = fPages.iterator(); >+ while (iterator.hasNext()) { >+ AbstractVMInstallPage page = (AbstractVMInstallPage)iterator.next(); >+ page.dispose(); >+ } >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 1; >+ composite.setLayout(layout); >+ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ SWTFactory.createLabel(composite, JREMessages.VMTypePage_3, 1); >+ >+ fTypesViewer = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.heightHint = 250; >+ data.widthHint = 300; >+ fTypesViewer.getTable().setLayoutData(data); >+ fTypesViewer.setContentProvider(new ArrayContentProvider()); >+ fTypesViewer.setLabelProvider(new TypeLabelProvider()); >+ fTypesViewer.setComparator(new ViewerComparator()); >+ fTypesViewer.addCheckStateListener(new ICheckStateListener() { >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ if (event.getChecked()) { >+ // only check one element >+ fTypesViewer.setCheckedElements(new Object[]{event.getElement()}); >+ setPageComplete(true); >+ updateNextPage(); >+ } else { >+ setPageComplete(false); >+ } >+ } >+ }); >+ fTypesViewer.setInput(JavaRuntime.getVMInstallTypes()); >+ setControl(composite); >+ >+ fTypesViewer.setChecked(JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE), true); >+ updateNextPage(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#getImage() >+ */ >+ public Image getImage() { >+ return JavaDebugImages.get(JavaDebugImages.IMG_WIZBAN_LIBRARY); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.WizardPage#getNextPage() >+ */ >+ public IWizardPage getNextPage() { >+ return fNextPage; >+ } >+ >+ private void updateNextPage() { >+ if (isPageComplete()) { >+ Object[] checkedElements = fTypesViewer.getCheckedElements(); >+ if (checkedElements.length == 1) { >+ IVMInstallType installType = (IVMInstallType)checkedElements[0]; >+ AbstractVMInstallPage page = ((VMInstallWizard)getWizard()).getPage(installType); >+ page.setWizard(getWizard()); >+ VMStandin standin = new VMStandin(installType, StandardVMPage.createUniqueId(installType)); >+ standin.setName(""); //$NON-NLS-1$ >+ page.setSelection(standin); >+ fNextPage = page; >+ fPages.add(page); >+ } >+ } >+ } >+ >+} >Index: schema/vmInstallPages.exsd >=================================================================== >RCS file: schema/vmInstallPages.exsd >diff -N schema/vmInstallPages.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/vmInstallPages.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,131 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.jdt.debug.ui"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.jdt.debug.ui" id="vmInstallPages" name="VM Install Pages"/> >+ </appInfo> >+ <documentation> >+ This extension point allows a wizard page to be contributed for VM installs that require custom editing controls. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="vmInstallPage"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="vmInstallPage"> >+ <annotation> >+ <documentation> >+ Contributes a wizard page for a specific VM install type. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="vmInstallType" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Specifies the VM install type this wizard page is to be used for. Unique identifier corresponding to an <code>IVMInstallType</code>'s id. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Wizard page implementation. Must be a subclass of <code>org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage</code>. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage:"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ 3.4 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ Following is an example definition of a VM install page. >+<p> >+<pre> >+<extension point="org.eclipse.jdt.debug.ui.vmInstallPages"> >+ <vmInstallPage >+ vmInstallType="org.eclipse.jdt.launching.EEVMType" >+ class="org.eclipse.jdt.internal.debug.ui.jres.EEVMPage"> >+ </vmInstallPage> >+</extension> >+</pre> >+</p> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ A wizard page must be a subclass of <code>org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage</code>. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ JDT provides a default implementation of a wizard page for VMs that do not contribute one. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2007 IBM Corporation and others.<br> >+All rights reserved. This program and the accompanying materials are made >+available under the terms of the Eclipse Public License v1.0 which >+accompanies this distribution, and is available at >+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/EEVMPage.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/EEVMPage.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/EEVMPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/EEVMPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,383 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.jres; >+ >+import java.io.File; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.internal.debug.ui.JavaDebugImages; >+import org.eclipse.jdt.internal.debug.ui.SWTFactory; >+import org.eclipse.jdt.internal.debug.ui.StatusInfo; >+import org.eclipse.jdt.internal.launching.EEVMInstall; >+import org.eclipse.jdt.internal.launching.EEVMType; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+ >+/** >+ * Page used to edit an 'EE' VM. >+ * >+ * @since 3.4 >+ */ >+public class EEVMPage extends AbstractVMInstallPage { >+ >+ // VM being edited or created >+ private VMStandin fVM; >+ private Text fVMName; >+ private Text fVMArgs; >+ private Text fEEFile; >+ private VMLibraryBlock fLibraryBlock; >+ private IStatus[] fFieldStatus = new IStatus[1]; >+ private boolean fIgnoreCallbacks = false; >+ >+ /** >+ * >+ */ >+ public EEVMPage() { >+ super(JREMessages.EEVMPage_0); >+ for (int i = 0; i < fFieldStatus.length; i++) { >+ fFieldStatus[i] = Status.OK_STATUS; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#getImage() >+ */ >+ public Image getImage() { >+ return JavaDebugImages.get(JavaDebugImages.IMG_WIZBAN_LIBRARY); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite p) { >+ // create a composite with standard margins and spacing >+ Composite composite = new Composite(p, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 3; >+ composite.setLayout(layout); >+ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ // VM location >+ SWTFactory.createLabel(composite, JREMessages.EEVMPage_1, 1); >+ fEEFile = SWTFactory.createSingleText(composite, 1); >+ Button folders = SWTFactory.createPushButton(composite, JREMessages.EEVMPage_2, null); >+ GridData data = (GridData) folders.getLayoutData(); >+ data.horizontalAlignment = GridData.END; >+ //VM name >+ SWTFactory.createLabel(composite, JREMessages.addVMDialog_jreName, 1); >+ fVMName = SWTFactory.createSingleText(composite, 2); >+ //VM arguments >+ Label label = SWTFactory.createLabel(composite, JREMessages.AddVMDialog_23, 1); >+ GridData gd = (GridData) label.getLayoutData(); >+ gd.verticalAlignment = SWT.BEGINNING; >+ fVMArgs = SWTFactory.createText(composite, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP, 2, ""); //$NON-NLS-1$ >+ gd = (GridData) fVMArgs.getLayoutData(); >+ gd.widthHint = 200; >+ gd.heightHint = 50; >+ //VM libraries block >+ SWTFactory.createLabel(composite, JREMessages.AddVMDialog_JRE_system_libraries__1, 3); >+ fLibraryBlock = new VMLibraryBlock(); >+ fLibraryBlock.setWizard(getWizard()); >+ fLibraryBlock.createControl(composite); >+ Control libControl = fLibraryBlock.getControl(); >+ gd = new GridData(GridData.FILL_BOTH); >+ gd.horizontalSpan = 3; >+ libControl.setLayoutData(gd); >+ >+ initializeFields(); >+ //add the listeners now to prevent them from monkeying with initialized settings >+ fVMName.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if (!fIgnoreCallbacks) { >+ validateVMName(); >+ } >+ } >+ }); >+ fEEFile.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if (!fIgnoreCallbacks) { >+ if (validateDefinitionFile().isOK()) { >+ reloadDefinitionFile(); >+ } >+ } >+ } >+ }); >+ folders.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) {} >+ public void widgetSelected(SelectionEvent e) { >+ FileDialog dialog = new FileDialog(getShell()); >+ dialog.setFilterExtensions(new String[]{"*.ee"}); //$NON-NLS-1$ >+ File file = getDefinitionFile(); >+ String text = fEEFile.getText(); >+ if (file != null && file.isFile()) { >+ text = file.getParentFile().getAbsolutePath(); >+ } >+ dialog.setFileName(text); >+ String newPath = dialog.open(); >+ if (newPath != null) { >+ fEEFile.setText(newPath); >+ } >+ } >+ }); >+ Dialog.applyDialogFont(composite); >+ setControl(composite); >+ } >+ >+ /** >+ * Validates the JRE location >+ * @return the status after validating the JRE location >+ */ >+ private IStatus validateDefinitionFile() { >+ String locationName = fEEFile.getText(); >+ IStatus s = null; >+ File file = null; >+ if (locationName.length() == 0) { >+ s = new StatusInfo(IStatus.INFO, JREMessages.EEVMPage_4); >+ } else { >+ file = new File(locationName); >+ if (!file.exists()) { >+ s = new StatusInfo(IStatus.ERROR, JREMessages.EEVMPage_5); >+ } else { >+ EEVMType.clearProperties(file); >+ final IStatus[] temp = new IStatus[1]; >+ final VMStandin[] vm = new VMStandin[1]; >+ final File tempFile = file; >+ Runnable r = new Runnable() { >+ public void run() { >+ try { >+ vm[0] = JavaRuntime.createVMFromDefinitionFile(tempFile, fVM.getName(), fVM.getId()); >+ temp[0] = Status.OK_STATUS; >+ } catch (CoreException e) { >+ temp[0] = e.getStatus(); >+ } >+ } >+ }; >+ BusyIndicator.showWhile(getShell().getDisplay(), r); >+ s = temp[0]; >+ } >+ } >+ setDefinitionFileStatus(s); >+ updatePageStatus(); >+ return s; >+ } >+ >+ /** >+ * Initializes the JRE attributes from the definition file >+ */ >+ private void reloadDefinitionFile() { >+ IStatus s = Status.OK_STATUS; >+ File file = getDefinitionFile(); >+ if (file != null && file.exists()) { >+ final IStatus[] temp = new IStatus[1]; >+ final VMStandin[] vm = new VMStandin[1]; >+ final File tempFile = file; >+ Runnable r = new Runnable() { >+ public void run() { >+ try { >+ vm[0] = JavaRuntime.createVMFromDefinitionFile(tempFile, fVM.getName(), fVM.getId()); >+ temp[0] = Status.OK_STATUS; >+ } catch (CoreException e) { >+ temp[0] = e.getStatus(); >+ } >+ } >+ }; >+ BusyIndicator.showWhile(getShell().getDisplay(), r); >+ s = temp[0]; >+ if (s.isOK()) { >+ fVM = vm[0]; >+ } >+ } >+ if (s.isOK() && file != null) { >+ String name = fVMName.getText(); >+ if (name == null || name.trim().length() == 0) { >+ // auto-generate VM name >+ String fileName = file.getName(); >+ int index = fileName.lastIndexOf("."); //$NON-NLS-1$ >+ if (index > 0) { >+ fileName = fileName.substring(0, index); >+ } >+ fVM.setName(fileName); >+ } >+ initializeFields(); >+ } >+ setDefinitionFileStatus(s); >+ } >+ >+ /** >+ * Validates the entered name of the VM >+ * @return the status of the name validation >+ */ >+ private void validateVMName() { >+ nameChanged(fVMName.getText()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#finish() >+ */ >+ public boolean finish() { >+ setFieldValuesToVM(fVM); >+ fLibraryBlock.finish(); >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#getSelection() >+ */ >+ public VMStandin getSelection() { >+ return fVM; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#setSelection(org.eclipse.jdt.launching.VMStandin) >+ */ >+ public void setSelection(VMStandin vm) { >+ super.setSelection(vm); >+ fVM = vm; >+ setTitle(JREMessages.EEVMPage_6); >+ setDescription(JREMessages.EEVMPage_7); >+ } >+ >+ /** >+ * initialize fields to the specified VM >+ * @param vm the VM to initialize from >+ */ >+ protected void setFieldValuesToVM(VMStandin vm) { >+ File eeFile = getDefinitionFile(); >+ File home = null; >+ if (eeFile != null) { >+ vm.setAttribute(EEVMInstall.ATTR_DEFINITION_FILE, eeFile.getPath()); >+ String homePath = EEVMType.getProperty(EEVMType.PROP_JAVA_HOME, eeFile); >+ if (homePath != null) { >+ home = new File(homePath); >+ } >+ } >+ vm.setInstallLocation(home); >+ vm.setName(fVMName.getText()); >+ >+ String argString = fVMArgs.getText().trim(); >+ if (argString != null && argString.length() > 0) { >+ vm.setVMArgs(argString); >+ } else { >+ vm.setVMArgs(null); >+ } >+ } >+ >+ /** >+ * Returns the definition file from the text control or <code>null</code> >+ * if none. >+ * >+ * @return definition file or <code>null</code> >+ */ >+ private File getDefinitionFile() { >+ String path = fEEFile.getText().trim(); >+ if (path.length() > 0) { >+ return new File(path); >+ } else { >+ return null; >+ } >+ } >+ >+ /** >+ * Creates a unique name for the VMInstallType >+ * @param vmType the vm install type >+ * @return a unique name >+ */ >+ protected static String createUniqueId(IVMInstallType vmType) { >+ String id = null; >+ do { >+ id = String.valueOf(System.currentTimeMillis()); >+ } while (vmType.findVMInstall(id) != null); >+ return id; >+ } >+ >+ /** >+ * Initialize the dialogs fields >+ */ >+ private void initializeFields() { >+ try { >+ fIgnoreCallbacks = true; >+ fLibraryBlock.setSelection(fVM); >+ fVMName.setText(fVM.getName()); >+ String eePath = fVM.getAttribute(EEVMInstall.ATTR_DEFINITION_FILE); >+ if (eePath != null) { >+ fEEFile.setText(eePath); >+ } >+ String vmArgs = fVM.getVMArgs(); >+ if (vmArgs != null) { >+ fVMArgs.setText(vmArgs); >+ } >+ validateVMName(); >+ validateDefinitionFile(); >+ } finally { >+ fIgnoreCallbacks = false; >+ } >+ } >+ >+ /** >+ * Sets the status of the definition file. >+ * >+ * @param status definition file status >+ */ >+ private void setDefinitionFileStatus(IStatus status) { >+ fFieldStatus[0] = status; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#getErrorMessage() >+ */ >+ public String getErrorMessage() { >+ String message = super.getErrorMessage(); >+ if (message == null) { >+ return fLibraryBlock.getErrorMessage(); >+ } >+ return message; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete() >+ */ >+ public boolean isPageComplete() { >+ boolean complete = super.isPageComplete(); >+ if (complete) { >+ return fLibraryBlock.isPageComplete(); >+ } >+ return complete; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#getVMStatus() >+ */ >+ protected IStatus[] getVMStatus() { >+ return fFieldStatus; >+ } >+ >+ >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/StandardVMPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,381 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.jres; >+ >+import java.io.File; >+import java.io.IOException; >+import java.net.URL; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.internal.debug.ui.JavaDebugImages; >+import org.eclipse.jdt.internal.debug.ui.SWTFactory; >+import org.eclipse.jdt.internal.debug.ui.StatusInfo; >+import org.eclipse.jdt.launching.AbstractVMInstallType; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.DirectoryDialog; >+import org.eclipse.swt.widgets.Text; >+ >+/** >+ * Page used to edit a standard VM. >+ * >+ * @since 3.4 >+ */ >+public class StandardVMPage extends AbstractVMInstallPage { >+ >+ // VM being edited or created >+ private VMStandin fVM; >+ private Text fVMName; >+ private Text fVMArgs; >+ private Text fJRERoot; >+ private VMLibraryBlock fLibraryBlock; >+// the VM install's javadoc location >+ private URL fJavadocLocation = null; >+ private boolean fAutoDetectAttributes = false; >+ private IStatus[] fFieldStatus = new IStatus[1]; >+ >+ /** >+ * >+ */ >+ public StandardVMPage() { >+ super(JREMessages.StandardVMPage_0); >+ for (int i = 0; i < fFieldStatus.length; i++) { >+ fFieldStatus[i] = Status.OK_STATUS; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#getImage() >+ */ >+ public Image getImage() { >+ return JavaDebugImages.get(JavaDebugImages.IMG_WIZBAN_LIBRARY); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite p) { >+ // create a composite with standard margins and spacing >+ Composite composite = new Composite(p, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 3; >+ composite.setLayout(layout); >+ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ // VM location >+ SWTFactory.createLabel(composite, JREMessages.addVMDialog_jreHome, 1); >+ fJRERoot = SWTFactory.createSingleText(composite, 1); >+ Button folders = SWTFactory.createPushButton(composite, JREMessages.AddVMDialog_22, null); >+ GridData data = (GridData) folders.getLayoutData(); >+ data.horizontalAlignment = GridData.END; >+ //VM name >+ SWTFactory.createLabel(composite, JREMessages.addVMDialog_jreName, 1); >+ fVMName = SWTFactory.createSingleText(composite, 2); >+ //VM arguments >+ SWTFactory.createLabel(composite, JREMessages.AddVMDialog_23, 1); >+ fVMArgs = SWTFactory.createSingleText(composite, 2); >+ //VM libraries block >+ SWTFactory.createLabel(composite, JREMessages.AddVMDialog_JRE_system_libraries__1, 3); >+ fLibraryBlock = new VMLibraryBlock(); >+ fLibraryBlock.setWizard(getWizard()); >+ fLibraryBlock.createControl(composite); >+ Control libControl = fLibraryBlock.getControl(); >+ GridData gd = new GridData(GridData.FILL_BOTH); >+ gd.horizontalSpan = 3; >+ libControl.setLayoutData(gd); >+ >+ >+ //add the listeners now to prevent them from monkeying with initialized settings >+ fVMName.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ validateVMName(); >+ } >+ }); >+ fJRERoot.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ validateJRELocation(); >+ } >+ }); >+ folders.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) {} >+ public void widgetSelected(SelectionEvent e) { >+ DirectoryDialog dialog = new DirectoryDialog(getShell()); >+ File file = new File(fJRERoot.getText()); >+ String text = fJRERoot.getText(); >+ if (file.isFile()) { >+ text = file.getParentFile().getAbsolutePath(); >+ } >+ dialog.setFilterPath(text); >+ dialog.setMessage(JREMessages.addVMDialog_pickJRERootDialog_message); >+ String newPath = dialog.open(); >+ if (newPath != null) { >+ fJRERoot.setText(newPath); >+ } >+ } >+ }); >+ Dialog.applyDialogFont(composite); >+ setControl(composite); >+ initializeFields(); >+ } >+ >+ /** >+ * Validates the JRE location >+ * @return the status after validating the JRE location >+ */ >+ private void validateJRELocation() { >+ String locationName = fJRERoot.getText(); >+ IStatus s = null; >+ File file = null; >+ if (locationName.length() == 0) { >+ s = new StatusInfo(IStatus.INFO, JREMessages.addVMDialog_enterLocation); >+ } >+ else { >+ file = new File(locationName); >+ if (!file.exists()) { >+ s = new StatusInfo(IStatus.ERROR, JREMessages.addVMDialog_locationNotExists); >+ } >+ else { >+ final IStatus[] temp = new IStatus[1]; >+ final File tempFile = file; >+ Runnable r = new Runnable() { >+ public void run() { >+ temp[0] = fVM.getVMInstallType().validateInstallLocation(tempFile); >+ } >+ }; >+ BusyIndicator.showWhile(getShell().getDisplay(), r); >+ s = temp[0]; >+ } >+ } >+ if (file != null) { >+ fVM.setInstallLocation(file); >+ } >+ if (s.isOK() && file != null) { >+ String name = fVMName.getText(); >+ if (name == null || name.trim().length() == 0) { >+ // auto-generate VM name >+ if (file.isFile()) { >+ String fileName = file.getName(); >+ int index = fileName.lastIndexOf(".ee"); //$NON-NLS-1$ >+ if (index > 0) { >+ fileName = fileName.substring(0, index); >+ } >+ fVMName.setText(fileName); >+ } else { >+ try { >+ String genName = null; >+ IPath path = new Path(file.getCanonicalPath()); >+ int segs = path.segmentCount(); >+ if (segs == 1) { >+ genName = path.segment(0); >+ } >+ else if (segs >= 2) { >+ String last = path.lastSegment(); >+ if ("jre".equalsIgnoreCase(last)) { //$NON-NLS-1$ >+ genName = path.segment(segs - 2); >+ } >+ else { >+ genName = last; >+ } >+ } >+ if (genName != null) { >+ fVMName.setText(genName); >+ } >+ } catch (IOException e) {} >+ } >+ } >+ } >+ detectJavadocLocation(); >+ setJRELocationStatus(s); >+ fLibraryBlock.setSelection(fVM); >+ updatePageStatus(); >+ } >+ >+ /** >+ * Auto-detects the default javadoc location >+ */ >+ private void detectJavadocLocation() { >+ if (fAutoDetectAttributes) { >+ IVMInstallType type = fVM.getVMInstallType(); >+ if (type instanceof AbstractVMInstallType) { >+ AbstractVMInstallType atype = (AbstractVMInstallType)type; >+ fJavadocLocation = atype.getDefaultJavadocLocation(getInstallLocation()); >+ String args = atype.getDefaultVMArguments(getInstallLocation()); >+ if (args != null) { >+ fVMArgs.setText(args); >+ } >+ } >+ } else { >+ fJavadocLocation = fVM.getJavadocLocation(); >+ } >+ } >+ >+ /** >+ * Returns the installation location as a file from the JRE root text control >+ * @return the installation location as a file >+ */ >+ protected File getInstallLocation() { >+ return new File(fJRERoot.getText()); >+ } >+ >+ /** >+ * Validates the entered name of the VM >+ * @return the status of the name validation >+ */ >+ private void validateVMName() { >+ nameChanged(fVMName.getText()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#finish() >+ */ >+ public boolean finish() { >+ setFieldValuesToVM(fVM); >+ fLibraryBlock.finish(); >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#getSelection() >+ */ >+ public VMStandin getSelection() { >+ return fVM; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#setSelection(org.eclipse.jdt.launching.VMStandin) >+ */ >+ public void setSelection(VMStandin vm) { >+ super.setSelection(vm); >+ fVM = vm; >+ fAutoDetectAttributes = vm.getJavadocLocation() == null; >+ setTitle(JREMessages.StandardVMPage_1); >+ setDescription(JREMessages.StandardVMPage_2); >+ } >+ >+ /** >+ * initialize fields to the specified VM >+ * @param vm the VM to initialize from >+ */ >+ protected void setFieldValuesToVM(VMStandin vm) { >+ File dir = new File(fJRERoot.getText()); >+ try { >+ vm.setInstallLocation(dir.getCanonicalFile()); >+ } >+ catch (IOException e) { >+ vm.setInstallLocation(dir.getAbsoluteFile()); >+ } >+ vm.setName(fVMName.getText()); >+ vm.setJavadocLocation(getURL()); >+ >+ String argString = fVMArgs.getText().trim(); >+ if (argString != null && argString.length() > 0) { >+ vm.setVMArgs(argString); >+ } >+ else { >+ vm.setVMArgs(null); >+ } >+ } >+ >+ /** >+ * Returns the URL for the javadoc location >+ * @return the URL for the javadoc location >+ */ >+ protected URL getURL() { >+ return fJavadocLocation; >+ } >+ >+ /** >+ * Creates a unique name for the VMInstallType >+ * @param vmType the vm install type >+ * @return a unique name >+ */ >+ protected static String createUniqueId(IVMInstallType vmType) { >+ String id = null; >+ do { >+ id = String.valueOf(System.currentTimeMillis()); >+ } while (vmType.findVMInstall(id) != null); >+ return id; >+ } >+ >+ /** >+ * Initialize the dialogs fields >+ */ >+ private void initializeFields() { >+ fLibraryBlock.setSelection(fVM); >+ fVMName.setText(fVM.getName()); >+ File installLocation = fVM.getInstallLocation(); >+ if (installLocation != null) { >+ fJRERoot.setText(installLocation.getAbsolutePath()); >+ } >+ String vmArgs = fVM.getVMArgs(); >+ if (vmArgs != null) { >+ fVMArgs.setText(vmArgs); >+ } >+ validateVMName(); >+ validateJRELocation(); >+ } >+ >+ /** >+ * Sets the status of the JRE location field. >+ * >+ * @param status JRE location status >+ */ >+ private void setJRELocationStatus(IStatus status) { >+ fFieldStatus[0] = status; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#getErrorMessage() >+ */ >+ public String getErrorMessage() { >+ String message = super.getErrorMessage(); >+ if (message == null) { >+ return fLibraryBlock.getErrorMessage(); >+ } >+ return message; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete() >+ */ >+ public boolean isPageComplete() { >+ boolean complete = super.isPageComplete(); >+ if (complete) { >+ return fLibraryBlock.isPageComplete(); >+ } >+ return complete; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage#getVMStatus() >+ */ >+ protected IStatus[] getVMStatus() { >+ return fFieldStatus; >+ } >+ >+} >Index: ui/org/eclipse/jdt/debug/ui/launchConfigurations/AbstractVMInstallPage.java >=================================================================== >RCS file: ui/org/eclipse/jdt/debug/ui/launchConfigurations/AbstractVMInstallPage.java >diff -N ui/org/eclipse/jdt/debug/ui/launchConfigurations/AbstractVMInstallPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/debug/ui/launchConfigurations/AbstractVMInstallPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,248 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.debug.ui.launchConfigurations; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.internal.debug.ui.jres.JREMessages; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.dialogs.IMessageProvider; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+ >+import com.ibm.icu.text.MessageFormat; >+ >+/** >+ * A wizard page used to edit the attributes of an installed JRE. A page is >+ * provided by JDT to edit standard JREs, but clients may contribute a custom >+ * page for a VM install type if required. >+ * <p> >+ * A VM install page is contributed via the <code>vmInstallPages</code> extension >+ * point. Following is an example definition of a VM install page. >+ * <pre> >+ * <extension point="org.eclipse.jdt.debug.ui.vmInstallPages"> >+ * <vmInstallPage >+ * vmInstallType="org.eclipse.jdt.launching.EEVMType" >+ * class="org.eclipse.jdt.internal.debug.ui.jres.EEVMPage"> >+ * </vmInstallPage> >+ * </extension> >+ * </pre> >+ * The attributes are specified as follows: >+ * <ul> >+ * <li><code>vmInstallType</code> Specifies the VM install type this wizard page is to be used for. >+ * Unique identifier corresponding to an <code>IVMInstallType</code>'s id.</li> >+ * <li><code>class</code> Wizard page implementation. Must be a subclass of >+ * <code>org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage</code>.</li> >+ * </ul> >+ * </p> >+ * <p> >+ * Clients contributing a custom VM install page via the <code>vmInstallPages</code> >+ * extension point must subclass this class. >+ * </p> >+ * @since 3.4 >+ */ >+public abstract class AbstractVMInstallPage extends WizardPage { >+ >+ /** >+ * Name of the original VM being edited, or <code>null</code> if none. >+ */ >+ private String fOriginalName = null; >+ >+ /** >+ * Status of VM name (to notify of name already in use) >+ */ >+ private IStatus fNameStatus = Status.OK_STATUS; >+ >+ private String[] fExistingNames; >+ >+ /** >+ * Constructs a new page with the given page name. >+ * >+ * @param pageName the name of the page >+ */ >+ protected AbstractVMInstallPage(String pageName) { >+ super(pageName); >+ } >+ >+ /** >+ * Creates a new wizard page with the given name, title, and image. >+ * >+ * @param pageName the name of the page >+ * @param title the title for this wizard page, >+ * or <code>null</code> if none >+ * @param titleImage the image descriptor for the title of this wizard page, >+ * or <code>null</code> if none >+ */ >+ protected AbstractVMInstallPage(String pageName, String title, ImageDescriptor titleImage) { >+ super(pageName, title, titleImage); >+ } >+ >+ /** >+ * Called when the VM install page wizard is closed by selecting >+ * the finish button. Implementers typically override this method to >+ * store the page result (new/changed vm install returned in >+ * getSelection) into its model. >+ * >+ * @return if the operation was successful. Only when returned >+ * <code>true</code>, the wizard will close. >+ */ >+ public abstract boolean finish(); >+ >+ /** >+ * Returns the edited or created VM install. This method >+ * may return <code>null</code> if no VM install exists. >+ * >+ * @return the edited or created VM install. >+ */ >+ public abstract VMStandin getSelection(); >+ >+ /** >+ * Sets the VM install to be edited. >+ * >+ * @param vm the VM install to edit >+ */ >+ public void setSelection(VMStandin vm) { >+ fOriginalName = vm.getName(); >+ } >+ >+ /** >+ * Updates the name status based on the new name. This method should be called >+ * by the page each time the VM name changes. >+ * >+ * @param newName new name of VM >+ */ >+ protected void nameChanged(String newName) { >+ fNameStatus = Status.OK_STATUS; >+ if (newName == null || newName.trim().length() == 0) { >+ int sev = IStatus.ERROR; >+ if (fOriginalName == null || fOriginalName.length() == 0) { >+ sev = IStatus.INFO; >+ } >+ fNameStatus = new Status(sev, JDIDebugUIPlugin.getUniqueIdentifier(), JREMessages.addVMDialog_enterName); >+ } else { >+ if (isDuplicateName(newName)) { >+ fNameStatus = new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), JREMessages.addVMDialog_duplicateName); >+ } else { >+ IStatus s = ResourcesPlugin.getWorkspace().validateName(newName, IResource.FILE); >+ if (!s.isOK()) { >+ fNameStatus = new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(JREMessages.AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1, new String[]{s.getMessage()})); >+ } >+ } >+ } >+ updatePageStatus(); >+ } >+ >+ /** >+ * Returns whether the name is already in use by an existing VM >+ * >+ * @param name new name >+ * @return whether the name is already in use >+ */ >+ private boolean isDuplicateName(String name) { >+ if (fExistingNames != null) { >+ for (int i = 0; i < fExistingNames.length; i++) { >+ if (name.equals(fExistingNames[i])) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Sets the names of existing VMs, not including the VM being edited. This method >+ * is called by the wizard and clients should not call this method. >+ * >+ * @param names existing VM names or an empty array >+ */ >+ public void setExistingNames(String[] names) { >+ fExistingNames = names; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.WizardPage#getNextPage() >+ */ >+ public IWizardPage getNextPage() { >+ return null; >+ } >+ >+ /** >+ * Sets this page's message based on the status severity. >+ * >+ * @param status status with message and severity >+ */ >+ protected void setStatusMessage(IStatus status) { >+ if (status.isOK()) { >+ setMessage(status.getMessage()); >+ } else { >+ switch (status.getSeverity()) { >+ case IStatus.ERROR: >+ setMessage(status.getMessage(), IMessageProvider.ERROR); >+ break; >+ case IStatus.INFO: >+ setMessage(status.getMessage(), IMessageProvider.INFORMATION); >+ break; >+ case IStatus.WARNING: >+ setMessage(status.getMessage(), IMessageProvider.WARNING); >+ break; >+ default: >+ break; >+ } >+ } >+ } >+ >+ /** >+ * Returns the current status of the name being used for the VM. >+ * >+ * @return status of current VM name >+ */ >+ protected IStatus getNameStatus() { >+ return fNameStatus; >+ } >+ >+ /** >+ * Updates the status message on the page, based on the status of the VM and other >+ * status provided by the page. >+ */ >+ protected void updatePageStatus() { >+ IStatus max = Status.OK_STATUS; >+ IStatus[] vmStatus = getVMStatus(); >+ for (int i = 0; i < vmStatus.length; i++) { >+ IStatus status = vmStatus[i]; >+ if (status.getSeverity() > max.getSeverity()) { >+ max = status; >+ } >+ } >+ if (fNameStatus.getSeverity() > max.getSeverity()) { >+ max = fNameStatus; >+ } >+ if (max.isOK()) { >+ setMessage(null, IMessageProvider.NONE); >+ setPageComplete(true); >+ } else { >+ setStatusMessage(max); >+ setPageComplete(false); >+ } >+ } >+ >+ /** >+ * Returns a collection of status messages pertaining to the current edit >+ * status of the VM on this page. An empty collection or a collection of >+ * OK status objects indicates all is well. >+ * >+ * @return collection of status objects for this page >+ */ >+ protected abstract IStatus[] getVMStatus(); >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/EditVMInstallWizard.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/EditVMInstallWizard.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/EditVMInstallWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/EditVMInstallWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.jres; >+ >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.VMStandin; >+ >+/** >+ * @since 3.4 >+ */ >+public class EditVMInstallWizard extends VMInstallWizard { >+ >+ private AbstractVMInstallPage fEditPage; >+ >+ /** >+ * Constructs a wizard to edit the given vm. >+ * >+ * @param vm vm to edit >+ * @param allVMs all VMs being edited >+ */ >+ public EditVMInstallWizard(VMStandin vm, IVMInstall[] allVMs) { >+ super(vm, allVMs); >+ setWindowTitle(JREMessages.EditVMInstallWizard_0); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#addPages() >+ */ >+ public void addPages() { >+ fEditPage = getPage(getVMInstall().getVMInstallType()); >+ fEditPage.setSelection(new VMStandin(getVMInstall())); >+ addPage(fEditPage); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#performFinish() >+ */ >+ public boolean performFinish() { >+ if (fEditPage.finish()) { >+ return super.performFinish(); >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.debug.ui.jres.VMInstallWizard#getResult() >+ */ >+ protected VMStandin getResult() { >+ return fEditPage.getSelection(); >+ } >+ >+ >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMInstallWizard.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMInstallWizard.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMInstallWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/AddVMInstallWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.jres; >+ >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.wizard.IWizardPage; >+ >+/** >+ * @since 3.4 >+ */ >+public class AddVMInstallWizard extends VMInstallWizard { >+ >+ private IWizardPage fTypePage = null; >+ >+ private VMStandin fResult = null; >+ >+ /** >+ * Constructs a wizard to add a new VM install. >+ * >+ * @param currentInstalls currently existing VMs, used for name validation >+ */ >+ public AddVMInstallWizard(IVMInstall[] currentInstalls) { >+ super(null, currentInstalls); >+ setForcePreviousAndNextButtons(true); >+ setWindowTitle(JREMessages.AddVMInstallWizard_0); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#addPages() >+ */ >+ public void addPages() { >+ fTypePage = new VMTypePage(); >+ addPage(fTypePage); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.debug.ui.jres.VMInstallWizard#getResult() >+ */ >+ protected VMStandin getResult() { >+ return fResult; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.debug.ui.jres.VMInstallWizard#canFinish() >+ */ >+ public boolean canFinish() { >+ IWizardPage currentPage = getContainer().getCurrentPage(); >+ return currentPage != fTypePage && super.canFinish() && currentPage.isPageComplete(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.debug.ui.jres.VMInstallWizard#performFinish() >+ */ >+ public boolean performFinish() { >+ IWizardPage currentPage = getContainer().getCurrentPage(); >+ if (currentPage instanceof AbstractVMInstallPage) { >+ AbstractVMInstallPage page = (AbstractVMInstallPage) currentPage; >+ boolean finish = page.finish(); >+ fResult = page.getSelection(); >+ return finish; >+ } >+ return false; >+ } >+ >+ >+ >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/VMInstallWizard.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/VMInstallWizard.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/VMInstallWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/VMInstallWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.debug.ui.jres; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants; >+import org.eclipse.jdt.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.wizard.Wizard; >+ >+/** >+ * >+ */ >+public abstract class VMInstallWizard extends Wizard { >+ >+ private VMStandin fEditVM; >+ private String[] fExistingNames; >+ >+ /** >+ * Constructs a new wizard to add/edit a vm install. >+ * >+ * @param editVM the VM being edited, or <code>null</code> if none >+ * @param currentInstalls current VM installs used to validate name changes >+ */ >+ public VMInstallWizard(VMStandin editVM, IVMInstall[] currentInstalls) { >+ fEditVM = editVM; >+ List names = new ArrayList(currentInstalls.length); >+ for (int i = 0; i < currentInstalls.length; i++) { >+ IVMInstall install = currentInstalls[i]; >+ if (!install.equals(editVM)) { >+ names.add(install.getName()); >+ } >+ } >+ fExistingNames = (String[]) names.toArray(new String[names.size()]); >+ } >+ >+ /** >+ * Returns the VM to edit, or <code>null</code> if creating a VM >+ * >+ * @return vm to edit or <code>null</code> >+ */ >+ protected VMStandin getVMInstall() { >+ return fEditVM; >+ } >+ >+ /** >+ * Returns the resulting VM after edit or creation or <code>null</code> if none. >+ * >+ * @return resulting VM >+ */ >+ protected abstract VMStandin getResult(); >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#performFinish() >+ */ >+ public boolean performFinish() { >+ return getResult() != null; >+ } >+ >+ /** >+ * Returns a page to use for editing a VM install type >+ * >+ * @param type >+ * @return >+ */ >+ public AbstractVMInstallPage getPage(IVMInstallType type) { >+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(JDIDebugUIPlugin.getUniqueIdentifier(), IJavaDebugUIConstants.EXTENSION_POINT_VM_INSTALL_PAGES); >+ IConfigurationElement[] infos= extensionPoint.getConfigurationElements(); >+ for (int i = 0; i < infos.length; i++) { >+ IConfigurationElement element = infos[i]; >+ String id = element.getAttribute("vmInstallType"); //$NON-NLS-1$ >+ if (type.getId().equals(id)) { >+ try { >+ AbstractVMInstallPage page = (AbstractVMInstallPage) element.createExecutableExtension("class"); //$NON-NLS-1$ >+ page.setExistingNames(fExistingNames); >+ return page; >+ } catch (CoreException e) { >+ JDIDebugUIPlugin.log(e); >+ } >+ } >+ } >+ StandardVMPage standardVMPage = new StandardVMPage(); >+ standardVMPage.setExistingNames(fExistingNames); >+ return standardVMPage; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 201758
:
78364
|
79019
|
79587
| 79685