Ben Konrath ccb00c
Index: src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java
Ben Konrath 02a0b8
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java,v
Ben Konrath ccb00c
retrieving revision 1.12.2.1
Ben Konrath ccb00c
diff -u -r1.12.2.1 InstallWizard2.java
Ben Konrath ccb00c
--- plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java	23 Aug 2006 03:55:35 -0000	1.12.2.1
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java	25 Sep 2006 22:38:03 -0000
Ben Konrath ccb00c
@@ -153,7 +153,7 @@
Ben Konrath ccb00c
 		addPage(licensePage);
Ben Konrath ccb00c
 		optionalFeaturesPage = new OptionalFeaturesPage(config);
Ben Konrath ccb00c
 		addPage(optionalFeaturesPage);
Ben Konrath ccb00c
-		targetPage = new TargetPage(config);
Ben Konrath ccb00c
+		targetPage = new TargetPage(config, isUpdate);
Ben Konrath ccb00c
 		addPage(targetPage);
Ben Konrath ccb00c
 	}
Ben Konrath ccb00c
 
Ben Konrath ccb00c
Index: src/org/eclipse/update/internal/ui/wizards/TargetPage.java
Ben Konrath ccb00c
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java,v
Ben Konrath ccb00c
retrieving revision 1.81.2.1
Ben Konrath ccb00c
diff -u -r1.81.2.1 TargetPage.java
Ben Konrath ccb00c
--- plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java	23 Aug 2006 03:55:35 -0000	1.81.2.1
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java	25 Sep 2006 22:38:03 -0000
Ben Konrath ccb00c
@@ -18,6 +18,9 @@
Ben Konrath ccb00c
 import java.util.HashSet;
Ben Konrath ccb00c
 import java.util.Iterator;
Ben Konrath 02a0b8
 
Ben Konrath ccb00c
+import org.eclipse.core.runtime.CoreException;
Ben Konrath ccb00c
+import org.eclipse.core.runtime.IStatus;
Ben Konrath ccb00c
+import org.eclipse.core.runtime.Platform;
Ben Konrath ccb00c
 import org.eclipse.jface.dialogs.Dialog;
Ben Konrath ccb00c
 import org.eclipse.jface.dialogs.IDialogSettings;
Ben Konrath ccb00c
 import org.eclipse.jface.resource.ImageDescriptor;
Ben Konrath ccb00c
@@ -92,6 +95,7 @@
Ben Konrath ccb00c
     private Label installLocation;
Ben Konrath ccb00c
     private Button changeLocation;
Ben Konrath ccb00c
     static HashSet added;
Ben Konrath ccb00c
+    private boolean isUpdate; // whether the wizard is updating a feature or installing a new one
Ben Konrath 02a0b8
 
Ben Konrath ccb00c
 	class JobsContentProvider
Ben Konrath ccb00c
 		extends DefaultContentProvider
Ben Konrath ccb00c
@@ -236,13 +240,14 @@
Ben Konrath 02a0b8
 	/**
Ben Konrath ccb00c
 	 * Constructor for ReviewPage2
Ben Konrath 02a0b8
 	 */
