Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java47
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AvailableIUViewQueryContext.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java148
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositories.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/Profiles.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/QueriedElementCollector.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/AvailableIUCollector.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/CategoryElementCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/IUProfilePropertyQuery.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/InstalledIUCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionElementCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/MetadataRepositoryElementCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/OtherIUVersionsCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/ProfileElementCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueriedElement.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/RollbackIUCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/UncategorizedElementCollector.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java33
24 files changed, 361 insertions, 152 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java
index 29e01bf7d..7d8ba8042 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java
@@ -14,6 +14,7 @@ import java.net.URL;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.director.IUProfilePropertyQuery;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery;
@@ -46,6 +47,12 @@ public class ProvAdminQueryProvider implements IQueryProvider {
public ElementQueryDescriptor getQueryDescriptor(Object element, int queryType) {
IQueryable queryable;
+ QueryContext queryContext = null;
+ // We don't currently use the query context to alter the query, but as soon as we do, we'll
+ // want to make sure it gets passed through to the appropriate elements. So
+ // we do that now.
+ if (element instanceof QueriedElement)
+ queryContext = ((QueriedElement) element).getQueryContext();
IPreferenceStore store = ProvAdminUIActivator.getDefault().getPreferenceStore();
boolean showGroupsOnly = store.getBoolean(PreferenceConstants.PREF_SHOW_GROUPS_ONLY);
boolean hideSystem = store.getBoolean(PreferenceConstants.PREF_HIDE_SYSTEM_REPOS);
@@ -71,22 +78,22 @@ public class ProvAdminQueryProvider implements IQueryProvider {
// Is it a rollback repository?
if (element instanceof RollbackRepositoryElement) {
Query profileQuery = new InstallableUnitQuery(((RollbackRepositoryElement) element).getProfileId());
- return new ElementQueryDescriptor(((RollbackRepositoryElement) element).getQueryable(), profileQuery, new AvailableIUCollector(this, ((RollbackRepositoryElement) element).getQueryable(), false));
+ return new ElementQueryDescriptor(((RollbackRepositoryElement) element).getQueryable(), profileQuery, new AvailableIUCollector(this, ((RollbackRepositoryElement) element).getQueryable(), queryContext, false));
}
// It is a regular repository.
// What should we show as a child of a repository?
if (element instanceof MetadataRepositoryElement) {
if (useCategories)
// We are using categories, group into categories first.
- return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), categoryQuery, new CategoryElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), true));
+ return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), categoryQuery, new CategoryElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), queryContext, true));
if (showGroupsOnly)
// Query all groups and use the query result to optionally select the latest version only
- return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), groupQuery, showLatest ? new LatestIUVersionElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), false) : new AvailableIUCollector(this, ((MetadataRepositoryElement) element).getQueryable(), false));
+ return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), groupQuery, showLatest ? new LatestIUVersionElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), queryContext, false) : new AvailableIUCollector(this, ((MetadataRepositoryElement) element).getQueryable(), queryContext, false));
if (showLatest)
// We are not querying groups, but we are showing the latest version only
- return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), allQuery, new LatestIUVersionElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), false));
+ return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), allQuery, new LatestIUVersionElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), queryContext, false));
// Show 'em all!
- return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), allQuery, new AvailableIUCollector(this, ((MetadataRepositoryElement) element).getQueryable(), false));
+ return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), allQuery, new AvailableIUCollector(this, ((MetadataRepositoryElement) element).getQueryable(), queryContext, false));
}
if (element instanceof MetadataRepositories) {
MetadataRepositories metaRepos = (MetadataRepositories) element;
@@ -96,15 +103,15 @@ public class ProvAdminQueryProvider implements IQueryProvider {
queryable = new QueryableMetadataRepositoryManager(IMetadataRepositoryManager.REPOSITORIES_NON_SYSTEM);
if (useCategories)
// We are using categories, group into categories first.
- return new ElementQueryDescriptor(queryable, categoryQuery, new CategoryElementCollector(this, queryable, true));
+ return new ElementQueryDescriptor(queryable, categoryQuery, new CategoryElementCollector(this, queryable, queryContext, true));
if (showGroupsOnly)
// Query all groups and use the query result to optionally select the latest version only
- return new ElementQueryDescriptor(queryable, groupQuery, showLatest ? new LatestIUVersionElementCollector(this, queryable, false) : new AvailableIUCollector(this, queryable, false));
+ return new ElementQueryDescriptor(queryable, groupQuery, showLatest ? new LatestIUVersionElementCollector(this, queryable, queryContext, false) : new AvailableIUCollector(this, queryable, queryContext, false));
if (showLatest)
// We are not querying groups, but we are showing the latest version only
- return new ElementQueryDescriptor(queryable, allQuery, new LatestIUVersionElementCollector(this, queryable, false));
+ return new ElementQueryDescriptor(queryable, allQuery, new LatestIUVersionElementCollector(this, queryable, queryContext, false));
// Show 'em all!
- return new ElementQueryDescriptor(queryable, allQuery, new AvailableIUCollector(this, queryable, false));
+ return new ElementQueryDescriptor(queryable, allQuery, new AvailableIUCollector(this, queryable, queryContext, false));
}
// Things have been grouped by category, now what?
// Handle uncategorized elements first
@@ -115,25 +122,25 @@ public class ProvAdminQueryProvider implements IQueryProvider {
if (showGroupsOnly)
firstPassQuery = new CompoundQuery(new Query[] {groupQuery, categoryQuery}, false);
queryable = ((UncategorizedCategoryElement) element).getQueryable();
- Collector collector = showLatest ? new LatestIUVersionElementCollector(this, queryable, false) : new AvailableIUCollector(this, queryable, false);
- return new ElementQueryDescriptor(queryable, firstPassQuery, new UncategorizedElementCollector(this, queryable, collector));
+ Collector collector = showLatest ? new LatestIUVersionElementCollector(this, queryable, queryContext, false) : new AvailableIUCollector(this, queryable, queryContext, false);
+ return new ElementQueryDescriptor(queryable, firstPassQuery, new UncategorizedElementCollector(this, queryable, queryContext, collector));
}
if (element instanceof CategoryElement) {
Query membersOfCategoryQuery = new AnyRequiredCapabilityQuery(((CategoryElement) element).getRequirements());
if (showGroupsOnly)
// Query all groups and use the query result to optionally select the latest version only
- return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), new CompoundQuery(new Query[] {new CompoundQuery(new Query[] {groupQuery, categoryQuery}, false), membersOfCategoryQuery}, true), showLatest ? new LatestIUVersionElementCollector(this, ((CategoryElement) element).getQueryable(), true) : new AvailableIUCollector(this, ((CategoryElement) element).getQueryable(), true));
+ return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), new CompoundQuery(new Query[] {new CompoundQuery(new Query[] {groupQuery, categoryQuery}, false), membersOfCategoryQuery}, true), showLatest ? new LatestIUVersionElementCollector(this, ((CategoryElement) element).getQueryable(), queryContext, true) : new AvailableIUCollector(this, ((CategoryElement) element).getQueryable(), queryContext, true));
if (showLatest)
// We are not querying groups, but we are showing the latest version only
- return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), membersOfCategoryQuery, new LatestIUVersionElementCollector(this, ((CategoryElement) element).getQueryable(), true));
+ return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), membersOfCategoryQuery, new LatestIUVersionElementCollector(this, ((CategoryElement) element).getQueryable(), queryContext, true));
// Show 'em all!
- return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), membersOfCategoryQuery, new AvailableIUCollector(this, ((CategoryElement) element).getQueryable(), true));
+ return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), membersOfCategoryQuery, new AvailableIUCollector(this, ((CategoryElement) element).getQueryable(), queryContext, true));
}
// We've already collapsed all versions, show the rest
if (element instanceof IUVersionsElement) {
IInstallableUnit iu = ((IUVersionsElement) element).getIU();
- return new ElementQueryDescriptor(((IUVersionsElement) element).getQueryable(), new InstallableUnitQuery(iu.getId()), new OtherIUVersionsCollector(iu, this, ((IUVersionsElement) element).getQueryable()));
+ return new ElementQueryDescriptor(((IUVersionsElement) element).getQueryable(), new InstallableUnitQuery(iu.getId()), new OtherIUVersionsCollector(iu, this, ((IUVersionsElement) element).getQueryable(), queryContext));
}
case IQueryProvider.AVAILABLE_UPDATES :
profile = (IProfile) ProvUI.getAdapter(element, IProfile.class);
@@ -154,7 +161,7 @@ public class ProvAdminQueryProvider implements IQueryProvider {
return null;
QueryableUpdates updateQueryable = new QueryableUpdates(toUpdate);
if (showLatest)
- collector = new LatestIUVersionCollector(this, updateQueryable, useCategories);
+ collector = new LatestIUVersionCollector(this, updateQueryable, queryContext, useCategories);
else
collector = new Collector();
return new ElementQueryDescriptor(updateQueryable, allQuery, collector);
@@ -165,8 +172,8 @@ public class ProvAdminQueryProvider implements IQueryProvider {
else
query = allQuery;
if (showGroupsOnly)
- return new ElementQueryDescriptor(profile, new CompoundQuery(new Query[] {groupQuery, query}, true), new InstalledIUCollector(this, profile));
- return new ElementQueryDescriptor(profile, query, new InstalledIUCollector(this, profile));
+ return new ElementQueryDescriptor(profile, new CompoundQuery(new Query[] {groupQuery, query}, true), new InstalledIUCollector(this, profile, queryContext));
+ return new ElementQueryDescriptor(profile, query, new InstalledIUCollector(this, profile, queryContext));
case IQueryProvider.METADATA_REPOS :
if (element instanceof MetadataRepositories) {
MetadataRepositories metaRepos = (MetadataRepositories) element;
@@ -176,14 +183,14 @@ public class ProvAdminQueryProvider implements IQueryProvider {
queryable = new QueryableMetadataRepositoryManager(hideSystem ? IMetadataRepositoryManager.REPOSITORIES_NON_SYSTEM : IMetadataRepositoryManager.REPOSITORIES_ALL);
} else
queryable = new QueryableMetadataRepositoryManager(hideSystem ? IMetadataRepositoryManager.REPOSITORIES_NON_SYSTEM : IMetadataRepositoryManager.REPOSITORIES_ALL);
- return new ElementQueryDescriptor(queryable, null, new MetadataRepositoryElementCollector(this));
+ return new ElementQueryDescriptor(queryable, null, new MetadataRepositoryElementCollector(this, queryContext));
case IQueryProvider.PROFILES :
queryable = new QueryableProfileRegistry();
return new ElementQueryDescriptor(queryable, new Query() {
public boolean isMatch(Object candidate) {
return ProvUI.getAdapter(candidate, IProfile.class) != null;
}
- }, new ProfileElementCollector(this, null));
+ }, new ProfileElementCollector(this, null, queryContext));
default :
return null;
}
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 c61ce0351..f7e2c2f91 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
@@ -154,7 +154,6 @@ abstract class ProvView extends ViewPart {
protected void addListeners() {
IPreferenceStore store = ProvAdminUIActivator.getDefault().getPreferenceStore();
preferenceListener = new IPropertyChangeListener() {
-
public void propertyChange(PropertyChangeEvent event) {
if (getVisualProperties().contains(event.getProperty())) {
ProvView.this.refreshAll();
@@ -163,7 +162,6 @@ abstract class ProvView extends ViewPart {
};
store.addPropertyChangeListener(preferenceListener);
-
}
protected void removeListeners() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AvailableIUViewQueryContext.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AvailableIUViewQueryContext.java
index 21cfdb032..024867cba 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AvailableIUViewQueryContext.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AvailableIUViewQueryContext.java
@@ -24,6 +24,14 @@ public class AvailableIUViewQueryContext extends QueryContext {
// Default to repo as this provides the fastest information
private int view = VIEW_BY_REPO;
+ // Whether to show latest versions only, defaults to
+ // true. Clients typically use a pref setting or dialog
+ // setting to initialize
+ private boolean showLatestVersionsOnly = true;
+ // Whether to hide things that are already installed
+ // Defaults to false since we wouldn't know what profile to use
+ private boolean hideAlreadyInstalled = false;
+ private String profileId = null;
public AvailableIUViewQueryContext(int viewType) {
this.view = viewType;
@@ -45,4 +53,29 @@ public class AvailableIUViewQueryContext extends QueryContext {
public void setViewType(int viewType) {
view = viewType;
}
+
+ public boolean getShowLatestVersionsOnly() {
+ return showLatestVersionsOnly;
+ }
+
+ public void setShowLatestVersionsOnly(boolean showLatest) {
+ showLatestVersionsOnly = showLatest;
+ }
+
+ public void hideAlreadyInstalled(String installedProfileId) {
+ profileId = installedProfileId;
+ hideAlreadyInstalled = true;
+ }
+
+ public void showAlreadyInstalled() {
+ hideAlreadyInstalled = false;
+ }
+
+ public boolean getHideAlreadyInstalled() {
+ return hideAlreadyInstalled;
+ }
+
+ public String getInstalledProfileId() {
+ return profileId;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
index f964d8d1f..83dcbf87f 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
@@ -65,6 +65,8 @@ public class ProvSDKMessages extends NLS {
public static String UpdateAndInstallDialog_Title;
public static String UpdateAndInstallDialog_Properties;
public static String UpdateAndInstallDialog_Refresh;
+ public static String UpdateAndInstallDialog_ShowAlreadyInstalledItems;
+ public static String UpdateAndInstallDialog_ShowLatestVersionsOnly;
public static String UpdateAndInstallDialog_ViewByCategory;
public static String UpdateAndInstallDialog_ViewByName;
public static String UpdateAndInstallDialog_ViewBySite;
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java
index 200c8adce..bd826e1ec 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java
@@ -46,6 +46,9 @@ public class ProvSDKQueryProvider implements IQueryProvider {
public ElementQueryDescriptor getQueryDescriptor(Object element, int queryType) {
IQueryable queryable;
+ QueryContext queryContext = null;
+ if (element instanceof QueriedElement)
+ queryContext = ((QueriedElement) element).getQueryContext();
boolean showLatest = ProvSDKUIActivator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION);
switch (queryType) {
case IQueryProvider.ARTIFACT_REPOS :
@@ -58,12 +61,38 @@ public class ProvSDKQueryProvider implements IQueryProvider {
}
});
case IQueryProvider.AVAILABLE_IUS :
+ // Things get more complicated if the user wants to filter out installed items.
+ // This involves setting up a secondary query for installed content that the various
+ // collectors will use to reject content. We can't use a compound query because the
+ // queryables are different (profile for installed content, repo for available content)
+ AvailableIUViewQueryContext availableViewQueryContext = null;
+ AvailableIUCollector availableIUCollector;
+ boolean hideInstalled = false;
+ ElementQueryDescriptor installedQueryDescriptor = null;
+ if (queryContext instanceof AvailableIUViewQueryContext) {
+ availableViewQueryContext = (AvailableIUViewQueryContext) ((QueriedElement) element).getQueryContext();
+ showLatest = availableViewQueryContext.getShowLatestVersionsOnly();
+ hideInstalled = availableViewQueryContext.getHideAlreadyInstalled();
+ String profileId = availableViewQueryContext.getInstalledProfileId();
+ if (hideInstalled && profileId != null) {
+ try {
+ IProfile profile = ProvisioningUtil.getProfile(profileId);
+ installedQueryDescriptor = new ElementQueryDescriptor(profile, new IUProfilePropertyByIdQuery(profile.getProfileId(), IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)), new Collector());
+ } catch (ProvisionException e) {
+ // just bail out, we won't try to query the installed
+ installedQueryDescriptor = null;
+ }
+ }
+ }
// Showing children of a rollback element
if (element instanceof RollbackRepositoryElement) {
Query profileIdQuery = new InstallableUnitQuery(((RollbackRepositoryElement) element).getProfileId());
Query rollbackIUQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_PROFILE, Boolean.toString(true));
- return new ElementQueryDescriptor(((RollbackRepositoryElement) element).getQueryable(), new CompoundQuery(new Query[] {profileIdQuery, rollbackIUQuery}, true), new RollbackIUCollector(this, ((RollbackRepositoryElement) element).getQueryable()));
+ availableIUCollector = new RollbackIUCollector(this, ((RollbackRepositoryElement) element).getQueryable(), queryContext);
+ if (hideInstalled && installedQueryDescriptor != null)
+ availableIUCollector.hideInstalledIUs(installedQueryDescriptor);
+ return new ElementQueryDescriptor(((RollbackRepositoryElement) element).getQueryable(), new CompoundQuery(new Query[] {profileIdQuery, rollbackIUQuery}, true), availableIUCollector);
}
Query groupQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_GROUP, Boolean.TRUE.toString());
@@ -77,24 +106,26 @@ public class ProvSDKQueryProvider implements IQueryProvider {
else
queryable = new QueryableMetadataRepositoryManager(IMetadataRepositoryManager.REPOSITORIES_NON_SYSTEM);
- if (metaRepos.getQueryContext() != null && metaRepos.getQueryContext() instanceof AvailableIUViewQueryContext) {
- AvailableIUViewQueryContext context = (AvailableIUViewQueryContext) metaRepos.getQueryContext();
- if (context.getViewType() == AvailableIUViewQueryContext.VIEW_FLAT) {
- Collector collector;
+ if (availableViewQueryContext != null) {
+ if (availableViewQueryContext.getViewType() == AvailableIUViewQueryContext.VIEW_FLAT) {
+ AvailableIUCollector collector;
if (showLatest)
- collector = new LatestIUVersionElementCollector(this, queryable, true);
+ collector = new LatestIUVersionElementCollector(this, queryable, queryContext, true);
else
- collector = new AvailableIUCollector(this, queryable, true);
+ collector = new AvailableIUCollector(this, queryable, queryContext, true);
+ if (hideInstalled && installedQueryDescriptor != null)
+ collector.hideInstalledIUs(installedQueryDescriptor);
return new ElementQueryDescriptor(queryable, groupQuery, collector);
}
}
- // If there is no query context, assume by category
- return new ElementQueryDescriptor(queryable, categoryQuery, new CategoryElementCollector(this, queryable, true));
+ // Assume category view if it wasn't flat or if there was no query context at all.
+ // Installed content not a concern for collecting categories
+ return new ElementQueryDescriptor(queryable, categoryQuery, new CategoryElementCollector(this, queryable, queryContext, true));
}
- // Showing children of a repository
+ // Showing children of a repository. We always show categories, no concern for filtering installed content
if (element instanceof MetadataRepositoryElement) {
- return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), categoryQuery, new CategoryElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), true));
+ return new ElementQueryDescriptor(((MetadataRepositoryElement) element).getQueryable(), categoryQuery, new CategoryElementCollector(this, ((MetadataRepositoryElement) element).getQueryable(), queryContext, true));
}
// Showing children of categories
@@ -103,18 +134,21 @@ public class ProvSDKQueryProvider implements IQueryProvider {
// Will have to look at all categories and groups and from there, figure out what's left
Query firstPassQuery = new CompoundQuery(new Query[] {groupQuery, categoryQuery}, false);
queryable = ((UncategorizedCategoryElement) element).getQueryable();
- Collector collector = showLatest ? new LatestIUVersionElementCollector(this, queryable, false) : new AvailableIUCollector(this, queryable, false);
- return new ElementQueryDescriptor(queryable, firstPassQuery, new UncategorizedElementCollector(this, queryable, collector));
+ availableIUCollector = showLatest ? new LatestIUVersionElementCollector(this, queryable, queryContext, false) : new AvailableIUCollector(this, queryable, queryContext, false);
+ if (hideInstalled && installedQueryDescriptor != null)
+ availableIUCollector.hideInstalledIUs(installedQueryDescriptor);
+ return new ElementQueryDescriptor(queryable, firstPassQuery, new UncategorizedElementCollector(this, queryable, queryContext, availableIUCollector));
}
if (element instanceof CategoryElement) {
Query membersOfCategoryQuery = new AnyRequiredCapabilityQuery(((CategoryElement) element).getRequirements());
- Collector collector;
if (showLatest)
- collector = new LatestIUVersionElementCollector(this, ((CategoryElement) element).getQueryable(), true);
+ availableIUCollector = new LatestIUVersionElementCollector(this, ((CategoryElement) element).getQueryable(), queryContext, true);
else
- collector = new AvailableIUCollector(this, ((CategoryElement) element).getQueryable(), true);
- return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), new CompoundQuery(new Query[] {new CompoundQuery(new Query[] {groupQuery, categoryQuery}, false), membersOfCategoryQuery}, true), collector);
+ availableIUCollector = new AvailableIUCollector(this, ((CategoryElement) element).getQueryable(), queryContext, true);
+ if (hideInstalled && installedQueryDescriptor != null)
+ availableIUCollector.hideInstalledIUs(installedQueryDescriptor);
+ return new ElementQueryDescriptor(((CategoryElement) element).getQueryable(), new CompoundQuery(new Query[] {new CompoundQuery(new Query[] {groupQuery, categoryQuery}, false), membersOfCategoryQuery}, true), availableIUCollector);
}
// If we are showing only the latest version, we never represent other versions as children.
if (element instanceof IUVersionsElement) {
@@ -125,7 +159,7 @@ public class ProvSDKQueryProvider implements IQueryProvider {
IInstallableUnit[] toUpdate;
Collector collector;
if (profile != null) {
- collector = profile.query(new IUProfilePropertyQuery(profile, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)), new Collector(), null);
+ collector = profile.query(new IUProfilePropertyByIdQuery(profile.getProfileId(), IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)), new Collector(), null);
toUpdate = (IInstallableUnit[]) collector.toArray(IInstallableUnit.class);
} else if (element instanceof UpdateEvent) {
try {
@@ -139,13 +173,13 @@ public class ProvSDKQueryProvider implements IQueryProvider {
return null;
QueryableUpdates updateQueryable = new QueryableUpdates(toUpdate);
if (showLatest)
- collector = new LatestIUVersionCollector(this, updateQueryable, true);
+ collector = new LatestIUVersionCollector(this, updateQueryable, queryContext, true);
else
collector = new Collector();
return new ElementQueryDescriptor(updateQueryable, allQuery, collector);
case IQueryProvider.INSTALLED_IUS :
profile = (IProfile) ProvUI.getAdapter(element, IProfile.class);
- return new ElementQueryDescriptor(profile, new IUProfilePropertyQuery(profile, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)), new InstalledIUCollector(this, profile));
+ return new ElementQueryDescriptor(profile, new IUProfilePropertyByIdQuery(profile.getProfileId(), IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)), new InstalledIUCollector(this, profile, queryContext));
case IQueryProvider.METADATA_REPOS :
if (element instanceof MetadataRepositories) {
MetadataRepositories metaRepos = (MetadataRepositories) element;
@@ -156,14 +190,14 @@ public class ProvSDKQueryProvider implements IQueryProvider {
metaRepos.setQueryable(queryable);
} else
queryable = new QueryableMetadataRepositoryManager(IMetadataRepositoryManager.REPOSITORIES_NON_SYSTEM);
- return new ElementQueryDescriptor(queryable, null, new MetadataRepositoryElementCollector(this));
+ return new ElementQueryDescriptor(queryable, null, new MetadataRepositoryElementCollector(this, queryContext));
case IQueryProvider.PROFILES :
queryable = new QueryableProfileRegistry();
return new ElementQueryDescriptor(queryable, new Query() {
public boolean isMatch(Object candidate) {
return ProvUI.getAdapter(candidate, IProfile.class) != null;
}
- }, new ProfileElementCollector(this, null));
+ }, new ProfileElementCollector(this, null, queryContext));
default :
return null;
}
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 b0675479c..989d64fef 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
@@ -25,6 +25,7 @@ import org.eclipse.equinox.internal.provisional.p2.ui.operations.*;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
import org.eclipse.equinox.internal.provisional.p2.ui.sdk.ProvPolicies;
import org.eclipse.equinox.internal.provisional.p2.ui.sdk.RepositoryManipulationDialog;
+import org.eclipse.equinox.internal.provisional.p2.ui.viewers.StructuredViewerProvisioningListener;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
@@ -56,12 +57,16 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
private static final String BUTTONACTION = "buttonAction"; //$NON-NLS-1$
private static final int DEFAULT_HEIGHT = 240;
private static final int DEFAULT_WIDTH = 300;
+ private static final int CHAR_INDENT = 5;
+ private static final int VERTICAL_MARGIN_DLU = 2;
private static final int DEFAULT_VIEW_TYPE = AvailableIUViewQueryContext.VIEW_BY_REPO;
private static final int INDEX_INSTALLED = 0;
private static final int INDEX_AVAILABLE = 1;
private static final String DIALOG_SETTINGS_SECTION = "UpdateAndInstallDialog"; //$NON-NLS-1$
private static final String SELECTED_TAB_SETTING = "SelectedTab"; //$NON-NLS-1$
private static final String AVAILABLE_VIEW_TYPE = "AvailableViewType"; //$NON-NLS-1$
+ private static final String SHOW_LATEST_VERSIONS_ONLY = "ShowLatestVersionsOnly"; //$NON-NLS-1$
+ private static final String HIDE_INSTALLED_IUS = "HideInstalledContent"; //$NON-NLS-1$
String profileId;
Display display;
@@ -72,10 +77,12 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
IRepositoryManipulator repositoryManipulator;
ChangeViewAction viewByRepo, viewFlat, viewCategory;
Button installedPropButton, availablePropButton, installButton, uninstallButton, updateButton, revertButton, manipulateRepoButton, addRepoButton, removeRepoButton;
+ Button showInstalledCheckbox, showLatestVersionsCheckbox;
ProgressIndicator progressIndicator;
Label progressLabel;
IPropertyChangeListener preferenceListener;
IJobChangeListener progressListener;
+ StructuredViewerProvisioningListener profileListener;
private class ChangeViewAction extends Action {
int viewType;
@@ -156,10 +163,18 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
});
updatePrefsLink.setText(ProvSDKMessages.UpdateAndInstallDialog_PrefLink);
createProgressArea(comp);
+ initializeWidgetState();
Dialog.applyDialogFont(comp);
return comp;
}
+ private void initializeWidgetState() {
+ // Set widgets according to query context
+ showInstalledCheckbox.setSelection(!queryContext.getHideAlreadyInstalled());
+ showLatestVersionsCheckbox.setSelection(queryContext.getShowLatestVersionsOnly());
+
+ }
+
private void createTabFolder(Composite parent) {
// tab folder
@@ -309,7 +324,10 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
- layout.marginHeight = 0;
+ layout.marginTop = 0;
+ // breathing room underneath last checkboxes
+ layout.marginBottom = convertVerticalDLUsToPixels(VERTICAL_MARGIN_DLU);
+
composite.setLayout(layout);
// Now the available group
@@ -318,6 +336,7 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
// Vertical buttons
Composite vButtonBar = (Composite) createAvailableIUsVerticalButtonBar(composite);
GridData data = new GridData(GridData.FILL_VERTICAL);
+ data.verticalIndent = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_BAR_HEIGHT);
vButtonBar.setLayoutData(data);
// Must be done after buttons are created so that the buttons can
@@ -327,9 +346,69 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
validateAvailableIUButtons();
}
});
+
+ // We might need to adjust the content of this viewer according to installation
+ // changes. We want to be very selective about refreshing.
+ profileListener = new StructuredViewerProvisioningListener(availableIUGroup.getStructuredViewer(), StructuredViewerProvisioningListener.PROV_EVENT_PROFILE, ProvSDKUIActivator.getDefault().getQueryProvider()) {
+ protected void profileAdded(String id) {
+ // do nothing
+ }
+
+ protected void profileRemoved(String id) {
+ // do nothing
+ }
+
+ protected void profileChanged(String id) {
+ if (id.equals(profileId)) {
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (isClosing())
+ return;
+ if (!showInstalledCheckbox.getSelection())
+ refreshAll();
+ }
+ });
+ }
+ }
+ };
+ ProvUI.addProvisioningListener(profileListener);
+
availableIUGroup.setUseBoldFontForFilteredItems(queryContext.getViewType() != AvailableIUViewQueryContext.VIEW_FLAT);
setDropTarget(availableIUGroup.getStructuredViewer().getControl());
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ gd.horizontalIndent = convertWidthInCharsToPixels(CHAR_INDENT);
+ gd.verticalIndent = convertVerticalDLUsToPixels(VERTICAL_MARGIN_DLU);
+ showLatestVersionsCheckbox = new Button(composite, SWT.CHECK);
+ showLatestVersionsCheckbox.setText(ProvSDKMessages.UpdateAndInstallDialog_ShowLatestVersionsOnly);
+ showLatestVersionsCheckbox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateAvailableViewState();
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ updateAvailableViewState();
+ }
+ });
+ showLatestVersionsCheckbox.setLayoutData(gd);
+
+ showInstalledCheckbox = new Button(composite, SWT.CHECK);
+ showInstalledCheckbox.setText(ProvSDKMessages.UpdateAndInstallDialog_ShowAlreadyInstalledItems);
+ showInstalledCheckbox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateAvailableViewState();
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ updateAvailableViewState();
+ }
+ });
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 2;
+ gd.horizontalIndent = convertWidthInCharsToPixels(CHAR_INDENT);
+ showInstalledCheckbox.setLayoutData(gd);
+
validateAvailableIUButtons();
return composite;
}
@@ -395,9 +474,12 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
parent.setRedraw(false);
validateAvailableIUButtons();
availableIUGroup.setUseBoldFontForFilteredItems(queryContext.getViewType() != AvailableIUViewQueryContext.VIEW_FLAT);
- // This triggers the viewer refresh
+ queryContext.setShowLatestVersionsOnly(showLatestVersionsCheckbox.getSelection());
+ if (showInstalledCheckbox.getSelection())
+ queryContext.showAlreadyInstalled();
+ else
+ queryContext.hideAlreadyInstalled(profileId);
availableIUGroup.setQueryContext(queryContext);
-
parent.layout(true);
parent.setRedraw(true);
}
@@ -434,6 +516,7 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
// Vertical buttons
Composite vButtonBar = (Composite) createInstalledIUsVerticalButtonBar(composite, ProvSDKUIActivator.getDefault().getQueryProvider());
GridData data = new GridData(GridData.FILL_VERTICAL);
+ data.verticalIndent = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_BAR_HEIGHT);
vButtonBar.setLayoutData(data);
// Must be done after buttons are created so that the buttons can
@@ -587,29 +670,44 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
}
private void readDialogSettings() {
+ if (tabFolder == null || tabFolder.isDisposed())
+ return;
+
+ // Initialize the query context using defaults and pref values
+ queryContext = new AvailableIUViewQueryContext(DEFAULT_VIEW_TYPE);
+ IPreferenceStore store = ProvSDKUIActivator.getDefault().getPreferenceStore();
+ queryContext.setShowLatestVersionsOnly(store.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION));
+ queryContext.hideAlreadyInstalled(profileId);
+
+ // Now refine it based on the dialog settings
IDialogSettings settings = ProvSDKUIActivator.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
if (section != null) {
- if (tabFolder != null && !tabFolder.isDisposed()) {
- int tab = 0;
- if (section.get(SELECTED_TAB_SETTING) != null)
- tab = section.getInt(SELECTED_TAB_SETTING);
- tabFolder.setSelection(tab);
-
- int viewType = DEFAULT_VIEW_TYPE;
- try {
- if (section.get(AVAILABLE_VIEW_TYPE) != null)
- viewType = section.getInt(AVAILABLE_VIEW_TYPE);
- queryContext = new AvailableIUViewQueryContext(viewType);
- } catch (NumberFormatException e) {
- // Ignore if there actually was a value that didn't parse.
- // We'll get a default query context below.
- }
+ // Default selected tab
+ int tab = 0;
+ if (section.get(SELECTED_TAB_SETTING) != null)
+ tab = section.getInt(SELECTED_TAB_SETTING);
+ tabFolder.setSelection(tab);
+
+ // View by...
+ try {
+ if (section.get(AVAILABLE_VIEW_TYPE) != null)
+ queryContext.setViewType(section.getInt(AVAILABLE_VIEW_TYPE));
+ } catch (NumberFormatException e) {
+ // Ignore if there actually was a value that didn't parse.
+ // We'll get a default query context below.
}
- }
- // If we did not find a setting for the query context, use a default
- if (queryContext == null) {
- queryContext = new AvailableIUViewQueryContext(DEFAULT_VIEW_TYPE);
+
+ // Show latest versions
+ if (section.get(SHOW_LATEST_VERSIONS_ONLY) != null)
+ queryContext.setShowLatestVersionsOnly(section.getBoolean(SHOW_LATEST_VERSIONS_ONLY));
+
+ // Hide installed content
+ boolean hideContent = section.getBoolean(HIDE_INSTALLED_IUS);
+ if (hideContent)
+ queryContext.hideAlreadyInstalled(profileId);
+ else
+ queryContext.showAlreadyInstalled();
}
}
@@ -617,6 +715,8 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
if (!tabFolder.isDisposed()) {
getDialogBoundsSettings().put(SELECTED_TAB_SETTING, tabFolder.getSelectionIndex());
getDialogBoundsSettings().put(AVAILABLE_VIEW_TYPE, queryContext.getViewType());
+ getDialogBoundsSettings().put(SHOW_LATEST_VERSIONS_ONLY, showLatestVersionsCheckbox.getSelection());
+ getDialogBoundsSettings().put(HIDE_INSTALLED_IUS, !showInstalledCheckbox.getSelection());
}
}
@@ -688,6 +788,10 @@ public class UpdateAndInstallDialog extends TrayDialog implements IViewMenuProvi
ProvisioningOperationRunner.removeJobChangeListener(progressListener);
progressListener = null;
}
+ if (profileListener != null) {
+ ProvUI.removeProvisioningListener(profileListener);
+ profileListener = null;
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
index 375445729..4a6fea6a9 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
@@ -40,6 +40,8 @@ UpdateAndInstallDialog_RemoveSiteOperationLabel=Remove Site
UpdateAndInstallDialog_RevertActionLabel=&Revert configuration...
UpdateAndInstallDialog_Properties=&Properties...
UpdateAndInstallDialog_Refresh=&Refresh
+UpdateAndInstallDialog_ShowAlreadyInstalledItems=Incl&ude items that have already been installed
+UpdateAndInstallDialog_ShowLatestVersionsOnly=Show only the &latest versions of available software
UpdateAndInstallDialog_ViewByCategory=&Category
UpdateAndInstallDialog_ViewByName=&Name
UpdateAndInstallDialog_ViewBySite=&Site
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java
index fab028dd2..71e3538ab 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/AvailableIUGroup.java
@@ -27,6 +27,7 @@ import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories
import org.eclipse.equinox.internal.provisional.p2.ui.model.RepositoryElement;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.*;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
+import org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement;
import org.eclipse.equinox.internal.provisional.p2.ui.query.QueryContext;
import org.eclipse.equinox.internal.provisional.p2.ui.viewers.*;
import org.eclipse.jface.viewers.*;
@@ -140,7 +141,7 @@ public class AvailableIUGroup extends StructuredIUGroup {
filteredTree.contentProviderSet(contentProvider);
// Input last.
- availableIUViewer.setInput(getInput());
+ availableIUViewer.setInput(getNewInput());
final StructuredViewerProvisioningListener listener = new StructuredViewerProvisioningListener(availableIUViewer, StructuredViewerProvisioningListener.PROV_EVENT_METADATA_REPOSITORY, getQueryProvider()) {
protected void repositoryAdded(final RepositoryEvent event) {
@@ -176,7 +177,7 @@ public class AvailableIUGroup extends StructuredIUGroup {
}
}
- Object getInput() {
+ Object getNewInput() {
MetadataRepositories input = new MetadataRepositories(getProvisioningContext().getMetadataRepositories());
input.setQueryContext(queryContext);
input.setQueryProvider(getQueryProvider());
@@ -184,14 +185,20 @@ public class AvailableIUGroup extends StructuredIUGroup {
}
/**
- * Set the query context to be used to traverse the model in this view. If the viewer has
- * already been created, reset the input with the new information.
- * @param context the query context
+ * Set the query context to be used to traverse the model in this view.
+ * If the viewer has been created and the input element honors the query
+ * context, refresh the viewer.
*/
public void setQueryContext(QueryContext context) {
this.queryContext = context;
- if (getStructuredViewer() != null)
- getStructuredViewer().setInput(getInput());
+ if (getStructuredViewer() == null)
+ return;
+
+ Object input = getStructuredViewer().getInput();
+ if (input instanceof QueriedElement) {
+ ((QueriedElement) input).setQueryContext(context);
+ getStructuredViewer().refresh();
+ }
}
public void setRepositoryRefreshFlags(int flags) {
@@ -250,8 +257,9 @@ public class AvailableIUGroup extends StructuredIUGroup {
else
op = new RefreshMetadataRepositoriesOperation(ProvUIMessages.AvailableIUGroup_RefreshOperationLabel, urls);
ProvisioningOperationRunner.schedule(op, getShell(), StatusManager.SHOW | StatusManager.LOG);
- // Calling this will create a new input and refresh the viewer
- setQueryContext(queryContext);
+ StructuredViewer v = getStructuredViewer();
+ if (v != null && !v.getControl().isDisposed())
+ v.setInput(getNewInput());
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositories.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositories.java
index 55f4f97f5..0edf082ad 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositories.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositories.java
@@ -38,6 +38,19 @@ public class MetadataRepositories extends RemoteQueriedElement {
this.metadataRepositories = metadataRepositories;
}
+ /*
+ * Overridden to check the query context. We might
+ * be showing repositories, or we might be flattening the
+ * view to some other element
+ * (non-Javadoc)
+ * @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement#getQueryType()
+ */
+ protected int getQueryType() {
+ if (queryContext == null)
+ return getDefaultQueryType();
+ return queryContext.getQueryType();
+ }
+
protected int getDefaultQueryType() {
return IQueryProvider.METADATA_REPOS;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/Profiles.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/Profiles.java
index cce06f2bd..36499e4e9 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/Profiles.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/Profiles.java
@@ -37,10 +37,6 @@ public class Profiles extends QueriedElement {
return null;
}
- protected int getQueryType() {
- return IQueryProvider.PROFILES;
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
@@ -53,8 +49,7 @@ public class Profiles extends QueriedElement {
* @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement#getDefaultQueryType()
*/
protected int getDefaultQueryType() {
- // TODO Auto-generated method stub
- return 0;
+ return IQueryProvider.PROFILES;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/QueriedElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/QueriedElementCollector.java
index 70bc6b91e..e442dfe35 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/QueriedElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/QueriedElementCollector.java
@@ -14,6 +14,7 @@ import org.eclipse.equinox.internal.provisional.p2.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
import org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement;
+import org.eclipse.equinox.internal.provisional.p2.ui.query.QueryContext;
/**
* Collector that assigns a query provider and the queryable
@@ -26,10 +27,12 @@ public class QueriedElementCollector extends Collector {
protected IQueryProvider queryProvider;
protected IQueryable queryable;
+ protected QueryContext queryContext;
- public QueriedElementCollector(IQueryProvider queryProvider, IQueryable queryable) {
+ public QueriedElementCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext) {
this.queryProvider = queryProvider;
this.queryable = queryable;
+ this.queryContext = queryContext;
}
/**
@@ -46,6 +49,8 @@ public class QueriedElementCollector extends Collector {
if (!element.knowsQueryable()) {
element.setQueryable(queryable);
}
+ if (element.getQueryContext() == null)
+ element.setQueryContext(queryContext);
}
return super.accept(match);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/AvailableIUCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/AvailableIUCollector.java
index fa7a6208d..e859e0824 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/AvailableIUCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/AvailableIUCollector.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.ui.query;
+import java.util.Collection;
import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
+import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.equinox.internal.provisional.p2.ui.model.CategoryElement;
import org.eclipse.equinox.internal.provisional.p2.ui.model.QueriedElementCollector;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
@@ -26,12 +28,20 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
public class AvailableIUCollector extends QueriedElementCollector {
private boolean makeCategories;
+ private ElementQueryDescriptor installedQueryDescriptor;
+ private boolean hideInstalledIUs = false;
+ Collection installedElements = null;
- public AvailableIUCollector(IQueryProvider queryProvider, IQueryable queryable, boolean makeCategories) {
- super(queryProvider, queryable);
+ public AvailableIUCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext, boolean makeCategories) {
+ super(queryProvider, queryable, queryContext);
this.makeCategories = makeCategories;
}
+ public void hideInstalledIUs(ElementQueryDescriptor installedQuery) {
+ installedQueryDescriptor = installedQuery;
+ hideInstalledIUs = true;
+ }
+
/**
* Accepts a result that matches the query criteria.
*
@@ -40,14 +50,28 @@ public class AvailableIUCollector extends QueriedElementCollector {
* or <code>false</code> to indicate the query should stop.
*/
public boolean accept(Object match) {
+ if (hideInstalledIUs && installedElements == null)
+ initializeInstalledElements();
+ if (hideInstalledIUs) {
+ IInstallableUnit iu = (IInstallableUnit) ProvUI.getAdapter(match, IInstallableUnit.class);
+ if (installedElements.contains(iu))
+ return true;
+ }
+ // If it's not an IU, it's an element and work is done
if (!(match instanceof IInstallableUnit))
return super.accept(match);
+
+ // We need to make an element
IInstallableUnit iu = (IInstallableUnit) match;
if (makeCategories && isCategory(iu))
return super.accept(new CategoryElement(iu));
return super.accept(makeDefaultElement(iu));
}
+ private void initializeInstalledElements() {
+ installedElements = installedQueryDescriptor.queryable.query(installedQueryDescriptor.query, installedQueryDescriptor.collector, null).toCollection();
+ }
+
protected Object makeDefaultElement(IInstallableUnit iu) {
return new AvailableIUElement(iu, null);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/CategoryElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/CategoryElementCollector.java
index 591714fc8..69b06630f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/CategoryElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/CategoryElementCollector.java
@@ -31,8 +31,8 @@ public class CategoryElementCollector extends QueriedElementCollector {
private boolean groupUncategorized;
private Set referredIUs = new HashSet();
- public CategoryElementCollector(IQueryProvider queryProvider, IQueryable queryable, boolean showUncategorized) {
- super(queryProvider, queryable);
+ public CategoryElementCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext, boolean showUncategorized) {
+ super(queryProvider, queryable, queryContext);
this.groupUncategorized = showUncategorized;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/IUProfilePropertyQuery.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/IUProfilePropertyQuery.java
deleted file mode 100644
index 44cddfaa1..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/IUProfilePropertyQuery.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.provisional.p2.ui.query;
-
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery;
-
-/**
- * A query that searches for {@link IInstallableUnit} instances that have
- * a property associated with the specified profile, whose value matches the provided value.
- */
-public class IUProfilePropertyQuery extends IUPropertyQuery {
- private IProfile profile;
-
- /**
- * Creates a new query on the given property name and value.
- */
- public IUProfilePropertyQuery(IProfile profile, String propertyName, String propertyValue) {
- super(propertyName, propertyValue);
- this.profile = profile;
- }
-
- protected String getProperty(IInstallableUnit iu, String name) {
- return profile.getInstallableUnitProperty(iu, name);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/InstalledIUCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/InstalledIUCollector.java
index 313ae2f16..c74352de0 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/InstalledIUCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/InstalledIUCollector.java
@@ -24,8 +24,8 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
*/
public class InstalledIUCollector extends QueriedElementCollector {
- public InstalledIUCollector(IQueryProvider queryProvider, IProfile profile) {
- super(queryProvider, profile);
+ public InstalledIUCollector(IQueryProvider queryProvider, IProfile profile, QueryContext queryContext) {
+ super(queryProvider, profile, queryContext);
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionCollector.java
index a8108293c..4a14dca59 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionCollector.java
@@ -25,8 +25,8 @@ public class LatestIUVersionCollector extends AvailableIUCollector {
private HashMap uniqueIds = new HashMap();
- public LatestIUVersionCollector(IQueryProvider queryProvider, IQueryable queryable, boolean makeCategories) {
- super(queryProvider, queryable, makeCategories);
+ public LatestIUVersionCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext, boolean makeCategories) {
+ super(queryProvider, queryable, queryContext, makeCategories);
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionElementCollector.java
index c47c12a7a..977dbae32 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/LatestIUVersionElementCollector.java
@@ -22,8 +22,8 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
* @since 3.4
*/
public class LatestIUVersionElementCollector extends LatestIUVersionCollector {
- public LatestIUVersionElementCollector(IQueryProvider queryProvider, IQueryable queryable, boolean makeCategories) {
- super(queryProvider, queryable, makeCategories);
+ public LatestIUVersionElementCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext, boolean makeCategories) {
+ super(queryProvider, queryable, queryContext, makeCategories);
}
protected Object makeDefaultElement(IInstallableUnit iu) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/MetadataRepositoryElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/MetadataRepositoryElementCollector.java
index 710133916..1c32d693e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/MetadataRepositoryElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/MetadataRepositoryElementCollector.java
@@ -23,8 +23,8 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
*/
public class MetadataRepositoryElementCollector extends QueriedElementCollector {
- public MetadataRepositoryElementCollector(IQueryProvider queryProvider) {
- super(queryProvider, null);
+ public MetadataRepositoryElementCollector(IQueryProvider queryProvider, QueryContext queryContext) {
+ super(queryProvider, null, queryContext);
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/OtherIUVersionsCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/OtherIUVersionsCollector.java
index e032a36ae..e69e37638 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/OtherIUVersionsCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/OtherIUVersionsCollector.java
@@ -25,8 +25,8 @@ public class OtherIUVersionsCollector extends QueriedElementCollector {
private IInstallableUnit iu;
- public OtherIUVersionsCollector(IInstallableUnit iu, IQueryProvider queryProvider, IQueryable queryable) {
- super(queryProvider, queryable);
+ public OtherIUVersionsCollector(IInstallableUnit iu, IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext) {
+ super(queryProvider, queryable, queryContext);
this.iu = iu;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/ProfileElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/ProfileElementCollector.java
index 1092fb3ac..a5ebe020c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/ProfileElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/ProfileElementCollector.java
@@ -23,8 +23,8 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
*/
public class ProfileElementCollector extends QueriedElementCollector {
- public ProfileElementCollector(IQueryProvider queryProvider, IProfile profile) {
- super(queryProvider, profile);
+ public ProfileElementCollector(IQueryProvider queryProvider, IProfile profile, QueryContext queryContext) {
+ super(queryProvider, profile, queryContext);
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueriedElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueriedElement.java
index e238bbdf6..3560009f2 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueriedElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueriedElement.java
@@ -57,12 +57,22 @@ public abstract class QueriedElement extends ProvElement {
return null;
}
+ /**
+ * Return the query type that is appropriate for this element when there
+ * is no query context.
+ * @return The integer query type
+ */
protected abstract int getDefaultQueryType();
+ /**
+ * Return the query type that should be used for this element.
+ * Depending on the element, the query type may take the query context
+ * into account. Subclasses should override this method if there are
+ * context-dependent decisions to be made to determine the query.
+ * @return The integer query type
+ */
protected int getQueryType() {
- if (queryContext == null)
- return getDefaultQueryType();
- return queryContext.getQueryType();
+ return getDefaultQueryType();
}
public void setQueryProvider(IQueryProvider queryProvider) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/RollbackIUCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/RollbackIUCollector.java
index 07c4e8b72..b698707f6 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/RollbackIUCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/RollbackIUCollector.java
@@ -23,8 +23,8 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
*/
public class RollbackIUCollector extends AvailableIUCollector {
- public RollbackIUCollector(IQueryProvider queryProvider, IQueryable queryable) {
- super(queryProvider, queryable, false);
+ public RollbackIUCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext) {
+ super(queryProvider, queryable, queryContext, false);
}
protected Object makeDefaultElement(IInstallableUnit iu) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/UncategorizedElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/UncategorizedElementCollector.java
index cbffbe0e1..45c85480f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/UncategorizedElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/UncategorizedElementCollector.java
@@ -34,8 +34,8 @@ public class UncategorizedElementCollector extends QueriedElementCollector {
private HashMap allOthersById = new HashMap();
private Collector resultCollector;
- public UncategorizedElementCollector(IQueryProvider queryProvider, IQueryable queryable, Collector resultCollector) {
- super(queryProvider, queryable);
+ public UncategorizedElementCollector(IQueryProvider queryProvider, IQueryable queryable, QueryContext queryContext, Collector resultCollector) {
+ super(queryProvider, queryable, queryContext);
this.resultCollector = resultCollector;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java
index a79219d1e..c0d57fcdc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/viewers/StructuredViewerProvisioningListener.java
@@ -19,7 +19,6 @@ import org.eclipse.equinox.internal.provisional.p2.engine.ProfileEvent;
import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
@@ -134,11 +133,7 @@ public class StructuredViewerProvisioningListener implements SynchronousProvisio
protected void profileChanged(final String profileId) {
display.asyncExec(new Runnable() {
public void run() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench.isClosing())
- return;
-
- if (viewer.getControl().isDisposed())
+ if (isClosing())
return;
// We want to refresh the affected profile, so we
// construct a profile element on this profile.
@@ -171,15 +166,12 @@ public class StructuredViewerProvisioningListener implements SynchronousProvisio
asyncRefresh();
}
- private void asyncRefresh() {
+ protected void asyncRefresh() {
display.asyncExec(new Runnable() {
public void run() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench.isClosing())
+ if (isClosing())
return;
- Control control = viewer.getControl();
- if (control != null && !control.isDisposed())
- refreshAll();
+ refreshAll();
}
});
}
@@ -197,4 +189,21 @@ public class StructuredViewerProvisioningListener implements SynchronousProvisio
public int getEventTypes() {
return eventTypes;
}
+
+ /**
+ * Return whether the viewer is closing or shutting down.
+ * This method should be used in async execs to ensure that
+ * the viewer is still alive.
+ * @return a boolean indicating whether the viewer is closing
+ */
+ protected boolean isClosing() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench.isClosing())
+ return true;
+
+ if (viewer.getControl().isDisposed())
+ return true;
+
+ return false;
+ }
}

Back to the top