Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/IUViewQueryContext.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/Policy.java25
7 files changed, 98 insertions, 8 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
index edbfb0b76..54b6f131b 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2010 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
@@ -125,6 +125,7 @@ public class ProvUI {
queryContext.setShowInstallChildren(policy.getShowDrilldownRequirements());
queryContext.setShowProvisioningPlanChildren(policy.getShowDrilldownRequirements());
queryContext.setUseCategories(policy.getGroupByCategory());
+ queryContext.setFilterOnEnv(policy.getFilterOnEnv());
return queryContext;
}
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 8a0fb51a2..cd4dbc20c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2010 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
@@ -170,6 +170,7 @@ public class ProvUIMessages extends NLS {
public static String AvailableIUsPage_AddButton;
public static String AvailableIUsPage_AllSites;
public static String AvailableIUsPage_Description;
+ public static String AvailableIUsPage_FilterOnEnvCheckBox;
public static String AvailableIUsPage_GotoInstallInfo;
public static String AvailableIUsPage_GotoProperties;
public static String AvailableIUsPage_GroupByCategory;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
index 8223eb25d..3bee4d934 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -12,7 +12,8 @@
package org.eclipse.equinox.internal.p2.ui;
import java.net.URI;
-import java.util.Collection;
+import java.util.*;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.ui.model.*;
import org.eclipse.equinox.internal.p2.ui.query.*;
import org.eclipse.equinox.p2.engine.IProfile;
@@ -47,6 +48,39 @@ public class QueryProvider {
this.ui = ui;
}
+ /*
+ * Return a map of key/value pairs which are set to the environment settings
+ * for the given profile. May return <code>null</code> or an empty <code>Map</code>
+ * if the settings cannot be obtained.
+ */
+ private static Map<String, String> getEnvFromProfile(IProfile profile) {
+ String environments = profile.getProperty(IProfile.PROP_ENVIRONMENTS);
+ if (environments == null)
+ return null;
+ Map<String, String> result = new HashMap<String, String>();
+ for (StringTokenizer tokenizer = new StringTokenizer(environments, ","); tokenizer.hasMoreElements();) { //$NON-NLS-1$
+ String entry = tokenizer.nextToken();
+ int i = entry.indexOf('=');
+ String key = entry.substring(0, i).trim();
+ String value = entry.substring(i + 1).trim();
+ result.put(key, value);
+ }
+ return result;
+ }
+
+ // If we are supposed to filter out the results based on the environment settings in
+ // the target profile then create a compound query otherwise just return the given query
+ private IQuery<IInstallableUnit> createEnvironmentFilterQuery(IUViewQueryContext context, IProfile profile, IQuery<IInstallableUnit> query) {
+ if (!context.getFilterOnEnv())
+ return query;
+ Map<String, String> environment = getEnvFromProfile(profile);
+ if (environment == null)
+ return query;
+ IInstallableUnit envIU = InstallableUnit.contextIU(environment);
+ IQuery<IInstallableUnit> filterQuery = QueryUtil.createMatchQuery("filter == null || $0 ~= filter", envIU); //$NON-NLS-1$
+ return QueryUtil.createCompoundQuery(query, filterQuery, true);
+ }
+
public ElementQueryDescriptor getQueryDescriptor(final QueriedElement element) {
// Initialize queryable, queryContext, and queryType from the element.
// In some cases we override this.
@@ -79,6 +113,9 @@ public class QueryProvider {
IQuery<IInstallableUnit> topLevelQuery = policy.getVisibleAvailableIUQuery();
IQuery<IInstallableUnit> categoryQuery = QueryUtil.createIUCategoryQuery();
+ topLevelQuery = createEnvironmentFilterQuery(context, targetProfile, topLevelQuery);
+ categoryQuery = createEnvironmentFilterQuery(context, targetProfile, categoryQuery);
+
// Showing child IU's of a group of repositories, or of a single repository
if (element instanceof MetadataRepositories || element instanceof MetadataRepositoryElement) {
if (context.getViewType() == IUViewQueryContext.AVAILABLE_VIEW_FLAT || !context.getUseCategories()) {
@@ -108,6 +145,7 @@ public class QueryProvider {
} else {
memberOfCategoryQuery = QueryUtil.createIUCategoryMemberQuery(((IIUElement) element).getIU());
}
+ memberOfCategoryQuery = createEnvironmentFilterQuery(context, targetProfile, memberOfCategoryQuery);
availableIUWrapper = new AvailableIUWrapper(queryable, element, true, drillDownTheChildren);
if (targetProfile != null)
availableIUWrapper.markInstalledIUs(targetProfile, hideInstalled);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
index a2fa76698..65ade48b4 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
@@ -52,7 +52,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
AvailableIUGroup availableIUGroup;
Composite availableIUButtonBar;
Link installLink;
- Button useCategoriesCheckbox, hideInstalledCheckbox, showLatestVersionsCheckbox, resolveAllCheckbox;
+ Button useCategoriesCheckbox, hideInstalledCheckbox, showLatestVersionsCheckbox, resolveAllCheckbox, filterOnEnvCheckBox;
SashForm sashForm;
IUColumnConfig nameColumn, versionColumn;
StructuredViewerProvisioningListener profileListener;
@@ -277,6 +277,20 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
}, ProvUIMessages.AvailableIUsPage_GotoInstallInfo);
installLink.setLayoutData(gd);
+ filterOnEnvCheckBox = new Button(parent, SWT.CHECK);
+ filterOnEnvCheckBox.setText(ProvUIMessages.AvailableIUsPage_FilterOnEnvCheckBox);
+ filterOnEnvCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateQueryContext();
+ availableIUGroup.updateAvailableViewState();
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ updateQueryContext();
+ availableIUGroup.updateAvailableViewState();
+ }
+ });
+
if (getPolicy().getRepositoriesVisible()) {
// Checkbox
resolveAllCheckbox = new Button(parent, SWT.CHECK);
@@ -349,6 +363,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
queryContext.setViewType(IUViewQueryContext.AVAILABLE_VIEW_BY_CATEGORY);
else
queryContext.setViewType(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
+ queryContext.setFilterOnEnv(filterOnEnvCheckBox.getSelection());
}
private Link createLink(Composite parent, IAction action, String text) {
@@ -389,6 +404,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
hideInstalledCheckbox.setSelection(queryContext.getHideAlreadyInstalled());
showLatestVersionsCheckbox.setSelection(queryContext.getShowLatestVersionsOnly());
useCategoriesCheckbox.setSelection(queryContext.shouldGroupByCategories());
+ filterOnEnvCheckBox.setSelection(queryContext.getFilterOnEnv());
availableIUGroup.updateAvailableViewState();
if (initialSelections != null)
availableIUGroup.setChecked(initialSelections);
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 18acb9e0d..c323c5f70 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2009 IBM Corporation and others.
+# Copyright (c) 2007, 2010 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
@@ -190,6 +190,7 @@ AvailableIUGroup_NoSitesExplanation=There is no site selected.
AvailableIUsPage_AddButton=&Add...
AvailableIUsPage_AllSites=--All Available Sites--
AvailableIUsPage_Description=Check the items that you wish to install.
+AvailableIUsPage_FilterOnEnvCheckBox=Show only software applicable to target environment
AvailableIUsPage_GotoInstallInfo=What is <a>already installed</a>?
AvailableIUsPage_GotoProperties=<a>More...</a>
AvailableIUsPage_GroupByCategory=&Group items by category
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/IUViewQueryContext.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/IUViewQueryContext.java
index 0aa3daf34..8f36fb56c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/IUViewQueryContext.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/IUViewQueryContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -44,6 +44,8 @@ public class IUViewQueryContext {
private boolean showAvailableChildren = false;
// Whether to drill down into items in a provisioning plan
private boolean showProvisioningPlanChildren = true;
+ // Whether to filter out IUs based on the environment settings of the target profile
+ private boolean filterOnEnv = false;
private String profileId = null;
@@ -100,6 +102,14 @@ public class IUViewQueryContext {
this.profileId = profileId;
}
+ public void setFilterOnEnv(boolean filterOnEnv) {
+ this.filterOnEnv = filterOnEnv;
+ }
+
+ public boolean getFilterOnEnv() {
+ return filterOnEnv;
+ }
+
/**
* Set a boolean that indicates whether categories should be used when
* viewing by repository.
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/Policy.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/Policy.java
index 71e68ea44..f7ee19d52 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/Policy.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/Policy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -78,6 +78,7 @@ public class Policy {
private int restartPolicy = RESTART_POLICY_PROMPT_RESTART_OR_APPLY;
private String repoPrefPageId;
private String repoPrefPageName;
+ private boolean filterOnEnv = false;
/**
* Answer a boolean indicating whether the caller should continue to work with the
@@ -261,6 +262,28 @@ public class Policy {
}
/**
+ * Return a boolean value indicating whether or not the list of available
+ * software should be filtered based on the environment settings of the profile.
+ *
+ * @return <code>true</code> if the results should be filtered
+ * and <code>false</code> otherwise.
+ */
+ public boolean getFilterOnEnv() {
+ return filterOnEnv;
+ }
+
+ /**
+ * Set a boolean value indicating whether or not the list of available
+ * software should be filtered based on the environment settings of the profile.
+ *
+ * @param filterOnEnv <code>true</code> if the results should be filtered
+ * and <code>false</code> otherwise.
+ */
+ public void setFilterOnEnv(boolean filterOnEnv) {
+ this.filterOnEnv = filterOnEnv;
+ }
+
+ /**
* Return a boolean indicating whether available software should be
* grouped by category.
*

Back to the top