Ben Konrath ccb00c
-	public TargetPage(IInstallConfiguration config) {
Ben Konrath ccb00c
+	public TargetPage(IInstallConfiguration config, boolean isUpdate) {
Ben Konrath ccb00c
 		super("Target"); //$NON-NLS-1$
Ben Konrath ccb00c
 		setTitle(UpdateUIMessages.InstallWizard_TargetPage_title); 
Ben Konrath ccb00c
 		setDescription(UpdateUIMessages.InstallWizard_TargetPage_desc); 
Ben Konrath ccb00c
 		this.config = config;
Ben Konrath ccb00c
 		UpdateUI.getDefault().getLabelProvider().connect(this);
Ben Konrath ccb00c
 		configListener = new ConfigListener();
Ben Konrath ccb00c
+		this.isUpdate = isUpdate;
Ben Konrath 02a0b8
 	}
Ben Konrath ccb00c
 
Ben Konrath ccb00c
 	public void setJobs(IInstallFeatureOperation[] jobs) {
Ben Konrath ccb00c
@@ -273,7 +278,7 @@
Ben Konrath ccb00c
         label.setLayoutData(gd);
Ben Konrath ccb00c
 
Ben Konrath ccb00c
 		installLocation = new Label(client, SWT.NULL);
Ben Konrath ccb00c
-        installLocation.setText("foo"); //$NON-NLS-1$
Ben Konrath ccb00c
+        installLocation.setText(""); //$NON-NLS-1$
Ben Konrath ccb00c
         gd = new GridData(GridData.FILL_HORIZONTAL);
Ben Konrath ccb00c
         installLocation.setLayoutData(gd);
Ben Konrath ccb00c
         
Ben Konrath ccb00c
@@ -656,12 +661,45 @@
Ben Konrath ccb00c
 				continue;
Ben Konrath ccb00c
 			}
Ben Konrath ccb00c
 
Ben Konrath ccb00c
-			jobs[i].setTargetSite(getFirstTargetSite(jobs[i]));
Ben Konrath ccb00c
+			IConfiguredSite csite = getFirstTargetSite(jobs[i]);
Ben Konrath ccb00c
+			if (csite == null && Platform.getInstallLocation().isReadOnly() && isUpdate == false) {
Ben Konrath ccb00c
+				// there are no updateable sites, the installation location is read-only and we are installing a new feature
Ben Konrath ccb00c
+				// make an update site in the user's home direcotry
Ben Konrath ccb00c
+				File site = new File(System.getProperty("user.home") + File.separator + ".eclipse" + File.separator + //$NON-NLS-1$ //$NON-NLS-2$
Ben Konrath ccb00c
+					Platform.getProduct().getId() + File.separator + "updates"); //$NON-NLS-1$
Ben Konrath ccb00c
+				
Ben Konrath ccb00c
+				try {
Ben Konrath ccb00c
+					csite = config.createConfiguredSite(site);
Ben Konrath ccb00c
+					config.addConfiguredSite(csite);
Ben Konrath ccb00c
+					IStatus status = csite.verifyUpdatableStatus();
Ben Konrath ccb00c
+					if (!status.isOK())
Ben Konrath ccb00c
+						throw new CoreException(status);
Ben Konrath ccb00c
+					
Ben Konrath ccb00c
+				} catch (CoreException e) {
Ben Konrath ccb00c
+					// there was a problem, the user must choose an installation site
Ben Konrath ccb00c
+					csite = null;
Ben Konrath ccb00c
+					// no need to check if the directory exists because File.delete() returns false if it's not there
Ben Konrath ccb00c
+					deleteDir(site);
Ben Konrath ccb00c
+				}
Ben Konrath ccb00c
+			}
Ben Konrath ccb00c
 
Ben Konrath ccb00c
+			jobs[i].setTargetSite(csite);
Ben Konrath ccb00c
 		}
Ben Konrath ccb00c
 
Ben Konrath ccb00c
 	}
