Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-12-22 17:14:25 +0000
committerJohn Arthorne2009-12-22 17:14:25 +0000
commit030f9ceaac21fb05bc4316560e683e59e20e4bb7 (patch)
tree0385e135b422c33446e7c2ee0383cfd0533762bd /bundles
parentca010afc13cb919ad766fdc5aaec721b3ed0b6c0 (diff)
downloadrt.equinox.p2-030f9ceaac21fb05bc4316560e683e59e20e4bb7.tar.gz
rt.equinox.p2-030f9ceaac21fb05bc4316560e683e59e20e4bb7.tar.xz
rt.equinox.p2-030f9ceaac21fb05bc4316560e683e59e20e4bb7.zip
Bug 298333 - TranslationSupport cleanup
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java (renamed from bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java)246
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUPropertiesGroup.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionStatusPage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/CategoryElement.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUComparator.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java2
25 files changed, 255 insertions, 199 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
index bd6c6f09e..7e7dcba8b 100644
--- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
@@ -25,6 +25,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.core.internal.preferences,
org.eclipse.core.runtime.preferences,
org.eclipse.equinox.internal.p2.core.helpers,
+ org.eclipse.equinox.internal.p2.metadata,
org.eclipse.equinox.internal.p2.metadata.repository,
org.eclipse.equinox.internal.p2.metadata.repository.io,
org.eclipse.equinox.internal.p2.persistence,
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
index af2ad0025..b99ded205 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
@@ -18,6 +18,7 @@ import java.util.zip.GZIPOutputStream;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.*;
+import org.eclipse.equinox.internal.p2.metadata.TranslationSupport;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
@@ -113,6 +114,10 @@ public class SimpleProfileRegistry implements IProfileRegistry {
if (selfProfile == null)
return;
+ //register default locale provider where metadata translations are found
+ //TODO ideally this should not be hard-coded to the current profile
+ TranslationSupport.getInstance().setTranslationSource(selfProfile);
+
if (DebugHelper.DEBUG_PROFILE_REGISTRY)
DebugHelper.debug(PROFILE_REGISTRY, "SimpleProfileRegistry.updateSelfProfile"); //$NON-NLS-1$
boolean changed = false;
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
index 7dd5783e0..fddab46cd 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/InstallableUnit.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import org.eclipse.equinox.p2.metadata.ICopyright;
-
import java.util.ArrayList;
import java.util.Map;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
@@ -140,6 +138,10 @@ public class InstallableUnit implements IInstallableUnit {
return properties().getProperty(key);
}
+ public String getProperty(String key, String locale) {
+ return TranslationSupport.getInstance().getIUProperty(this, key, locale);
+ }
+
public IProvidedCapability[] getProvidedCapabilities() {
return providedCapabilities;
}
@@ -260,13 +262,17 @@ public class InstallableUnit implements IInstallableUnit {
}
public void setLicenses(ILicense[] license) {
- this.licenses = license;
+ this.licenses = license == null ? NO_LICENSE : license;
}
public ILicense[] getLicenses() {
return licenses;
}
+ public ILicense[] getLicenses(String locale) {
+ return TranslationSupport.getInstance().getLicenses(this, locale);
+ }
+
public void setCopyright(ICopyright copyright) {
this.copyright = copyright;
}
@@ -275,6 +281,10 @@ public class InstallableUnit implements IInstallableUnit {
return copyright;
}
+ public ICopyright getCopyright(String locale) {
+ return TranslationSupport.getInstance().getCopyright(this, locale);
+ }
+
public boolean satisfies(IRequirement candidate) {
if (candidate.getMatches() instanceof RequiredCapability) {
for (int i = 0; i < providedCapabilities.length; i++) {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
index fc259ea64..7a98558ff 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/ResolvedInstallableUnit.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata;
-import org.eclipse.equinox.p2.metadata.ICopyright;
-
import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.*;
@@ -61,6 +59,10 @@ public class ResolvedInstallableUnit implements IInstallableUnit {
return original.getProperty(key);
}
+ public String getProperty(String key, String locale) {
+ return original.getProperty(key, locale);
+ }
+
public Map getProperties() {
return original.getProperties();
}
@@ -165,10 +167,18 @@ public class ResolvedInstallableUnit implements IInstallableUnit {
return original.getLicenses();
}
+ public ILicense[] getLicenses(String locale) {
+ return original.getLicenses(locale);
+ }
+
public ICopyright getCopyright() {
return original.getCopyright();
}
+ public ICopyright getCopyright(String locale) {
+ return original.getCopyright(locale);
+ }
+
public boolean satisfies(IRequirement candidate) {
IProvidedCapability[] provides = getProvidedCapabilities();
for (int i = 0; i < provides.length; i++)
diff --git a/bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java
index a3ea2d835..9c6a0ca9f 100644
--- a/bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java
@@ -9,45 +9,46 @@
* IBM Corporation - initial API and implementation
* EclipseSource - ongoing development
*******************************************************************************/
-package org.eclipse.equinox.p2.common;
+package org.eclipse.equinox.internal.p2.metadata;
import java.lang.ref.SoftReference;
import java.util.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.internal.p2.common.Activator;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.*;
+import org.eclipse.osgi.service.localization.LocaleProvider;
/**
* TranslationSupport provides string translations for properties of an
- * IInstallableUnit. Clients can specify a queryable that should be used
+ * IInstallableUnit. Clients can specify an {@link IQueryable} that should be used
* to obtain the translation fragment IU's, as well as the locale that
* should be used for translations.
*
* @since 2.0
*/
public class TranslationSupport {
-
// TODO: these constants should come from API, eg. IInstallableUnit or ???
static final Locale DEFAULT_LOCALE = new Locale("df", "LT"); //$NON-NLS-1$//$NON-NLS-2$
- static final String NAMESPACE_IU_LOCALIZATION = "org.eclipse.equinox.p2.localization"; //$NON-NLS-1$
+ private static TranslationSupport instance;
+ static final String NAMESPACE_IU_LOCALIZATION = "org.eclipse.equinox.p2.localization"; //$NON-NLS-1$
private IQueryable fragmentSource;
- private Locale locale;
// Cache the IU fragments that provide localizations for a given locale.
- // map: locale => soft reference to a queryResult
- private Map LocaleCollectorCache = new HashMap(2);
+ // Map<String,SoftReference<IQueryResult>>: locale => soft reference to a queryResult
+ private Map localeCollectorCache = new HashMap(2);
+
+ private LocaleProvider localeProvider;
+
+ public synchronized static TranslationSupport getInstance() {
+ if (instance == null)
+ instance = new TranslationSupport();
+ return instance;
+ }
/**
* Create an instance of TranslationSupport for the current locale.
@@ -56,45 +57,38 @@ public class TranslationSupport {
*
* @since 2.0
*/
- public TranslationSupport() {
- locale = getCurrentLocale();
- //Due to performance problems, by default we restrict locale lookup to the current profile (see bug 233958)
- fragmentSource = getSelfProfile();
- }
-
- /**
- * Set the queryable that should be used to obtain translation fragment
- * IUs.
- *
- * @param queryable a queryable that can supply the appropriate NLS
- * translation fragments
- */
- public void setTranslationSource(IQueryable queryable) {
- this.fragmentSource = queryable;
+ private TranslationSupport() {
+ super();
+ //no instantiate
}
/**
- * Set the locale that should be used when obtaining translations.
- * @param locale the locale for which translations should be retrieved.
*/
- public void setLocale(Locale locale) {
- this.locale = locale;
+ private List buildLocaleVariants(String locale) {
+ ArrayList result = new ArrayList(4);
+ int lastSeparator;
+ while (true) {
+ result.add(locale);
+ lastSeparator = locale.lastIndexOf('_');
+ if (lastSeparator == -1)
+ break;
+ locale = locale.substring(0, lastSeparator);
+ }
+ // Add the default locale (most general)
+ result.add(DEFAULT_LOCALE.toString());
+ return result;
}
/**
- * Return an array of licenses for the specified IInstallableUnit,
- * localized for the receiver's locale.
- *
- * @param iu the IInstallableUnit in question
- * @return the localized licenses defined by the IInstallableUnit
+ * Cache the translated property value to optimize future retrieval of the same value.
+ * Currently we just cache on the installable unit object in memory. In future
+ * we should push support for localized property retrieval into IInstallableUnit
+ * so we aren't required to reach around the API here.
*/
- public ILicense[] getLicenses(IInstallableUnit iu) {
- ILicense[] licenses = iu.getLicenses();
- ILicense[] translatedLicenses = new ILicense[licenses.length];
- for (int i = 0; i < licenses.length; i++) {
- translatedLicenses[i] = getLicense(iu, licenses[i]);
- }
- return translatedLicenses;
+ private String cacheResult(IInstallableUnit iu, String localizedKey, String localizedValue) {
+ if (iu instanceof InstallableUnit)
+ ((InstallableUnit) iu).setLocalizedProperty(localizedKey, localizedValue);
+ return localizedValue;
}
/**
@@ -104,45 +98,103 @@ public class TranslationSupport {
* @param iu the IInstallableUnit in question
* @return the localized copyright defined by the IInstallableUnit
*/
- public ICopyright getCopyright(IInstallableUnit iu) {
+ public ICopyright getCopyright(IInstallableUnit iu, String locale) {
+ if (locale == null)
+ locale = getCurrentLocale();
ICopyright copyright = iu.getCopyright();
String body = (copyright != null ? copyright.getBody() : null);
if (body == null || body.length() <= 1 || body.charAt(0) != '%')
return copyright;
final String actualKey = body.substring(1); // Strip off the %
- body = getLocalizedIUProperty(iu, actualKey);
+ body = getLocalizedIUProperty(iu, actualKey, locale);
return MetadataFactory.createCopyright(copyright.getLocation(), body);
}
+ private String getCurrentLocale() {
+ if (localeProvider != null)
+ return localeProvider.getLocale().toString();
+ return Locale.getDefault().toString();
+ }
+
/**
* Return the localized value for the specified IInstallableUnit
* property.
*
* @param iu the IInstallableUnit in question
* @param propertyKey the name of the property to be retrieved
+ * @param locale The locale to return the property for
* @return the localized property value, or <code>null</code> if no
* such property is defined.
*/
- public String getIUProperty(IInstallableUnit iu, String propertyKey) {
+ public String getIUProperty(IInstallableUnit iu, String propertyKey, String locale) {
+ if (locale == null)
+ locale = getCurrentLocale();
String value = iu.getProperty(propertyKey);
if (value == null || value.length() <= 1 || value.charAt(0) != '%')
return value;
// else have a localizable property
final String actualKey = value.substring(1); // Strip off the %
- return getLocalizedIUProperty(iu, actualKey);
+ return getLocalizedIUProperty(iu, actualKey, locale);
}
- private ILicense getLicense(IInstallableUnit iu, ILicense license) {
+ private ILicense getLicense(IInstallableUnit iu, ILicense license, String locale) {
String body = (license != null ? license.getBody() : null);
if (body == null || body.length() <= 1 || body.charAt(0) != '%')
return license;
final String actualKey = body.substring(1); // Strip off the %
- body = getLocalizedIUProperty(iu, actualKey);
+ body = getLocalizedIUProperty(iu, actualKey, locale);
return MetadataFactory.createLicense(license.getLocation(), body);
}
- private String getLocalizedIUProperty(IInstallableUnit iu, String actualKey) {
- String localizedKey = makeLocalizedKey(actualKey, locale.toString());
+ /**
+ * Return an array of licenses for the specified IInstallableUnit,
+ * localized for the receiver's locale.
+ *
+ * @param iu the IInstallableUnit in question
+ * @return the localized licenses defined by the IInstallableUnit
+ */
+ public ILicense[] getLicenses(IInstallableUnit iu, String locale) {
+ if (locale == null)
+ locale = getCurrentLocale();
+ ILicense[] licenses = iu.getLicenses();
+ ILicense[] translatedLicenses = new ILicense[licenses.length];
+ for (int i = 0; i < licenses.length; i++) {
+ translatedLicenses[i] = getLicense(iu, licenses[i], locale);
+ }
+ return translatedLicenses;
+ }
+
+ /**
+ * Collects the installable unit fragments that contain locale data for the given locales.
+ */
+ private synchronized IQueryResult getLocalizationFragments(List localeVariants, String locale) {
+ if (fragmentSource == null) {
+ LogHelper.log(new Status(IStatus.ERROR, MetadataActivator.PI_METADATA, "Profile registry unavailable. Default language will be used.", new RuntimeException())); //$NON-NLS-1$
+ return Collector.EMPTY_COLLECTOR;
+ }
+
+ SoftReference queryResultReference = (SoftReference) localeCollectorCache.get(locale);
+ if (queryResultReference != null) {
+ Collector cached = (Collector) queryResultReference.get();
+ if (cached != null)
+ return cached;
+ }
+
+ final List locales = localeVariants;
+
+ IQuery[] localeQuery = new IQuery[locales.size()];
+ for (int j = 0; j < locales.size(); j++) {
+ localeQuery[j] = new RequiredCapability(NAMESPACE_IU_LOCALIZATION, (String) locales.get(j), VersionRange.emptyRange, null, false, false);
+ }
+
+ IQuery iuQuery = new PipedQuery(new IQuery[] {new FragmentQuery(), CompoundQuery.createCompoundQuery(localeQuery, false)});
+ IQueryResult collected = fragmentSource.query(iuQuery, null);
+ localeCollectorCache.put(locale, new SoftReference(collected));
+ return collected;
+ }
+
+ private String getLocalizedIUProperty(IInstallableUnit iu, String actualKey, String locale) {
+ String localizedKey = makeLocalizedKey(actualKey, locale);
String localizedValue = null;
//first check for a cached localized value
@@ -154,10 +206,10 @@ public class TranslationSupport {
if (localizedValue != null)
return localizedValue;
- final List locales = buildLocaleVariants();
+ final List locales = buildLocaleVariants(locale);
final IInstallableUnit theUnit = iu;
- IQueryResult localizationFragments = getLocalizationFragments(locales);
+ IQueryResult localizationFragments = getLocalizationFragments(locales, locale);
MatchQuery hostLocalizationQuery = new MatchQuery() {
public boolean isMatch(Object object) {
@@ -202,82 +254,28 @@ public class TranslationSupport {
return cacheResult(iu, localizedKey, actualKey);
}
- /**
- * Cache the translated property value to optimize future retrieval of the same value.
- * Currently we just cache on the installable unit object in memory. In future
- * we should push support for localized property retrieval into IInstallableUnit
- * so we aren't required to reach around the API here.
- */
- private String cacheResult(IInstallableUnit iu, String localizedKey, String localizedValue) {
- if (iu instanceof InstallableUnit)
- ((InstallableUnit) iu).setLocalizedProperty(localizedKey, localizedValue);
- return localizedValue;
+ private String makeLocalizedKey(String actualKey, String localeImage) {
+ return localeImage + '.' + actualKey;
}
/**
- * Collects the installable unit fragments that contain locale data for the given locales.
+ * Set the locale that should be used when obtaining translations.
+ * @param provider the locale for which translations should be retrieved.
*/
- private synchronized IQueryResult getLocalizationFragments(List localeVariants) {
- if (fragmentSource == null) {
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Profile registry unavailable. Default language will be used.", new RuntimeException())); //$NON-NLS-1$
- return Collector.EMPTY_COLLECTOR;
- }
-
- SoftReference queryResultReference = (SoftReference) LocaleCollectorCache.get(locale);
- if (queryResultReference != null) {
- Collector cached = (Collector) queryResultReference.get();
- if (cached != null)
- return cached;
- }
-
- final List locales = localeVariants;
-
- IQuery[] localeQuery = new IQuery[locales.size()];
- for (int j = 0; j < locales.size(); j++) {
- localeQuery[j] = new RequiredCapability(NAMESPACE_IU_LOCALIZATION, (String) locales.get(j), VersionRange.emptyRange, null, false, false);
- }
-
- IQuery iuQuery = new PipedQuery(new IQuery[] {new FragmentQuery(), CompoundQuery.createCompoundQuery(localeQuery, false)});
- IQueryResult collected = fragmentSource.query(iuQuery, null);
- LocaleCollectorCache.put(locale, new SoftReference(collected));
- return collected;
+ public void setLocaleProvider(LocaleProvider provider) {
+ this.localeProvider = provider;
}
/**
+ * Set the {@link IQueryable} that should be used to obtain translation fragment
+ * IUs. Returns the previous translation source.
+ *
+ * @param queryable an {@link IQueryable} that can supply the appropriate NLS
+ * translation fragments
*/
- private List buildLocaleVariants() {
- String nl = locale.toString();
- ArrayList result = new ArrayList(4);
- int lastSeparator;
- while (true) {
- result.add(nl);
- lastSeparator = nl.lastIndexOf('_');
- if (lastSeparator == -1)
- break;
- nl = nl.substring(0, lastSeparator);
- }
- // Add the default locale (most general)
- result.add(DEFAULT_LOCALE.toString());
- return result;
- }
-
- private String makeLocalizedKey(String actualKey, String localeImage) {
- return localeImage + '.' + actualKey;
- }
-
- private Locale getCurrentLocale() {
- return Locale.getDefault();
- }
-
- private IProfile getSelfProfile() {
- IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(Activator.getContext(), IProvisioningAgent.SERVICE_NAME);
- if (agent == null)
- return null;
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- if (registry == null) {
- return null;
- }
- IProfile profile = registry.getProfile(IProfileRegistry.SELF);
- return profile;
+ public IQueryable setTranslationSource(IQueryable queryable) {
+ IQueryable previous = fragmentSource;
+ this.fragmentSource = queryable;
+ return previous;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java
index 2e7a6b3bf..76ab1d44e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/IInstallableUnit.java
@@ -115,15 +115,39 @@ public interface IInstallableUnit extends IVersionedId, Comparable {
public IInstallableUnitFragment[] getFragments();
/**
- * Get an <i>unmodifiable copy</i> of the properties
+ * Returns an <i>unmodifiable copy</i> of the properties
* associated with the installable unit.
*
- * @return an <i>unmodifiable copy</i> of the IU properties.
+ * @return an <i>unmodifiable copy</i> of the properties of this installable unit.
*/
public Map getProperties();
+ /**
+ * Returns the untranslated property of this installable unit associated with the given key.
+ * Returns <code>null</code> if no such property is defined.
+ * <p>
+ * If the property value has been externalized, this method will return a string containing
+ * the translation key rather than a human-readable string. For this reason, clients
+ * wishing to obtain the value for a property that is typically translated should use
+ * {@link #getProperty(String, String)} instead.
+ * </p>
+ *
+ * @param key The property key to retrieve a property value for
+ * @return the property that applies to this installable unit or <code>null</code>
+ */
public String getProperty(String key);
+ /**
+ * Returns the property of this installable unit associated with the given key.
+ * Returns <code>null</code> if no such property is defined or no applicable
+ * translation is available.
+ *
+ * @param key The property key to retrieve a property value for
+ * @param locale The locale to translate the property for, or null to use the current locale.
+ * @return the property that applies to this installable unit or <code>null</code>
+ */
+ public String getProperty(String key, String locale);
+
public IProvidedCapability[] getProvidedCapabilities();
public IRequirement[] getRequiredCapabilities();
@@ -175,18 +199,52 @@ public interface IInstallableUnit extends IVersionedId, Comparable {
public IUpdateDescriptor getUpdateDescriptor();
/**
- * Returns the license that applies to this installable unit.
- * @return the license that applies to this installable unit or <code>null</code>
+ * Returns the untranslated licenses that apply to this installable unit.
+ * <p>
+ * If the license text has been externalized, this method will return strings containing
+ * the translation keys rather than human-readable strings. For this reason, clients
+ * wishing to obtain a license for display to an end user should use {@link #getLicenses(String)}
+ * instead.
+ * </p>
+ * @return the licenses that apply to this installable unit
*/
public ILicense[] getLicenses();
/**
- * Returns the copyright that applies to this installable unit.
+ * Returns the licenses that apply to this installable unit. Any translation of the
+ * licenses for the given locale will be applied. Returns an empty array if this
+ * unit has no licenses, or if the available licenses are externalized and do not
+ * have translations available for the given locale.
+ *
+ * @param locale The locale to translate the license for, or null to use the current locale.
+ * @return the translated licenses that apply to this installable unit
+ */
+ public ILicense[] getLicenses(String locale);
+
+ /**
+ * Returns the untranslated copyright that applies to this installable unit.
+ * <p>
+ * If the copyright text has been externalized, this method will return strings containing
+ * the translation keys rather than human-readable strings. For this reason, clients
+ * wishing to obtain a copyright for display to an end user should use {@link #getCopyright(String)}
+ * instead.
+ * </p>
* @return the copyright that applies to this installable unit or <code>null</code>
*/
public ICopyright getCopyright();
/**
+ * Returns the copyright that applies to this installable unit. Any translation of the
+ * copyright for the given locale will be applied. Returns <code>null</code> if this
+ * unit has no copyright, or if the copyright is externalized and no translations are
+ * available for the given locale.
+ *
+ * @param locale The locale to translate the copyright for, or null to use the current locale.
+ * @return the copyright that applies to this installable unit or <code>null</code>
+ */
+ public ICopyright getCopyright(String locale);
+
+ /**
* Returns whether this InstallableUnit is equal to the given object.
*
* This method returns <i>true</i> if:
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
index 3f0d1f1e3..0c749234e 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
@@ -16,7 +16,6 @@ import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.provisional.p2.director.RequestStatus;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
@@ -146,7 +145,7 @@ public class PlanAnalyzer {
if (iu == null)
return Messages.PlanAnalyzer_Items;
// Get the iu name in the default locale
- String name = new TranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (name != null)
return name;
return iu.getId();
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
index 16e14357e..c0de41634 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
@@ -13,7 +13,6 @@ package org.eclipse.equinox.internal.p2.operations;
import java.util.HashMap;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
@@ -57,7 +56,7 @@ public class ResolutionResult {
if (iu == null)
return Messages.PlanAnalyzer_Items;
// Get the iu name in the default locale
- String name = new TranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (name != null)
return name;
return iu.getId();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
index a7e844eea..a46c8ae6f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
@@ -330,6 +330,18 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
return null;
}
+ public String getProperty(String key, String locale) {
+ return getProperty(key);
+ }
+
+ public ILicense[] getLicenses(String locale) {
+ return license;
+ }
+
+ public ICopyright getCopyright(String locale) {
+ return copyright;
+ }
+
}
class SPITouchpointData implements ITouchpointData {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUPropertiesGroup.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUPropertiesGroup.java
index a5c2b3f95..ac7b80810 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUPropertiesGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/IUPropertiesGroup.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.internal.p2.ui.admin.dialogs;
import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
@@ -67,7 +66,7 @@ public class IUPropertiesGroup extends IUGroup {
String[] userPropNames = new String[] {ProvAdminUIMessages.IUPropertiesGroup_NamePropertyLabel, ProvAdminUIMessages.IUPropertiesGroup_DescriptionPropertyLabel, ProvAdminUIMessages.IUPropertiesGroup_ProviderPropertyLabel};
for (int i = 0; i < propNames.length; i++) {
TableItem item = new TableItem(propertiesTable, SWT.NULL);
- String value = new TranslationSupport().getIUProperty(getIU(), propNames[i]);
+ String value = getIU().getProperty(propNames[i], null);
if (value != null)
item.setText(new String[] {userPropNames[i], value});
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
index 08fa4ee2a..f049f96ce 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
@@ -15,7 +15,6 @@ import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
@@ -42,7 +41,6 @@ public class ProvUIActivator extends AbstractUIPlugin {
private ProvisioningSession session;
private ProvisioningUI ui;
- private TranslationSupport translationSupport;
public static BundleContext getContext() {
return context;
@@ -165,10 +163,4 @@ public class ProvUIActivator extends AbstractUIPlugin {
public ProvisioningSession getSession() {
return session;
}
-
- public TranslationSupport getTranslationSupport() {
- if (translationSupport == null)
- translationSupport = new TranslationSupport();
- return translationSupport;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java
index 9ae1f1c59..502f86aeb 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUPatternFilter.java
@@ -14,7 +14,6 @@ import org.eclipse.equinox.internal.p2.ui.model.CategoryElement;
import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
import org.eclipse.equinox.internal.p2.ui.viewers.IUColumnConfig;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.dialogs.PatternFilter;
@@ -91,7 +90,7 @@ public class AvailableIUPatternFilter extends PatternFilter {
IInstallableUnit iu = ((IIUElement) element).getIU();
if (checkName) {
// Get the iu name in the default locale
- text = ProvisioningUI.getDefaultUI().getTranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ text = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (text != null && wordMatches(text))
return true;
}
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 fb43b4551..fee436ce4 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
@@ -444,11 +444,11 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
IInstallableUnit[] selected = getSelectedIUs();
if (selected.length == 1) {
StringBuffer result = new StringBuffer();
- String description = getProvisioningUI().getTranslationSupport().getIUProperty(selected[0], IInstallableUnit.PROP_DESCRIPTION);
+ String description = selected[0].getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
if (description != null) {
result.append(description);
} else {
- String name = getProvisioningUI().getTranslationSupport().getIUProperty(selected[0], IInstallableUnit.PROP_NAME);
+ String name = selected[0].getProperty(IInstallableUnit.PROP_NAME, null);
if (name != null)
result.append(name);
else
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java
index c607dea07..6eebf3e56 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java
@@ -10,13 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.dialogs;
-import org.eclipse.equinox.p2.metadata.ICopyright;
-
import java.net.MalformedURLException;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.p2.metadata.ICopyright;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -34,7 +32,7 @@ public class IUCopyrightPropertyPage extends IUPropertyPage {
protected Control createIUPage(Composite parent, IInstallableUnit iu) {
// Get the copyright in the current locale
- final ICopyright copyright = ProvisioningUI.getDefaultUI().getTranslationSupport().getCopyright(iu);
+ final ICopyright copyright = iu.getCopyright(null);
if (copyright != null && copyright.getBody().length() > 0) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java
index 339b620b1..cca891543 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java
@@ -13,9 +13,7 @@ package org.eclipse.equinox.internal.p2.ui.dialogs;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -31,8 +29,6 @@ import org.eclipse.swt.widgets.*;
*/
public class IUGeneralInfoPropertyPage extends IUPropertyPage {
- TranslationSupport translations = ProvisioningUI.getDefaultUI().getTranslationSupport();
-
protected Control createIUPage(Composite parent, IInstallableUnit iu) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -56,17 +52,17 @@ public class IUGeneralInfoPropertyPage extends IUPropertyPage {
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Get general info in the default locale
- addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_NameLabel, translations.getIUProperty(iu, IInstallableUnit.PROP_NAME));
+ addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_NameLabel, iu.getProperty(IInstallableUnit.PROP_NAME, null));
addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_IdentifierLabel, iu.getId());
addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_VersionLabel, iu.getVersion().toString());
- addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_ProviderLabel, translations.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER));
- addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_ContactLabel, translations.getIUProperty(iu, IInstallableUnit.PROP_CONTACT));
+ addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_ProviderLabel, iu.getProperty(IInstallableUnit.PROP_PROVIDER, null));
+ addField(composite, ProvUIMessages.IUGeneralInfoPropertyPage_ContactLabel, iu.getProperty(IInstallableUnit.PROP_CONTACT, null));
}
private void createDescriptionSection(Composite parent, IInstallableUnit iu) {
// Get the iu description in the default locale
- String description = translations.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION);
+ String description = iu.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
if (description != null && description.length() > 0) {
Group group = new Group(parent, SWT.NONE);
group.setText(ProvUIMessages.IUGeneralInfoPropertyPage_DescriptionLabel);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java
index 60f2a6dab..bf465eb48 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java
@@ -14,7 +14,6 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -32,7 +31,7 @@ public class IULicensePropertyPage extends IUPropertyPage {
protected Control createIUPage(Composite parent, IInstallableUnit iu) {
// Get the license in the default locale
- ILicense[] licenses = ProvisioningUI.getDefaultUI().getTranslationSupport().getLicenses(iu);
+ ILicense[] licenses = iu.getLicenses(null);
final ILicense license;
//FIXME
if (licenses.length > 0 && licenses[0].getBody() != null && licenses[0].getBody().length() > 0) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionStatusPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionStatusPage.java
index 0c7fad04b..d0cd6ed67 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionStatusPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionStatusPage.java
@@ -91,7 +91,7 @@ public abstract class ResolutionStatusPage extends ProvisioningWizardPage {
protected String getIUDescription(IInstallableUnit iu) {
// Get the iu description in the default locale
- String description = getProvisioningUI().getTranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION);
+ String description = iu.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
if (description == null)
description = ""; //$NON-NLS-1$
return description;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java
index 8a3bfa2f8..a8b7e0646 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java
@@ -43,7 +43,7 @@ public abstract class WizardWithLicenses extends ProvisioningOperationWizard {
IInstallableUnit[] ius = new IInstallableUnit[0];
if (planSelections != null)
ius = ElementUtils.elementsToIUs(planSelections);
- return new AcceptLicensesWizardPage(ui.getLicenseManager(), ui.getTranslationSupport(), ius, operation);
+ return new AcceptLicensesWizardPage(ui.getLicenseManager(), ius, operation);
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/CategoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/CategoryElement.java
index 65fffc76b..cb4526b63 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/CategoryElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/CategoryElement.java
@@ -17,7 +17,6 @@ import org.eclipse.equinox.internal.p2.ui.QueryProvider;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* Element wrapper class for IU's that represent categories of
@@ -95,7 +94,7 @@ public class CategoryElement extends RemoteQueriedElement implements IIUElement
}
private String getMergeKey(IInstallableUnit iu) {
- String mergeKey = ProvisioningUI.getDefaultUI().getTranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ String mergeKey = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (mergeKey == null || mergeKey.length() == 0) {
mergeKey = iu.getId();
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUComparator.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUComparator.java
index d5fe03a52..4ab3e9a4c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUComparator.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUComparator.java
@@ -11,9 +11,7 @@
package org.eclipse.equinox.internal.p2.ui.viewers;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
@@ -52,18 +50,17 @@ public class IUComparator extends ViewerComparator {
String key1, key2;
if (key == IU_NAME) {
- TranslationSupport translations = ProvisioningUI.getDefaultUI().getTranslationSupport();
// Compare the iu names in the default locale.
// If a name is not defined, we use blank if we know the id is shown in another
// column. If the id is not shown elsewhere, then we are displaying it, so use
// the id instead.
- key1 = translations.getIUProperty(iu1, IInstallableUnit.PROP_NAME);
+ key1 = iu1.getProperty(IInstallableUnit.PROP_NAME, null);
if (key1 == null)
if (showingId)
key1 = ""; //$NON-NLS-1$
else
key1 = iu1.getId();
- key2 = translations.getIUProperty(iu2, IInstallableUnit.PROP_NAME);
+ key2 = iu2.getProperty(IInstallableUnit.PROP_NAME, null);
if (key2 == null)
if (showingId)
key2 = ""; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
index cd8e43376..f26c04ebd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
@@ -21,7 +21,6 @@ import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
import org.eclipse.equinox.internal.p2.ui.model.ProvElement;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.viewers.*;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Font;
@@ -94,7 +93,7 @@ public class IUDetailsLabelProvider extends ColumnLabelProvider implements ITabl
return iu.getId();
case IUColumnConfig.COLUMN_NAME :
// Get the iu name in the current locale
- String name = ProvisioningUI.getDefaultUI().getTranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (name != null)
return name;
// If the iu name is not available, we return blank if we know know we are
@@ -214,7 +213,7 @@ public class IUDetailsLabelProvider extends ColumnLabelProvider implements ITabl
IInstallableUnit iu = (IInstallableUnit) ProvUI.getAdapter(element, IInstallableUnit.class);
if (iu == null || toolTipProperty == null)
return null;
- return ProvisioningUI.getDefaultUI().getTranslationSupport().getIUProperty(iu, toolTipProperty);
+ return iu.getProperty(toolTipProperty, null);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
index 9c575c982..a47b46aa8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
@@ -21,7 +21,6 @@ import org.eclipse.equinox.internal.p2.ui.viewers.IUColumnConfig;
import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.common.LicenseManager;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
@@ -143,13 +142,12 @@ public class AcceptLicensesWizardPage extends WizardPage {
private IInstallableUnit[] originalIUs;
HashMap licensesToIUs; // License -> IU Name
private LicenseManager manager;
- private TranslationSupport translations;
IUColumnConfig nameColumn;
IUColumnConfig versionColumn;
static String getIUName(IInstallableUnit iu) {
StringBuffer buf = new StringBuffer();
- String name = ProvisioningUI.getDefaultUI().getTranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (name != null)
buf.append(name);
else
@@ -163,15 +161,13 @@ public class AcceptLicensesWizardPage extends WizardPage {
* Create a license acceptance page for showing licenses to the user.
*
* @param manager the license manager that should be used to check for already accepted licenses. May be <code>null</code>.
- * @param translationSupport the translation support to use for retrieving localized licenses and other properties
* @param ius the IInstallableUnits for which licenses should be checked
* @param operation the provisioning operation describing what changes are to take place on the profile
*/
- public AcceptLicensesWizardPage(LicenseManager manager, TranslationSupport translationSupport, IInstallableUnit[] ius, ProfileChangeOperation operation) {
+ public AcceptLicensesWizardPage(LicenseManager manager, IInstallableUnit[] ius, ProfileChangeOperation operation) {
super("AcceptLicenses"); //$NON-NLS-1$
setTitle(ProvUIMessages.AcceptLicensesWizardPage_Title);
this.manager = manager;
- this.translations = translationSupport;
update(ius, operation);
}
@@ -290,7 +286,7 @@ public class AcceptLicensesWizardPage extends WizardPage {
if (singleIU != null) {
String licenseBody = ""; //$NON-NLS-1$
// We've already established before calling this method that it's a single IU with a single license
- ILicense[] licenses = translations.getLicenses(singleIU);
+ ILicense[] licenses = singleIU.getLicenses(null);
if (licenses.length > 0 && licenses[0].getBody() != null) {
licenseBody = licenses[0].getBody();
}
@@ -391,11 +387,11 @@ public class AcceptLicensesWizardPage extends WizardPage {
HashMap namesSeen = new HashMap(); // map of License->HashSet of names with that license
for (int i = 0; i < iusToCheck.length; i++) {
IInstallableUnit iu = iusToCheck[i];
- ILicense[] licenses = translations.getLicenses(iu);
+ ILicense[] licenses = iu.getLicenses(null);
for (int k = 0; k < licenses.length; k++) {
ILicense license = licenses[k];
if (manager != null && !manager.isAccepted(license)) {
- String name = translations.getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
if (name == null)
name = iu.getId();
// Have we already found this license?
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
index b41a213da..d7c68f9e3 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
@@ -187,7 +187,7 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
void updateDetailsArea() {
IInstallableUnit[] selected = installedIUGroup.getSelectedIUs();
if (selected.length == 1) {
- String description = ui.getTranslationSupport().getIUProperty(selected[0], IInstallableUnit.PROP_DESCRIPTION);
+ String description = selected[0].getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
if (description != null) {
detailsArea.setText(description);
return;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
index 105572b7b..52f1f4baa 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
@@ -20,7 +20,6 @@ import org.eclipse.equinox.internal.p2.ui.dialogs.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
import org.eclipse.equinox.p2.common.LicenseManager;
-import org.eclipse.equinox.p2.common.TranslationSupport;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -126,15 +125,6 @@ public class ProvisioningUI {
}
/**
- * Return the translation support used to get localized metadata values.
- *
- * @return the translation support, must not be <code>null</code>
- */
- public TranslationSupport getTranslationSupport() {
- return ProvUIActivator.getDefault().getTranslationSupport();
- }
-
- /**
* Return an install operation that describes installing the specified IInstallableUnits from the
* provided list of repositories.
*
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index e1639b22c..48179373e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
@@ -481,7 +481,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
public String getName() {
if (iu != null) {
- return ui.getTranslationSupport().getIUProperty(iu, IInstallableUnit.PROP_NAME);
+ return iu.getProperty(IInstallableUnit.PROP_NAME, null);
}
return pe.getLabel(null);
}

Back to the top