Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2007-10-11 15:06:39 -0400
committerSusan Franklin2007-10-11 15:06:39 -0400
commit89bae677ef23a6adad13735db6be7008ae160434 (patch)
tree4ac8b49b08e01da899eb776b243b25373383365f
parent48f2ea960be18897bca114495eddd0a7719fecf1 (diff)
downloadrt.equinox.p2-89bae677ef23a6adad13735db6be7008ae160434.tar.gz
rt.equinox.p2-89bae677ef23a6adad13735db6be7008ae160434.tar.xz
rt.equinox.p2-89bae677ef23a6adad13735db6be7008ae160434.zip
Bug 204823 - [prov] [ui] Confusing mixture of entry points and groups in end user UI
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IPlanner.java (renamed from bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector2.java)26
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java328
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java164
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/ProvisioningPlan.java (renamed from bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/DirectorResult.java)6
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java119
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimplePlanner.java (renamed from bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector2.java)145
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/Profile.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/IProfileInstallRegistry.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/InstallRegistry.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnitConstants.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithoutEntryPoint.java)8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithEntryPoint.java81
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java90
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/plugin.properties1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/plugin.xml11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java99
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIMessages.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUProfilePropertiesGroup.java75
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/InstalledIUPropertyPage.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/messages.properties15
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/PreferenceConstants.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvUIPreferenceInitializer.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvisioningPrefPage.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java66
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java178
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java91
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties40
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUtil.java151
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/BecomeAction.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java88
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProvisioningAction.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java65
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java120
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUGroup.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUImplementationGroup.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUPropertiesGroup.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableIUElement.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableUpdateElement.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/InstalledIUElement.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddProfileOperation.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/BecomeOperation.java71
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallOperation.java58
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java134
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveProfilesOperation.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RepositoryOperation.java152
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UninstallOperation.java76
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UpdateOperation.java80
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUColumnConfig.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/IOperationConfirmer.java)30
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUDetailsLabelProvider.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUProfilePropertyFilter.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/InstallIUDropAdapter.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/StructuredViewerProvisioningListener.java6
79 files changed, 1567 insertions, 1808 deletions
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
index 4ac477d69..8197091fd 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
@@ -227,14 +227,14 @@ public class ProvisioningHelper {
throw new ProvisionException(error.toString());
}
- IDirector2 director = (IDirector2) ServiceHelper.getService(Activator.getContext(), IDirector2.class.getName());
- if (director == null)
- throw new ProvisionException("No director service found.");
+ IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.class.getName());
+ if (planner == null)
+ throw new ProvisionException("No planner service found.");
Engine engine = (Engine) ServiceHelper.getService(Activator.getContext(), Engine.class.getName());
if (engine == null)
throw new ProvisionException("No director service found.");
- DirectorResult result = director.install(new IInstallableUnit[] {toInstall}, profile, null, progress);
+ ProvisioningPlan result = planner.getInstallPlan(new IInstallableUnit[] {toInstall}, profile, progress);
if (!result.getStatus().isOK())
return result.getStatus();
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
index a00ad7594..812fad4af 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
@@ -16,8 +16,7 @@ import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.console.ProvisioningHelper;
import org.eclipse.equinox.p2.core.helpers.LogHelper;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.p2.director.DirectorResult;
-import org.eclipse.equinox.p2.director.IDirector2;
+import org.eclipse.equinox.p2.director.*;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.phases.SizingPhase;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -75,10 +74,14 @@ public class Application implements IApplication {
if (currentFlavor != null && !currentFlavor.endsWith(flavor))
throw new RuntimeException("Install flavor not consistent with profile flavor");
- IDirector2 director = (IDirector2) ServiceHelper.getService(Activator.getContext(), IDirector2.class.getName());
+ IDirector director = (IDirector) ServiceHelper.getService(Activator.getContext(), IDirector.class.getName());
if (director == null)
throw new RuntimeException("Director could not be loaded");
+ IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.class.getName());
+ if (planner == null)
+ throw new RuntimeException("Planner could not be loaded");
+
Engine engine = (Engine) ServiceHelper.getService(Activator.getContext(), Engine.class.getName());
if (engine == null)
throw new RuntimeException("Engine could not be loaded");
@@ -86,13 +89,13 @@ public class Application implements IApplication {
ProvisioningHelper.addArtifactRepository(artifactRepositoryLocation);
IMetadataRepository metadataRepository = ProvisioningHelper.addMetadataRepository(metadataRepositoryLocation);
IInstallableUnit[] roots = Query.query(new IQueryable[] {metadataRepository}, root, version == null ? null : new VersionRange(version, true, version, true), null, false, null);
- DirectorResult result = null;
+ ProvisioningPlan result = null;
IStatus operationStatus = null;
if (roots.length > 0) {
if (install) {
- result = director.install(roots, profile, null, new NullProgressMonitor());
+ result = planner.getInstallPlan(roots, profile, new NullProgressMonitor());
} else {
- result = director.uninstall(roots, profile, new NullProgressMonitor());
+ result = planner.getUninstallPlan(roots, profile, new NullProgressMonitor());
}
if (!result.getStatus().isOK())
operationStatus = result.getStatus();
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java
index d23b63a31..a622c37de 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java
@@ -29,6 +29,7 @@ public class Messages extends NLS {
public static String Director_Uninstall_Problems;
public static String Director_Nothing_To_Uninstall;
public static String Director_Cannot_Uninstall;
+ public static String Director_Already_Installed;
public static String Director_Replace_Problems;
public static String Director_Become_Problems;
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties
index 795fa00db..b39b3ac20 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties
@@ -13,10 +13,11 @@ Director_Uninstall_Problems=Problems occurred while uninstalling.
Director_Install_Problems=Problems occurred while installing.
Director_Cannot_Uninstall=Can not uninstall {0} because others IUs depend on it.
Director_Nothing_To_Uninstall=Nothing to uninstall.
+Director_Already_Installed={0} is already installed.
Director_Replace_Problems=Problems occurred while replacing.
Director_Become_Problems=Problems occured while running become.
Director_Unexpected_IU=The installable unit {0} can not be used here.
-Director_Task_Installing=Installing {0} to {1}
+Director_Task_Installing=Installing into {1}
Director_Task_Uninstalling=Uninstalling
Director_Task_Updating=Updating
Director_Task_Resolving_Dependencies=Resolving dependencies
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java
index 4ad233379..e75535422 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java
@@ -29,11 +29,10 @@ public interface IDirector {
*
* @param toInstall The units to install
* @param profile The profile to install into
- * @param entryPoint The user visible name of the entry point. If <code>null</code> is being passed, no entry point gets created
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
*/
- public IStatus install(IInstallableUnit[] toInstall, Profile profile, String entryPoint, IProgressMonitor monitor);
+ public IStatus install(IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
/**
* Uninstalls the given units from the given profile.
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector2.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IPlanner.java
index a85fd4ff5..02ac5203d 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector2.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IPlanner.java
@@ -13,41 +13,37 @@ import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
- * Directors are responsible for determining what should be done to a given
+ * Planners are responsible for determining what should be done to a given
* profile to reshape it as requested. That is, given the current state of a
* profile, a description of the desired end state of that profile and metadata
- * describing the available IUs, a director produces a list of provisioning
- * operations (e.g., install, update or uninstall) to perform on the related IUs.
- * Directors are also able to validate profiles and assist in the diagnosis of
- * configuration errors. Note that directors may range in complexity from
- * very simple (e.g., reading a list of bundles from a static file) to very complex.
+ * describing the available IUs, a planner produces a plan that lists the
+ * provisioning operands that the engine should perform.
*/
-public interface IDirector2 {
+public interface IPlanner {
/**
- * Installs the given units into the given profile.
+ * Provides a plan for installing the given units into the given profile.
*
* @param toInstall The units to install
* @param profile The profile to install into
- * @param entryPoint The user visible name of the entry point. If <code>null</code> is being passed, no entry point gets created
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
*/
- public DirectorResult install(IInstallableUnit[] toInstall, Profile profile, String entryPoint, IProgressMonitor monitor);
+ public ProvisioningPlan getInstallPlan(IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
/**
- * Uninstalls the given units from the given profile.
+ * Provides a plan for uninstalling the given units from the given profile.
*
* @param toUninstall The units to uninstall
* @param profile The profile from which to uninstall
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
*/
- public DirectorResult uninstall(IInstallableUnit[] toUninstall, Profile profile, IProgressMonitor monitor);
+ public ProvisioningPlan getUninstallPlan(IInstallableUnit[] toUninstall, Profile profile, IProgressMonitor monitor);
- public DirectorResult become(IInstallableUnit target, Profile profile, IProgressMonitor monitor);
+ public ProvisioningPlan getBecomePlan(IInstallableUnit target, Profile profile, IProgressMonitor monitor);
- public DirectorResult replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
+ public ProvisioningPlan getReplacePlan(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
- //TODO And many more operations for uninstallation and the rest ! See bug 179819
+ public IInstallableUnit[] updatesFor(IInstallableUnit toUpdate);
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java
deleted file mode 100644
index 715600543..000000000
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * 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.equinox.p2.director;
-
-import java.net.URL;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.director.*;
-import org.eclipse.equinox.internal.p2.rollback.FormerState;
-import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
-import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.p2.core.location.AgentLocation;
-import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.resolution.ResolutionHelper;
-import org.eclipse.osgi.service.resolver.VersionRange;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-
-public class NewSimpleDirector implements IDirector {
- static final int ExpandWork = 10;
- static final int OperationWork = 100;
- private Engine engine;
-
- public static void tagAsImplementation(IMetadataRepository repository) {
- if (repository != null && repository.getProperties().getProperty(IRepository.IMPLEMENTATION_ONLY_KEY) == null) {
- if (repository.isModifiable())
- repository.getModifiableProperties().setProperty(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
- }
- }
-
- public NewSimpleDirector() {
- URL rollbackLocation = null;
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName());
- rollbackLocation = agentLocation.getTouchpointDataArea("director");
- ProvisioningEventBus eventBus = (ProvisioningEventBus) ServiceHelper.getService(DirectorActivator.context, ProvisioningEventBus.class.getName());
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
- IMetadataRepository rollbackRepo = manager.loadRepository(rollbackLocation, null);
- if (rollbackRepo == null)
- rollbackRepo = manager.createRepository(rollbackLocation, "Agent rollback repo", "org.eclipse.equinox.p2.metadata.repository.simpleRepository"); //$NON-NLS-1$//$NON-NLS-2$
- if (rollbackRepo == null)
- throw new IllegalStateException("Unable to open or create Agent's rollback repository");
- tagAsImplementation(rollbackRepo);
- new FormerState(eventBus, rollbackRepo);
- engine = (Engine) ServiceHelper.getService(DirectorActivator.context, Engine.class.getName());
- }
-
- //TODO This is really gross!!!!! We need to make things uniform
- private IInstallableUnit[] toArray(Iterator it) {
- ArrayList result = new ArrayList();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- protected IInstallableUnit[] createEntryPointHelper(String entryPointName, IInstallableUnit[] content) {
- if (entryPointName == null)
- return content;
- return new IInstallableUnit[] {createEntryPoint(entryPointName, content)};
- }
-
- protected InstallableUnit createEntryPoint(String entryPointName, IInstallableUnit[] content) {
- InstallableUnit result = new InstallableUnit();
- result.setId("entry point " + entryPointId(content)); //$NON-NLS-1$
- result.setVersion(new Version(0, 0, 0, Long.toString(System.currentTimeMillis())));
- result.setRequiredCapabilities(IUTransformationHelper.toRequirements(content, false));
- result.setProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY, Boolean.TRUE.toString());
- result.setProperty(IInstallableUnitConstants.NAME, entryPointName);
- return result;
- }
-
- private String entryPointId(IInstallableUnit[] ius) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < ius.length; i++) {
- result.append(ius[i].getId());
- if (i < ius.length - 1)
- result.append(", "); //$NON-NLS-1$
- }
- return result.toString();
- }
-
- public IStatus install(IInstallableUnit[] installRoots, Profile profile, String entryPointName, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, ExpandWork + OperationWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Install_Problems, null);
- // Get the list of ius installed in the profile we are installing into
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- //Compute the complete closure of things to install to successfully install the installRoots.
- NewDependencyExpander expander = new NewDependencyExpander(createEntryPointHelper(entryPointName, installRoots), alreadyInstalled, gatherAvailableInstallableUnits(installRoots), profile, true);
- // NewDependencyExpander expander = new NewDependencyExpander(installRoots, alreadyInstalled, gatherAvailableInstallableUnits(), profile, true);
- IStatus expanderResult = expander.expand(sub.newChild(ExpandWork));
- if (!expanderResult.isOK()) {
- result.merge(expanderResult);
- return result;
- }
-
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(Arrays.asList(alreadyInstalled));
- List oldStateOrder = oldStateHelper.getSorted();
-
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), expander.getRecommendations());
- Collection newState = newStateHelper.attachCUs(expander.getAllInstallableUnits());
- List newStateOrder = newStateHelper.getSorted();
-
- //TODO Here we need to sort the operations to ensure that the dependents will be treated first (see ensureDependencyOrder)
- sub.setTaskName(NLS.bind(Messages.Director_Task_Installing, entryPointName, profile.getValue(Profile.PROP_INSTALL_FOLDER)));
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateOrder, newStateOrder), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result.isOK() ? Status.OK_STATUS : result;
- } finally {
- sub.done();
- }
- }
-
- private Operand[] generateOperations(Collection fromState, Collection toState, List fromStateOrder, List newStateOrder) {
- return sortOperations(new OperationGenerator().generateOperation(fromState, toState), newStateOrder, fromStateOrder);
- }
-
- private Operand[] sortOperations(Operand[] toSort, List installOrder, List uninstallOrder) {
- List updateOp = new ArrayList();
- for (int i = 0; i < toSort.length; i++) {
- Operand op = toSort[i];
- if (op.first() == null && op.second() != null) {
- installOrder.set(installOrder.indexOf(op.second()), op);
- continue;
- }
- if (op.first() != null && op.second() == null) {
- uninstallOrder.set(uninstallOrder.indexOf(op.first()), op);
- continue;
- }
- if (op.first() != null && op.second() != null) {
- updateOp.add(op);
- continue;
- }
- }
- int i = 0;
- for (Iterator iterator = installOrder.iterator(); iterator.hasNext();) {
- Object elt = iterator.next();
- if (elt instanceof Operand) {
- toSort[i++] = (Operand) elt;
- }
- }
- for (Iterator iterator = uninstallOrder.iterator(); iterator.hasNext();) {
- Object elt = iterator.next();
- if (elt instanceof Operand) {
- toSort[i++] = (Operand) elt;
- }
- }
- for (Iterator iterator = updateOp.iterator(); iterator.hasNext();) {
- Object elt = iterator.next();
- if (elt instanceof Operand) {
- toSort[i++] = (Operand) elt;
- }
- }
- return toSort;
- }
-
- public IStatus become(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Become_Problems, null);
-
- if (!Boolean.valueOf(target.getProperty(IInstallableUnitConstants.PROFILE_IU_KEY)).booleanValue()) {
- result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Unexpected_IU, target.getId())));
- return result;
- }
-
- //TODO Here we need to deal with the change of properties between the two profiles
- //Also if the profile changes (locations are being modified, etc), should not we do a full uninstall then an install?
- //Maybe it depends on the kind of changes in a profile
- //We need to get all the ius that were part of the profile and give that to be what to become
- NewDependencyExpander toExpander = new NewDependencyExpander(new IInstallableUnit[] {target}, null, gatherAvailableInstallableUnits(new IInstallableUnit[] {target}), profile, true);
- toExpander.expand(sub.newChild(ExpandWork));
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), toExpander.getRecommendations());
- Collection newState = newStateHelper.attachCUs(toExpander.getAllInstallableUnits());
- newState.remove(target);
-
- Iterator it = profile.getInstallableUnits();
- Collection oldIUs = new HashSet();
- for (; it.hasNext();) {
- oldIUs.add(it.next());
- }
-
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(oldIUs);
- sub.setTaskName(Messages.Director_Task_Updating);
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result;
- } finally {
- sub.done();
- }
- }
-
- private IInstallableUnit[] inProfile(IInstallableUnit[] toFind, Profile profile, boolean found, IProgressMonitor monitor) {
- ArrayList result = new ArrayList(toFind.length);
- for (int i = 0; i < toFind.length; i++) {
- if (profile.query(toFind[i].getId(), new VersionRange(toFind[i].getVersion(), true, toFind[i].getVersion(), true), null, false, monitor).length > 0) {
- if (found)
- result.add(toFind[i]);
- } else {
- if (!found)
- result.add(toFind[i]);
- }
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- public IStatus uninstall(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- IInstallableUnit[] toReallyUninstall = inProfile(uninstallRoots, profile, true, sub.newChild(0));
- if (toReallyUninstall.length == 0) {
- return new Status(IStatus.OK, DirectorActivator.PI_DIRECTOR, Messages.Director_Nothing_To_Uninstall);
- } else if (toReallyUninstall.length != uninstallRoots.length) {
- uninstallRoots = toReallyUninstall;
- }
-
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Uninstall_Problems, null);
-
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(Arrays.asList(alreadyInstalled));
-
- NewDependencyExpander expander = new NewDependencyExpander(uninstallRoots, new IInstallableUnit[0], alreadyInstalled, profile, true);
- expander.expand(sub.newChild(ExpandWork / 2));
- Collection toUninstallClosure = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(expander.getAllInstallableUnits());
-
- Collection remainingIUs = new HashSet(oldState);
- remainingIUs.removeAll(toUninstallClosure);
- NewDependencyExpander finalExpander = new NewDependencyExpander(null, (IInstallableUnit[]) remainingIUs.toArray(new IInstallableUnit[remainingIUs.size()]), gatherAvailableInstallableUnits(uninstallRoots), profile, true);
- finalExpander.expand(sub.newChild(ExpandWork / 2));
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection newState = newStateHelper.attachCUs(finalExpander.getAllInstallableUnits());
-
- for (int i = 0; i < uninstallRoots.length; i++) {
- if (newState.contains(uninstallRoots[i]))
- result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Cannot_Uninstall, uninstallRoots[i])));
- }
- if (!result.isOK())
- return result;
-
- sub.setTaskName(Messages.Director_Task_Uninstalling);
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result.isOK() ? Status.OK_STATUS : result;
- } finally {
- sub.done();
- }
- }
-
- protected IInstallableUnit[] gatherAvailableInstallableUnits(IInstallableUnit[] additionalSource) {
- IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
- IMetadataRepository[] repos = repoMgr.getKnownRepositories();
- List results = new ArrayList();
- if (additionalSource != null) {
- for (int i = 0; i < additionalSource.length; i++) {
- results.add(additionalSource[i]);
- }
- }
-
- for (int i = 0; i < repos.length; i++) {
- results.addAll(Arrays.asList(repos[i].getInstallableUnits(null)));
- }
- return (IInstallableUnit[]) results.toArray(new IInstallableUnit[results.size()]);
- }
-
- public IStatus replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Replace_Problems, null);
-
- //TODO Need to worry about the entry points
-
- //find the things being updated in the profile
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- IInstallableUnit[] uninstallRoots = toUninstall;
-
- //compute the transitive closure and remove them.
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(Arrays.asList(alreadyInstalled));
-
- NewDependencyExpander expander = new NewDependencyExpander(uninstallRoots, new IInstallableUnit[0], alreadyInstalled, profile, true);
- expander.expand(sub.newChild(ExpandWork / 2));
- Collection toUninstallClosure = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(expander.getAllInstallableUnits());
-
- //add the new set.
- Collection remainingIUs = new HashSet(oldState);
- remainingIUs.removeAll(toUninstallClosure);
- // for (int i = 0; i < updateRoots.length; i++) {
- // remainingIUs.add(updateRoots[i]);
- // }
- NewDependencyExpander finalExpander = new NewDependencyExpander(toInstall, (IInstallableUnit[]) remainingIUs.toArray(new IInstallableUnit[remainingIUs.size()]), gatherAvailableInstallableUnits(null), profile, true);
- finalExpander.expand(sub.newChild(ExpandWork / 2));
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection newState = newStateHelper.attachCUs(finalExpander.getAllInstallableUnits());
-
- sub.setTaskName(Messages.Director_Task_Updating);
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result.isOK() ? Status.OK_STATUS : result;
- } finally {
- sub.done();
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java
deleted file mode 100644
index 2954c855e..000000000
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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.equinox.p2.director;
-
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.director.DirectorActivator;
-import org.eclipse.equinox.internal.p2.director.Messages;
-import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.resolution.ResolutionHelper;
-import org.eclipse.osgi.service.resolver.VersionRange;
-
-//TODO The "extends" relationship with the director is a hack to get stuffs working
-public class Oracle extends NewSimpleDirector {
- public Object canInstall(IInstallableUnit[] toAdd, Profile profile, IProgressMonitor monitor) {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, "oracle", null);
- SubMonitor sub = SubMonitor.convert(monitor, ExpandWork + OperationWork);
- try {
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- if (alreadyIn(alreadyInstalled, toAdd[0])) {
- return Boolean.FALSE;
- }
- //Compute the complete closure of things to install to successfully install the installRoots.
- NewDependencyExpander expander = new NewDependencyExpander(toAdd, alreadyInstalled, gatherAvailableInstallableUnits(toAdd), profile, true);
- IStatus expanderResult = expander.expand(sub);
- sub.worked(ExpandWork);
- if (expanderResult.isOK()) {
- return Boolean.TRUE;
- }
- Collection resolved = expander.getAllInstallableUnits();
- Collection entryPoints = new HashSet();
- for (Iterator iterator = resolved.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
- // if ("true".equals(iu.getProperty("entryPoint"))) {
- entryPoints.add(iu);
- // }
- }
- Collection initialEntryPoints = new HashSet();
- for (int i = 0; i < alreadyInstalled.length; i++) {
- // if ("true".equals(alreadyInstalled[i].getProperty("entryPoint"))) {
- initialEntryPoints.add(alreadyInstalled[i]);
- // }
- }
- initialEntryPoints.removeAll(entryPoints);
- if (initialEntryPoints.size() != 0) {
- return initialEntryPoints;
- }
- return Boolean.FALSE;
- } finally {
- sub.done();
- }
- }
-
- public boolean canInstall(IInstallableUnit[] toAdd, IInstallableUnit[] toUpdate, Profile profile, IProgressMonitor monitor) {
- IInstallableUnit[] replacements = new IInstallableUnit[toUpdate.length + toAdd.length];
- for (int i = 0; i < toUpdate.length; i++) {
- replacements[i] = containsUpdate(toUpdate[i]);
- //TODO We need to be able to deal with multiple updates and even where is none
- if (replacements[i] == null)
- return false;
- }
- System.arraycopy(toAdd, 0, replacements, toUpdate.length, toAdd.length);
-
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Uninstall_Problems, null);
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
-
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- Collection oldState = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(Arrays.asList(alreadyInstalled));
-
- NewDependencyExpander expander = new NewDependencyExpander(toUpdate, new IInstallableUnit[0], alreadyInstalled, profile, true);
- expander.expand(sub);
- Collection toUninstallClosure = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(expander.getAllInstallableUnits());
-
- Collection remainingIUs = new HashSet(oldState);
- remainingIUs.removeAll(toUninstallClosure);
- NewDependencyExpander finalExpander = new NewDependencyExpander(replacements, (IInstallableUnit[]) remainingIUs.toArray(new IInstallableUnit[remainingIUs.size()]), gatherAvailableInstallableUnits(toAdd), profile, true);
- finalExpander.expand(sub);
- Collection newState = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(finalExpander.getAllInstallableUnits());
-
- return true;
- }
-
- private IInstallableUnit containsUpdate(IInstallableUnit iu) {
- IInstallableUnit[] candidates = gatherAvailableInstallableUnits(null);
- for (int i = 0; i < candidates.length; i++) {
- if (iu.getId().equals(candidates[i].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
- if (iu.equals(candidates[i]))
- continue;
- VersionRange range = new VersionRange(candidates[i].getProperty(IInstallableUnitConstants.UPDATE_RANGE));
- if (range.isIncluded(iu.getVersion()) && candidates[i].getVersion().compareTo(iu.getVersion()) > 0)
- return candidates[i];
- }
- }
- return null;
- }
-
- private boolean alreadyIn(IInstallableUnit[] ius, IInstallableUnit id) {
- for (int i = 0; i < ius.length; i++) {
- if (ius[i].equals(id))
- return true;
- }
- return false;
- }
-
- private IInstallableUnit[] toArray(Iterator it) {
- ArrayList result = new ArrayList();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- public Collection hasUpdate(IInstallableUnit toUpdate) {
- if (toUpdate.getProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY) != null)
- return entryPointProcessing(toUpdate);
- IInstallableUnit[] allius = gatherAvailableInstallableUnits(null);
- Set updates = new HashSet();
- for (int i = 0; i < allius.length; i++) {
- if (toUpdate.getId().equals(allius[i].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
- if (toUpdate.getVersion().compareTo(allius[i].getVersion()) < 0 && new VersionRange(allius[i].getProperty(IInstallableUnitConstants.UPDATE_RANGE)).isIncluded(toUpdate.getVersion()))
- updates.add(allius[i]);
- }
- }
- return updates;
- }
-
- private Collection entryPointProcessing(IInstallableUnit entryPoint) {
- ArrayList updates = new ArrayList();
- RequiredCapability[] entries = entryPoint.getRequiredCapabilities();
- for (int i = 0; i < entries.length; i++) {
- if (!IInstallableUnit.IU_NAMESPACE.equals(entries[i].getNamespace()))
- continue;
- IInstallableUnit[] allius = gatherAvailableInstallableUnits(null);
- IInstallableUnit match = null;
- for (int j = 0; j < allius.length; j++) {
- if (entries[i].getName().equals(allius[j].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
- if (new VersionRange(allius[j].getProperty(IInstallableUnitConstants.UPDATE_RANGE)).isIncluded(entries[i].getRange().getMinimum()) && allius[j].getVersion().compareTo(entries[i].getRange().getMinimum()) > 0) {
- if (match == null || allius[j].getVersion().compareTo(match.getVersion()) > 0)
- match = allius[j];
- }
- }
- }
- if (match != null)
- updates.add(match);
- }
- if (updates.size() == 0)
- return updates;
- String entryPointName = entryPoint.getProperty(IInstallableUnitConstants.NAME);
- if (entryPointName == null)
- entryPointName = entryPoint.getId();
- InstallableUnit newEntryPoint = createEntryPoint(entryPointName, (IInstallableUnit[]) updates.toArray(new IInstallableUnit[updates.size()]));
- newEntryPoint.setProperty(IInstallableUnitConstants.UPDATE_FROM, entryPoint.getId());
- ArrayList result = new ArrayList();
- result.add(newEntryPoint);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/DirectorResult.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/ProvisioningPlan.java
index 3d37220c8..ef70bf67d 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/DirectorResult.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/ProvisioningPlan.java
@@ -11,15 +11,15 @@ package org.eclipse.equinox.p2.director;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.engine.Operand;
-public class DirectorResult {
+public class ProvisioningPlan {
private IStatus status;
private Operand[] operands;
- public DirectorResult(IStatus status) {
+ public ProvisioningPlan(IStatus status) {
this(status, null);
}
- public DirectorResult(IStatus status, Operand[] operands) {
+ public ProvisioningPlan(IStatus status, Operand[] operands) {
this.status = status;
this.operands = operands;
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java
new file mode 100644
index 000000000..6217e2dbe
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.equinox.p2.director;
+
+import java.net.URL;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.director.DirectorActivator;
+import org.eclipse.equinox.internal.p2.director.Messages;
+import org.eclipse.equinox.internal.p2.rollback.FormerState;
+import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
+import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.p2.core.location.AgentLocation;
+import org.eclipse.equinox.p2.core.repository.IRepository;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.osgi.util.NLS;
+
+public class SimpleDirector implements IDirector {
+ static final int OperationWork = 100;
+ private Engine engine;
+ private IPlanner planner;
+
+ public static void tagAsImplementation(IMetadataRepository repository) {
+ if (repository != null && repository.getProperties().getProperty(IRepository.IMPLEMENTATION_ONLY_KEY) == null) {
+ if (repository.isModifiable())
+ repository.getModifiableProperties().setProperty(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
+ }
+ }
+
+ public SimpleDirector() {
+ URL rollbackLocation = null;
+ AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName());
+ rollbackLocation = agentLocation.getTouchpointDataArea("director");
+ ProvisioningEventBus eventBus = (ProvisioningEventBus) ServiceHelper.getService(DirectorActivator.context, ProvisioningEventBus.class.getName());
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
+ IMetadataRepository rollbackRepo = manager.loadRepository(rollbackLocation, null);
+ if (rollbackRepo == null)
+ rollbackRepo = manager.createRepository(rollbackLocation, "Agent rollback repo", "org.eclipse.equinox.p2.metadata.repository.simpleRepository"); //$NON-NLS-1$//$NON-NLS-2$
+ if (rollbackRepo == null)
+ throw new IllegalStateException("Unable to open or create Agent's rollback repository");
+ tagAsImplementation(rollbackRepo);
+ new FormerState(eventBus, rollbackRepo);
+ engine = (Engine) ServiceHelper.getService(DirectorActivator.context, Engine.class.getName());
+ if (engine == null)
+ throw new IllegalStateException("Provisioning engine is not registered");
+ planner = (IPlanner) ServiceHelper.getService(DirectorActivator.context, IPlanner.class.getName());
+ if (planner == null)
+ throw new IllegalStateException("Unable to find provisioning planner");
+ }
+
+ public IStatus install(IInstallableUnit[] installRoots, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getInstallPlan(installRoots, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(NLS.bind(Messages.Director_Task_Installing, profile.getValue(Profile.PROP_INSTALL_FOLDER)));
+ try {
+ IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ if (!engineResult.isOK())
+ return engineResult;
+ // mark the roots as such
+ for (int i = 0; i < installRoots.length; i++)
+ profile.setInstallableUnitProfileProperty(installRoots[i], IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
+
+ return engineResult;
+ } finally {
+ sub.done();
+ }
+ }
+
+ public IStatus become(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getBecomePlan(target, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(Messages.Director_Task_Updating);
+ try {
+ return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ } finally {
+ sub.done();
+ }
+ }
+
+ public IStatus uninstall(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getUninstallPlan(uninstallRoots, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(Messages.Director_Task_Uninstalling);
+ try {
+ return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ } finally {
+ sub.done();
+ }
+ }
+
+ public IStatus replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getReplacePlan(toUninstall, toInstall, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(Messages.Director_Task_Updating);
+ try {
+ return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ } finally {
+ sub.done();
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector2.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimplePlanner.java
index c76b1419b..56990566c 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector2.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimplePlanner.java
@@ -8,100 +8,48 @@
******************************************************************************/
package org.eclipse.equinox.p2.director;
-import java.net.URL;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.director.*;
-import org.eclipse.equinox.internal.p2.rollback.FormerState;
-import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.p2.core.location.AgentLocation;
-import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.engine.Operand;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.resolution.ResolutionHelper;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-public class SimpleDirector2 implements IDirector2 {
+public class SimplePlanner implements IPlanner {
static final int ExpandWork = 10;
- static final int OperationWork = 100;
- public static void tagAsImplementation(IMetadataRepository repository) {
- if (repository != null && repository.getProperties().getProperty(IRepository.IMPLEMENTATION_ONLY_KEY) == null) {
- if (repository.isModifiable())
- repository.getModifiableProperties().setProperty(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
- }
- }
-
- public SimpleDirector2() {
- URL rollbackLocation = null;
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName());
- rollbackLocation = agentLocation.getTouchpointDataArea("director");
- ProvisioningEventBus eventBus = (ProvisioningEventBus) ServiceHelper.getService(DirectorActivator.context, ProvisioningEventBus.class.getName());
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
- IMetadataRepository rollbackRepo = manager.loadRepository(rollbackLocation, null);
- if (rollbackRepo == null)
- rollbackRepo = manager.createRepository(rollbackLocation, "Agent rollback repo", "org.eclipse.equinox.p2.metadata.repository.simpleRepository"); //$NON-NLS-1$//$NON-NLS-2$
- if (rollbackRepo == null)
- throw new IllegalStateException("Unable to open or create Agent's rollback repository");
- tagAsImplementation(rollbackRepo);
- new FormerState(eventBus, rollbackRepo);
- }
-
- //TODO This is really gross!!!!! We need to make things uniform
- private IInstallableUnit[] toArray(Iterator it) {
- ArrayList result = new ArrayList();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- protected IInstallableUnit[] createEntryPointHelper(String entryPointName, IInstallableUnit[] content) {
- if (entryPointName == null)
- return content;
- return new IInstallableUnit[] {createEntryPoint(entryPointName, content)};
- }
-
- protected InstallableUnit createEntryPoint(String entryPointName, IInstallableUnit[] content) {
- InstallableUnit result = new InstallableUnit();
- result.setId("entry point " + entryPointId(content)); //$NON-NLS-1$
- result.setVersion(new Version(0, 0, 0, Long.toString(System.currentTimeMillis())));
- result.setRequiredCapabilities(IUTransformationHelper.toRequirements(content, false));
- result.setProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY, Boolean.TRUE.toString());
- result.setProperty(IInstallableUnitConstants.NAME, entryPointName);
- return result;
- }
-
- private String entryPointId(IInstallableUnit[] ius) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < ius.length; i++) {
- result.append(ius[i].getId());
- if (i < ius.length - 1)
- result.append(", "); //$NON-NLS-1$
- }
- return result.toString();
- }
-
- public DirectorResult install(IInstallableUnit[] installRoots, Profile profile, String entryPointName, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, ExpandWork + OperationWork);
+ public ProvisioningPlan getInstallPlan(IInstallableUnit[] installRoots, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Install_Problems, null);
// Get the list of ius installed in the profile we are installing into
IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
+
+ // If any of these are already installed, return a warning status
+ // specifying that they are already installed.
+ for (int i = 0; i < installRoots.length; i++)
+ for (int j = 0; j < alreadyInstalled.length; j++)
+ if (installRoots[i].equals(alreadyInstalled[j]))
+ result.merge(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Already_Installed, installRoots[i].getId())));
+
+ if (!result.isOK()) {
+ return new ProvisioningPlan(result);
+ }
//Compute the complete closure of things to install to successfully install the installRoots.
- NewDependencyExpander expander = new NewDependencyExpander(createEntryPointHelper(entryPointName, installRoots), alreadyInstalled, gatherAvailableInstallableUnits(installRoots), profile, true);
+ NewDependencyExpander expander = new NewDependencyExpander(installRoots, alreadyInstalled, gatherAvailableInstallableUnits(installRoots), profile, true);
// NewDependencyExpander expander = new NewDependencyExpander(installRoots, alreadyInstalled, gatherAvailableInstallableUnits(), profile, true);
IStatus expanderResult = expander.expand(sub.newChild(ExpandWork));
if (!expanderResult.isOK()) {
result.merge(expanderResult);
- return new DirectorResult(result);
+ return new ProvisioningPlan(result);
}
ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
@@ -111,10 +59,7 @@ public class SimpleDirector2 implements IDirector2 {
ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), expander.getRecommendations());
Collection newState = newStateHelper.attachCUs(expander.getAllInstallableUnits());
List newStateOrder = newStateHelper.getSorted();
-
- //TODO Here we need to sort the operations to ensure that the dependents will be treated first (see ensureDependencyOrder)
- sub.setTaskName(NLS.bind(Messages.Director_Task_Installing, entryPointName, profile.getValue(Profile.PROP_INSTALL_FOLDER)));
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateOrder, newStateOrder));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateOrder, newStateOrder));
} finally {
sub.done();
}
@@ -163,15 +108,15 @@ public class SimpleDirector2 implements IDirector2 {
return toSort;
}
- public DirectorResult become(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
+ public ProvisioningPlan getBecomePlan(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Become_Problems, null);
if (!Boolean.valueOf(target.getProperty(IInstallableUnitConstants.PROFILE_IU_KEY)).booleanValue()) {
result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Unexpected_IU, target.getId())));
- return new DirectorResult(result);
+ return new ProvisioningPlan(result);
}
//TODO Here we need to deal with the change of properties between the two profiles
@@ -192,8 +137,7 @@ public class SimpleDirector2 implements IDirector2 {
ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
Collection oldState = oldStateHelper.attachCUs(oldIUs);
- sub.setTaskName(Messages.Director_Task_Updating);
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
} finally {
sub.done();
}
@@ -213,13 +157,13 @@ public class SimpleDirector2 implements IDirector2 {
return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
}
- public DirectorResult uninstall(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
+ public ProvisioningPlan getUninstallPlan(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
IInstallableUnit[] toReallyUninstall = inProfile(uninstallRoots, profile, true, sub.newChild(0));
if (toReallyUninstall.length == 0) {
- return new DirectorResult(new Status(IStatus.OK, DirectorActivator.PI_DIRECTOR, Messages.Director_Nothing_To_Uninstall));
+ return new ProvisioningPlan(new Status(IStatus.OK, DirectorActivator.PI_DIRECTOR, Messages.Director_Nothing_To_Uninstall));
} else if (toReallyUninstall.length != uninstallRoots.length) {
uninstallRoots = toReallyUninstall;
}
@@ -246,10 +190,9 @@ public class SimpleDirector2 implements IDirector2 {
result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Cannot_Uninstall, uninstallRoots[i])));
}
if (!result.isOK())
- return new DirectorResult(result);
+ return new ProvisioningPlan(result);
- sub.setTaskName(Messages.Director_Task_Uninstalling);
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
} finally {
sub.done();
}
@@ -271,14 +214,10 @@ public class SimpleDirector2 implements IDirector2 {
return (IInstallableUnit[]) results.toArray(new IInstallableUnit[results.size()]);
}
- public DirectorResult replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
+ public ProvisioningPlan getReplacePlan(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Replace_Problems, null);
-
- //TODO Need to worry about the entry points
-
//find the things being updated in the profile
IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
IInstallableUnit[] uninstallRoots = toUninstall;
@@ -302,10 +241,30 @@ public class SimpleDirector2 implements IDirector2 {
ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
Collection newState = newStateHelper.attachCUs(finalExpander.getAllInstallableUnits());
- sub.setTaskName(Messages.Director_Task_Updating);
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
} finally {
sub.done();
}
}
+
+ public IInstallableUnit[] updatesFor(IInstallableUnit toUpdate) {
+ IInstallableUnit[] allius = gatherAvailableInstallableUnits(null);
+ Set updates = new HashSet();
+ for (int i = 0; i < allius.length; i++) {
+ if (toUpdate.getId().equals(allius[i].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
+ if (toUpdate.getVersion().compareTo(allius[i].getVersion()) < 0 && new VersionRange(allius[i].getProperty(IInstallableUnitConstants.UPDATE_RANGE)).isIncluded(toUpdate.getVersion()))
+ updates.add(allius[i]);
+ }
+ }
+ return (IInstallableUnit[]) updates.toArray(new IInstallableUnit[updates.size()]);
+ }
+
+ //TODO This is really gross!!!!! We need to make things uniform
+ private IInstallableUnit[] toArray(Iterator it) {
+ ArrayList result = new ArrayList();
+ while (it.hasNext()) {
+ result.add(it.next());
+ }
+ return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/Profile.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/Profile.java
index d0325db93..8196f72b0 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/Profile.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/Profile.java
@@ -139,4 +139,24 @@ public class Profile implements IQueryable {
public Iterator getInstallableUnits() {
return Arrays.asList(getAllInstallableUnits()).iterator();
}
+
+ public String getInstallableUnitProfileProperty(IInstallableUnit iu, String key) {
+ IInstallRegistry registry = (IInstallRegistry) ServiceHelper.getService(EngineActivator.getContext(), IInstallRegistry.class.getName());
+ if (registry == null)
+ return null;
+ IProfileInstallRegistry profile = registry.getProfileInstallRegistry(this);
+ if (profile == null)
+ return null;
+ return profile.getInstallableUnitProfileProperty(iu, key);
+ }
+
+ public String setInstallableUnitProfileProperty(IInstallableUnit iu, String key, String value) {
+ IInstallRegistry registry = (IInstallRegistry) ServiceHelper.getService(EngineActivator.getContext(), IInstallRegistry.class.getName());
+ if (registry == null)
+ return null;
+ IProfileInstallRegistry profile = registry.getProfileInstallRegistry(this);
+ if (profile == null)
+ return null;
+ return profile.setInstallableUnitProfileProperty(iu, key, value);
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/IProfileInstallRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/IProfileInstallRegistry.java
index f740cc842..e0b778af3 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/IProfileInstallRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/IProfileInstallRegistry.java
@@ -14,14 +14,18 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
public interface IProfileInstallRegistry {
- public abstract IInstallableUnit[] getInstallableUnits();
+ public IInstallableUnit[] getInstallableUnits();
- public abstract IInstallableUnit getInstallableUnit(String id, String version);
+ public IInstallableUnit getInstallableUnit(String id, String version);
- public abstract void addInstallableUnits(IInstallableUnit toAdd);
+ public void addInstallableUnits(IInstallableUnit toAdd);
- public abstract void removeInstallableUnits(IInstallableUnit toRemove);
+ public void removeInstallableUnits(IInstallableUnit toRemove);
- public abstract String getProfileId();
+ public String getProfileId();
+
+ public String getInstallableUnitProfileProperty(IInstallableUnit iu, String key);
+
+ public String setInstallableUnitProfileProperty(IInstallableUnit iu, String key, String value);
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/InstallRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/InstallRegistry.java
index cffdfb0eb..f723721e6 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/InstallRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/installregistry/InstallRegistry.java
@@ -17,10 +17,12 @@ import java.util.*;
import org.eclipse.equinox.internal.p2.engine.EngineActivator;
import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
import org.eclipse.equinox.p2.core.eventbus.SynchronousProvisioningListener;
+import org.eclipse.equinox.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.core.location.AgentLocation;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.osgi.service.datalocation.Location;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
@@ -54,7 +56,18 @@ public class InstallRegistry implements IInstallRegistry {
if (event.isInstall() && event.getOperand().second() != null) {
registry.addInstallableUnits(event.getOperand().second().getOriginal());
} else if (event.isUninstall() && event.getOperand().first() != null) {
- registry.removeInstallableUnits(event.getOperand().first().getOriginal());
+ IInstallableUnit original = event.getOperand().first().getOriginal();
+ String value = registry.getInstallableUnitProfileProperty(original, IInstallableUnitConstants.PROFILE_ROOT_IU);
+ boolean isRoot = value != null && value.equals(Boolean.toString(true));
+ registry.removeInstallableUnits(original);
+ // TODO this is odd because I'm setting up a property for something
+ // not yet installed in the registry. The implementation allows it and
+ // the assumption is that the second operand will get installed or else
+ // this change will never be committed. The alternative is to remember
+ // a transitory root value that we set when the install is received.
+ if (isRoot && event.getOperand().second() != null) {
+ registry.setInstallableUnitProfileProperty(event.getOperand().second().getOriginal(), IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
+ }
}
} else if (o instanceof CommitOperationEvent) {
persist();
@@ -145,10 +158,12 @@ public class InstallRegistry implements IInstallRegistry {
public class ProfileInstallRegistry implements IProfileInstallRegistry {
private String profileId; // id profile this data applies to
private Set installableUnits; //id
+ private Map iuPropertiesMap; // iu->OrderedProperties
ProfileInstallRegistry(String profileId) {
this.profileId = profileId;
this.installableUnits = new HashSet();
+ this.iuPropertiesMap = new HashMap();
}
public IInstallableUnit[] getInstallableUnits() {
@@ -162,6 +177,7 @@ public class InstallRegistry implements IInstallRegistry {
public void removeInstallableUnits(IInstallableUnit toRemove) {
installableUnits.remove(toRemove);
+ iuPropertiesMap.remove(toRemove);
}
public String getProfileId() {
@@ -176,5 +192,25 @@ public class InstallRegistry implements IInstallRegistry {
}
return null;
}
+
+ public String getInstallableUnitProfileProperty(IInstallableUnit toGet, String key) {
+ OrderedProperties properties = getInstallableUnitProfileProperties(toGet);
+ return properties.getProperty(key);
+ }
+
+ public String setInstallableUnitProfileProperty(IInstallableUnit toSet, String key, String value) {
+ OrderedProperties properties = getInstallableUnitProfileProperties(toSet);
+ return (String) properties.setProperty(key, value);
+ }
+
+ private OrderedProperties getInstallableUnitProfileProperties(IInstallableUnit toGet) {
+ OrderedProperties properties = (OrderedProperties) iuPropertiesMap.get(toGet);
+ if (properties == null) {
+ properties = new OrderedProperties();
+ iuPropertiesMap.put(toGet, properties);
+ }
+ return properties;
+ }
+
}
}
diff --git a/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java b/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java
index 66d4010eb..4d9863ca6 100644
--- a/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java
@@ -44,8 +44,8 @@ public class Activator implements BundleActivator {
private IDirector director;
private ServiceRegistration registrationDirector;
- private IDirector2 director2;
- private ServiceRegistration registrationDirector2;
+ private IPlanner planner;
+ private ServiceRegistration registrationPlanner;
public void start(BundleContext context) throws Exception {
//Need to do the configuration of all the bits and pieces:
@@ -58,7 +58,9 @@ public class Activator implements BundleActivator {
registerDefaultMetadataRepoManager();
registerInstallRegistry();
- //create the director
+ //create the director and planner. The planner must be
+ //registered first because the director finds it in its constructor.
+ registerPlanner();
registerDirector();
//create artifact repositories
@@ -68,6 +70,7 @@ public class Activator implements BundleActivator {
public void stop(BundleContext context) throws Exception {
unregisterDefaultArtifactRepoManager();
unregisterDirector();
+ unregisterPlanner();
unregisterInstallRegistry();
unregisterDefaultMetadataRepoManager();
unregisterProfileRegistry();
@@ -77,19 +80,23 @@ public class Activator implements BundleActivator {
}
private void registerDirector() {
- director = new NewSimpleDirector();
+ director = new SimpleDirector();
registrationDirector = context.registerService(IDirector.class.getName(), director, null);
-
- director2 = new SimpleDirector2();
- registrationDirector2 = context.registerService(IDirector2.class.getName(), director2, null);
}
private void unregisterDirector() {
registrationDirector.unregister();
director = null;
+ }
+
+ private void registerPlanner() {
+ planner = new SimplePlanner();
+ registrationPlanner = context.registerService(IPlanner.class.getName(), planner, null);
+ }
- registrationDirector2.unregister();
- director2 = null;
+ private void unregisterPlanner() {
+ registrationPlanner.unregister();
+ planner = null;
}
private void registerProfileRegistry() {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnitConstants.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnitConstants.java
index 56cc9c871..99b577468 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnitConstants.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnitConstants.java
@@ -30,7 +30,6 @@ public interface IInstallableUnitConstants {
public String UPDATE_RANGE = "equinox.p2.update.range"; //$NON-NLS-1$
//TODO This is not the ideal location for these constants
- public String ENTRYPOINT_IU_KEY = "entryPoint"; //$NON-NLS-1$
public static final String PROFILE_IU_KEY = "profileIU"; //$NON-NLS-1$
-
+ public static final String PROFILE_ROOT_IU = "profileRootIU"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 6a84a8965..b5536cceb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.director.IDirector;
+import org.eclipse.equinox.p2.director.IPlanner;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.RequiredCapability;
@@ -122,6 +123,10 @@ public class AbstractProvisioningTest extends TestCase {
return (IDirector) ServiceHelper.getService(TestActivator.getContext(), IDirector.class.getName());
}
+ public IPlanner createPlanner() {
+ return (IPlanner) ServiceHelper.getService(TestActivator.getContext(), IPlanner.class.getName());
+ }
+
public void printProfile(Profile toPrint) {
boolean containsIU = false;
for (Iterator iterator = toPrint.getInstallableUnits(); iterator.hasNext();) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java
index feced95bd..92e5a385a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java
@@ -28,8 +28,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(RollbackTest.class);
suite.addTestSuite(SingletonTest.class);
suite.addTestSuite(UninstallTest.class);
- suite.addTestSuite(UpdateTestWithoutEntryPoint.class);
- suite.addTestSuite(UpdateTestWithEntryPoint.class);
+ suite.addTestSuite(UpdateTest.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
index 593b504dc..11c84e5f7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
@@ -63,7 +63,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//Install into a profile in which the filter is satisfied
Profile satisfied = new Profile("Satisfied." + getName());
satisfied.setValue(Profile.PROP_ENVIRONMENTS, "FilterKey=true");
- IStatus result = director.install(toInstallArray, satisfied, null, null);
+ IStatus result = director.install(toInstallArray, satisfied, null);
assertTrue("1.0", result.isOK());
assertProfileContains("1.1", satisfied, allUnits);
@@ -97,7 +97,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
Profile profile = new Profile("TestProfile." + getName());
IDirector director = createDirector();
- IStatus result = director.install(toInstallArray, profile, null, null);
+ IStatus result = director.install(toInstallArray, profile, null);
if (!result.isOK())
LogHelper.log(result);
assertTrue("1.0", result.isOK());
@@ -121,7 +121,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
Profile profile = new Profile("TestProfile." + getName());
IDirector director = createDirector();
- IStatus result = director.install(allUnits, profile, null, null);
+ IStatus result = director.install(allUnits, profile, null);
if (!result.isOK())
LogHelper.log(result);
assertTrue("1.0", result.isOK());
@@ -152,12 +152,12 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
Profile profile = new Profile("TestProfile." + getName());
IDirector director = createDirector();
- IStatus result = director.install(toInstallArray, profile, null, null);
+ IStatus result = director.install(toInstallArray, profile, null);
assertTrue("1.0", !result.isOK());
//try again with the filter satisfied
profile.setValue(Profile.PROP_ENVIRONMENTS, "osgi.os=blort");
- result = director.install(toInstallArray, profile, null, null);
+ result = director.install(toInstallArray, profile, null);
assertTrue("2.0", result.isOK());
}
@@ -185,7 +185,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
Profile profile = new Profile("TestProfile." + getName());
IDirector director = createDirector();
- IStatus result = director.install(toInstallArray, profile, null, null);
+ IStatus result = director.install(toInstallArray, profile, null);
if (!result.isOK())
LogHelper.log(result);
assertTrue("1.0", result.isOK());
@@ -215,7 +215,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
Profile profile = new Profile("TestProfile." + getName());
IDirector director = createDirector();
- IStatus result = director.install(toInstallArray, profile, null, null);
+ IStatus result = director.install(toInstallArray, profile, null);
if (!result.isOK())
LogHelper.log(result);
assertTrue("1.0", result.isOK());
@@ -246,7 +246,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
Profile profile = new Profile("TestProfile." + getName());
IDirector director = createDirector();
- IStatus result = director.install(toInstallArray, profile, null, null);
+ IStatus result = director.install(toInstallArray, profile, null);
if (!result.isOK())
LogHelper.log(result);
assertTrue("1.0", result.isOK());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
index a658f6728..a9e9a369f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
@@ -65,10 +65,10 @@ public class OracleTest extends AbstractProvisioningTest {
}
public void testInstallA1() {
- assertEquals(director.install(new IInstallableUnit[] {a1}, profile, null, null).getSeverity(), IStatus.OK);
+ assertEquals(director.install(new IInstallableUnit[] {a1}, profile, null).getSeverity(), IStatus.OK);
createTestMetdataRepository(new IInstallableUnit[] {d2});
// assertEquals(new Oracle().canInstall(new IInstallableUnit[] {b1}, profile, null), true);
- assertEquals(director.install(new IInstallableUnit[] {b1}, profile, null, null).getSeverity(), IStatus.OK);
+ assertEquals(director.install(new IInstallableUnit[] {b1}, profile, null).getSeverity(), IStatus.OK);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
index e595615b0..70174635a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
@@ -8,10 +8,8 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import java.util.Collection;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.director.IDirector;
-import org.eclipse.equinox.p2.director.Oracle;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -68,11 +66,11 @@ public class OracleTest2 extends AbstractProvisioningTest {
}
- /*
- * TODO Currently this test throws ClassCastException
- */
- public void _testInstallA1() {
- assertEquals(director.install(new IInstallableUnit[] {a1}, profile, null, null).getSeverity(), IStatus.OK);
+ /* I'm not sure what this test should look like now
+ *
+
+ public void testInstallA1() {
+ assertEquals(director.install(new IInstallableUnit[] {a1}, profile, null).getSeverity(), IStatus.OK);
createTestMetdataRepository(new IInstallableUnit[] {a2, c2, b1});
Collection brokenEntryPoint = (Collection) new Oracle().canInstall(new IInstallableUnit[] {b1}, profile, null);
@@ -81,12 +79,13 @@ public class OracleTest2 extends AbstractProvisioningTest {
new Oracle().hasUpdate(a1);
System.out.println(new Oracle().canInstall(new IInstallableUnit[] {b1}, (IInstallableUnit[]) brokenEntryPoint.toArray(new IInstallableUnit[brokenEntryPoint.size()]), profile, null));
}
+ */
public void testInstallA1bis() {
profile = new Profile("testInstallA1bis." + getName());
director = createDirector();
createTestMetdataRepository(new IInstallableUnit[] {a1, a2, c1, c2, b1});
- assertEquals(director.install(new IInstallableUnit[] {a1}, profile, null, null).getSeverity(), IStatus.OK);
+ assertEquals(director.install(new IInstallableUnit[] {a1}, profile, null).getSeverity(), IStatus.OK);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
index 91cdd46eb..27efb8aed 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
@@ -40,7 +40,7 @@ public class RollbackTest extends AbstractProvisioningTest {
}
public void test() {
- System.out.println(director.install(new IInstallableUnit[] {a1}, profile, null, new NullProgressMonitor()));
+ System.out.println(director.install(new IInstallableUnit[] {a1}, profile, new NullProgressMonitor()));
printProfile(profile);
IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
IMetadataRepository repo = null;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java
index 1522e9baa..87f0f595e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java
@@ -66,16 +66,16 @@ public class SingletonTest extends AbstractProvisioningTest {
public void testMultipleVersionNonSingleton() {
//The installation of junit38 and junit 40 together should succeed
- assertEquals(director.install(new IInstallableUnit[] {junit38, junit40}, profile, null, new NullProgressMonitor()).getSeverity(), IStatus.OK);
+ assertEquals(director.install(new IInstallableUnit[] {junit38, junit40}, profile, new NullProgressMonitor()).getSeverity(), IStatus.OK);
}
public void testMultipleVersionSingleton() {
//The installation of junit38 and junit 40 together should succeed
- assertEquals(director.install(new IInstallableUnit[] {f1, f1_1}, profile, null, new NullProgressMonitor()).getSeverity(), IStatus.ERROR);
+ assertEquals(director.install(new IInstallableUnit[] {f1, f1_1}, profile, new NullProgressMonitor()).getSeverity(), IStatus.ERROR);
}
public void testMultipleVersionSingleton2() {
//The installation of junit38 and junit 40 together should succeed
- assertEquals(director.install(new IInstallableUnit[] {f2, f2_1}, profile, null, new NullProgressMonitor()).getSeverity(), IStatus.ERROR);
+ assertEquals(director.install(new IInstallableUnit[] {f2, f2_1}, profile, new NullProgressMonitor()).getSeverity(), IStatus.ERROR);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java
index 65efb55b7..0a844dc30 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java
@@ -31,7 +31,7 @@ public class UninstallTest extends AbstractProvisioningTest {
}
public void testUninstall() {
- System.out.println(director.install(new IInstallableUnit[] {a1}, profile, null, null));
+ System.out.println(director.install(new IInstallableUnit[] {a1}, profile, null));
director.uninstall(new IInstallableUnit[] {a1}, profile, null);
assertEmptyProfile(profile);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithoutEntryPoint.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
index 2bef12e17..84090be12 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithoutEntryPoint.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
@@ -19,7 +19,7 @@ import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.osgi.framework.Version;
-public class UpdateTestWithoutEntryPoint extends AbstractProvisioningTest {
+public class UpdateTest extends AbstractProvisioningTest {
InstallableUnit f1;
InstallableUnit f1_1;
InstallableUnit f1_4;
@@ -59,18 +59,18 @@ public class UpdateTestWithoutEntryPoint extends AbstractProvisioningTest {
profile = new Profile("TestProfile." + getName());
director = createDirector();
- director.install(new IInstallableUnit[] {fa}, profile, null, null);
+ director.install(new IInstallableUnit[] {fa}, profile, null);
createTestMetdataRepository(new IInstallableUnit[] {f1_1, f1_4});
}
public void testInstall() {
- assertEquals(director.install(new IInstallableUnit[] {f1_1}, profile, null, new NullProgressMonitor()).getSeverity(), IStatus.OK);
+ assertEquals(director.install(new IInstallableUnit[] {f1_1}, profile, new NullProgressMonitor()).getSeverity(), IStatus.OK);
for (Iterator iterator = profile.getInstallableUnits(); iterator.hasNext();) {
System.out.println(iterator.next());
}
- assertEquals(director.install(new IInstallableUnit[] {f1_4}, profile, null, new NullProgressMonitor()).getSeverity(), IStatus.ERROR);
+ assertEquals(director.install(new IInstallableUnit[] {f1_4}, profile, new NullProgressMonitor()).getSeverity(), IStatus.ERROR);
// director.replace(new IInstallableUnit[] {fap}, profile, new NullProgressMonitor());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithEntryPoint.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithEntryPoint.java
deleted file mode 100644
index 41319e31d..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTestWithEntryPoint.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * 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.equinox.p2.tests.director;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.p2.director.IDirector;
-import org.eclipse.equinox.p2.director.Oracle;
-import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-import org.osgi.framework.Version;
-
-public class UpdateTestWithEntryPoint extends AbstractProvisioningTest {
- InstallableUnit f1;
- InstallableUnit f1_1;
-
- IDirector director;
- Profile profile;
-
- protected void setUp() throws Exception {
- f1 = new InstallableUnit();
- f1.setId("f1");
- f1.setVersion(new Version(1, 0, 0));
- f1.setSingleton(true);
-
- f1_1 = new InstallableUnit();
- f1_1.setId("f1");
- f1_1.setVersion(new Version(1, 1, 0));
- f1_1.setSingleton(true);
- f1_1.setProperty(IInstallableUnitConstants.UPDATE_FROM, "f1");
- f1_1.setProperty(IInstallableUnitConstants.UPDATE_RANGE, "[1.0.0, 2.0.0)");
-
- profile = new Profile("TestProfile." + getName());
- director = createDirector();
- createTestMetdataRepository(new IInstallableUnit[] {f1_1, f1});
- }
-
- public void testInstall() {
- //TODO Currently this test is failing
- if (true)
- return;
-
- String entryPointName = "e1";
- assertEquals(director.install(new IInstallableUnit[] {f1}, profile, entryPointName, new NullProgressMonitor()).getSeverity(), IStatus.OK);
- for (Iterator iterator = profile.getInstallableUnits(); iterator.hasNext();) {
- System.out.println(iterator.next());
-
- }
-
- //TODO This should return an error because we are trying to update something that would cause the entry point to be unsatisfied
- //director.update(new IInstallableUnit[] {f1_1}, profile, new NullProgressMonitor());
-
- IInstallableUnit toReplace = get(entryPointName, profile);
- Collection updates = new Oracle().hasUpdate(toReplace);
-
- director.replace(new IInstallableUnit[] {toReplace}, (IInstallableUnit[]) updates.toArray(new IInstallableUnit[updates.size()]), profile, new NullProgressMonitor());
-
- //TODO Add a test to verify that we are not going down in the version
- //TODO Add a test to verify that we respect the ranges
-
- }
-
- private IInstallableUnit get(String id, Profile p) {
- Iterator it = profile.getInstallableUnits();
- while (it.hasNext()) {
- IInstallableUnit o = (IInstallableUnit) it.next();
- if (o.getId().equals(id))
- return o;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java
index 00ac1a06c..a3bcf38bf 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java
@@ -97,7 +97,7 @@ public class DirectorTest extends TestCase {
if (allJobs.size() != 0) {
allRoots[0] = (IInstallableUnit) allJobs.iterator().next();
if (!doUninstall) {
- operationStatus = director.install(allRoots, p, null, new NullProgressMonitor());
+ operationStatus = director.install(allRoots, p, new NullProgressMonitor());
} else {
operationStatus = director.uninstall(allRoots, p, new NullProgressMonitor());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
index 639d26c9a..e5c3cb354 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
@@ -13,11 +13,10 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.director.IDirector;
-import org.eclipse.equinox.p2.director.Oracle;
+import org.eclipse.equinox.p2.director.IPlanner;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -31,6 +30,7 @@ public class End2EndTest extends AbstractProvisioningTest {
private IMetadataRepository[] repos;
private IDirector director;
+ private IPlanner planner;
protected void setUp() throws Exception {
ServiceReference sr = TestActivator.context.getServiceReference(IDirector.class.getName());
@@ -38,6 +38,7 @@ public class End2EndTest extends AbstractProvisioningTest {
throw new RuntimeException("Director service not available");
}
director = createDirector();
+ planner = createPlanner();
ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName());
IMetadataRepositoryManager mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2);
if (mgr == null) {
@@ -82,91 +83,10 @@ public class End2EndTest extends AbstractProvisioningTest {
return profile1;
}
- private Collection extractIUs(Profile p) {
- Collection result = new HashSet();
- Iterator it = p.getInstallableUnits();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return result;
- }
-
- public void testInstallSDKWithEntryPoint() {
- Profile profile1 = createProfile("profile1");
- //First we install the sdk
- IStatus s = director.install(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, profile1, "entryPoint1", new NullProgressMonitor());
- assertOK(s);
- Collection iusInstalled = extractIUs(profile1);
- IInstallableUnit firstSnapshot = getIU("profile1"); //This should represent the empty profile
- assertNotNull(firstSnapshot);
- assertNotNull(firstSnapshot.getProperty("profileIU"));
- IInstallableUnit firstEntryPoint = null;
- try {
- firstEntryPoint = getIU(IInstallableUnitConstants.ENTRYPOINT_IU_KEY, "true")[0];
- } catch (ArrayIndexOutOfBoundsException e) {
- fail("We expect to find an entry point");
- }
-
- //The uninstallation should not work since there is an entyr point
- s = director.uninstall(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, profile1, new NullProgressMonitor());
- assertNotOK(s);
-
- //The uninstallation of the entry point should lead to an empty profile
- s = director.uninstall(new IInstallableUnit[] {firstEntryPoint}, profile1, new NullProgressMonitor());
- assertOK(s);
-
- assertEmptyProfile(profile1);
- IInstallableUnit[] snapshots = getIUs("profile1");
- assertEquals(2, snapshots.length);
- assertEquals(false, profile1.getIterator("sdk", VersionRange.emptyRange, null, false).hasNext());
-
- // Now test the rollback to a previous state, in this case we reinstall the SDK
- s = director.become(snapshots[0].equals(firstSnapshot) ? snapshots[1] : snapshots[0], profile1, new NullProgressMonitor());
- if (!s.isOK())
- fail("The become operation failed");
-
- assertNotNull(getIU("sdk"));
- assertEquals(firstEntryPoint, getIU(firstEntryPoint.getId()));
- Collection afterRollback = extractIUs(profile1);
-
- //Verify that the rollback brought back everything we had
- Collection iusInstalledCopy = new HashSet(iusInstalled);
- iusInstalled.removeAll(afterRollback);
- afterRollback.removeAll(iusInstalledCopy);
- assertEquals(0, iusInstalled.size());
- assertEquals(0, afterRollback.size());
-
- //Now update for the SDK itself
- Collection snapshotsBeforeUpdate = Arrays.asList(getIUs("profile1"));
- assertEquals(1, new Oracle().hasUpdate(getIU("sdk", new Version("3.3.0"))).size());
- s = director.replace(new IInstallableUnit[] {firstEntryPoint}, new IInstallableUnit[] {(IInstallableUnit) new Oracle().hasUpdate(getIU("sdk", new Version("3.3.0"))).iterator().next()}, profile1, new NullProgressMonitor());
- assertOK(s);
- assertProfileContainsAll("", profile1, new IInstallableUnit[] {getIU("sdk", new Version("3.4.0"))});
- Collection snapsshotsAfterUpdate = new ArrayList(Arrays.asList(getIUs("profile1")));
- snapsshotsAfterUpdate.removeAll(snapshotsBeforeUpdate);
- IInstallableUnit former = (IInstallableUnit) snapsshotsAfterUpdate.iterator().next();
-
- //Now come back to a 3.3 install
- s = director.become(former, profile1, new NullProgressMonitor());
- assertOK(s);
-
- //Test replace the sdk 3.3 entry point with 3.4
- assertEquals(1, new Oracle().hasUpdate(firstEntryPoint).size());
- s = director.replace(new IInstallableUnit[] {firstEntryPoint}, new IInstallableUnit[] {(IInstallableUnit) new Oracle().hasUpdate(firstEntryPoint).iterator().next()}, profile1, new NullProgressMonitor());
- assertOK(s);
- assertProfileContainsAll("", profile1, new IInstallableUnit[] {getIU("sdk", new Version("3.4.0"))});
- assertNotIUs(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, profile1.getInstallableUnits());
-
- //Remove everything from the profile by becoming an empty profile
- s = director.become(firstSnapshot, profile1, new NullProgressMonitor());
- assertOK(s);
- // assertEmptyProfile(profile1);
- }
-
public void testInstallSDK() {
Profile profile2 = createProfile("profile2");
//First we install the sdk
- IStatus s = director.install(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, profile2, null, new NullProgressMonitor());
+ IStatus s = director.install(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, profile2, new NullProgressMonitor());
if (!s.isOK())
fail("Installation failed");
IInstallableUnit firstSnapshot = getIU("profile2"); //This should represent the empty profile
@@ -191,7 +111,7 @@ public class End2EndTest extends AbstractProvisioningTest {
assertNotNull(getIU("sdk"));
//Test replace
- s = director.replace(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, new IInstallableUnit[] {getIU("sdk", new Version("3.4.0"))}, profile2, new NullProgressMonitor());
+ s = director.replace(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, planner.updatesFor(getIU("sdk", new Version("3.3.0"))), profile2, new NullProgressMonitor());
assertOK(s);
assertProfileContainsAll("", profile2, new IInstallableUnit[] {getIU("sdk", new Version("3.4.0"))});
assertNotIUs(new IInstallableUnit[] {getIU("sdk", new Version("3.3.0"))}, profile2.getInstallableUnits());
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/plugin.properties b/bundles/org.eclipse.equinox.p2.ui.admin/plugin.properties
index 422c4cd5d..92c0d0098 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/plugin.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/plugin.properties
@@ -22,4 +22,5 @@ Profiles.name=Profiles
Provisioning.title=Provisioning
Profile.name=Profile
IU.name=Installable Unit
+InstalledIU.name=IU Profile Properties
Repository.name=Repository \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/plugin.xml b/bundles/org.eclipse.equinox.p2.ui.admin/plugin.xml
index 579b97bf8..f5a5261db 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/plugin.xml
@@ -87,6 +87,17 @@
</or>
</enabledWhen>
</page>
+ <page
+ name="%InstalledIU.name"
+ class="org.eclipse.equinox.internal.p2.ui.admin.dialogs.InstalledIUPropertyPage"
+ id="org.eclipse.equinox.internal.p2.ui.admin.dialogs.InstalledIUPropertyPage">
+ <enabledWhen>
+ <instanceof
+ value="org.eclipse.equinox.p2.ui.model.InstalledIUElement">
+ </instanceof>
+ </enabledWhen>
+ </page>
+
<page
name="%Repository.name"
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
index abc9c10b7..066645797 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
@@ -15,8 +15,6 @@ import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddMetadataRepositoryDialog;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddProfileDialog;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.ui.IProfileChooser;
import org.eclipse.equinox.p2.ui.actions.BecomeAction;
@@ -27,7 +25,8 @@ import org.eclipse.equinox.p2.ui.viewers.IUDragAdapter;
import org.eclipse.equinox.p2.ui.viewers.ProvElementLabelProvider;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.widgets.Shell;
@@ -91,9 +90,8 @@ public class MetadataRepositoriesView extends RepositoriesView {
protected void makeActions() {
super.makeActions();
- installAction = new InstallAction(ProvAdminUIMessages.InstallIUCommandLabel, viewer, null, null, getProfileChooser(), getShell());
- installAction.setEntryPointStrategy(InstallAction.ENTRYPOINT_OPTIONAL);
- becomeAction = new BecomeAction(ProvAdminUIMessages.BecomeIUCommandLabel, viewer, null, null, getProfileChooser(), getShell());
+ installAction = new InstallAction(viewer, null, getProfileChooser(), getShell());
+ becomeAction = new BecomeAction(viewer, null, getProfileChooser(), getShell());
}
private IProfileChooser getProfileChooser() {
@@ -130,28 +128,6 @@ public class MetadataRepositoriesView extends RepositoriesView {
};
}
- protected void selectionChanged(IStructuredSelection selection) {
- super.selectionChanged(selection);
- if (selection.size() < 1) {
- installAction.setEnabled(false);
- becomeAction.setEnabled(false);
- }
- Object[] selectionArray = selection.toArray();
- if (selectionArray.length == 1 && selectionArray[0] instanceof IInstallableUnit) {
- IInstallableUnit iu = (IInstallableUnit) selectionArray[0];
- becomeAction.setEnabled(Boolean.valueOf(iu.getProperty(IInstallableUnitConstants.PROFILE_IU_KEY)).booleanValue());
- } else {
- becomeAction.setEnabled(false);
- }
- for (int i = 0; i < selectionArray.length; i++) {
- if (!(selectionArray[i] instanceof IInstallableUnit)) {
- installAction.setEnabled(false);
- return;
- }
- }
- installAction.setEnabled(true);
- }
-
protected void fillContextMenu(IMenuManager manager) {
if (installAction.isEnabled()) {
manager.add(new Separator());
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
index 24d7edf49..0a0a6aadb 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
@@ -13,29 +13,22 @@ package org.eclipse.equinox.internal.p2.ui.admin;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddProfileDialog;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.UpdateAndInstallDialog;
-import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.actions.*;
-import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
+import org.eclipse.equinox.p2.ui.actions.UninstallAction;
+import org.eclipse.equinox.p2.ui.actions.UpdateAction;
import org.eclipse.equinox.p2.ui.model.*;
-import org.eclipse.equinox.p2.ui.operations.*;
+import org.eclipse.equinox.p2.ui.operations.ProfileOperation;
+import org.eclipse.equinox.p2.ui.operations.RemoveProfilesOperation;
import org.eclipse.equinox.p2.ui.viewers.InstallIUDropAdapter;
import org.eclipse.equinox.p2.ui.viewers.StructuredViewerProvisioningListener;
import org.eclipse.jface.action.*;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
@@ -69,10 +62,9 @@ public class ProfilesView extends ProvView {
profilesOnly.add(element);
}
}
- IUndoableOperation op = new RemoveProfilesOperation(ProvAdminUIMessages.Ops_RemoveProfileOperationLabel, (Profile[]) profilesOnly.toArray(new Profile[profilesOnly.size()]));
+ ProfileOperation op = new RemoveProfilesOperation(ProvAdminUIMessages.Ops_RemoveProfileOperationLabel, (Profile[]) profilesOnly.toArray(new Profile[profilesOnly.size()]));
try {
- // TODO hook into platform progress service
- IStatus status = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, null, ProvUI.getUIInfoAdapter(ProfilesView.this.getShell()));
+ IStatus status = op.execute(null, ProvUI.getUIInfoAdapter(ProfilesView.this.getShell()));
if (status.isOK()) {
viewer.refresh();
}
@@ -97,8 +89,8 @@ public class ProfilesView extends ProvView {
private class InstallIntoProfileAction extends Action {
InstallIntoProfileAction() {
- setText(ProvAdminUIMessages.InstallIUCommandLabel);
- setToolTipText(ProvAdminUIMessages.InstallIUCommandTooltip);
+ setText(ProvUI.INSTALL_COMMAND_LABEL);
+ setToolTipText(ProvUI.INSTALL_COMMAND_TOOLTIP);
}
public void run() {
@@ -128,9 +120,8 @@ public class ProfilesView extends ProvView {
protected void configureViewer(TreeViewer treeViewer) {
super.configureViewer(treeViewer);
treeViewer.setInput(new AllProfiles());
- InstallIUDropAdapter adapter = new InstallIUDropAdapter(treeViewer, getOperationConfirmer());
+ InstallIUDropAdapter adapter = new InstallIUDropAdapter(treeViewer);
adapter.setFeedbackEnabled(false);
- adapter.setEntryPointStrategy(InstallAction.ENTRYPOINT_OPTIONAL);
Transfer[] transfers = new Transfer[] {org.eclipse.jface.util.LocalSelectionTransfer.getTransfer()};
treeViewer.addDropSupport(DND.DROP_COPY, transfers, adapter);
}
@@ -174,10 +165,8 @@ public class ProfilesView extends ProvView {
super.makeActions();
addProfileAction = new AddProfileAction();
removeProfileAction = new RemoveProfileAction();
- uninstallAction = new UninstallAction(ProvAdminUIMessages.UninstallIUCommandLabel, viewer, getOperationConfirmer(), null, getProfileChooser(), getShell());
- uninstallAction.setToolTipText(ProvAdminUIMessages.UninstallIUCommandTooltip);
- updateAction = new UpdateAction(ProvAdminUIMessages.UpdateIUCommandLabel, viewer, getOperationConfirmer(), null, getProfileChooser(), getShell());
- updateAction.setToolTipText(ProvAdminUIMessages.UpdateIUCommandTooltip);
+ uninstallAction = new UninstallAction(viewer, null, getProfileChooser(), getShell());
+ updateAction = new UpdateAction(viewer, null, getProfileChooser(), getShell());
propertiesAction = new PropertyDialogAction(this.getSite(), viewer);
installAction = new InstallIntoProfileAction();
@@ -196,52 +185,21 @@ public class ProfilesView extends ProvView {
protected void selectionChanged(IStructuredSelection ss) {
super.selectionChanged(ss);
if (ss.size() == 1) {
- propertiesAction.setEnabled(true);
if (ss.getFirstElement() instanceof Profile)
installAction.setEnabled(true);
else
installAction.setEnabled(false);
- } else {
- propertiesAction.setEnabled(false);
}
Object[] selectionArray = ss.toArray();
- Object parent = null;
if (selectionArray.length > 0) {
- uninstallAction.setEnabled(true);
- updateAction.setEnabled(true);
removeProfileAction.setEnabled(true);
-
for (int i = 0; i < selectionArray.length; i++) {
- if (selectionArray[i] instanceof InstalledIUElement) {
- InstalledIUElement element = (InstalledIUElement) selectionArray[i];
- if (parent == null) {
- parent = element.getParent(null);
- } else if (parent != element.getParent(null)) {
- uninstallAction.setEnabled(false);
- updateAction.setEnabled(false);
- break;
- }
- } else {
- uninstallAction.setEnabled(false);
- updateAction.setEnabled(false);
+ if (!(selectionArray[i] instanceof Profile)) {
+ removeProfileAction.setEnabled(false);
break;
}
}
- // If the selections weren't all IU's, see if they are all
- // profiles
- if (!uninstallAction.isEnabled()) {
- for (int i = 0; i < selectionArray.length; i++) {
- if (!(selectionArray[i] instanceof Profile)) {
- removeProfileAction.setEnabled(false);
- break;
- }
- }
- } else {
- removeProfileAction.setEnabled(false);
- }
} else {
- uninstallAction.setEnabled(false);
- updateAction.setEnabled(false);
removeProfileAction.setEnabled(false);
}
}
@@ -276,35 +234,4 @@ public class ProfilesView extends ProvView {
}
};
}
-
- private IOperationConfirmer getOperationConfirmer() {
- return new IOperationConfirmer() {
-
- public boolean continuePerformingOperation(ProvisioningOperation op, Shell shell) {
- String confirmMessage;
- if (op instanceof InstallOperation) {
- confirmMessage = NLS.bind(ProvAdminUIMessages.Ops_ConfirmIUInstall, ((InstallOperation) op).getProfileId());
- } else if (op instanceof UninstallOperation) {
- confirmMessage = ProvAdminUIMessages.ProfilesView_ConfirmUninstallMessage;
- } else {
- return true;
- }
- boolean proceed = true;
- IPreferenceStore store = ProvAdminUIActivator.getDefault().getPreferenceStore();
- if (store.getBoolean(PreferenceConstants.PREF_CONFIRM_SELECTION_INSTALL)) {
- MessageDialogWithToggle dlg = MessageDialogWithToggle.openYesNoCancelQuestion(shell, op.getLabel(), confirmMessage, ProvAdminUIMessages.ProfilesView_AlwaysConfirmSelectionInstallOps, true, null, null);
- int ret = dlg.getReturnCode();
- if (!(ret == Window.CANCEL || ret == -1)) { // return
- // code of -1 corresponds with ESC
- // even if no was pressed, we still want to store
- // the toggle state.
- store.setValue(PreferenceConstants.PREF_CONFIRM_SELECTION_INSTALL, dlg.getToggleState());
- }
- proceed = dlg.getReturnCode() == IDialogConstants.YES_ID;
- }
- return proceed;
- }
- };
- }
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIMessages.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIMessages.java
index f700e42f8..f05a6a005 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIMessages.java
@@ -42,33 +42,24 @@ public class ProvAdminUIMessages extends NLS {
public static String ArtifactRepositoriesView_RemoveRepositoryOperationLabel;
public static String ProfilesView_AddProfileTooltip;
public static String ProfilesView_AddProfileLabel;
- public static String ProfilesView_ConfirmUninstallMessage;
public static String ProfilesView_RemoveProfileLabel;
public static String ProfilesView_RemoveProfileTooltip;
// Preferences
public static String ProvisioningPrefPage_ConfirmSelectionInstallOps;
+ public static String InstalledIUPropertyPage_NoInfoAvailable;
public static String ProvisioningPrefPage_HideInternalRepos;
public static String ProvisioningPrefPage_ShowGroupsOnly;
public static String ProvisioningPrefPage_Description;
public static String Ops_RemoveProfileOperationLabel;
- public static String Ops_ConfirmIUInstall;
public static String AddProfileDialog_OperationLabel;
public static String AddProfileDialog_DuplicateProfileID;
public static String UpdateAndInstallDialog_AvailableIUsPageLabel;
public static String UpdateAndInstallDialog_InstalledIUsPageLabel;
+ public static String UpdateAndInstallDialog_Title;
- public static String Ops_InstallIUOperationLabel;
- public static String Ops_UninstallIUOperationLabel;
- public static String Ops_UpdateIUOperationLabel;
-
- public static String InstallIUCommandLabel;
- public static String BecomeIUCommandLabel;
- public static String InstallIUCommandTooltip;
- public static String UninstallIUCommandLabel;
- public static String UninstallIUCommandTooltip;
- public static String UpdateIUCommandLabel;
- public static String UpdateIUCommandTooltip;
public static String ProvView_RefreshCommandLabel;
public static String ProvView_RefreshCommandTooltip;
+
+ public static String ProfileRootPropertyName;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
index 5203a5d9e..d00aa9641 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
@@ -58,7 +58,7 @@ abstract class ProvView extends ViewPart {
viewer.getTree().setHeaderVisible(true);
viewer.setContentProvider(getContentProvider());
viewer.setInput(getInput());
- viewer.setLabelProvider(new ProvElementLabelProvider());
+ viewer.setLabelProvider(getLabelProvider());
viewer.setComparator(new ViewerComparator());
configureViewer(viewer);
addListeners();
@@ -217,4 +217,8 @@ abstract class ProvView extends ViewPart {
tc.setWidth(600);
tc.setResizable(true);
}
+
+ protected ILabelProvider getLabelProvider() {
+ return new ProvElementLabelProvider();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java
index 45ea4a529..83447c3ae 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.internal.p2.ui.admin.dialogs;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
@@ -20,12 +19,12 @@ import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
import org.eclipse.equinox.p2.ui.dialogs.ProfileGroup;
import org.eclipse.equinox.p2.ui.operations.AddProfileOperation;
+import org.eclipse.equinox.p2.ui.operations.ProfileOperation;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.PlatformUI;
/**
* Dialog that allows a profile to be defined and added.
@@ -77,10 +76,9 @@ public class AddProfileDialog extends StatusDialog {
if (addedProfile == null) {
return false;
}
- IUndoableOperation op = new AddProfileOperation(ProvAdminUIMessages.AddProfileDialog_OperationLabel, addedProfile);
+ ProfileOperation op = new AddProfileOperation(ProvAdminUIMessages.AddProfileDialog_OperationLabel, addedProfile);
try {
- // TODO hook into platform progress service
- PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, null, ProvUI.getUIInfoAdapter(getShell()));
+ op.execute(null, ProvUI.getUIInfoAdapter(getShell()));
} catch (ExecutionException e) {
ProvUI.handleException(e.getCause(), null);
return false;
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUProfilePropertiesGroup.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUProfilePropertiesGroup.java
new file mode 100644
index 000000000..d3884f072
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUProfilePropertiesGroup.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.equinox.internal.p2.ui.admin.dialogs;
+
+import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
+import org.eclipse.equinox.p2.ui.dialogs.IUGroup;
+import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * An IUPropertiesGroup is a reusable UI component that displays and edits the
+ * user-oriented properties of an IU. It can be used in
+ * different dialogs that manipulate or define IU's.
+ *
+ * @since 3.4
+ */
+public class IUProfilePropertiesGroup extends IUGroup {
+
+ private Table propertiesTable;
+
+ public IUProfilePropertiesGroup(final Composite parent, InstalledIUElement iuElement, ModifyListener listener) {
+ super(parent, iuElement, listener);
+ }
+
+ protected Composite createGroupComposite(Composite parent, ModifyListener listener) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ GridData data = new GridData();
+ data.widthHint = 400;
+ composite.setLayoutData(data);
+
+ propertiesTable = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessVerticalSpace = true;
+ propertiesTable.setLayoutData(data);
+ propertiesTable.setHeaderVisible(true);
+ TableColumn nameColumn = new TableColumn(propertiesTable, SWT.NONE);
+ nameColumn.setResizable(true);
+ nameColumn.setWidth(200);
+ TableColumn valueColumn = new TableColumn(propertiesTable, SWT.NONE);
+ valueColumn.setResizable(true);
+ valueColumn.setWidth(250);
+ initializeFields();
+ return composite;
+ }
+
+ private void initializeFields() {
+ if (iuElement == null || !(iuElement instanceof InstalledIUElement)) {
+ return;
+ }
+ String[] propNames = new String[] {IInstallableUnitConstants.PROFILE_ROOT_IU};
+ String[] userPropNames = new String[] {ProvAdminUIMessages.ProfileRootPropertyName};
+ for (int i = 0; i < propNames.length; i++) {
+ TableItem item = new TableItem(propertiesTable, SWT.NULL);
+ String value = ((InstalledIUElement) iuElement).getProfile().getInstallableUnitProfileProperty(getIU(), propNames[i]);
+ if (value != null)
+ item.setText(new String[] {userPropNames[i], value});
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/InstalledIUPropertyPage.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/InstalledIUPropertyPage.java
new file mode 100644
index 000000000..4a1fa07fc
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/InstalledIUPropertyPage.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.equinox.internal.p2.ui.admin.dialogs;
+
+import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
+import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * PropertyPage that shows an IU's properties
+ *
+ * @since 3.4
+ */
+public class InstalledIUPropertyPage extends PropertyPage {
+
+ private IUProfilePropertiesGroup iuGroup;
+
+ protected Control createContents(Composite parent) {
+ Object element = getElement();
+ if (!(element instanceof InstalledIUElement)) {
+ Label label = new Label(parent, SWT.DEFAULT);
+ label.setText(ProvAdminUIMessages.InstalledIUPropertyPage_NoInfoAvailable);
+ return label;
+ }
+ iuGroup = new IUProfilePropertiesGroup(parent, (InstalledIUElement) element, new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ // not editable
+ }
+ });
+ Dialog.applyDialogFont(iuGroup.getComposite());
+ return iuGroup.getComposite();
+ }
+
+ public boolean performOk() {
+ return true;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java
index d7e8bc2f5..b4c288c6c 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java
@@ -46,7 +46,7 @@ public class UpdateAndInstallDialog extends TrayDialog {
}
protected void configureShell(Shell shell) {
- shell.setText(ProvAdminUIMessages.Ops_InstallIUOperationLabel);
+ shell.setText(ProvAdminUIMessages.UpdateAndInstallDialog_Title);
super.configureShell(shell);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/messages.properties b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/messages.properties
index cfa8be90e..42eff327a 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/messages.properties
@@ -12,6 +12,7 @@
ProvisioningPrefPage_Description=Provisioning
ProvisioningPrefPage_ConfirmSelectionInstallOps=&Confirm install and uninstall operations
ProvisioningPrefPage_ShowGroupsOnly=Show only &group IU's
+InstalledIUPropertyPage_NoInfoAvailable=No profile-specific properties are available.
ProvisioningPrefPage_HideInternalRepos=Hide internal repositories in repository views
AddRepositoryDialog_InvalidURL=Invalid URL
AddProfileDialog_Title=Add Profile
@@ -35,20 +36,10 @@ ProfilesView_AddProfileLabel=Add a new profile
ProvView_RefreshCommandLabel=Refresh
ProfilesView_RemoveProfileLabel=Remove
ProfilesView_RemoveProfileTooltip=Remove the selected profiles
-ProfilesView_ConfirmUninstallMessage=Uninstall selected IU's?
AddProfileDialog_DuplicateProfileID=The profile ID is already in use.
Ops_RemoveProfileOperationLabel=Remove Profiles
-Ops_ConfirmIUInstall=Install selected IUs into {0}?
ProfilesView_AlwaysConfirmSelectionInstallOps=Always confirm install and uninstall operations
UpdateAndInstallDialog_InstalledIUsPageLabel=Installed IUs
UpdateAndInstallDialog_AvailableIUsPageLabel=Available IUs
-Ops_InstallIUOperationLabel=Install
-InstallIUCommandLabel=&Install...
-InstallIUCommandTooltip=Install the selected IUs
-BecomeIUCommandLabel=&Become...
-Ops_UninstallIUOperationLabel=Uninstall
-UninstallIUCommandLabel=&Uninstall...
-UninstallIUCommandTooltip=Uninstall the selected IUs
-Ops_UpdateIUOperationLabel=Update
-UpdateIUCommandLabel=Check for u&pdates...
-UpdateIUCommandTooltip=See if updates are available for the selected IUs
+UpdateAndInstallDialog_Title=Install/Update
+ProfileRootPropertyName=Profile Root
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/PreferenceConstants.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/PreferenceConstants.java
index 605b994d1..6d80dacf7 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/PreferenceConstants.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/PreferenceConstants.java
@@ -15,7 +15,6 @@ package org.eclipse.equinox.internal.p2.ui.admin.preferences;
*/
public class PreferenceConstants {
- public static final String PREF_CONFIRM_SELECTION_INSTALL = "org.eclipse.equinox.p2.ui.admin.confirmDragInstall"; //$NON-NLS-1$
public static final String PREF_SHOW_GROUPS_ONLY = "org.eclipse.equinox.p2.ui.admin.showGroupsOnly"; //$NON-NLS-1$
public static final String PREF_HIDE_IMPLEMENTATION_REPOS = "org.eclipse.equinox.p2.ui.admin.hideImplementationRepos"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvUIPreferenceInitializer.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvUIPreferenceInitializer.java
index 2f2e35a52..52748f29f 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvUIPreferenceInitializer.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvUIPreferenceInitializer.java
@@ -28,7 +28,6 @@ public class ProvUIPreferenceInitializer extends AbstractPreferenceInitializer {
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = ProvAdminUIActivator.getDefault().getPreferenceStore();
- store.setDefault(PreferenceConstants.PREF_CONFIRM_SELECTION_INSTALL, true);
store.setDefault(PreferenceConstants.PREF_SHOW_GROUPS_ONLY, true);
store.setDefault(PreferenceConstants.PREF_HIDE_IMPLEMENTATION_REPOS, true);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvisioningPrefPage.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvisioningPrefPage.java
index a19173222..77ed1660d 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvisioningPrefPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/preferences/ProvisioningPrefPage.java
@@ -36,7 +36,6 @@ public class ProvisioningPrefPage extends FieldEditorPreferencePage implements I
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
public void createFieldEditors() {
- addField(new BooleanFieldEditor(PreferenceConstants.PREF_CONFIRM_SELECTION_INSTALL, ProvAdminUIMessages.ProvisioningPrefPage_ConfirmSelectionInstallOps, getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.PREF_SHOW_GROUPS_ONLY, ProvAdminUIMessages.ProvisioningPrefPage_ShowGroupsOnly, getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.PREF_HIDE_IMPLEMENTATION_REPOS, ProvAdminUIMessages.ProvisioningPrefPage_HideInternalRepos, getFieldEditorParent()));
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java
index 79fdfd2e7..18a37db8f 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java
@@ -15,7 +15,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.ui.IRepositoryManipulator;
import org.eclipse.equinox.p2.ui.dialogs.UpdateAndInstallGroup;
import org.eclipse.equinox.p2.ui.viewers.IUGroupFilter;
-import org.eclipse.equinox.p2.ui.viewers.IUPropertyFilter;
+import org.eclipse.equinox.p2.ui.viewers.IUProfilePropertyFilter;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.resource.JFaceResources;
@@ -55,7 +55,7 @@ public class UpdateAndInstallDialog extends TrayDialog {
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
- ViewerFilter filter = new IUPropertyFilter(IInstallableUnitConstants.ENTRYPOINT_IU_KEY, Boolean.toString(true));
+ ViewerFilter filter = new IUProfilePropertyFilter(IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
UpdateAndInstallGroup group = new UpdateAndInstallGroup(parent, profile, new ViewerFilter[] {filter}, new ViewerFilter[] {new IUGroupFilter()}, ProvSDKMessages.UpdateAndInstallDialog_InstalledFeatures, ProvSDKMessages.UpdateAndInstallDialog_AvailableFeatures, getRepositoryManipulator(), null, TAB_WIDTH_IN_DLUS, TAB_HEIGHT_IN_DLUS, fontMetrics);
Dialog.applyDialogFont(group.getControl());
return group.getControl();
diff --git a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
index de5fac301..9c65d5451 100644
--- a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Import-Package: org.eclipse.equinox.configurator,
org.eclipse.equinox.p2.core.repository,
org.eclipse.equinox.p2.director,
org.eclipse.equinox.p2.engine,
+ org.eclipse.equinox.p2.engine.phases,
org.eclipse.equinox.p2.metadata,
org.eclipse.equinox.p2.metadata.repository,
org.eclipse.equinox.p2.query,
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java
new file mode 100644
index 000000000..41e108f56
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.equinox.internal.p2.ui;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.engine.phases.SizingPhase;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.ProvisioningUtil;
+import org.eclipse.equinox.p2.ui.model.AvailableIUElement;
+import org.eclipse.equinox.p2.ui.operations.InstallOperation;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
+import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
+import org.eclipse.swt.widgets.Shell;
+
+public class InstallDialog extends ProfileModificationDialog {
+
+ public InstallDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile) {
+ super(parentShell, ius, profile, ProvUIMessages.InstallIUOperationLabel, ProvUIMessages.InstallDialog_InstallSelectionMessage);
+ }
+
+ protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor, IAdaptable uiInfo) {
+ try {
+ IInstallableUnit[] selectedIUs = elementsToIUs(selectedElements);
+ ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(selectedIUs, profile, monitor, uiInfo);
+ IStatus status = plan.getStatus();
+ if (status.isOK())
+ return new InstallOperation(ProvUIMessages.InstallIUOperationLabel, profile.getProfileId(), plan, selectedIUs);
+ ProvUI.reportStatus(status);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
+ return null;
+ }
+
+ protected String getOkButtonString() {
+ return ProvUIMessages.InstallIUOperationLabel;
+ }
+
+ protected IUColumnConfig[] getColumnConfig() {
+ return new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_ID), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION), new IUColumnConfig(ProvUIMessages.ProvUI_SizeColumnTitle, IUColumnConfig.COLUMN_SIZE)};
+ }
+
+ protected long getSize(IInstallableUnit iu) {
+ long size;
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(new IInstallableUnit[] {iu}, profile, new NullProgressMonitor(), ProvUI.getUIInfoAdapter(getShell()));
+ SizingPhase info = ProvisioningUtil.getSizeInfo(plan, profile, new NullProgressMonitor(), ProvUI.getUIInfoAdapter(getShell()));
+ size = info.getDlSize();
+ } catch (ProvisionException e) {
+ size = AvailableIUElement.SIZE_UNKNOWN;
+ }
+ return size;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java
new file mode 100644
index 000000000..2b9147d77
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * 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.equinox.internal.p2.ui;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.model.AvailableIUElement;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
+import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
+import org.eclipse.equinox.p2.ui.viewers.IUDetailsLabelProvider;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+abstract class ProfileModificationDialog extends TrayDialog {
+ private static final int DEFAULT_HEIGHT = 250;
+ private static final int DEFAULT_WIDTH = 600;
+ private static final int DEFAULT_COLUMN_WIDTH = 200;
+ private String title;
+ private String message;
+ private IInstallableUnit[] ius;
+ Profile profile;
+ CheckboxTableViewer listViewer;
+ StaticContentProvider contentProvider;
+ private ProfileModificationOperation resultOperation;
+
+ ProfileModificationDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile, String title, String message) {
+ super(parentShell);
+ this.title = title;
+ this.message = message;
+ this.ius = ius;
+ this.profile = profile;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ initializeDialogUnits(composite);
+
+ // Create message area;
+ Label label = new Label(composite, SWT.NONE);
+ if (message != null) {
+ label.setText(message);
+ }
+ listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.FULL_SELECTION);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = DEFAULT_HEIGHT;
+ data.widthHint = DEFAULT_WIDTH;
+ Table table = listViewer.getTable();
+ table.setLayoutData(data);
+ table.setHeaderVisible(true);
+ IUColumnConfig[] columns = getColumnConfig();
+ for (int i = 0; i < columns.length; i++) {
+ TableColumn tc = new TableColumn(table, SWT.LEFT, i);
+ tc.setWidth(DEFAULT_COLUMN_WIDTH);
+ tc.setResizable(true);
+ tc.setText(columns[i].columnTitle);
+ tc.setWidth(convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH));
+ }
+ contentProvider = new StaticContentProvider(makeElements(ius));
+ listViewer.setContentProvider(contentProvider);
+ listViewer.setInput(new Object());
+ listViewer.setLabelProvider(new IUDetailsLabelProvider(getColumnConfig()));
+ listViewer.setAllChecked(true);
+
+ addSelectionButtons(composite);
+ Dialog.applyDialogFont(composite);
+ return composite;
+ }
+
+ protected AvailableIUElement[] makeElements(IInstallableUnit[] iusToShow) {
+ AvailableIUElement[] elements = new AvailableIUElement[iusToShow.length];
+ for (int i = 0; i < iusToShow.length; i++) {
+ elements[i] = new AvailableIUElement(iusToShow[i], getSize(iusToShow[i]));
+ }
+ return elements;
+ }
+
+ /*
+ * (non-Javadoc) Method declared in Window.
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ if (title != null) {
+ shell.setText(title);
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, getOkButtonString(), true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /**
+ * Add the selection and deselection buttons to the dialog.
+ * @param composite org.eclipse.swt.widgets.Composite
+ */
+ private void addSelectionButtons(Composite composite) {
+ Composite buttonComposite = new Composite(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 0;
+ layout.marginWidth = 0;
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false));
+
+ Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, ProvUIMessages.UpdateAndInstallSelectionDialog_SelectAllLabel, false);
+
+ SelectionListener listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ listViewer.setAllChecked(true);
+ }
+ };
+ selectButton.addSelectionListener(listener);
+
+ Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, ProvUIMessages.UpdateAndInstallSelectionDialog_DeselectAllLabel, false);
+
+ listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ listViewer.setAllChecked(false);
+ }
+ };
+ deselectButton.addSelectionListener(listener);
+ }
+
+ protected void okPressed() {
+ resultOperation = null;
+ // TODO may need progress monitor
+ IProgressMonitor monitor = new NullProgressMonitor();
+ resultOperation = createProfileModificationOperation(getSelectedElements(), monitor, ProvUI.getUIInfoAdapter(getShell()));
+ super.okPressed();
+ }
+
+ public ProfileModificationOperation getOperation() {
+ return resultOperation;
+ }
+
+ private Object[] getSelectedElements() {
+ return listViewer.getCheckedElements();
+ }
+
+ protected IInstallableUnit[] elementsToIUs(Object[] elements) {
+ IInstallableUnit[] theIUs = new IInstallableUnit[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ theIUs[i] = (IInstallableUnit) ((IAdaptable) elements[i]).getAdapter(IInstallableUnit.class);
+ }
+ return theIUs;
+ }
+
+ protected abstract ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor, IAdaptable uiInfo);
+
+ protected abstract String getOkButtonString();
+
+ protected IUColumnConfig[] getColumnConfig() {
+ return ProvUI.getIUColumnConfig();
+ }
+
+ protected long getSize(IInstallableUnit iu) {
+ return AvailableIUElement.SIZE_UNKNOWN;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
index 56d4beb8f..83b88af23 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
@@ -32,27 +32,24 @@ public class ProvUIMessages extends NLS {
public static String ColocatedRepositoryManipulatorGroup_LocationColumnHeader;
public static String ColocatedRepositoryManipulatorGroup_NameColumnHeader;
public static String ColocatedRepositoryManipulatorGroup_Remove;
- public static String InstallAction_EntryPointNameRequired;
- public static String InstallAction_InstallConfirmTitle;
- public static String InstallAction_InstallInfoTitle;
- public static String InstallAction_InstallNotPermitted;
- public static String InstallAction_NameEntryPointMessage;
- public static String InstallOperation_CannotInstall;
+ public static String InstallDialog_InstallSelectionMessage;
public static String IUPropertiesGroup_CopyrightProperty;
public static String IUPropertiesGroup_DescriptionProperty;
public static String IUPropertiesGroup_LicenseProperty;
+ public static String IUDetailsLabelProvider_Unknown;
public static String IUPropertiesGroup_NameProperty;
public static String IUPropertiesGroup_ProviderProperty;
public static String ProfileGroup_Cache;
public static String ProfileGroup_SelectBundlePoolCache;
+ public static String ProvisioningUtil_InstallProgressName;
// utility error messages
public static String ProvisioningUtil_NoRepositoryManager;
public static String ProvisioningUtil_AddRepositoryFailure;
public static String ProvisioningUtil_RepoNotWritable;
public static String ProvisioningUtil_RepositoryNotFound;
public static String ProvisioningUtil_NoProfileRegistryFound;
- public static String ProvisioningUtil_NoDirectorFound;
- public static String ProvisioningUtil_NoOracleFound;
+ public static String ProvisioningUtil_NoPlannerFound;
+ public static String ProvisioningUtil_NoEngineFound;
public static String ProvisioningUtil_NoIUFound;
public static String ProvisioningUtil_NoInstallRegistryFound;
public static String ProvisioningUtil_NoProfileInstallRegistryFound;
@@ -67,10 +64,19 @@ public class ProvUIMessages extends NLS {
public static String ProvisioningOperation_ExecuteErrorTitle;
public static String ProvisioningOperation_RedoErrorTitle;
public static String ProvisioningOperation_UndoErrorTitle;
- public static String Ops_InstallIUOperationLabel;
- public static String Ops_UninstallIUOperationLabel;
- public static String Ops_UpdateIUOperationLabel;
- public static String Ops_BecomeIUOperationLabel;
+ public static String InstallIUOperationLabel;
+ public static String InstallIUCommandLabel;
+ public static String InstallIUCommandTooltip;
+ public static String UninstallDialog_UninstallMessage;
+ public static String UninstallIUOperationLabel;
+ public static String UninstallIUCommandLabel;
+ public static String UninstallIUCommandTooltip;
+ public static String UpdateIUOperationLabel;
+ public static String UpdateIUCommandLabel;
+ public static String UpdateIUCommandTooltip;
+ public static String BecomeIUOperationLabel;
+ public static String BecomeIUCommandLabel;
+ public static String BecomeIUCommandTooltip;
// Property pages
public static String ProfilePropertyPage_NoProfileSelected;
@@ -115,16 +121,16 @@ public class ProvUIMessages extends NLS {
public static String UpdateAction_UpdatesAvailableTitle;
public static String PlatformUpdateTitle;
public static String PlatformRestartMessage;
+ public static String ProvUI_NameColumnTitle;
+ public static String ProvUI_SizeColumnTitle;
+ public static String ProvUI_VersionColumnTitle;
public static String OptionalPlatformRestartMessage;
// Operations
- public static String UpdateAndInstallGroup_Install;
public static String UpdateAndInstallGroup_Properties;
+ public static String UpdateAndInstallSelectionDialog_DeselectAllLabel;
+ public static String UpdateAndInstallSelectionDialog_SelectAllLabel;
public static String UpdateAndInstallGroup_Refresh;
- public static String UpdateAndInstallGroup_Uninstall;
- public static String UpdateAndInstallGroup_Update;
public static String UpdateOperation_NothingToUpdate;
- // TODO
- public final static String IUDetailsLabelProvider_Unknown = "FIXME";
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java
new file mode 100644
index 000000000..c570cb9e8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.equinox.internal.p2.ui;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.ProvisioningUtil;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
+import org.eclipse.swt.widgets.Shell;
+
+public class UninstallDialog extends ProfileModificationDialog {
+
+ public UninstallDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile) {
+ super(parentShell, ius, profile, ProvUIMessages.UninstallIUOperationLabel, ProvUIMessages.UninstallDialog_UninstallMessage);
+ }
+
+ protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor, IAdaptable uiInfo) {
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getUninstallPlan(elementsToIUs(selectedElements), profile, monitor, uiInfo);
+ IStatus status = plan.getStatus();
+ if (status.isOK())
+ return new ProfileModificationOperation(ProvUIMessages.UninstallIUOperationLabel, profile.getProfileId(), plan);
+ ProvUI.reportStatus(status);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
+ return null;
+ }
+
+ protected String getOkButtonString() {
+ return ProvUIMessages.UninstallIUOperationLabel;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java
new file mode 100644
index 000000000..fcadb817b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.equinox.internal.p2.ui;
+
+import java.util.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.engine.phases.SizingPhase;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.ProvisioningUtil;
+import org.eclipse.equinox.p2.ui.model.AvailableIUElement;
+import org.eclipse.equinox.p2.ui.model.AvailableUpdateElement;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
+import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
+import org.eclipse.swt.widgets.Shell;
+
+public class UpdateDialog extends ProfileModificationDialog {
+
+ public UpdateDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile) {
+ super(parentShell, ius, profile, ProvUIMessages.UpdateAction_UpdatesAvailableTitle, ProvUIMessages.UpdateAction_UpdatesAvailableMessage);
+ }
+
+ protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor, IAdaptable uiInfo) {
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getReplacePlan(getIUsToReplace(selectedElements), elementsToIUs(selectedElements), profile, monitor, uiInfo);
+ IStatus status = plan.getStatus();
+ if (status.isOK())
+ return new ProfileModificationOperation(ProvUIMessages.UpdateIUOperationLabel, profile.getProfileId(), plan);
+ ProvUI.reportStatus(status);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
+ return null;
+ }
+
+ protected String getOkButtonString() {
+ return ProvUIMessages.UpdateIUOperationLabel;
+ }
+
+ protected IUColumnConfig[] getColumnConfig() {
+ return new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_ID), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION), new IUColumnConfig(ProvUIMessages.ProvUI_SizeColumnTitle, IUColumnConfig.COLUMN_SIZE)};
+ }
+
+ protected AvailableIUElement[] makeElements(IInstallableUnit[] ius) {
+ List elements = new ArrayList();
+ for (int i = 0; i < ius.length; i++) {
+ try {
+ IInstallableUnit[] replacementIUs = ProvisioningUtil.updatesFor(new IInstallableUnit[] {ius[i]}, profile, null, ProvUI.getUIInfoAdapter(getShell()));
+ for (int j = 0; j < replacementIUs.length; j++) {
+ elements.add(new AvailableUpdateElement(replacementIUs[j], getSize(ius[i], replacementIUs[j]), ius[i]));
+ }
+ } catch (ProvisionException e) {
+ break;
+ }
+ }
+ return (AvailableIUElement[]) elements.toArray(new AvailableIUElement[elements.size()]);
+ }
+
+ private IInstallableUnit[] getIUsToReplace(Object[] replacementElements) {
+ Set iusToReplace = new HashSet();
+ for (int i = 0; i < replacementElements.length; i++) {
+ if (replacementElements[i] instanceof AvailableUpdateElement) {
+ iusToReplace.add(((AvailableUpdateElement) replacementElements[i]).getIUToBeUpdated());
+ }
+ }
+ return (IInstallableUnit[]) iusToReplace.toArray(new IInstallableUnit[iusToReplace.size()]);
+ }
+
+ protected long getSize(IInstallableUnit iuToRemove, IInstallableUnit iuToAdd) {
+ long size;
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getReplacePlan(new IInstallableUnit[] {iuToRemove}, new IInstallableUnit[] {iuToAdd}, profile, new NullProgressMonitor(), ProvUI.getUIInfoAdapter(getShell()));
+ SizingPhase info = ProvisioningUtil.getSizeInfo(plan, profile, new NullProgressMonitor(), ProvUI.getUIInfoAdapter(getShell()));
+ size = info.getDlSize();
+ } catch (ProvisionException e) {
+ size = AvailableIUElement.SIZE_UNKNOWN;
+ }
+ return size;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
index 80932b4a2..d9cf5e1dc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
@@ -9,13 +9,14 @@
# IBM Corporation - initial API and implementation
###############################################################################
+ProvisioningUtil_InstallProgressName=Installing...
ProvisioningUtil_NoRepositoryManager=No repository manager was found
ProvisioningUtil_AddRepositoryFailure=Unable to add repository {0}
ProvisioningUtil_RepositoryNotFound=Could not find repository {0}
ProvisioningUtil_RepoNotWritable=Repository is not writable
ProvisioningUtil_NoProfileRegistryFound=No profile registry was found
-ProvisioningUtil_NoDirectorFound=No director was found
-ProvisioningUtil_NoOracleFound=No oracle was found
+ProvisioningUtil_NoPlannerFound=No provisioning planner was found
+ProvisioningUtil_NoEngineFound=No provisioning engine was found
ProvisioningUtil_NoIUFound=Could not find installable unit {0}:{1}
ProvisioningUtil_NoInstallRegistryFound=No install registry was found
ProvisioningUtil_NoProfileInstallRegistryFound=No profile install registry was found
@@ -24,10 +25,19 @@ ProvisioningUtil_RepositoriesSearched=The following repositories were searched:
ProvisioningOperation_ExecuteErrorTitle=Error while executing the "{0}" operation
ProvisioningOperation_RedoErrorTitle=Error while redoing the "{0}" operation
ProvisioningOperation_UndoErrorTitle=Error while undoing the "{0}" operation
-Ops_InstallIUOperationLabel=Install
-Ops_UninstallIUOperationLabel=Uninstall
-Ops_UpdateIUOperationLabel=Update
-Ops_BecomeIUOperationLabel=Become
+InstallIUOperationLabel=Install
+InstallIUCommandLabel=&Install...
+InstallIUCommandTooltip=Install the selected items
+UninstallDialog_UninstallMessage=The following items will be uninstalled.
+UninstallIUOperationLabel=Uninstall
+UninstallIUCommandLabel=&Uninstall...
+UninstallIUCommandTooltip=Uninstall the selected items
+UpdateIUOperationLabel=Update
+UpdateIUCommandLabel=&Check for updates...
+UpdateIUCommandTooltip=See if updates are available for the selected items
+BecomeIUOperationLabel=Rollback
+BecomeIUCommandLabel=&Rollback...
+BecomeIUCommandTooltip=Roll back to a previously installed configuration
ProvDropAdapter_NoIUsToDrop=No IUs were available to be dropped
ProvDropAdapter_InvalidDropTarget=Invalid drop target
@@ -35,6 +45,7 @@ ProvDropAdapter_UnsupportedDropOperation=Unsupported drop operation
ProfilePropertyPage_NoProfileSelected=There was no profile selected
IUPropertyPage_NoIUSelected=There was no IU selected
+IUDetailsLabelProvider_Unknown=Unknown
IUPropertiesGroup_NameProperty=Name
IUPropertiesGroup_ProviderProperty=Provider
IUPropertiesGroup_LicenseProperty=License
@@ -76,21 +87,15 @@ AddRepositoryDialog_DuplicateURL=Duplicate URL
UpdateAndInstallGroup_Properties=Properties...
+UpdateAndInstallSelectionDialog_DeselectAllLabel=&Deselect All
+UpdateAndInstallSelectionDialog_SelectAllLabel=&Select All
UpdateAction_UpdateInformationTitle=Update Information
-UpdateAction_UpdatesAvailableMessage=Updates are available for the following items. Select the items you wish to update.
+UpdateAction_UpdatesAvailableMessage=Select the updates you wish to install.
UpdateAction_UpdatesAvailableTitle=Available Updates
-UpdateAndInstallGroup_Uninstall=Uninstall...
UpdateOperation_NothingToUpdate=There is nothing to update.
-UpdateAndInstallGroup_Install=Install...
UpdateAndInstallGroup_Refresh=Refresh
-UpdateAndInstallGroup_Update=Check for updates...
ChooseProfileDialog_DefaultDialogTitle=Select a profile
-InstallOperation_CannotInstall=The specified IU's cannot be installed.
-InstallAction_InstallInfoTitle=Install Information
-InstallAction_InstallNotPermitted=The install is not valid for the current configuration. (And I can't explain further given the current API).
-InstallAction_InstallConfirmTitle=Confirm Install
-InstallAction_NameEntryPointMessage=Enter a name for the installed software.
-InstallAction_EntryPointNameRequired=A name must be supplied.
+InstallDialog_InstallSelectionMessage=Select the items you wish to install.
AddColocatedRepositoryDialog_InvalidURL=The URL is not valid.
ColocatedRepositoryManipulatorGroup_Add=Add...
ColocatedRepositoryManipulatorGroup_Remove=Remove
@@ -102,6 +107,9 @@ IUPropertiesGroup_CopyrightProperty=Copyright
PlatformUpdateTitle = Software Updates
PlatformRestartMessage = You will need to restart the system for the changes to take effect. \
Would you like to restart now?
+ProvUI_NameColumnTitle=Name
+ProvUI_SizeColumnTitle=Download Size
+ProvUI_VersionColumnTitle=Version
OptionalPlatformRestartMessage = It is recommended you restart the system for the changes to take effect, \
but it may be possible to apply the changes you have made without restarting. \
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java
index b3bcb8c0e..cb576ea16 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java
@@ -12,7 +12,8 @@
package org.eclipse.equinox.p2.ui;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.ui.viewers.IUDetailsLabelProvider;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
@@ -26,7 +27,17 @@ import org.eclipse.ui.statushandlers.StatusManager;
*/
public class ProvUI {
- private static int[] iuColumnConfig = new int[] {IUDetailsLabelProvider.COLUMN_ID, IUDetailsLabelProvider.COLUMN_VERSION};
+ // Public constants for common command and tooltip names
+ public static final String INSTALL_COMMAND_LABEL = ProvUIMessages.InstallIUCommandLabel;
+ public static final String INSTALL_COMMAND_TOOLTIP = ProvUIMessages.InstallIUCommandTooltip;
+ public static final String UNINSTALL_COMMAND_LABEL = ProvUIMessages.UninstallIUCommandLabel;
+ public static final String UNINSTALL_COMMAND_TOOLTIP = ProvUIMessages.UninstallIUCommandTooltip;
+ public static final String UPDATE_COMMAND_LABEL = ProvUIMessages.UpdateIUCommandLabel;
+ public static final String UPDATE_COMMAND_TOOLTIP = ProvUIMessages.UpdateIUCommandTooltip;
+ public static final String ROLLBACK_COMMAND_LABEL = ProvUIMessages.BecomeIUCommandLabel;
+ public static final String ROLLBACK_COMMAND_TOOLTIP = ProvUIMessages.BecomeIUCommandTooltip;
+
+ private static IUColumnConfig[] iuColumnConfig = new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_ID), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION)};
/**
* Make an <code>IAdaptable</code> that adapts to the specified shell,
@@ -86,11 +97,11 @@ public class ProvUI {
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
}
- public static int[] getIUDetailsColumns() {
+ public static IUColumnConfig[] getIUColumnConfig() {
return iuColumnConfig;
}
- public static void setIUDetailsColumns(int[] columnConfig) {
+ public static void setIUColumnConfig(IUColumnConfig[] columnConfig) {
iuColumnConfig = columnConfig;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUtil.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUtil.java
index 7bcab9d89..b5c7f2c20 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUtil.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUtil.java
@@ -13,7 +13,8 @@ package org.eclipse.equinox.p2.ui;
import java.io.IOException;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.configurator.Configurator;
import org.eclipse.equinox.internal.p2.ui.ApplyProfileChangesDialog;
@@ -23,11 +24,12 @@ import org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.director.IDirector;
-import org.eclipse.equinox.p2.director.Oracle;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.director.IPlanner;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.phases.SizingPhase;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.query.CompoundIterator;
@@ -43,6 +45,19 @@ import org.eclipse.ui.PlatformUI;
* @since 3.4
*/
public class ProvisioningUtil {
+
+ private static final class SizingPhaseSet extends PhaseSet {
+ static SizingPhase sizingPhase;
+
+ SizingPhaseSet() {
+ super(new Phase[] {sizingPhase = new SizingPhase(100, "Compute sizes")}); //$NON-NLS-1$
+ }
+
+ SizingPhase getSizingPhase() {
+ return sizingPhase;
+ }
+ }
+
public static IMetadataRepository addMetadataRepository(URL location, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null)
@@ -220,19 +235,22 @@ public class ProvisioningUtil {
}
/*
- * See if the specified IU's can be installed in the profile
+ * Get the plan for the specified install operation
*/
- public static boolean canInstall(IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ public static ProvisioningPlan getInstallPlan(IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
Assert.isNotNull(profile);
Assert.isNotNull(toInstall);
+ return getPlanner().getInstallPlan(toInstall, profile, monitor);
+ }
- // TODO should I be getting an Oracle from a service helper?
- // Oracle oracle = (Oracle) ServiceHelper.getService(ProvUIActivator.getContext(), Oracle.class.getName());
- Oracle oracle = new Oracle();
- if (oracle == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoOracleFound);
- }
- return oracle.canInstall(toInstall, profile, monitor).equals(Boolean.TRUE);
+ /*
+ * Get the plan for the specified update operation
+ */
+ public static ProvisioningPlan getReplacePlan(IInstallableUnit[] toUninstall, IInstallableUnit[] replacements, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ Assert.isNotNull(profile);
+ Assert.isNotNull(toUninstall);
+ Assert.isNotNull(replacements);
+ return getPlanner().getReplacePlan(toUninstall, replacements, profile, monitor);
}
/*
@@ -240,91 +258,56 @@ public class ProvisioningUtil {
* Useful when checking for updates and letting the user decide
* which IU's to update.
*/
- public static Collection updatesFor(IInstallableUnit toUpdate, IProgressMonitor monitor) throws ProvisionException {
+ public static IInstallableUnit[] updatesFor(IInstallableUnit toUpdate, IProgressMonitor monitor) throws ProvisionException {
Assert.isNotNull(toUpdate);
-
- // TODO should I be getting an Oracle from a service helper?
- // Oracle oracle = (Oracle) ServiceHelper.getService(ProvUIActivator.getContext(), Oracle.class.getName());
- Oracle oracle = new Oracle();
- if (oracle == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoOracleFound);
- }
- return oracle.hasUpdate(toUpdate);
+ return getPlanner().updatesFor(toUpdate);
}
/*
* See what updates might be available for the specified IU's.
- * Useful for bulk update that can be directly passed to the update helper.
+ * Useful for bulk update that can be directly passed to the engine.
*/
public static IInstallableUnit[] updatesFor(IInstallableUnit[] toUpdate, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
Assert.isNotNull(profile);
Assert.isNotNull(toUpdate);
- // TODO should I be getting an Oracle from a service helper?
- // Oracle oracle = (Oracle) ServiceHelper.getService(ProvUIActivator.getContext(), Oracle.class.getName());
- Oracle oracle = new Oracle();
- if (oracle == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoOracleFound);
- }
+ IPlanner planner = getPlanner();
ArrayList allUpdates = new ArrayList();
for (int i = 0; i < toUpdate.length; i++) {
- allUpdates.addAll(oracle.hasUpdate(toUpdate[i]));
+ IInstallableUnit[] updates = planner.updatesFor(toUpdate[i]);
+ for (int j = 0; j < updates.length; j++)
+ allUpdates.add(updates[j]);
}
return (IInstallableUnit[]) allUpdates.toArray(new IInstallableUnit[allUpdates.size()]);
}
/*
- * Install the specified IU's
+ * Get a plan for becoming
*/
- public static IStatus install(IInstallableUnit[] toInstall, String entryPointName, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- Assert.isNotNull(profile);
- Assert.isNotNull(toInstall);
-
- IDirector director = (IDirector) ServiceHelper.getService(ProvUIActivator.getContext(), IDirector.class.getName());
- if (director == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoDirectorFound);
- }
- return director.install(toInstall, profile, entryPointName, monitor);
- }
-
- public static IStatus become(IInstallableUnit toBecome, Profile profile, IProgressMonitor monitor) throws ProvisionException {
+ public static ProvisioningPlan getBecomePlan(IInstallableUnit toBecome, Profile profile, IProgressMonitor monitor) throws ProvisionException {
Assert.isNotNull(profile);
Assert.isNotNull(toBecome);
-
- IDirector director = (IDirector) ServiceHelper.getService(ProvUIActivator.getContext(), IDirector.class.getName());
- if (director == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoDirectorFound);
- }
- return director.become(toBecome, profile, monitor);
+ return getPlanner().getBecomePlan(toBecome, profile, monitor);
}
/*
- * Uninstall the specified IU's
+ * Get the plan to uninstall the specified IU's
*/
- public static IStatus uninstall(IInstallableUnit[] toUninstall, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ public static ProvisioningPlan getUninstallPlan(IInstallableUnit[] toUninstall, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
Assert.isNotNull(profile);
Assert.isNotNull(toUninstall);
-
- IDirector director = (IDirector) ServiceHelper.getService(ProvUIActivator.getContext(), IDirector.class.getName());
- if (director == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoDirectorFound);
- }
- return director.uninstall(toUninstall, profile, monitor);
+ return getPlanner().getUninstallPlan(toUninstall, profile, monitor);
}
/*
- * Uninstall the specified IU's
+ * Get sizing info for the specified IU's
*/
- public static IStatus update(IInstallableUnit[] toUninstall, IInstallableUnit[] replacements, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- Assert.isNotNull(profile);
- Assert.isNotNull(toUninstall);
- Assert.isNotNull(replacements);
-
- IDirector director = (IDirector) ServiceHelper.getService(ProvUIActivator.getContext(), IDirector.class.getName());
- if (director == null) {
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoDirectorFound);
- }
- return director.replace(toUninstall, replacements, profile, monitor);
+ public static SizingPhase getSizeInfo(ProvisioningPlan plan, Profile profile, IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ SizingPhaseSet set = new SizingPhaseSet();
+ IStatus status = getEngine().perform(profile, set, plan.getOperands(), monitor);
+ if (status.isOK())
+ return set.getSizingPhase();
+ return null;
}
// TODO This method is only in the util class so that I can generate an
@@ -354,7 +337,37 @@ public class ProvisioningUtil {
}
}
+ public static IStatus performInstall(ProvisioningPlan plan, Profile profile, IInstallableUnit[] installRoots, IProgressMonitor monitor) throws ProvisionException {
+ IStatus engineResult = performProvisioningPlan(plan, profile, monitor);
+ if (engineResult.isOK()) {
+ // mark the roots as such
+ for (int i = 0; i < installRoots.length; i++)
+ profile.setInstallableUnitProfileProperty(installRoots[i], IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
+ }
+ return engineResult;
+ }
+
+ public static IStatus performProvisioningPlan(ProvisioningPlan plan, Profile profile, IProgressMonitor monitor) throws ProvisionException {
+ return getEngine().perform(profile, new DefaultPhaseSet(), plan.getOperands(), monitor);
+ }
+
private static IStatus error(String message) {
return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, message);
}
+
+ private static Engine getEngine() throws ProvisionException {
+ Engine engine = (Engine) ServiceHelper.getService(ProvUIActivator.getContext(), Engine.class.getName());
+ if (engine == null) {
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoEngineFound);
+ }
+ return engine;
+ }
+
+ private static IPlanner getPlanner() throws ProvisionException {
+ IPlanner planner = (IPlanner) ServiceHelper.getService(ProvUIActivator.getContext(), IPlanner.class.getName());
+ if (planner == null) {
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoPlannerFound);
+ }
+ return planner;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/BecomeAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/BecomeAction.java
index dd15a5070..7f8eb19f6 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/BecomeAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/BecomeAction.java
@@ -11,27 +11,55 @@
package org.eclipse.equinox.p2.ui.actions;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.IProfileChooser;
-import org.eclipse.equinox.p2.ui.operations.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
+import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
public class BecomeAction extends ProfileModificationAction {
- public static final int ENTRYPOINT_FORCE = 1;
- public static final int ENTRYPOINT_OPTIONAL = 2;
- public static final int ENTRYPOINT_NEVER = 3;
- int entryPointStrategy = ENTRYPOINT_NEVER;
- public BecomeAction(String text, ISelectionProvider selectionProvider, IOperationConfirmer confirmer, Profile profile, IProfileChooser chooser, Shell shell) {
- super(text, selectionProvider, confirmer, profile, chooser, shell);
+ public BecomeAction(ISelectionProvider selectionProvider, Profile profile, IProfileChooser chooser, Shell shell) {
+ super(ProvUI.ROLLBACK_COMMAND_LABEL, selectionProvider, profile, chooser, shell);
+ setToolTipText(ProvUI.ROLLBACK_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] toBecome, Profile targetProfile, IProgressMonitor monitor) {
- return new BecomeOperation(ProvUIMessages.Ops_BecomeIUOperationLabel, targetProfile.getProfileId(), toBecome[0]);
+ protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] toBecome, Profile targetProfile, IProgressMonitor monitor, IAdaptable uiInfo) {
+ if (toBecome.length == 1) {
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getBecomePlan(toBecome[0], targetProfile, monitor);
+ IStatus planStatus = plan.getStatus();
+ if (planStatus.isOK())
+ return new ProfileModificationOperation(ProvUIMessages.BecomeIUOperationLabel, targetProfile.getProfileId(), plan);
+ ProvUI.reportStatus(planStatus);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ // fall through and return null
+ }
+ }
+ return null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * Overridden to enable only on single selections with a profile IU.
+ */
+ public void selectionChanged(IStructuredSelection selection) {
+ Object[] selectionArray = selection.toArray();
+ if (selectionArray.length == 1 && selectionArray[0] instanceof IInstallableUnit) {
+ IInstallableUnit iu = (IInstallableUnit) selectionArray[0];
+ setEnabled(Boolean.valueOf(iu.getProperty(IInstallableUnitConstants.PROFILE_IU_KEY)).booleanValue());
+ } else {
+ setEnabled(false);
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java
index 111ba8418..a89096a88 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java
@@ -11,78 +11,62 @@
package org.eclipse.equinox.p2.ui.actions;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.ui.InstallDialog;
import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.operations.*;
-import org.eclipse.jface.dialogs.*;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.window.Window;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
public class InstallAction extends ProfileModificationAction {
- public static final int ENTRYPOINT_FORCE = 1;
- public static final int ENTRYPOINT_OPTIONAL = 2;
- public static final int ENTRYPOINT_NEVER = 3;
- int entryPointStrategy = ENTRYPOINT_FORCE;
- public InstallAction(String text, ISelectionProvider selectionProvider, IOperationConfirmer confirmer, Profile profile, IProfileChooser chooser, Shell shell) {
- super(text, selectionProvider, confirmer, profile, chooser, shell);
+ public InstallAction(ISelectionProvider selectionProvider, Profile profile, IProfileChooser chooser, Shell shell) {
+ super(ProvUI.INSTALL_COMMAND_LABEL, selectionProvider, profile, chooser, shell);
+ setToolTipText(ProvUI.INSTALL_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
+ protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor, IAdaptable uiInfo) {
// First validate whether the install can happen
try {
- if (ProvisioningUtil.canInstall(ius, targetProfile, monitor, ProvUI.getUIInfoAdapter(getShell()))) {
- // Get a name for the entry point
- // TODO eventually this should be a specialized dialog for confirming an install, showing size, etc.
- String entryPointName = null;
- if (entryPointStrategy != ENTRYPOINT_NEVER) {
- entryPointName = getDefaultEntryPointName(ius);
- InputDialog dialog = new InputDialog(getShell(), ProvUIMessages.InstallAction_InstallConfirmTitle, ProvUIMessages.InstallAction_NameEntryPointMessage, entryPointName, new IInputValidator() {
- public String isValid(String string) {
- if (string.length() > 0 || entryPointStrategy == ENTRYPOINT_OPTIONAL)
- return null;
- return ProvUIMessages.InstallAction_EntryPointNameRequired;
- }
- });
- if (dialog.open() == Window.CANCEL)
- return null;
- entryPointName = dialog.getValue();
- if (entryPointName.length() == 0) {
- entryPointName = null;
- }
- }
- if (entryPointName == null) {
- if (entryPointStrategy == ENTRYPOINT_FORCE) {
- // shouldn't happen, but just in case
- return null;
- }
- }
- return new InstallOperation(ProvUIMessages.Ops_InstallIUOperationLabel, targetProfile.getProfileId(), ius, entryPointName);
+ ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(ius, targetProfile, monitor, uiInfo);
+ IStatus status = plan.getStatus();
+ if (status.isOK()) {
+ InstallDialog dialog = new InstallDialog(getShell(), ius, targetProfile);
+ dialog.open();
+ return dialog.getOperation();
}
- MessageDialog.openInformation(getShell(), ProvUIMessages.InstallAction_InstallInfoTitle, ProvUIMessages.InstallAction_InstallNotPermitted);
+ ProvUI.reportStatus(status);
} catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
// fall through and return null
}
return null;
}
- private String getDefaultEntryPointName(IInstallableUnit[] ius) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < ius.length; i++) {
- result.append(ius[i].getId());
- if (i < ius.length - 1)
- result.append(", "); //$NON-NLS-1$
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * Overridden to enable only on selections with IU's. Does not validate
+ * whether the IU is already installed in a particular profile.
+ */
+ public void selectionChanged(IStructuredSelection selection) {
+ Object[] selectionArray = selection.toArray();
+ if (selectionArray.length < 1) {
+ setEnabled(false);
+ } else {
+ for (int i = 0; i < selectionArray.length; i++) {
+ if (!(selectionArray[i] instanceof IInstallableUnit)) {
+ setEnabled(false);
+ return;
+ }
+ }
+ setEnabled(true);
}
- return result.toString();
-
- }
-
- public void setEntryPointStrategy(int strategy) {
- entryPointStrategy = strategy;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java
index bd8e11cce..accf5964e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java
@@ -21,13 +21,11 @@ import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.operations.IOperationConfirmer;
import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.statushandlers.StatusManager;
abstract class ProfileModificationAction extends ProvisioningAction {
@@ -35,8 +33,8 @@ abstract class ProfileModificationAction extends ProvisioningAction {
Profile profile;
IProfileChooser profileChooser;
- public ProfileModificationAction(String text, ISelectionProvider selectionProvider, IOperationConfirmer confirmer, Profile profile, IProfileChooser profileChooser, Shell shell) {
- super(text, selectionProvider, confirmer, shell);
+ public ProfileModificationAction(String text, ISelectionProvider selectionProvider, Profile profile, IProfileChooser profileChooser, Shell shell) {
+ super(text, selectionProvider, shell);
this.profile = profile;
this.profileChooser = profileChooser;
}
@@ -70,7 +68,7 @@ abstract class ProfileModificationAction extends ProvisioningAction {
final Profile prof = targetProfile;
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
- ops[0] = validateAndGetOperation(ius, prof, monitor);
+ ops[0] = validateAndGetOperation(ius, prof, monitor, ProvUI.getUIInfoAdapter(getShell()));
}
};
try {
@@ -84,16 +82,12 @@ abstract class ProfileModificationAction extends ProvisioningAction {
if (ops[0] == null)
return;
- if (operationConfirmer != null && !operationConfirmer.continuePerformingOperation(ops[0], getShell())) {
- return;
- }
-
final IStatus[] status = new IStatus[1];
final IAdaptable adapter = ProvUI.getUIInfoAdapter(getShell());
runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
- status[0] = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(ops[0], monitor, adapter);
+ status[0] = ops[0].execute(monitor, adapter);
if (!status[0].isOK()) {
StatusManager.getManager().handle(status[0], StatusManager.SHOW | StatusManager.LOG);
}
@@ -128,5 +122,5 @@ abstract class ProfileModificationAction extends ProvisioningAction {
* If so, return an operation representing it. If not, return null.
* We assume the user has been notified if something couldn't happen.
*/
- protected abstract ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor);
+ protected abstract ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor, IAdaptable uiInfo);
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProvisioningAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProvisioningAction.java
index 0933c3ff8..caf89b5ad 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProvisioningAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProvisioningAction.java
@@ -11,24 +11,28 @@
package org.eclipse.equinox.p2.ui.actions;
-import org.eclipse.equinox.p2.ui.operations.IOperationConfirmer;
-import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.*;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionProviderAction;
public abstract class ProvisioningAction extends SelectionProviderAction {
- protected IOperationConfirmer operationConfirmer;
private Shell shell;
- protected ProvisioningAction(String text, ISelectionProvider selectionProvider, IOperationConfirmer confirmer, Shell shell) {
+ protected ProvisioningAction(String text, ISelectionProvider selectionProvider, Shell shell) {
super(selectionProvider, text);
- this.operationConfirmer = confirmer;
this.shell = shell;
if (this.shell == null) {
shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
}
+ // prime the selection validation
+ ISelection selection = selectionProvider.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ selectionChanged((IStructuredSelection) selection);
+ } else {
+ selectionChanged(selection);
+ }
}
protected Shell getShell() {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java
index 751ffeece..1ce550362 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java
@@ -11,22 +11,71 @@
package org.eclipse.equinox.p2.ui.actions;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.ui.UninstallDialog;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.IProfileChooser;
-import org.eclipse.equinox.p2.ui.operations.*;
+import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
public class UninstallAction extends ProfileModificationAction {
- public UninstallAction(String text, ISelectionProvider selectionProvider, IOperationConfirmer confirmer, Profile profile, IProfileChooser chooser, Shell shell) {
- super(text, selectionProvider, confirmer, profile, chooser, shell);
+ public UninstallAction(ISelectionProvider selectionProvider, Profile profile, IProfileChooser chooser, Shell shell) {
+ super(ProvUI.UNINSTALL_COMMAND_LABEL, selectionProvider, profile, chooser, shell);
+ setToolTipText(ProvUI.UNINSTALL_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
- return new UninstallOperation(ProvUIMessages.Ops_UninstallIUOperationLabel, targetProfile.getProfileId(), ius);
+ protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor, IAdaptable uiInfo) {
+ // First validate whether the uninstall can happen
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getUninstallPlan(ius, targetProfile, monitor, uiInfo);
+ IStatus status = plan.getStatus();
+ if (status.isOK()) {
+ UninstallDialog dialog = new UninstallDialog(getShell(), ius, targetProfile);
+ dialog.open();
+ return dialog.getOperation();
+ }
+ ProvUI.reportStatus(status);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ // fall through and return null
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * Overridden to enable only on selections of installed IU's with the same parent
+ */
+ public void selectionChanged(IStructuredSelection selection) {
+ Object[] selectionArray = selection.toArray();
+ Object parent = null;
+ if (selectionArray.length > 0) {
+ setEnabled(true);
+ for (int i = 0; i < selectionArray.length; i++) {
+ if (selectionArray[i] instanceof InstalledIUElement) {
+ InstalledIUElement element = (InstalledIUElement) selectionArray[i];
+ if (parent == null) {
+ parent = element.getParent(null);
+ } else if (parent != element.getParent(null)) {
+ setEnabled(false);
+ break;
+ }
+ } else {
+ setEnabled(false);
+ break;
+ }
+ }
+ } else {
+ setEnabled(false);
+ }
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java
index fcbc2a6db..e676aeb52 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java
@@ -11,102 +11,78 @@
package org.eclipse.equinox.p2.ui.actions;
-import java.util.*;
+import java.util.ArrayList;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.internal.p2.ui.UpdateDialog;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.operations.*;
-import org.eclipse.equinox.p2.ui.viewers.IUDetailsLabelProvider;
+import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
+import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
public class UpdateAction extends ProfileModificationAction {
- private final class UpdateListSelectionDialog extends ListSelectionDialog {
- UpdateListSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider, ILabelProvider labelProvider, String message) {
- super(parentShell, input, contentProvider, labelProvider, message);
- }
-
- protected Control createDialogArea(Composite parent) {
- Control control = super.createDialogArea(parent);
- Table table = getViewer().getTable();
- table.setHeaderVisible(true);
- TableColumn tc = new TableColumn(table, SWT.LEFT, 0);
- tc.setResizable(true);
- tc.setWidth(200);
- tc = new TableColumn(table, SWT.LEFT, 1);
- tc.setWidth(200);
- tc.setResizable(true);
- getViewer().setInput(new Object());
- return control;
- }
+ public UpdateAction(ISelectionProvider selectionProvider, Profile profile, IProfileChooser chooser, Shell shell) {
+ super(ProvUI.UPDATE_COMMAND_LABEL, selectionProvider, profile, chooser, shell);
+ setToolTipText(ProvUI.UPDATE_COMMAND_TOOLTIP);
}
- private final class UpdateContentProvider implements IStructuredContentProvider {
- private final Object[] elements;
-
- UpdateContentProvider(Object[] elements) {
- this.elements = elements;
- }
-
- public Object[] getElements(Object inputElement) {
- return elements;
- }
-
- public void dispose() {
- // nothing to dispose
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // input is static
- }
- }
-
- public UpdateAction(String text, ISelectionProvider selectionProvider, IOperationConfirmer confirmer, Profile profile, IProfileChooser chooser, Shell shell) {
- super(text, selectionProvider, confirmer, profile, chooser, shell);
- }
-
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
+ protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor, IAdaptable uiInfo) {
// Collect the replacements for each IU individually so that
// the user can decide what to update
try {
- Collection[] replacements = new Collection[ius.length];
ArrayList iusWithUpdates = new ArrayList();
for (int i = 0; i < ius.length; i++) {
- replacements[i] = ProvisioningUtil.updatesFor(ius[i], monitor);
- if (replacements[i].size() > 0)
+ IInstallableUnit[] replacements = ProvisioningUtil.updatesFor(ius[i], monitor);
+ if (replacements.length > 0)
iusWithUpdates.add(ius[i]);
}
if (iusWithUpdates.size() > 0) {
- final Object[] elements = iusWithUpdates.toArray();
- ListSelectionDialog dialog = new UpdateListSelectionDialog(getShell(), new Object(), new UpdateContentProvider(elements), new IUDetailsLabelProvider(), ProvUIMessages.UpdateAction_UpdatesAvailableMessage);
- dialog.setInitialSelections(elements);
- dialog.setTitle(ProvUIMessages.UpdateAction_UpdatesAvailableTitle);
- int ret = dialog.open();
- IInstallableUnit[] iusToUpdate = new IInstallableUnit[0];
- if (ret != Window.CANCEL) {
- Object[] result = dialog.getResult();
- if (result != null && result.length > 0) {
- iusToUpdate = (IInstallableUnit[]) Arrays.asList(dialog.getResult()).toArray(new IInstallableUnit[result.length]);
- IInstallableUnit[] replacementIUs = ProvisioningUtil.updatesFor(iusToUpdate, targetProfile, monitor, ProvUI.getUIInfoAdapter(getShell()));
- if (replacementIUs.length > 0) {
- return new UpdateOperation(ProvUIMessages.Ops_UpdateIUOperationLabel, targetProfile.getProfileId(), iusToUpdate, replacementIUs);
- }
- }
- }
- } else {
- MessageDialog.openInformation(getShell(), ProvUIMessages.UpdateAction_UpdateInformationTitle, ProvUIMessages.UpdateOperation_NothingToUpdate);
+ UpdateDialog dialog = new UpdateDialog(getShell(), (IInstallableUnit[]) iusWithUpdates.toArray(new IInstallableUnit[iusWithUpdates.size()]), targetProfile);
+ dialog.open();
+ return dialog.getOperation();
}
+ MessageDialog.openInformation(getShell(), ProvUIMessages.UpdateAction_UpdateInformationTitle, ProvUIMessages.UpdateOperation_NothingToUpdate);
} catch (ProvisionException e) {
// fall through and return null
}
return null;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * Overridden to enable only on selections of installed IU's with the same parent
+ */
+ public void selectionChanged(IStructuredSelection selection) {
+ Object[] selectionArray = selection.toArray();
+ Object parent = null;
+ if (selectionArray.length > 0) {
+ setEnabled(true);
+ for (int i = 0; i < selectionArray.length; i++) {
+ if (selectionArray[i] instanceof InstalledIUElement) {
+ InstalledIUElement element = (InstalledIUElement) selectionArray[i];
+ if (parent == null) {
+ parent = element.getParent(null);
+ } else if (parent != element.getParent(null)) {
+ setEnabled(false);
+ break;
+ }
+ } else {
+ setEnabled(false);
+ break;
+ }
+ }
+ } else {
+ setEnabled(false);
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUGroup.java
index d82e12f67..fc0be5780 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUGroup.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.dialogs;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
@@ -22,11 +23,11 @@ import org.eclipse.swt.widgets.Composite;
*/
public abstract class IUGroup {
- protected IInstallableUnit iu;
+ protected Object iuElement;
private Composite composite;
- IUGroup(final Composite parent, IInstallableUnit iu, ModifyListener listener) {
- this.iu = iu;
+ protected IUGroup(final Composite parent, Object iu, ModifyListener listener) {
+ this.iuElement = iu;
composite = createGroupComposite(parent, listener);
}
@@ -37,7 +38,11 @@ public abstract class IUGroup {
}
public IInstallableUnit getIU() {
- return iu;
+ if (iuElement instanceof IInstallableUnit)
+ return (IInstallableUnit) iuElement;
+ if (iuElement instanceof IAdaptable)
+ return ((IInstallableUnit) ((IAdaptable) iuElement).getAdapter(IInstallableUnit.class));
+ return null;
}
public void updateIU() {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUImplementationGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUImplementationGroup.java
index 57aaa1351..4c1cc990f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUImplementationGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUImplementationGroup.java
@@ -72,8 +72,7 @@ public class IUImplementationGroup extends IUGroup {
gdList.horizontalSpan = 2;
gdList.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 5);
- // TODO will existing IUs be editable?
- boolean editable = iu == null && listener != null;
+ boolean editable = iuElement == null && listener != null;
Label label = new Label(composite, SWT.NONE);
label.setText(ProvUIMessages.IUGroup_ID);
@@ -134,6 +133,7 @@ public class IUImplementationGroup extends IUGroup {
}
private void initializeFields() {
+ IInstallableUnit iu = getIU();
if (iu == null) {
return;
}
@@ -170,12 +170,12 @@ public class IUImplementationGroup extends IUGroup {
}
public void updateIU() {
- if (iu == null) {
- iu = new InstallableUnit();
+ if (iuElement == null) {
+ iuElement = new InstallableUnit();
}
// If it's not an InstallableUnit it is not editable
- if (iu instanceof InstallableUnit) {
- InstallableUnit unit = (InstallableUnit) iu;
+ if (iuElement instanceof InstallableUnit) {
+ InstallableUnit unit = (InstallableUnit) iuElement;
unit.setId(id.getText().trim());
unit.setVersion(new Version(version.getText().trim()));
unit.setProperty(IInstallableUnit.IU_NAMESPACE, namespace.getText().trim());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUPropertiesGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUPropertiesGroup.java
index 8b1f365bb..73d7bec98 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUPropertiesGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/IUPropertiesGroup.java
@@ -59,14 +59,14 @@ public class IUPropertiesGroup extends IUGroup {
}
private void initializeFields() {
- if (iu == null) {
+ if (iuElement == null) {
return;
}
String[] propNames = new String[] {IInstallableUnitConstants.NAME, IInstallableUnitConstants.DESCRIPTION, IInstallableUnitConstants.PROVIDER, IInstallableUnitConstants.COPYRIGHT, IInstallableUnitConstants.LICENSE};
String[] userPropNames = new String[] {ProvUIMessages.IUPropertiesGroup_NameProperty, ProvUIMessages.IUPropertiesGroup_DescriptionProperty, ProvUIMessages.IUPropertiesGroup_ProviderProperty, ProvUIMessages.IUPropertiesGroup_CopyrightProperty, ProvUIMessages.IUPropertiesGroup_LicenseProperty};
for (int i = 0; i < propNames.length; i++) {
TableItem item = new TableItem(propertiesTable, SWT.NULL);
- String value = iu.getProperty(propNames[i]);
+ String value = getIU().getProperty(propNames[i]);
if (value != null)
item.setText(new String[] {userPropNames[i], value});
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
index 94808b8eb..db9eefcff 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
@@ -16,8 +16,7 @@ import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.ui.*;
import org.eclipse.equinox.p2.ui.actions.*;
import org.eclipse.equinox.p2.ui.model.*;
-import org.eclipse.equinox.p2.ui.viewers.IUDetailsLabelProvider;
-import org.eclipse.equinox.p2.ui.viewers.StructuredViewerProvisioningListener;
+import org.eclipse.equinox.p2.ui.viewers.*;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
@@ -120,6 +119,8 @@ public class UpdateAndInstallGroup {
data = new GridData(GridData.FILL_VERTICAL);
buttonBar.setLayoutData(data);
+ // Must be done after buttons are created so that the buttons can
+ // register and receive their selection notifications before us.
availableIUViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
validateAvailableIUButtons(event.getSelection());
@@ -155,8 +156,8 @@ public class UpdateAndInstallGroup {
// Add the buttons to the button bar.
availablePropButton = createVerticalButton(composite, ProvUIMessages.UpdateAndInstallGroup_Properties, false);
availablePropButton.setData(BUTTONACTION, new PropertyDialogAction(new SameShellProvider(parent.getShell()), availableIUViewer));
- installButton = createVerticalButton(composite, ProvUIMessages.UpdateAndInstallGroup_Install, false);
- installButton.setData(BUTTONACTION, new InstallAction(ProvUIMessages.UpdateAndInstallGroup_Install, availableIUViewer, null, profile, null, parent.getShell()));
+ installButton = createVerticalButton(composite, ProvUIMessages.InstallIUCommandLabel, false);
+ installButton.setData(BUTTONACTION, new InstallAction(availableIUViewer, profile, null, parent.getShell()));
Button refreshButton = createVerticalButton(composite, ProvUIMessages.UpdateAndInstallGroup_Refresh, false);
refreshButton.setData(BUTTONACTION, new Action() {
public void runWithEvent(Event event) {
@@ -179,8 +180,10 @@ public class UpdateAndInstallGroup {
}
void validateAvailableIUButtons(ISelection selection) {
- availablePropButton.setEnabled(((IStructuredSelection) selection).size() == 1);
- installButton.setEnabled(!selection.isEmpty());
+ // This relies on the actions themselves receiving the selection changed
+ // listener before we do, since we use their state to enable the buttons
+ updateEnablement(availablePropButton);
+ updateEnablement(installButton);
}
private Control createInstalledIUsPage(Composite parent, ViewerFilter[] iuFilters) {
@@ -199,6 +202,7 @@ public class UpdateAndInstallGroup {
installedIUViewer.setContentProvider(new ProfileContentProvider());
installedIUViewer.setInput(profile);
installedIUViewer.setLabelProvider(new IUDetailsLabelProvider());
+
if (iuFilters != null) {
installedIUViewer.setFilters(iuFilters);
}
@@ -214,6 +218,8 @@ public class UpdateAndInstallGroup {
data = new GridData(GridData.FILL_VERTICAL);
buttonBar.setLayoutData(data);
+ // Must be done after buttons are created so that the buttons can
+ // register and receive their selection notifications before us.
installedIUViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
validateInstalledIUButtons(event.getSelection());
@@ -248,10 +254,10 @@ public class UpdateAndInstallGroup {
// Add the buttons to the button bar.
installedPropButton = createVerticalButton(composite, ProvUIMessages.UpdateAndInstallGroup_Properties, false);
installedPropButton.setData(BUTTONACTION, new PropertyDialogAction(new SameShellProvider(parent.getShell()), installedIUViewer));
- uninstallButton = createVerticalButton(composite, ProvUIMessages.UpdateAndInstallGroup_Uninstall, false);
- uninstallButton.setData(BUTTONACTION, new UninstallAction(ProvUIMessages.UpdateAndInstallGroup_Uninstall, installedIUViewer, null, profile, null, parent.getShell()));
- updateButton = createVerticalButton(composite, ProvUIMessages.UpdateAndInstallGroup_Update, false);
- updateButton.setData(BUTTONACTION, new UpdateAction(ProvUIMessages.UpdateAndInstallGroup_Update, installedIUViewer, null, profile, null, parent.getShell()));
+ uninstallButton = createVerticalButton(composite, ProvUIMessages.UninstallIUCommandLabel, false);
+ uninstallButton.setData(BUTTONACTION, new UninstallAction(installedIUViewer, profile, null, parent.getShell()));
+ updateButton = createVerticalButton(composite, ProvUIMessages.UpdateIUCommandLabel, false);
+ updateButton.setData(BUTTONACTION, new UpdateAction(installedIUViewer, profile, null, parent.getShell()));
if (repositoryManipulator != null) {
Button repoButton = createVerticalButton(composite, repositoryManipulator.getLabel(), false);
repoButton.setData(BUTTONACTION, new Action() {
@@ -277,9 +283,20 @@ public class UpdateAndInstallGroup {
}
void validateInstalledIUButtons(ISelection selection) {
- installedPropButton.setEnabled(((IStructuredSelection) selection).size() == 1);
- uninstallButton.setEnabled(!selection.isEmpty());
- updateButton.setEnabled(!selection.isEmpty());
+ // Note that this relies on the actions getting the selection notification
+ // before we do, since we rely on the action enablement to update
+ // the buttons. This should be ok since the buttons
+ // hook the listener on create.
+ updateEnablement(installedPropButton);
+ updateEnablement(uninstallButton);
+ updateEnablement(updateButton);
+ }
+
+ private void updateEnablement(Button button) {
+ IAction action = getButtonAction(button);
+ if (action != null) {
+ button.setEnabled(action.isEnabled());
+ }
}
private Button createVerticalButton(Composite parent, String label, boolean defaultButton) {
@@ -305,12 +322,18 @@ public class UpdateAndInstallGroup {
}
void verticalButtonPressed(Event event) {
- Object data = event.widget.getData(BUTTONACTION);
+ IAction action = getButtonAction(event.widget);
+ if (action != null) {
+ action.runWithEvent(event);
+ }
+ }
+
+ private IAction getButtonAction(Widget widget) {
+ Object data = widget.getData(BUTTONACTION);
if (data == null || !(data instanceof IAction)) {
- return;
+ return null;
}
- IAction action = (IAction) data;
- action.runWithEvent(event);
+ return (IAction) data;
}
private GridData setButtonLayoutData(Button button) {
@@ -338,15 +361,15 @@ public class UpdateAndInstallGroup {
return Dialog.convertVerticalDLUsToPixels(fm, dlus);
}
- //TODO: callers should be able to configure the table columns as well as the label provider
private void setTableColumns(Table table) {
+ // TODO will we ever let callers set the column config?
+ IUColumnConfig[] columns = ProvUI.getIUColumnConfig();
table.setHeaderVisible(true);
- // don't externalize, these strings will go away soon enough
- String[] columnHeaders = {"Name", "Version"};
- for (int i = 0; i < columnHeaders.length; i++) {
+
+ for (int i = 0; i < columns.length; i++) {
TableColumn tc = new TableColumn(table, SWT.NONE, i);
tc.setResizable(true);
- tc.setText(columnHeaders[i]);
+ tc.setText(columns[i].columnTitle);
tc.setWidth(convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableIUElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableIUElement.java
index de033e18c..6ce5c4f17 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableIUElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableIUElement.java
@@ -25,10 +25,11 @@ import org.eclipse.equinox.p2.ui.ProvUIImages;
*/
public class AvailableIUElement extends ProvElement {
- int size;
+ public static final long SIZE_UNKNOWN = -1;
+ long size;
IInstallableUnit iu;
- public AvailableIUElement(IInstallableUnit iu, int size) {
+ public AvailableIUElement(IInstallableUnit iu, long size) {
this.size = size;
this.iu = iu;
}
@@ -66,7 +67,7 @@ public class AvailableIUElement extends ProvElement {
return super.getAdapter(adapter);
}
- public int getSize() {
+ public long getSize() {
return size;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableUpdateElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableUpdateElement.java
new file mode 100644
index 000000000..b25154f5c
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/AvailableUpdateElement.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.equinox.p2.ui.model;
+
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+
+/**
+ * Element wrapper class for IU's that are available for installation.
+ * Used instead of the plain IU when additional information such as sizing
+ * info is necessary.
+ *
+ * @since 3.4
+ */
+public class AvailableUpdateElement extends AvailableIUElement {
+
+ IInstallableUnit iuToBeUpdated;
+
+ public AvailableUpdateElement(IInstallableUnit iu, long size, IInstallableUnit iuToBeUpdated) {
+ super(iu, size);
+ this.iuToBeUpdated = iuToBeUpdated;
+ }
+
+ public IInstallableUnit getIUToBeUpdated() {
+ return iuToBeUpdated;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/InstalledIUElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/InstalledIUElement.java
index d098bed4a..9bc61eda0 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/InstalledIUElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/InstalledIUElement.java
@@ -70,4 +70,8 @@ public class InstalledIUElement extends ProvElement {
public Profile getProfile() {
return parent;
}
+
+ public IInstallableUnit getIU() {
+ return iu;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddProfileOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddProfileOperation.java
index 8b6e9e379..dbe54bd3c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddProfileOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddProfileOperation.java
@@ -21,7 +21,6 @@ import org.eclipse.equinox.p2.ui.ProvisioningUtil;
* @since 3.4
*/
public class AddProfileOperation extends ProfileOperation {
- private boolean added = false;
public AddProfileOperation(String label, Profile profile) {
super(label, new Profile[] {profile});
@@ -29,31 +28,6 @@ public class AddProfileOperation extends ProfileOperation {
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
ProvisioningUtil.addProfile(getProfiles()[0], monitor, uiInfo);
- added = true;
return okStatus();
}
-
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- ProvisioningUtil.removeProfile(profileIds[0], monitor, uiInfo);
- added = false;
- return okStatus();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- */
- public boolean canExecute() {
- return super.canExecute() && !added;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
- */
- public boolean canUndo() {
- return super.canUndo() && added;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/BecomeOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/BecomeOperation.java
deleted file mode 100644
index 0e8776f27..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/BecomeOperation.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.equinox.p2.ui.operations;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvisioningUtil;
-
-/**
- * An operation that installs the specified IU's into the specified profile
- *
- * @since 3.4
- */
-public class BecomeOperation extends ProfileModificationOperation {
-
- private boolean installed = false;
-
- public BecomeOperation(String label, String profileID, IInstallableUnit toBecome) {
- super(label, profileID, new IInstallableUnit[] {toBecome}, null);
- }
-
- protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- IStatus status = ProvisioningUtil.become(ius[0], getProfiles()[0], monitor);
- if (status.isOK()) {
- installed = true;
- }
- return status;
- }
-
- // TODO We need to see what this means in the light of engine rollback
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- return Status.OK_STATUS;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- */
- public boolean canExecute() {
- return isValid() && !installed;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
- */
- public boolean canUndo() {
- return isValid() && installed;
- }
-
- /*
- * (non-Javadoc)
- * Overridden to use the Oracle to compute the validity of an install.
- * @see org.eclipse.equinox.p2.ui.operations.ProvisioningOperation#computeExecutionStatus(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus computeExecutionStatus(IProgressMonitor monitor) {
- //TODO Need to do the proper thing here
- return Status.OK_STATUS;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallOperation.java
index ea8ea67d8..20979ad2f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallOperation.java
@@ -11,10 +11,9 @@
package org.eclipse.equinox.p2.ui.operations;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvUIActivator;
import org.eclipse.equinox.p2.ui.ProvisioningUtil;
/**
@@ -24,59 +23,14 @@ import org.eclipse.equinox.p2.ui.ProvisioningUtil;
*/
public class InstallOperation extends ProfileModificationOperation {
- private boolean installed = false;
+ IInstallableUnit[] installRoots;
- public InstallOperation(String label, String profileID, IInstallableUnit[] ius, String entryPointName) {
- super(label, profileID, ius, entryPointName);
+ public InstallOperation(String label, String profileID, ProvisioningPlan plan, IInstallableUnit[] ius) {
+ super(label, profileID, plan);
+ this.installRoots = ius;
}
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- IStatus status = ProvisioningUtil.install(ius, entryPointName, getProfiles()[0], monitor, uiInfo);
- if (status.isOK()) {
- installed = true;
- }
- return status;
- }
-
- // TODO undo is more likely a rollback than an uninstall? Need to clarify
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- IStatus status = ProvisioningUtil.uninstall(ius, getProfiles()[0], monitor, uiInfo);
- if (status.isOK()) {
- installed = false;
- }
- return status;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- */
- public boolean canExecute() {
- return isValid() && !installed;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
- */
- public boolean canUndo() {
- return isValid() && installed;
- }
-
- /*
- * (non-Javadoc)
- * Overridden to use the Oracle to compute the validity of an install.
- * @see org.eclipse.equinox.p2.ui.operations.ProvisioningOperation#computeExecutionStatus(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus computeExecutionStatus(IProgressMonitor monitor) {
- try {
- if (ProvisioningUtil.canInstall(ius, getProfile(), monitor, null))
- return okStatus();
- return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, ProvUIMessages.InstallOperation_CannotInstall, null);
- } catch (ProvisionException e) {
- return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getLocalizedMessage(), e);
- }
+ return ProvisioningUtil.performInstall(plan, getProfile(), installRoots, monitor);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java
index 53d8a27f8..61a7e63bd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java
@@ -10,32 +10,28 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.operations;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.ProvisioningUtil;
/**
* Abstract class representing provisioning profile operations
*
* @since 3.4
*/
-public abstract class ProfileModificationOperation extends ProfileOperation {
+public class ProfileModificationOperation extends ProfileOperation {
- IInstallableUnit[] ius;
- String entryPointName;
+ ProvisioningPlan plan;
- ProfileModificationOperation(String label, String id, IInstallableUnit[] ius, String entryPointName) {
+ public ProfileModificationOperation(String label, String id, ProvisioningPlan plan) {
super(label, new String[] {id});
- this.entryPointName = entryPointName;
- this.ius = ius;
- }
-
- ProfileModificationOperation(String label, String id, IInstallableUnit[] ius) {
- this(label, id, ius, null);
+ this.plan = plan;
}
boolean isValid() {
- return super.isValid() && ius != null && ius.length > 0;
+ return super.isValid() && plan != null && plan.getStatus().isOK();
}
public String getProfileId() {
@@ -54,13 +50,7 @@ public abstract class ProfileModificationOperation extends ProfileOperation {
}
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.equinox.p2.ui.operations.ProvisioningOperation#getAffectedObjects()
- */
- public Object[] getAffectedObjects() {
- if (ius != null)
- return ius;
- return super.getAffectedObjects();
+ protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
+ return ProvisioningUtil.performProvisioningPlan(plan, getProfile(), monitor);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java
index 538d20edc..e59be473e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java
@@ -11,12 +11,10 @@
package org.eclipse.equinox.p2.ui.operations;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.ui.ProvUIActivator;
-import org.eclipse.equinox.p2.ui.ProvisioningUndoSupport;
import org.eclipse.osgi.util.NLS;
/**
@@ -25,17 +23,12 @@ import org.eclipse.osgi.util.NLS;
* @since 3.4
*/
-public abstract class ProvisioningOperation extends AbstractOperation implements IAdvancedUndoableOperation, IAdvancedUndoableOperation2 {
+public abstract class ProvisioningOperation {
- /*
- * Specifies whether any user prompting is appropriate while computing
- * status.
- */
- protected boolean quietCompute = false;
+ private String label;
public ProvisioningOperation(String label) {
- super(label);
- addContext(ProvisioningUndoSupport.getProvisioningUndoContext());
+ this.label = label;
}
/**
@@ -46,22 +39,7 @@ public abstract class ProvisioningOperation extends AbstractOperation implements
try {
status = doExecute(monitor, uiInfo);
} catch (final ProvisionException e) {
- throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_ExecuteErrorTitle, getLabel()), e);
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
- return status;
- }
-
- /**
- *
- */
- public IStatus redo(IProgressMonitor monitor, final IAdaptable uiInfo) throws ExecutionException {
- IStatus status;
- try {
- status = doExecute(monitor, uiInfo);
- } catch (final ProvisionException e) {
- throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_RedoErrorTitle, getLabel()), e);
+ throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_ExecuteErrorTitle, label, e));
} catch (OperationCanceledException e) {
return Status.CANCEL_STATUS;
}
@@ -69,37 +47,6 @@ public abstract class ProvisioningOperation extends AbstractOperation implements
}
/**
- *
- */
- public IStatus undo(IProgressMonitor monitor, final IAdaptable uiInfo) throws ExecutionException {
- IStatus status;
- try {
- status = doUndo(monitor, uiInfo);
- } catch (final ProvisionException e) {
- throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_UndoErrorTitle, getLabel()), e);
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
- return status;
- }
-
- /**
- * Perform the specific work involved in undoing this operation.
- *
- * @param monitor
- * the progress monitor to use for the operation
- * @param uiInfo
- * the IAdaptable (or <code>null</code>) provided by the
- * caller in order to supply UI information for prompting the
- * user if necessary. When this parameter is not
- * <code>null</code>, it contains an adapter for the
- * org.eclipse.swt.widgets.Shell.class
- * @throws ProvisionException
- * propagates any ProvisionException thrown
- */
- protected abstract IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException;
-
- /**
* Perform the specific work involved in executing this operation.
*
* @param monitor
@@ -116,79 +63,16 @@ public abstract class ProvisioningOperation extends AbstractOperation implements
*/
protected abstract IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canRedo()
- */
- public boolean canRedo() {
- return canExecute();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#aboutToNotify(org.eclipse.core.commands.operations.OperationHistoryEvent)
- */
- public void aboutToNotify(OperationHistoryEvent event) {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#getAffectedObjects()
- */
- public Object[] getAffectedObjects() {
- return new Object[0];
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#computeRedoableStatus(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus computeRedoableStatus(IProgressMonitor monitor) throws ExecutionException {
- return computeExecutionStatus(monitor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus computeUndoableStatus(IProgressMonitor monitor) throws ExecutionException {
- return okStatus();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#computeExecutionStatus(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus computeExecutionStatus(IProgressMonitor monitor) throws ExecutionException {
- return okStatus();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#runInBackground()
- */
- public boolean runInBackground() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#setQuietCompute(boolean)
- */
- public void setQuietCompute(boolean quiet) {
- quietCompute = quiet;
- }
-
protected IStatus okStatus() {
return Status.OK_STATUS;
}
protected IStatus failureStatus() {
- return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, getLabel());
+ return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, label);
+ }
+
+ public String getLabel() {
+ return label;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveProfilesOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveProfilesOperation.java
index cbe323690..ae0fe9b8f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveProfilesOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveProfilesOperation.java
@@ -21,8 +21,6 @@ import org.eclipse.equinox.p2.ui.ProvisioningUtil;
* @since 3.4
*/
public class RemoveProfilesOperation extends ProfileOperation {
- private boolean removed = false;
-
public RemoveProfilesOperation(String label, Profile[] profiles) {
super(label, profiles);
}
@@ -32,33 +30,6 @@ public class RemoveProfilesOperation extends ProfileOperation {
ProvisioningUtil.removeProfile(profileIds[i], monitor, uiInfo);
}
// assume the best if no exception
- removed = true;
- return okStatus();
- }
-
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- for (int i = 0; i < cachedProfiles.length; i++) {
- ProvisioningUtil.addProfile(cachedProfiles[i], monitor, uiInfo);
- }
- removed = false;
return okStatus();
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- */
- public boolean canExecute() {
- return profileIds != null && !removed;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
- */
- public boolean canUndo() {
- return cachedProfiles != null && removed;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RepositoryOperation.java
index f0154abea..73da481c1 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RepositoryOperation.java
@@ -11,13 +11,20 @@
package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.ui.ProvUIActivator;
+import org.eclipse.osgi.util.NLS;
/**
* Abstract class representing provisioning repository operations
*
* @since 3.4
*/
-public abstract class RepositoryOperation extends ProvisioningOperation {
+public abstract class RepositoryOperation extends AbstractOperation implements IAdvancedUndoableOperation2 {
URL[] urls;
String[] names;
@@ -28,6 +35,84 @@ public abstract class RepositoryOperation extends ProvisioningOperation {
this.names = names;
}
+ /**
+ * Perform the specific work involved in undoing this operation.
+ *
+ * @param monitor
+ * the progress monitor to use for the operation
+ * @param uiInfo
+ * the IAdaptable (or <code>null</code>) provided by the
+ * caller in order to supply UI information for prompting the
+ * user if necessary. When this parameter is not
+ * <code>null</code>, it contains an adapter for the
+ * org.eclipse.swt.widgets.Shell.class
+ * @throws ProvisionException
+ * propagates any ProvisionException thrown
+ */
+ protected abstract IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException;
+
+ /**
+ * Perform the specific work involved in executing this operation.
+ *
+ * @param monitor
+ * the progress monitor to use for the operation
+ * @param uiInfo
+ * the IAdaptable (or <code>null</code>) provided by the
+ * caller in order to supply UI information for prompting the
+ * user if necessary. When this parameter is not
+ * <code>null</code>, it contains an adapter for the
+ * org.eclipse.swt.widgets.Shell.class
+ * @throws ProvisionException
+ * propagates any ProvisionException thrown
+ *
+ */
+ protected abstract IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException;
+
+ /**
+ *
+ */
+ public IStatus execute(IProgressMonitor monitor, final IAdaptable uiInfo) throws ExecutionException {
+ IStatus status;
+ try {
+ status = doExecute(monitor, uiInfo);
+ } catch (final ProvisionException e) {
+ throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_ExecuteErrorTitle, getLabel()), e);
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ }
+ return status;
+ }
+
+ /**
+ *
+ */
+ public IStatus redo(IProgressMonitor monitor, final IAdaptable uiInfo) throws ExecutionException {
+ IStatus status;
+ try {
+ status = doExecute(monitor, uiInfo);
+ } catch (final ProvisionException e) {
+ throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_RedoErrorTitle, getLabel()), e);
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ }
+ return status;
+ }
+
+ /**
+ *
+ */
+ public IStatus undo(IProgressMonitor monitor, final IAdaptable uiInfo) throws ExecutionException {
+ IStatus status;
+ try {
+ status = doUndo(monitor, uiInfo);
+ } catch (final ProvisionException e) {
+ throw new ExecutionException(NLS.bind(ProvUIMessages.ProvisioningOperation_UndoErrorTitle, getLabel()), e);
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ }
+ return status;
+ }
+
public boolean canExecute() {
return urls != null;
}
@@ -35,4 +120,69 @@ public abstract class RepositoryOperation extends ProvisioningOperation {
public boolean canUndo() {
return urls != null;
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#getAffectedObjects()
+ */
+ public Object[] getAffectedObjects() {
+ return urls;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#computeRedoableStatus(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus computeRedoableStatus(IProgressMonitor monitor) throws ExecutionException {
+ return computeExecutionStatus(monitor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#computeUndoableStatus(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus computeUndoableStatus(IProgressMonitor monitor) throws ExecutionException {
+ return okStatus();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#computeExecutionStatus(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus computeExecutionStatus(IProgressMonitor monitor) throws ExecutionException {
+ return okStatus();
+ } /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#runInBackground()
+ */
+
+ public boolean runInBackground() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#setQuietCompute(boolean)
+ */
+ public void setQuietCompute(boolean quiet) {
+ // do nothing for now
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation#aboutToNotify(org.eclipse.core.commands.operations.OperationHistoryEvent)
+ */
+ public void aboutToNotify(OperationHistoryEvent event) {
+ // do nothing
+ }
+
+ protected IStatus okStatus() {
+ return Status.OK_STATUS;
+ }
+
+ protected IStatus failureStatus() {
+ return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, getLabel());
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UninstallOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UninstallOperation.java
deleted file mode 100644
index 2a18eb1fd..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UninstallOperation.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * 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.equinox.p2.ui.operations;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
-import org.eclipse.equinox.p2.ui.ProvisioningUtil;
-
-/**
- * An operation that uninstalls the specified IU's from the specified profile
- *
- * @since 3.4
- */
-public class UninstallOperation extends ProfileModificationOperation {
-
- private boolean installed = true;
-
- public UninstallOperation(String label, String profileID, IInstallableUnit[] ius) {
- super(label, profileID, ius);
- }
-
- protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- for (int i = 0; i < ius.length; i++) {
- if (entryPointName == null) {
- String prop = ius[i].getProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY);
- if (prop != null && Boolean.valueOf(prop).booleanValue()) {
- entryPointName = ius[i].getProperty(IInstallableUnitConstants.NAME);
- }
- } else {
- break;
- }
- }
- IStatus status = ProvisioningUtil.uninstall(ius, getProfiles()[0], monitor, uiInfo);
- if (status.isOK()) {
- installed = false;
- }
- return status;
- }
-
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- IStatus status = ProvisioningUtil.install(ius, entryPointName, getProfiles()[0], monitor, uiInfo);
- if (status.isOK()) {
- installed = true;
- }
- return status;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- */
- public boolean canExecute() {
- // TODO should make sure it's actually installed in the profile
- return isValid() && installed;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
- */
- public boolean canUndo() {
- return isValid() && !installed;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UpdateOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UpdateOperation.java
deleted file mode 100644
index 265f4faa5..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UpdateOperation.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * 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.equinox.p2.ui.operations;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvUIActivator;
-import org.eclipse.equinox.p2.ui.ProvisioningUtil;
-
-/**
- * An operation that installs the specified IU's into the specified profile
- *
- * @since 3.4
- */
-public class UpdateOperation extends ProfileModificationOperation {
-
- private IInstallableUnit[] replacementIUs;
-
- public UpdateOperation(String label, String profileID, IInstallableUnit[] toUpdate, IInstallableUnit[] replacements) {
- super(label, profileID, toUpdate);
- replacementIUs = replacements;
- }
-
- protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- return ProvisioningUtil.update(ius, replacementIUs, getProfiles()[0], monitor, uiInfo);
- }
-
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- // won't get called because canUndo() is currently false;
- return Status.OK_STATUS;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute()
- */
- public boolean canExecute() {
- return isValid();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.operations.AbstractOperation#canUndo()
- */
- // TODO this should be implemented as a rollback
- public boolean canUndo() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.commands.operations.IAdvancedUndoableOperation2#computeExecutionStatus(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus computeExecutionStatus(IProgressMonitor monitor) throws ExecutionException {
- if (replacementIUs == null) {
- try {
- replacementIUs = ProvisioningUtil.updatesFor(ius, getProfile(), monitor, null);
- } catch (ProvisionException e) {
- return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getLocalizedMessage(), e);
- }
- }
- if (replacementIUs.length > 0) {
- return okStatus();
- }
- return new Status(IStatus.INFO, ProvUIActivator.PLUGIN_ID, ProvUIMessages.UpdateOperation_NothingToUpdate);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/IOperationConfirmer.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUColumnConfig.java
index 3e0e4d21b..bf4d8cd4d 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/IOperationConfirmer.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUColumnConfig.java
@@ -8,25 +8,25 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.ui.operations;
-import org.eclipse.swt.widgets.Shell;
+package org.eclipse.equinox.p2.ui.viewers;
/**
- * Interface for confirming provisioning operations
+ * Data structure describing a column to be shown in an IU view.
*
* @since 3.4
*/
+public class IUColumnConfig {
+ public final static int COLUMN_ID = 0;
+ public final static int COLUMN_NAME = 1;
+ public final static int COLUMN_VERSION = 2;
+ public final static int COLUMN_SIZE = 3;
-public interface IOperationConfirmer {
- /**
- * Return a boolean indicating whether the operation should continue.
- *
- * @param op
- * the operation to be performed.
- * @param shell
- * the shell that should be used for prompting
- * @return a boolean indicating whether the operation should be performed.
- */
- public boolean continuePerformingOperation(ProvisioningOperation op, Shell shell);
-}
+ public String columnTitle;
+ public int columnField;
+
+ public IUColumnConfig(String title, int columnField) {
+ this.columnTitle = title;
+ this.columnField = columnField;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUDetailsLabelProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUDetailsLabelProvider.java
index 41dc031e5..b13e0c311 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUDetailsLabelProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUDetailsLabelProvider.java
@@ -30,37 +30,32 @@ import org.eclipse.swt.graphics.Image;
* @since 3.4
*/
public class IUDetailsLabelProvider extends LabelProvider implements ITableLabelProvider {
- public final static int COLUMN_ID = 0;
- public final static int COLUMN_NAME = 1;
- public final static int COLUMN_VERSION = 2;
- public final static int COLUMN_SIZE = 3;
-
final static int PRIMARY_COLUMN = 0;
final static String BLANK = ""; //$NON-NLS-1$
- private int[] columnConfig = ProvUI.getIUDetailsColumns();
+ private IUColumnConfig[] columnConfig = ProvUI.getIUColumnConfig();
public IUDetailsLabelProvider() {
// use default column config
}
- public IUDetailsLabelProvider(int[] columnConfig) {
+ public IUDetailsLabelProvider(IUColumnConfig[] columnConfig) {
Assert.isLegal(columnConfig.length > 0);
this.columnConfig = columnConfig;
}
public String getText(Object obj) {
- return getColumnText(obj, columnConfig[0]);
+ return getColumnText(obj, columnConfig[0].columnField);
}
public Image getImage(Object obj) {
- return getColumnImage(obj, columnConfig[0]);
+ return getColumnImage(obj, columnConfig[0].columnField);
}
public String getColumnText(Object element, int columnIndex) {
- int columnContent = COLUMN_ID;
- if (columnIndex <= columnConfig.length) {
- columnContent = columnConfig[columnIndex];
+ int columnContent = IUColumnConfig.COLUMN_ID;
+ if (columnIndex < columnConfig.length) {
+ columnContent = columnConfig[columnIndex].columnField;
}
IInstallableUnit iu = getIU(element);
@@ -68,16 +63,16 @@ public class IUDetailsLabelProvider extends LabelProvider implements ITableLabel
return BLANK;
switch (columnContent) {
- case COLUMN_ID :
+ case IUColumnConfig.COLUMN_ID :
return iu.getId();
- case COLUMN_NAME :
+ case IUColumnConfig.COLUMN_NAME :
String name = iu.getProperty(IInstallableUnitConstants.NAME);
if (name != null)
return name;
return BLANK;
- case COLUMN_VERSION :
+ case IUColumnConfig.COLUMN_VERSION :
return iu.getVersion().toString();
- case COLUMN_SIZE :
+ case IUColumnConfig.COLUMN_SIZE :
return getIUSize(element);
}
return BLANK;
@@ -99,8 +94,13 @@ public class IUDetailsLabelProvider extends LabelProvider implements ITableLabel
}
private String getIUSize(Object element) {
- if (element instanceof AvailableIUElement)
- return Integer.toString(((AvailableIUElement) element).getSize());
+ if (element instanceof AvailableIUElement) {
+ long size = ((AvailableIUElement) element).getSize();
+ if (size != AvailableIUElement.SIZE_UNKNOWN) {
+ // TODO should do something prettier here
+ return Long.toString(size);
+ }
+ }
return ProvUIMessages.IUDetailsLabelProvider_Unknown;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUProfilePropertyFilter.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUProfilePropertyFilter.java
new file mode 100644
index 000000000..d732a4492
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/IUProfilePropertyFilter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.equinox.p2.ui.viewers;
+
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+
+/**
+ * Viewer filter which shows only IUs that have a property matching
+ * the specified value.
+ *
+ * @since 3.4
+ */
+public class IUProfilePropertyFilter extends IUPropertyFilter {
+
+ public IUProfilePropertyFilter(String name, String value) {
+ super(name, value);
+ }
+
+ protected String getProperty(IInstallableUnit iu, Object parentElement, String key) {
+ if (parentElement instanceof Profile)
+ return ((Profile) parentElement).getInstallableUnitProfileProperty(iu, key);
+ return super.getProperty(iu, parentElement, key);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/InstallIUDropAdapter.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/InstallIUDropAdapter.java
index 83955b235..8a6cd7a78 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/InstallIUDropAdapter.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/InstallIUDropAdapter.java
@@ -18,7 +18,6 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.ProvUIActivator;
import org.eclipse.equinox.p2.ui.actions.InstallAction;
import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
-import org.eclipse.equinox.p2.ui.operations.IOperationConfirmer;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.dnd.*;
@@ -34,8 +33,6 @@ import org.eclipse.swt.widgets.Shell;
public class InstallIUDropAdapter extends ViewerDropAdapter {
static boolean DEBUG = false;
- private IOperationConfirmer confirmer;
- private int entryPointStrategy = InstallAction.ENTRYPOINT_FORCE;
/**
* Constructs a new drop adapter.
@@ -46,9 +43,8 @@ public class InstallIUDropAdapter extends ViewerDropAdapter {
* a confirmer that should be used to confirm the operation, or
* <code>null</code> if no confirmation is necessary.
*/
- public InstallIUDropAdapter(StructuredViewer viewer, IOperationConfirmer confirmer) {
+ public InstallIUDropAdapter(StructuredViewer viewer) {
super(viewer);
- this.confirmer = confirmer;
}
/**
@@ -147,8 +143,7 @@ public class InstallIUDropAdapter extends ViewerDropAdapter {
throw new UnsupportedOperationException("This ISelectionProvider is static, and cannot be modified."); //$NON-NLS-1$
}
};
- InstallAction action = new InstallAction(ProvUIMessages.Ops_InstallIUOperationLabel, selectionProvider, confirmer, profile, null, getShell());
- action.setEntryPointStrategy(entryPointStrategy);
+ InstallAction action = new InstallAction(selectionProvider, profile, null, getShell());
if (DEBUG)
System.out.println("Running install action"); //$NON-NLS-1$
action.run();
@@ -235,8 +230,4 @@ public class InstallIUDropAdapter extends ViewerDropAdapter {
}
return null;
}
-
- public void setEntryPointStrategy(int strategy) {
- entryPointStrategy = strategy;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/StructuredViewerProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/StructuredViewerProvisioningListener.java
index 76fa7ffce..b9f02b168 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/StructuredViewerProvisioningListener.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/StructuredViewerProvisioningListener.java
@@ -51,8 +51,10 @@ public class StructuredViewerProvisioningListener implements SynchronousProvisio
final Profile profile = event.getProfile();
display.asyncExec(new Runnable() {
public void run() {
- viewer.refresh(profile);
-
+ if (viewer.getInput() instanceof Profile)
+ viewer.refresh();
+ else
+ viewer.refresh(profile);
}
});
} else if (o instanceof ProfileEvent && ((eventTypes & PROV_EVENT_IU) == PROV_EVENT_IU)) {

Back to the top