Ben Konrath ccb00c
-	
Ben Konrath ccb00c
+
Ben Konrath ccb00c
+	private boolean deleteDir(File dir) {
Ben Konrath ccb00c
+        if (dir.isDirectory()) {
Ben Konrath ccb00c
+            String[] files = dir.list();
Ben Konrath ccb00c
+            for (int i=0; i < files.length; i++) {
Ben Konrath ccb00c
+                if (!deleteDir(new File(dir, files[i]))) {
Ben Konrath ccb00c
+                    return false;
Ben Konrath ccb00c
+                }
Ben Konrath ccb00c
+            }
Ben Konrath ccb00c
+        }
Ben Konrath ccb00c
+        return dir.delete();
Ben Konrath ccb00c
+    }
Ben Konrath ccb00c
+
Ben Konrath ccb00c
 	private IConfiguredSite getMostReceantlyUsedSite() {
Ben Konrath ccb00c
 		IDialogSettings master = UpdateUI.getDefault().getDialogSettings();
Ben Konrath ccb00c
 		IDialogSettings section = master.getSection(TargetSiteDialog.MOST_RECEANTLY_USED_SITE_URL);
Ben Konrath ccb00c
@@ -696,7 +734,7 @@
Ben Konrath ccb00c
 		IConfiguredSite[] sites = config.getConfiguredSites();
Ben Konrath ccb00c
 		for (int i = 0; i < sites.length; i++) {
Ben Konrath ccb00c
 			IConfiguredSite csite = sites[i];
Ben Konrath ccb00c
-			if (getSiteVisibility(csite, job)) 
Ben Konrath ccb00c
+			if (getSiteVisibility(csite, job) && csite.getSite().getCurrentConfiguredSite().verifyUpdatableStatus().isOK())
Ben Konrath ccb00c
 				return csite;
Ben Konrath ccb00c
 		}
Ben Konrath ccb00c
 		return null;
Ben Konrath ccb00c
Index: src/org/eclipse/update/search/UpdateSearchRequest.java
Ben Konrath ccb00c
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/search/UpdateSearchRequest.java,v
Ben Konrath ccb00c
retrieving revision 1.31
Ben Konrath ccb00c
diff -u -r1.31 UpdateSearchRequest.java
Ben Konrath ccb00c
--- plugins/org.eclipse.update.core/src/org/eclipse/update/search/UpdateSearchRequest.java	8 Aug 2006 20:21:42 -0000	1.31
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/search/UpdateSearchRequest.java	25 Sep 2006 22:38:05 -0000
Ben Konrath ccb00c
@@ -282,6 +282,10 @@
Ben Konrath 02a0b8
 					// currently, the next conditional is only executed (qsite!=null) when
Ben Konrath 02a0b8
 					// running an update search. 
Ben Konrath 02a0b8
 					if (qsite != null && searchFeatureProvidedSites) {
Ben Konrath 02a0b8
+						// do not update features that are installed in read-only locations
Ben Konrath 02a0b8
+						IFeature feature = query.getFeature();
Ben Konrath 02a0b8
+						if (feature != null && !feature.getSite().getCurrentConfiguredSite().verifyUpdatableStatus().isOK())
Ben Konrath 02a0b8
+							continue;
Ben Konrath 02a0b8
 						// check for mapping
Ben Konrath 02a0b8
 						IUpdateSiteAdapter mappedSite = getMappedSite(updatePolicy, qsite);
Ben Konrath 02a0b8
 						// when there is no mapped site the feature is not updatable
Ben Konrath 02a0b8
Index: src/org/eclipse/update/search/IUpdateSearchQuery.java
Ben Konrath 02a0b8
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/search/IUpdateSearchQuery.java,v
Ben Konrath 02a0b8
retrieving revision 1.8
Ben Konrath 02a0b8
diff -u -r1.8 IUpdateSearchQuery.java
Ben Konrath 02a0b8
--- plugins/org.eclipse.update.core/src/org/eclipse/update/search/IUpdateSearchQuery.java	1 Mar 2005 20:29:16 -0000	1.8
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/search/IUpdateSearchQuery.java	25 Sep 2006 22:38:05 -0000
Ben Konrath 02a0b8
@@ -7,6 +7,7 @@
Ben Konrath 02a0b8
  *
Ben Konrath 02a0b8
  * Contributors:
Ben Konrath 02a0b8
  *     IBM Corporation - initial API and implementation
Ben Konrath 02a0b8
+ *     Red Hat Incorporated - getFeature() API addition
Ben Konrath 02a0b8
  *******************************************************************************/
Ben Konrath 02a0b8
 package org.eclipse.update.search;
Ben Konrath 02a0b8
 
Ben Konrath 02a0b8
@@ -50,4 +51,12 @@
Ben Konrath 02a0b8
  * @param monitor a progress monitor to report search progress within the provided site
Ben Konrath 02a0b8
  */
Ben Konrath 02a0b8
 	public void run(ISite site, String [] categoriesToSkip, IUpdateSearchFilter filter, IUpdateSearchResultCollector collector, IProgressMonitor monitor);
Ben Konrath 02a0b8
+	
Ben Konrath 02a0b8
+/**
Ben Konrath 02a0b8
+ * Returns IFeature associated with the IUpdateSearchQuery
Ben Konrath 02a0b8
+ * 
Ben Konrath 02a0b8
+ * @return the IFeature that is associated with the IUpdateSearchQuery
Ben Konrath 02a0b8
+ * @since 3.2
Ben Konrath 02a0b8
+ */
Ben Konrath ccb00c
+	public IFeature getFeature();
Ben Konrath 02a0b8
 }
Ben Konrath 02a0b8
Index: src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java
Ben Konrath 02a0b8
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java,v
Ben Konrath ccb00c
retrieving revision 1.9
Ben Konrath ccb00c
diff -u -r1.9 OptionalFeatureSearchCategory.java
Ben Konrath ccb00c
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java	11 Apr 2006 15:47:09 -0000	1.9
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java	25 Sep 2006 22:38:05 -0000
Ben Konrath 02a0b8
@@ -76,6 +76,13 @@
Ben Konrath 02a0b8
 		public IQueryUpdateSiteAdapter getQuerySearchSite() {
Ben Konrath 02a0b8
 			return null;
Ben Konrath 02a0b8
 		}
Ben Konrath ccb00c
+		
Ben Konrath 02a0b8
+		/* (non-Javadoc)
Ben Konrath 02a0b8
+		 * @see org.eclipse.update.internal.ui.search.ISearchQuery#getFeature()
Ben Konrath 02a0b8
+		 */
Ben Konrath 02a0b8
+		public IFeature getFeature() {
Ben Konrath ccb00c
+				return null;
Ben Konrath 02a0b8
+		}
Ben Konrath 02a0b8
 	}
Ben Konrath 02a0b8
 
