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 79587 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-ui-oct2.patch (text/plain), 143.07 KB, created by
Darin Wright
on 2007-10-02 17:29:20 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2007-10-02 17:29:20 EDT
Size:
143.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug.ui >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 2 Oct 2007 21:28:43 -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; >@@ -81,18 +79,18 @@ > protected Button fDefaultButton; > > /** >- * Constructor for VMLibraryBlock. >+ * Constructs a new wizard page with the given name. >+ * >+ * @param pageName page name > */ >- public VMLibraryBlock(AddVMDialog dialog) { >- fDialog = dialog; >- } >+ VMLibraryBlock() { >+ super("JRE System Libraries"); >+ } > >- /** >- * 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 +130,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 +177,19 @@ > break; > } > } >- fDialog.setSystemLibraryStatus(status); >- fDialog.updateStatusLine(); >- } >- >- /** >- * Saves settings in the given working copy >- */ >- public void performApply(IVMInstall vm) { >- if (isDefaultLocations(vm)) { >- vm.setLibraryLocations(null); >+ 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 +205,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 +217,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 +368,60 @@ > 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.launching.IVMInstallChangedListener#defaultVMInstallChanged(org.eclipse.jdt.launching.IVMInstall, org.eclipse.jdt.launching.IVMInstall) >+ */ >+ public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallChangedListener#vmAdded(org.eclipse.jdt.launching.IVMInstall) >+ */ >+ public void vmAdded(IVMInstall vm) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallChangedListener#vmRemoved(org.eclipse.jdt.launching.IVMInstall) >+ */ >+ public void vmRemoved(IVMInstall vm) { >+ } >+ > } >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 2 Oct 2007 21:28:43 -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/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 2 Oct 2007 21:28:43 -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 VMWizardDialog(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 VMWizardDialog(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 VMWizardDialog(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 2 Oct 2007 21:28:43 -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/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 2 Oct 2007 21:28:43 -0000 >@@ -58,17 +58,17 @@ > 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: >+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 >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: 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 2 Oct 2007 21:28:43 -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/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 2 Oct 2007 21:28:43 -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: 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 curretly existing VMs, used for name validation >+ */ >+ public AddVMInstallWizard(IVMInstall[] currentInstalls) { >+ super(null, currentInstalls); >+ setForcePreviousAndNextButtons(true); >+ setWindowTitle("Add JRE"); >+ } >+ >+ /* (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/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,202 @@ >+/******************************************************************************* >+ * 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.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.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.util.IPropertyChangeListener; >+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 fStandardPage; >+ >+ 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("Select JRE Type"); >+ setDescription("Select the type of installed JRE to add."); >+ setTitle("Add Installed JRE"); >+ } >+ >+ >+ /* (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.removePropertyChangeListener((IPropertyChangeListener) getWizard()); >+ 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, "Installed JRE &Types:", 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); >+ >+ fStandardPage = new StandardVMPage(); >+ fStandardPage.setWizard(getWizard()); >+ fNextPage = fStandardPage; >+ 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 = getPage(installType); >+ page.addPropertyChangeListener((IPropertyChangeListener) getWizard()); >+ VMStandin standin = new VMStandin(installType, StandardVMPage.createUniqueId(installType)); >+ standin.setName(""); >+ page.setSelection(standin); >+ fNextPage = page; >+ fPages.add(page); >+ } >+ } >+ } >+ >+ /** >+ * Returns a page to use for editing a VM install type >+ * >+ * @param type >+ * @return >+ */ >+ private 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"); >+ page.setWizard(getWizard()); >+ return page; >+ } catch (CoreException e) { >+ JDIDebugUIPlugin.log(e); >+ } >+ } >+ } >+ return fStandardPage; >+ } >+ >+} >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,423 @@ >+/******************************************************************************* >+ * 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.debug.core.DebugPlugin; >+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.IVMInstall; >+import org.eclipse.jdt.launching.IVMInstall2; >+import org.eclipse.jdt.launching.IVMInstallType; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IMessageProvider; >+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("Add Standard VM"); >+ 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()) { >+ 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() { >+ fireNameChange(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("Define Installed JRE"); >+ setDescription("Specify attributes for an installed JRE"); >+ } >+ >+ /** >+ * 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); >+ } >+ } >+ } >+ >+ /** >+ * 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()); >+ } >+ if (fVM instanceof IVMInstall2) { >+ IVMInstall2 vm2 = (IVMInstall2) fVM; >+ String vmArgs = vm2.getVMArgs(); >+ if (vmArgs != null) { >+ fVMArgs.setText(vmArgs); >+ } >+ } else { >+ String[] vmArgs = fVM.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()); >+ } >+ } >+ validateVMName(); >+ validateJRELocation(); >+ } >+ >+ /** >+ * Sets the status of the JRE location field. >+ * >+ * @param status JRE location status >+ */ >+ private void setJRELocationStatus(IStatus status) { >+ fFieldStatus[0] = status; >+ } >+ >+ private void updatePageStatus() { >+ IStatus max = Status.OK_STATUS; >+ for (int i = 0; i < fFieldStatus.length; i++) { >+ IStatus status = fFieldStatus[i]; >+ if (status.getSeverity() > max.getSeverity()) { >+ max = status; >+ } >+ } >+ if (max.isOK()) { >+ setMessage(null, IMessageProvider.NONE); >+ setPageComplete(true); >+ } else { >+ setStatusMessage(max); >+ setPageComplete(false); >+ } >+ } >+ >+ /* (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; >+ } >+ >+ >+} >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,130 @@ >+/******************************************************************************* >+ * 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.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.debug.ui.launchConfigurations.AbstractVMInstallPage; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.launching.IVMInstall; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.wizard.Wizard; >+ >+import com.ibm.icu.text.MessageFormat; >+ >+/** >+ * >+ */ >+public abstract class VMInstallWizard extends Wizard implements IPropertyChangeListener { >+ >+ private IStatus fNameStatus = Status.OK_STATUS; >+ >+ private VMStandin fEditVM; >+ private IVMInstall[] fInstalls; >+ >+ /** >+ * 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; >+ fInstalls = currentInstalls; >+ } >+ >+ /** >+ * 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; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) >+ */ >+ public void propertyChange(PropertyChangeEvent event) { >+ if (AbstractVMInstallPage.P_JRE_NAME.equals(event.getProperty())) { >+ fNameStatus = Status.OK_STATUS; >+ String name = (String) event.getNewValue(); >+ if (name == null || name.trim().length() == 0) { >+ fNameStatus = new Status(IStatus.INFO, JDIDebugUIPlugin.getUniqueIdentifier(), JREMessages.addVMDialog_enterName); >+ } else { >+ if (isDuplicateName(name)) { >+ fNameStatus = new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), JREMessages.addVMDialog_duplicateName); >+ } else { >+ IStatus s = ResourcesPlugin.getWorkspace().validateName(name, 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()})); >+ } >+ } >+ } >+ } >+ getContainer().updateMessage(); >+ getContainer().updateButtons(); >+ } >+ >+ /** >+ * 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) { >+ for (int i = 0; i < fInstalls.length; i++) { >+ IVMInstall vm = fInstalls[i]; >+ if (name.equals(vm.getName())) { >+ // don't consider VM being edited >+ if (!vm.equals(fEditVM)) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Returns a status describing the status of the current name of the VM being edited/created. >+ * >+ * @return status >+ */ >+ protected IStatus getNameStatus() { >+ return fNameStatus; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#canFinish() >+ */ >+ public boolean canFinish() { >+ return getNameStatus().isOK() && super.canFinish(); >+ } >+ >+ /** >+ * 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; >+ } >+ >+} >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,175 @@ >+/******************************************************************************* >+ * 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.runtime.IStatus; >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.jdt.launching.VMStandin; >+import org.eclipse.jface.dialogs.IMessageProvider; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+ >+/** >+ * 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. >+ * >+ * @since 3.4 >+ */ >+public abstract class AbstractVMInstallPage extends WizardPage { >+ >+ /** >+ * Property name constant (value <code>"org.eclipse.jdt.debug.ui.jre.name"</code>) >+ * for a JRE's name. >+ */ >+ public static final String P_JRE_NAME = "org.eclipse.jdt.debug.ui.jre.name"; //$NON-NLS-1$ >+ >+ /** >+ * Name of the original VM being edited, or <code>null</code> if none. >+ */ >+ private String fOriginalName = null; >+ >+ /** >+ * Property change listeners >+ */ >+ private ListenerList fListeners = new ListenerList(); >+ >+ /** >+ * 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); >+ } >+ >+ /** >+ * Adds the specified property change listener to this page. Listeners >+ * are notified when the properties defined by this interface change. >+ * For example, when the name of a JRE changes. >+ * <p> >+ * Has no effect if an identical listener is already registered. >+ * </p> >+ * @param listener property change listener >+ */ >+ public void addPropertyChangeListener(IPropertyChangeListener listener) { >+ fListeners.add(listener); >+ } >+ >+ /** >+ * 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(); >+ >+ /** >+ * Removes the specified property change listener. >+ * <p> >+ * Has no effect if the listener is not already registered. >+ * </p> >+ * @param listener property change listener >+ */ >+ public void removePropertyChangeListener(IPropertyChangeListener listener) { >+ fListeners.remove(listener); >+ } >+ >+ /** >+ * Sets the VM install to be edited. >+ * >+ * @param vm the VM install to edit >+ */ >+ public void setSelection(VMStandin vm) { >+ fOriginalName = vm.getName(); >+ } >+ >+ /** >+ * Fires a name change event specifying the new name. >+ * >+ * @param newName >+ */ >+ protected void fireNameChange(String newName) { >+ fireChangeEvent(new PropertyChangeEvent(this, P_JRE_NAME, fOriginalName, newName)); >+ } >+ >+ /** >+ * Fires the event to all listeners. >+ * >+ * @param event event to fire >+ */ >+ protected void fireChangeEvent(PropertyChangeEvent event) { >+ Object[] listeners = fListeners.getListeners(); >+ for (int i = 0; i < listeners.length; i++) { >+ IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; >+ listener.propertyChange(event); >+ } >+ } >+ >+ /* (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; >+ } >+ } >+ } >+} >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,410 @@ >+/******************************************************************************* >+ * 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.CoreException; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugPlugin; >+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.IVMInstall; >+import org.eclipse.jdt.launching.IVMInstall2; >+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.jface.dialogs.IMessageProvider; >+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.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; >+// the VM install's javadoc location >+ private URL fJavadocLocation = null; >+ private boolean fAutoDetectAttributes = false; >+ private IStatus[] fFieldStatus = new IStatus[1]; >+ >+ /** >+ * >+ */ >+ public EEVMPage() { >+ super("Add EE VM"); >+ 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, "&Definition File:", 1); >+ fEEFile = SWTFactory.createSingleText(composite, 1); >+ Button folders = SWTFactory.createPushButton(composite, "F&ile...", 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(); >+ } >+ }); >+ fEEFile.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ validateDefinitionFile(); >+ } >+ }); >+ 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 = new File(fEEFile.getText()); >+ String text = fEEFile.getText(); >+ if (file.isFile()) { >+ text = file.getParentFile().getAbsolutePath(); >+ } >+ dialog.setFileName(text); >+ String newPath = dialog.open(); >+ if (newPath != null) { >+ fEEFile.setText(newPath); >+ } >+ } >+ }); >+ Dialog.applyDialogFont(composite); >+ setControl(composite); >+ initializeFields(); >+ } >+ >+ /** >+ * Validates the JRE location >+ * @return the status after validating the JRE location >+ */ >+ private void validateDefinitionFile() { >+ String locationName = fEEFile.getText(); >+ IStatus s = null; >+ File file = null; >+ if (locationName.length() == 0) { >+ s = new StatusInfo(IStatus.INFO, "Enter definition file"); >+ } >+ else { >+ file = new File(locationName); >+ if (!file.exists()) { >+ s = new StatusInfo(IStatus.ERROR, "Definition file does not exist"); >+ } >+ else { >+ 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()) { >+ 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); >+ } >+ fVMName.setText(fileName); >+ } >+ } >+ detectJavadocLocation(); >+ setJRELocationStatus(s); >+ fLibraryBlock.setSelection(fVM); >+ String args = fVM.getVMArgs(); >+ if (args != null) { >+ fVMArgs.setText(args); >+ } >+ 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(fEEFile.getText()); >+ } >+ >+ /** >+ * Validates the entered name of the VM >+ * @return the status of the name validation >+ */ >+ private void validateVMName() { >+ fireNameChange(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("Define Installed JRE"); >+ setDescription("Specify attributes for an installed JRE"); >+ } >+ >+ /** >+ * initialize fields to the specified VM >+ * @param vm the VM to initialize from >+ */ >+ protected void setFieldValuesToVM(IVMInstall vm) { >+ File dir = new File(fEEFile.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); >+ } >+ } >+ } >+ >+ /** >+ * 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()); >+// String eePath = fVM.getAttribute(EEVMInstall.ATTR_DEFINITION_FILE); >+// if (eePath != null) { >+// fEEFile.setText(eePath); >+// } >+ if (fVM instanceof IVMInstall2) { >+ IVMInstall2 vm2 = (IVMInstall2) fVM; >+ String vmArgs = vm2.getVMArgs(); >+ if (vmArgs != null) { >+ fVMArgs.setText(vmArgs); >+ } >+ } else { >+ String[] vmArgs = fVM.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()); >+ } >+ } >+ validateVMName(); >+ validateDefinitionFile(); >+ } >+ >+ /** >+ * Sets the status of the JRE location field. >+ * >+ * @param status JRE location status >+ */ >+ private void setJRELocationStatus(IStatus status) { >+ fFieldStatus[0] = status; >+ } >+ >+ private void updatePageStatus() { >+ IStatus max = Status.OK_STATUS; >+ for (int i = 0; i < fFieldStatus.length; i++) { >+ IStatus status = fFieldStatus[i]; >+ if (status.getSeverity() > max.getSeverity()) { >+ max = status; >+ } >+ } >+ if (max.isOK()) { >+ setMessage(null, IMessageProvider.NONE); >+ setPageComplete(true); >+ } else { >+ setStatusMessage(max); >+ setPageComplete(false); >+ } >+ } >+ >+ /* (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; >+ } >+ >+ >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/jres/VMWizardDialog.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/jres/VMWizardDialog.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/jres/VMWizardDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/jres/VMWizardDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * 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.core.runtime.IStatus; >+import org.eclipse.jface.dialogs.IMessageProvider; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * @since 3.4 >+ */ >+public class VMWizardDialog extends WizardDialog { >+ >+ /** >+ * @param parentShell >+ * @param newWizard >+ */ >+ public VMWizardDialog(Shell parentShell, VMInstallWizard newWizard) { >+ super(parentShell, newWizard); >+ } >+ >+ public void updateMessage() { >+ VMInstallWizard wizard = (VMInstallWizard) getWizard(); >+ IStatus status = wizard.getNameStatus(); >+ if (status.isOK()) { >+ super.updateMessage(); >+ } 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; >+ } >+ } >+ } >+ >+ >+} >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,81 @@ >+/******************************************************************************* >+ * 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("Edit JRE"); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#dispose() >+ */ >+ public void dispose() { >+ fEditPage.removePropertyChangeListener(this); >+ super.dispose(); >+ } >+ >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#addPages() >+ */ >+ public void addPages() { >+ fEditPage = getEditPage(); >+ fEditPage.setSelection(new VMStandin(getVMInstall())); >+ fEditPage.addPropertyChangeListener(this); >+ addPage(fEditPage); >+ } >+ >+ /** >+ * @return >+ */ >+ private AbstractVMInstallPage getEditPage() { >+ // TODO: based on extension >+ return new StandardVMPage(); >+ } >+ >+ /* (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: 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,121 @@ >+<?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> >+ [Enter extension point usage example here.] >+ </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> >#P org.eclipse.jdt.debug.tests >Index: tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java,v >retrieving revision 1.3 >diff -u -r1.3 EEDefinitionTests.java >--- tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java 14 Aug 2007 20:23:35 -0000 1.3 >+++ tests/org/eclipse/jdt/debug/tests/core/EEDefinitionTests.java 2 Oct 2007 21:28:45 -0000 >@@ -12,13 +12,14 @@ > > import java.io.File; > >+import org.eclipse.core.runtime.CoreException; > 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.jdt.debug.testplugin.JavaTestPlugin; > import org.eclipse.jdt.debug.tests.AbstractDebugTest; >-import org.eclipse.jdt.internal.launching.StandardVMType; >+import org.eclipse.jdt.internal.launching.EEVMType; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.IVMInstallType; > import org.eclipse.jdt.launching.JavaRuntime; >@@ -46,26 +47,34 @@ > } > > /** >- * Tests that the EE file is a valid install location >+ * Tests that the EE file is a valid file > */ >- public void testValidateInstallLocation() { >+ public void testValidateDefinitionFile() { > File file = getEEFile(); >- IVMInstallType vmType = getStandardVMInstallType(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- IStatus status = vmType.validateInstallLocation(file); >+ IStatus status = EEVMType.validateDefinitionFile(file); > assertTrue("Invalid install location", status.isOK()); > } > > /** >- * Tests default libraries for the EE file >+ * Tests that the EE install location validation returns an INFO status. > */ >- public void testDefaultLibraries() { >+ public void testValidateInstallLocation() { > File file = getEEFile(); >- IVMInstallType vmType = getStandardVMInstallType(); >+ IVMInstallType vmType = getVMInstallType(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- LibraryLocation[] libs = vmType.getDefaultLibraryLocations(file); >+ assertNotNull("Missing EE VM type", vmType); >+ IStatus status = vmType.validateInstallLocation(file); >+ assertTrue("Invalid install location", status.getSeverity() == IStatus.INFO); >+ } >+ >+ /** >+ * Tests libraries for the EE file >+ */ >+ public void testLibraries() { >+ File file = getEEFile(); >+ assertNotNull("Missing EE file", file); >+ LibraryLocation[] libs = EEVMType.getLibraryLocations(file); > String[] expected = new String[]{"end.jar", "classes.txt", "others.txt", "ext1.jar", "ext2.jar", "opt-ext.jar"}; > assertEquals("Wrong number of libraries", expected.length, libs.length); > for (int i = 0; i < expected.length; i++) { >@@ -87,15 +96,25 @@ > } > > /** >+ * Tests default libraries for an EE VM type are empty. >+ */ >+ public void testDefaultLibraries() { >+ File file = getEEFile(); >+ IVMInstallType vmType = getVMInstallType(); >+ assertNotNull("Missing EE file", file); >+ assertNotNull("Missing EE VM type", vmType); >+ LibraryLocation[] libs = vmType.getDefaultLibraryLocations(file); >+ assertEquals("Wrong number of libraries", 0, libs.length); >+ } >+ >+ /** > * Tests default VM arguments. All arguments from the EE file should get passed through in the > * same order to the command line. > */ >- public void testDefaultVMArguments() { >+ public void testVMArguments() { > File file = getEEFile(); >- StandardVMType vmType = (StandardVMType) getStandardVMInstallType(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- String defaultVMArguments = vmType.getDefaultVMArguments(file); >+ String defaultVMArguments = EEVMType.getVMArguments(file); > String[] expected = new String[] { > "-Dee.executable", > "-Dee.executable.console", >@@ -123,18 +142,15 @@ > /** > * Test compatible environments > */ >- public void testCompatibleEEs() { >+ public void testCompatibleEEs() throws CoreException { > IVMInstall install = null; >- StandardVMType vmType = (StandardVMType) getStandardVMInstallType(); >+ EEVMType vmType = (EEVMType) getVMInstallType(); > try { > File file = getEEFile(); > assertNotNull("Missing EE file", file); >- assertNotNull("Missing standard VM type", vmType); >- VMStandin vm = new VMStandin(vmType, "test-ee-file-id"); >- vm.setInstallLocation(file); >- vm.setName("test-ee-file"); >- vm.setVMArgs(vmType.getDefaultVMArguments(file)); >- install = vm.convertToRealVM(); >+ assertNotNull("Missing EE VM type", vmType); >+ VMStandin standin = JavaRuntime.createVMFromDefinitionFile(file, "test-ee-file", "test-ee-file-id"); >+ install = standin.convertToRealVM(); > > IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); > IExecutionEnvironment[] envs = manager.getExecutionEnvironments(); >@@ -143,9 +159,9 @@ > IExecutionEnvironment env = envs[i]; > if (env.getId().equals("CDC-1.1/Foundation-1.1")) { > found11 = true; >- assertTrue("Should be strictly compatible with " + env.getId(), env.isStrictlyCompatible(vm)); >+ assertTrue("Should be strictly compatible with " + env.getId(), env.isStrictlyCompatible(install)); > } else if (env.getId().indexOf("jdt.debug.tests") < 0) { >- assertFalse("Should *not* be strictly compatible with " + env.getId(), env.isStrictlyCompatible(vm)); >+ assertFalse("Should *not* be strictly compatible with " + env.getId(), env.isStrictlyCompatible(install)); > } > } > assertTrue("Did not find foundation 1.1 environment", found11); >@@ -160,7 +176,7 @@ > return JavaTestPlugin.getDefault().getFileInPlugin(TEST_EE_FILE); > } > >- protected IVMInstallType getStandardVMInstallType() { >- return JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE); >+ protected IVMInstallType getVMInstallType() { >+ return JavaRuntime.getVMInstallType(EEVMType.ID_EE_VM_TYPE); > } > } >Index: testfiles/test-jre/bin/test-foundation11.ee >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/testfiles/test-jre/bin/test-foundation11.ee,v >retrieving revision 1.2 >diff -u -r1.2 test-foundation11.ee >--- testfiles/test-jre/bin/test-foundation11.ee 14 Aug 2007 19:26:56 -0000 1.2 >+++ testfiles/test-jre/bin/test-foundation11.ee 2 Oct 2007 21:28:45 -0000 >@@ -25,6 +25,7 @@ > -Dee.name=Eclipse JDT Test JRE Definition > -Dee.description=Foundation Specification v1.1 > -Dee.copyright=(c) Copyright IBM Corp. 2007 All Rights Reserved >+-Djava.home=.. > > # all args should get passed through to command line > -XspecialArg:123 >\ No newline at end of file >Index: testfiles/test-jre/bin/test-foundation11-win32.ee >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.tests/testfiles/test-jre/bin/test-foundation11-win32.ee,v >retrieving revision 1.1 >diff -u -r1.1 test-foundation11-win32.ee >--- testfiles/test-jre/bin/test-foundation11-win32.ee 14 Aug 2007 19:26:56 -0000 1.1 >+++ testfiles/test-jre/bin/test-foundation11-win32.ee 2 Oct 2007 21:28:45 -0000 >@@ -25,6 +25,7 @@ > -Dee.name=Eclipse JDT Test JRE Definition > -Dee.description=Foundation Specification v1.1 > -Dee.copyright=(c) Copyright IBM Corp. 2007 All Rights Reserved >+-Djava.home=.. > > # all args should get passed through to command line > -XspecialArg:123 >\ No newline at end of file >#P org.eclipse.jdt.launching >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 2 Oct 2007 21:28:47 -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: 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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:47 -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,40 @@ > } > 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() { >+ // TODO: >+ return "Execution Environment Description"; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.launching.IVMInstallType#validateInstallLocation(java.io.File) >+ */ >+ public IStatus validateInstallLocation(File installLocationOrDefinitionFile) { >+ return new Status(IStatus.INFO, LaunchingPlugin.getUniqueIdentifier(), "Unable to validate install location."); >+ } > } >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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:47 -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 2 Oct 2007 21:28:48 -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/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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:47 -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/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 2 Oct 2007 21:28:48 -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; >@@ -1592,7 +1594,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 +2660,46 @@ > } > } > } >+ >+ /** >+ * 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(), >+ "Failed to create VM install", e)); >+ } >+ } >+ standin.setAttribute(EEVMInstall.ATTR_JAVA_VERSION, EEVMType.getJavaVersion(eeFile)); >+ standin.setAttribute(EEVMInstall.ATTR_DEFINITION_FILE, eeFile.getPath()); >+ standin.setVMArgs(EEVMType.getVMArguments(eeFile)); >+ return standin; >+ } else { >+ throw new CoreException(status); >+ } >+ } > > } >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 2 Oct 2007 21:28:47 -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: 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; >+ } >+ >+ >+ >+}
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