Ben Konrath 02a0b8
 	public void addVersionedIdentifier(VersionedIdentifier vid) {
Ben Konrath 02a0b8
Index: src/org/eclipse/update/internal/search/UpdatesSearchCategory.java
Ben Konrath 02a0b8
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/search/UpdatesSearchCategory.java,v
Ben Konrath ccb00c
retrieving revision 1.27
Ben Konrath ccb00c
diff -u -r1.27 UpdatesSearchCategory.java
Ben Konrath ccb00c
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/UpdatesSearchCategory.java	11 Apr 2006 15:47:09 -0000	1.27
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/UpdatesSearchCategory.java	25 Sep 2006 22:38:05 -0000
Ben Konrath 02a0b8
@@ -285,6 +285,10 @@
Ben Konrath 02a0b8
 			monitor.worked(1);
Ben Konrath 02a0b8
 			monitor.done();
Ben Konrath 02a0b8
 		}
Ben Konrath ccb00c
+		
Ben Konrath 02a0b8
+		public IFeature getFeature() {
Ben Konrath 02a0b8
+			return candidate;
Ben Konrath ccb00c
+		}	
Ben Konrath 02a0b8
 	}
Ben Konrath 02a0b8
 
Ben Konrath 02a0b8
 	private ArrayList candidates;
Ben Konrath 02a0b8
Index: src/org/eclipse/update/internal/search/SiteSearchCategory.java
Ben Konrath 02a0b8
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java,v
Ben Konrath ccb00c
retrieving revision 1.14.2.1
Ben Konrath ccb00c
diff -u -r1.14.2.1 SiteSearchCategory.java
Ben Konrath ccb00c
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java	18 Aug 2006 23:31:21 -0000	1.14.2.1
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java	25 Sep 2006 22:38:05 -0000
Ben Konrath ccb00c
@@ -133,6 +133,14 @@
Ben Konrath 02a0b8
 		public IQueryUpdateSiteAdapter getQuerySearchSite() {
Ben Konrath 02a0b8
 			return null;
Ben Konrath 02a0b8
 		}
Ben Konrath ccb00c
+		
Ben Konrath 02a0b8
+		/* (non-Javadoc)
Ben Konrath 02a0b8
+		 * @see org.eclipse.update.internal.ui.search.ISearchQuery#getFeature()
Ben Konrath 02a0b8
+		 */
Ben Konrath 02a0b8
+		public IFeature getFeature() {
Ben Konrath ccb00c
+				return null;
Ben Konrath 02a0b8
+		}
Ben Konrath ccb00c
+		
Ben Konrath 02a0b8
 	}
Ben Konrath 02a0b8
 
Ben Konrath 02a0b8
 	public SiteSearchCategory() {
Ben Konrath 02a0b8
Index: src/org/eclipse/update/internal/core/ConfiguredSite.java
Ben Konrath 02a0b8
===================================================================
Ben Konrath ccb00c
RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java,v
Ben Konrath 02a0b8
retrieving revision 1.96
Ben Konrath 02a0b8
diff -u -r1.96 ConfiguredSite.java
Ben Konrath 02a0b8
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java	30 Mar 2006 02:34:37 -0000	1.96
Ben Konrath ccb00c
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java	25 Sep 2006 22:38:05 -0000
Ben Konrath 02a0b8
@@ -35,6 +35,7 @@
Ben Konrath 02a0b8
 import org.eclipse.core.runtime.IProgressMonitor;
Ben Konrath 02a0b8
 import org.eclipse.core.runtime.IStatus;
Ben Konrath 02a0b8
 import org.eclipse.core.runtime.MultiStatus;
Ben Konrath 02a0b8
+import org.eclipse.core.runtime.Platform;
Ben Konrath 02a0b8
 import org.eclipse.osgi.util.NLS;
Ben Konrath 02a0b8
 import org.eclipse.update.configuration.IActivity;
Ben Konrath 02a0b8
 import org.eclipse.update.configuration.IConfiguredSite;
Ben Konrath 02a0b8
@@ -803,7 +804,9 @@
Ben Konrath 02a0b8
 			}
Ben Konrath 02a0b8
 		} else {
Ben Konrath 02a0b8
 			File container = getSiteContaining(file);
Ben Konrath 02a0b8
-			if (container != null) {
Ben Konrath 02a0b8
+			// allow the install location to pass even though it looks like this
Ben Konrath 02a0b8
+			// site is contained in another site
Ben Konrath 02a0b8
+			if (container != null && !siteLocation.equals(Platform.getInstallLocation().getURL().getFile())) {
Ben Konrath 02a0b8
 				verifyStatus = createStatus(IStatus.ERROR, NLS.bind(Messages.ConfiguredSite_ContainedInAnotherSite, (new String[] { container.getAbsolutePath() })), null);
Ben Konrath 02a0b8
 				return verifyStatus;
Ben Konrath 02a0b8
 			}