Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 209697 Details for
Bug 236709
p2 should register bundle groups
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
work in progress - p2 repo
236709-p2.txt (text/plain), 41.30 KB, created by
DJ Houghton
on 2012-01-18 13:02:15 EST
(
hide
)
Description:
work in progress - p2 repo
Filename:
MIME Type:
Creator:
DJ Houghton
Created:
2012-01-18 13:02:15 EST
Size:
41.30 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/.project b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/.project >index 18fa42e..0a3bdda 100644 >--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/.project >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/.project >@@ -25,6 +25,11 @@ > <arguments> > </arguments> > </buildCommand> >+ <buildCommand> >+ <name>org.eclipse.pde.ds.core.builder</name> >+ <arguments> >+ </arguments> >+ </buildCommand> > </buildSpec> > <natures> > <nature>org.eclipse.pde.PluginNature</nature> >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF >index b348995..64ba6c1 100644 >--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF >@@ -43,7 +43,9 @@ Import-Package: javax.xml.parsers, > org.eclipse.osgi.service.resolver;version="1.2.0";resolution:=optional, > org.eclipse.osgi.util;version="1.1.0", > org.osgi.framework;version="1.3.0", >+ org.osgi.service.packageadmin;version="1.2.0", > org.osgi.service.prefs;version="1.1.1", > org.osgi.util.tracker;version="1.4.0", > org.w3c.dom, > org.xml.sax >+Service-Component: OSGI-INF/bundleGroup.xml >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/OSGI-INF/bundleGroup.xml b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/OSGI-INF/bundleGroup.xml >new file mode 100644 >index 0000000..0e41469 >--- /dev/null >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/OSGI-INF/bundleGroup.xml >@@ -0,0 +1,7 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="false" name="org.eclipse.equinox.p2.touchpoint.eclipse.bundlegroup"> >+ <implementation class="org.eclipse.equinox.internal.p2.touchpoint.eclipse.BundleGroupComponent"/> >+ <service> >+ <provide interface="org.eclipse.core.runtime.IBundleGroupProvider"/> >+ </service> >+</scr:component> >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/build.properties b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/build.properties >index 167d8e3..2af95ce 100644 >--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/build.properties >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/build.properties >@@ -14,7 +14,8 @@ bin.includes = META-INF/,\ > .,\ > plugin.xml,\ > about.html,\ >- plugin.properties >+ plugin.properties,\ >+ OSGI-INF/ > src.includes = about.html > javacTarget=jsr14 > javacSource=1.5 >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AboutInfo.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AboutInfo.java >new file mode 100644 >index 0000000..6c34b45 >--- /dev/null >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AboutInfo.java >@@ -0,0 +1,224 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.touchpoint.eclipse; >+ >+import java.net.URL; >+import java.util.Hashtable; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+ >+/** >+ * The information within this object is obtained from the about INI file. >+ * This file resides within an install configurations directory and must be a >+ * standard java property file. >+ * <p> >+ * This class is not intended to be instantiated or subclassed by clients. >+ * </p> >+ */ >+public final class AboutInfo { >+ private final static String INI_FILENAME = "about.ini"; //$NON-NLS-1$ >+ private final static String PROPERTIES_FILENAME = "about.properties"; //$NON-NLS-1$ >+ private final static String MAPPINGS_FILENAME = "about.mappings"; //$NON-NLS-1$ >+ >+ private String featureId; >+ private String versionId = ""; //$NON-NLS-1$ >+ private String providerName; >+ private String appName; >+ private URL windowImageURL; >+ private URL[] windowImagesURLs; >+ private URL aboutImageURL; >+ private URL featureImageURL; >+ private URL welcomePageURL; >+ private String aboutText; >+ private String welcomePerspective; >+ private String tipsAndTricksHref; >+ >+ /* >+ * Create a new about info for a feature with the given id. >+ */ >+ /* package */AboutInfo(String featureId) { >+ super(); >+ this.featureId = featureId; >+ } >+ >+ /** >+ * Returns the configuration information for the feature with the >+ * given id. >+ * >+ * @param featureId the feature id >+ * @param versionId the version id (of the feature) >+ * @param pluginId the plug-in id >+ * @return the configuration information for the feature >+ */ >+ public static AboutInfo readFeatureInfo(String featureId, String versionId, String pluginId) { >+ >+ AboutInfo info = new AboutInfo(featureId); >+ IniFileReader reader = new IniFileReader(featureId, pluginId, INI_FILENAME, PROPERTIES_FILENAME, MAPPINGS_FILENAME); >+ if (!reader.load().isOK()) >+ return info; >+ Hashtable<String, String> runtimeMappings = new Hashtable<String, String>(); >+ runtimeMappings.put("{featureVersion}", versionId); //$NON-NLS-1$ >+ info.versionId = versionId; >+ info.providerName = reader.getProviderName(); >+ info.appName = reader.getString("appName", true, runtimeMappings); //$NON-NLS-1$ >+ info.aboutText = reader.getString("aboutText", true, runtimeMappings); //$NON-NLS-1$ >+ info.windowImageURL = reader.getURL("windowImage"); //$NON-NLS-1$ >+ // look for the newer array, but if its not there then use the older, >+ // single image definition >+ info.windowImagesURLs = reader.getURLs("windowImages"); //$NON-NLS-1$ >+ info.aboutImageURL = reader.getURL("aboutImage"); //$NON-NLS-1$ >+ info.featureImageURL = reader.getURL("featureImage"); //$NON-NLS-1$ >+ info.welcomePageURL = reader.getURL("welcomePage"); //$NON-NLS-1$ >+ info.welcomePerspective = reader.getString("welcomePerspective", false, runtimeMappings); //$NON-NLS-1$ >+ info.tipsAndTricksHref = reader.getString("tipsAndTricksHref", false, runtimeMappings); //$NON-NLS-1$ >+ return info; >+ } >+ >+ /** >+ * Returns the URL for an image which can be shown in an "about" dialog >+ * for this product. Products designed to run "headless" typically would not >+ * have such an image. >+ * >+ * @return the URL for an about image, or <code>null</code> if none >+ */ >+ public URL getAboutImageURL() { >+ return aboutImageURL; >+ } >+ >+ /** >+ * Returns the URL for an image which can be shown in an "about features" >+ * dialog. Products designed to run "headless" typically would not have such an image. >+ * >+ * @return the URL for a feature image, or <code>null</code> if none >+ */ >+ public URL getFeatureImageURL() { >+ return featureImageURL; >+ } >+ >+ /** >+ * Returns the simple name of the feature image file. >+ * >+ * @return the simple name of the feature image file, >+ * or <code>null</code> if none >+ */ >+ public String getFeatureImageName() { >+ if (featureImageURL != null) { >+ IPath path = new Path(featureImageURL.getPath()); >+ return path.lastSegment(); >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the id for this feature. >+ * >+ * @return the feature id >+ */ >+ public String getFeatureId() { >+ return featureId; >+ } >+ >+ /** >+ * Returns the text to show in an "about" dialog for this product. >+ * Products designed to run "headless" typically would not have such text. >+ * >+ * @return the about text, or <code>null</code> if none >+ */ >+ public String getAboutText() { >+ return aboutText; >+ } >+ >+ /** >+ * Returns the application name or <code>null</code>. >+ * Note this is never shown to the user. >+ * It is used to initialize the SWT Display. >+ * <p> >+ * On Motif, for example, this can be used >+ * to set the name used for resource lookup. >+ * </p> >+ * >+ * @return the application name, or <code>null</code> >+ */ >+ public String getAppName() { >+ return appName; >+ } >+ >+ /** >+ * Returns the provider name or <code>null</code>. >+ * >+ * @return the provider name, or <code>null</code> >+ */ >+ public String getProviderName() { >+ return providerName; >+ } >+ >+ /** >+ * Returns the feature version id. >+ * >+ * @return the version id of the feature >+ */ >+ public String getVersionId() { >+ return versionId; >+ } >+ >+ /** >+ * Returns a <code>URL</code> for the welcome page. >+ * Products designed to run "headless" typically would not have such an page. >+ * >+ * @return the welcome page, or <code>null</code> if none >+ */ >+ public URL getWelcomePageURL() { >+ return welcomePageURL; >+ } >+ >+ /** >+ * Returns the ID of a perspective in which to show the welcome page. >+ * May be <code>null</code>. >+ * >+ * @return the welcome page perspective id, or <code>null</code> if none >+ */ >+ public String getWelcomePerspectiveId() { >+ return welcomePerspective; >+ } >+ >+ /** >+ * Returns a <code>String</code> for the tips and trick href. >+ * >+ * @return the tips and tricks href, or <code>null</code> if none >+ */ >+ public String getTipsAndTricksHref() { >+ return tipsAndTricksHref; >+ } >+ >+ /** >+ * Returns the image url for the window image to use for this product. >+ * Products designed to run "headless" typically would not have such an image. >+ * >+ * @return the image url for the window image, or <code>null</code> if none >+ */ >+ public URL getWindowImageURL() { >+ return windowImageURL; >+ } >+ >+ /** >+ * Return an array of image URLs for the window images to use for >+ * this product. The expectations is that the elements will be the same >+ * image rendered at different sizes. Products designed to run "headless" >+ * typically would not have such images. >+ * >+ * @return an array of the image descriptors for the window images, or >+ * <code>null</code> if none >+ * @since 3.0 >+ */ >+ public URL[] getWindowImagesURLs() { >+ return windowImagesURLs; >+ } >+} >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Activator.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Activator.java >index 77f5529..57c1a69 100644 >--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Activator.java >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Activator.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2011 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 >@@ -10,12 +10,18 @@ > *******************************************************************************/ > package org.eclipse.equinox.internal.p2.touchpoint.eclipse; > >-import org.osgi.framework.BundleActivator; >-import org.osgi.framework.BundleContext; >+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >+import org.eclipse.equinox.p2.core.IProvisioningAgent; >+import org.eclipse.equinox.p2.engine.IProfile; >+import org.eclipse.equinox.p2.engine.IProfileRegistry; >+import org.osgi.framework.*; >+import org.osgi.service.packageadmin.PackageAdmin; >+import org.osgi.util.tracker.ServiceTracker; > > public class Activator implements BundleActivator { > public static final String ID = "org.eclipse.equinox.p2.touchpoint.eclipse"; //$NON-NLS-1$ > private static BundleContext context = null; >+ private static ServiceTracker<?, ?> bundleTracker; > > public void start(BundleContext ctx) throws Exception { > Activator.context = ctx; >@@ -23,10 +29,48 @@ public class Activator implements BundleActivator { > > public void stop(BundleContext ctx) throws Exception { > Activator.context = null; >+ if (Activator.bundleTracker != null) { >+ Activator.bundleTracker.close(); >+ Activator.bundleTracker = null; >+ } > } > > public static BundleContext getContext() { > return Activator.context; > } > >+ /* >+ * Return the current profile or null if it cannot be retrieved. >+ */ >+ public static IProfile getProfile() { >+ IProvisioningAgent agent = getAgent(); >+ IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); >+ if (profileRegistry == null) >+ return null; >+ return profileRegistry.getProfile(IProfileRegistry.SELF); >+ } >+ >+ private static IProvisioningAgent getAgent() { >+ return (IProvisioningAgent) ServiceHelper.getService(Activator.getContext(), IProvisioningAgent.SERVICE_NAME); >+ } >+ >+ public static synchronized Bundle getBundle(String symbolicName) { >+ if (bundleTracker == null) { >+ bundleTracker = new ServiceTracker(getContext(), PackageAdmin.class, null); >+ bundleTracker.open(); >+ } >+ PackageAdmin admin = (PackageAdmin) bundleTracker.getService(); >+ if (admin == null) >+ return null; >+ Bundle[] bundles = admin.getBundles(symbolicName, null); >+ if (bundles == null) >+ return null; >+ //Return the first bundle that is not installed or uninstalled >+ for (int i = 0; i < bundles.length; i++) { >+ if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { >+ return bundles[i]; >+ } >+ } >+ return null; >+ } > } >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/BundleGroupComponent.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/BundleGroupComponent.java >new file mode 100644 >index 0000000..3631edb >--- /dev/null >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/BundleGroupComponent.java >@@ -0,0 +1,164 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.internal.p2.touchpoint.eclipse; >+ >+import java.net.URL; >+import java.util.*; >+import org.eclipse.core.runtime.IBundleGroup; >+import org.eclipse.core.runtime.IBundleGroupProvider; >+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; >+import org.eclipse.equinox.internal.p2.metadata.TranslationSupport; >+import org.eclipse.equinox.p2.engine.IProfile; >+import org.eclipse.equinox.p2.metadata.IInstallableUnit; >+import org.eclipse.equinox.p2.metadata.IRequirement; >+import org.eclipse.equinox.p2.query.IQueryResult; >+import org.eclipse.equinox.p2.query.QueryUtil; >+import org.osgi.framework.Bundle; >+ >+public class BundleGroupComponent implements IBundleGroupProvider { >+ >+ TranslationSupport translator = TranslationSupport.getInstance(); >+ >+ public class IUBundleGroup implements IBundleGroup, IBundleGroupConstants, IProductConstants { >+ IInstallableUnit iu; >+ AboutInfo branding; >+ >+ public IUBundleGroup(IInstallableUnit iu) { >+ this.iu = iu; >+ } >+ >+ private AboutInfo getBranding() { >+ if (branding == null) >+ branding = AboutInfo.readFeatureInfo(getIdentifier(), getVersion(), getIdentifier()); >+ return branding; >+ } >+ >+ public String getIdentifier() { >+ String id = iu.getId(); >+ if (id == null) >+ return null; >+ // trim the id if it ends in ".feature.group" so it looks more >+ // like a feature id than an IU id >+ final String END = ".feature.group"; //$NON-NLS-1$ >+ if (id.endsWith(END)) >+ id = id.substring(0, id.length() - END.length()); >+ return id; >+ } >+ >+ public String getName() { >+ return translator.getIUProperty(iu, IInstallableUnit.PROP_NAME); >+ } >+ >+ public String getVersion() { >+ return iu.getVersion().toString(); >+ } >+ >+ public String getDescription() { >+ return translator.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION); >+ } >+ >+ public String getProviderName() { >+ return translator.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER); >+ } >+ >+ public Bundle[] getBundles() { >+ Collection<Bundle> result = new HashSet<Bundle>(); >+ Collection<IRequirement> reqs = iu.getRequirements(); >+ for (IRequirement obj : reqs) { >+ if (!(obj instanceof IRequiredCapability)) >+ continue; >+ IRequiredCapability req = (IRequiredCapability) obj; >+ // we are only interested in requirements on other IUs >+ if (!IInstallableUnit.NAMESPACE_IU_ID.equals(req.getNamespace())) >+ continue; >+ String id = req.getName(); >+ Bundle b = Activator.getBundle(id); >+ if (b != null) >+ result.add(b); >+ } >+ return result.toArray(new Bundle[result.size()]); >+ } >+ >+ public String getProperty(String key) { >+ AboutInfo branding = getBranding(); >+ // IBundleGroupConstants >+ if (key.equals(FEATURE_IMAGE)) >+ return branding.getFeatureImageURL() == null ? null : branding.getFeatureImageURL().toExternalForm(); >+ else if (key.equals(TIPS_AND_TRICKS_HREF)) >+ return branding.getTipsAndTricksHref(); >+ else if (key.equals(IBundleGroupConstants.WELCOME_PAGE)) // same value is used by product and bundle group >+ return branding.getWelcomePageURL() == null ? null : branding.getWelcomePageURL().toExternalForm(); >+ else if (key.equals(WELCOME_PERSPECTIVE)) >+ return branding.getWelcomePerspectiveId(); >+ else if (key.equals(BRANDING_BUNDLE_ID)) >+ // TODO >+ return getIdentifier(); >+ else if (key.equals(BRANDING_BUNDLE_VERSION)) >+ // TODO >+ return getVersion(); >+ // IProductConstants >+ else if (key.equals(APP_NAME)) >+ return branding.getAppName(); >+ else if (key.equals(ABOUT_TEXT)) >+ return branding.getAboutText(); >+ else if (key.equals(ABOUT_IMAGE)) >+ return branding.getAboutImageURL() == null ? null : branding.getAboutImageURL().toExternalForm(); >+ else if (key.equals(WINDOW_IMAGE)) >+ return branding.getWindowImageURL() == null ? null : branding.getWindowImageURL().toExternalForm(); >+ else if (key.equals(WINDOW_IMAGES)) { >+ URL[] urls = branding.getWindowImagesURLs(); >+ if (urls == null) >+ return null; >+ StringBuffer windowImagesURLs = new StringBuffer(); >+ for (int i = 0; i < urls.length; i++) { >+ windowImagesURLs.append(urls[i].toExternalForm()); >+ if (i != urls.length - 1) >+ windowImagesURLs.append(','); >+ } >+ return windowImagesURLs.toString(); >+ } else if (key.equals(LICENSE_HREF)) >+ // TODO >+ //return getLicenseURL(); >+ return null; >+ >+ return translator.getIUProperty(iu, key); >+ } >+ >+ public String toString() { >+ return "IUBundleGroup(" + getIdentifier() + " " + getVersion() + ")"; >+ } >+ } >+ >+ public String getName() { >+ return Messages.bundleGroupComponentName; >+ } >+ >+ public IBundleGroup[] getBundleGroups() { >+ if (!isReconciling()) >+ return new IBundleGroup[0]; >+ IProfile profile = Activator.getProfile(); >+ IQueryResult<IInstallableUnit> profileQueryResult = profile.query(QueryUtil.createIUGroupQuery(), null); >+ List<IBundleGroup> result = new ArrayList<IBundleGroup>(); >+ for (Iterator<IInstallableUnit> it = profileQueryResult.iterator(); it.hasNext();) { >+ IInstallableUnit iu = it.next(); >+ result.add(new IUBundleGroup(iu)); >+ } >+ return result.toArray(new IUBundleGroup[result.size()]); >+ } >+ >+ /** >+ * Returns whether or not we are reconciling. Check the system property to see >+ * if the update manager is doing the work or not. >+ */ >+ public static boolean isReconciling() { >+ String reconcile = Activator.getContext().getProperty("org.eclipse.update.reconcile"); //$NON-NLS-1$ >+ return reconcile != null && reconcile.equalsIgnoreCase("false"); //$NON-NLS-1$ >+ } >+} >\ No newline at end of file >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IBundleGroupConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IBundleGroupConstants.java >new file mode 100644 >index 0000000..d352ce5 >--- /dev/null >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IBundleGroupConstants.java >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.touchpoint.eclipse; >+ >+/** >+ * These constants define the set of properties that the UI expects to >+ * be available via <code>IBundleGroup.getProperty(String)</code>. >+ * >+ * @since 3.0 >+ * @see org.eclipse.core.runtime.IBundleGroup#getProperty(String) >+ */ >+public interface IBundleGroupConstants { >+ /** >+ * An image which can be shown in an "about features" dialog (32x32). >+ */ >+ public static final String FEATURE_IMAGE = "featureImage"; //$NON-NLS-1$ >+ >+ /** >+ * A help reference for the feature's tips and tricks page (optional). >+ */ >+ public static final String TIPS_AND_TRICKS_HREF = "tipsAndTricksHref"; //$NON-NLS-1$ >+ >+ /** >+ * A URL for the feature's welcome page (special XML-based format) >+ * ($nl$/ prefix to permit locale-specific translations of entire file). >+ * Products designed to run "headless" typically would not have such a page. >+ */ >+ public static final String WELCOME_PAGE = "welcomePage"; //$NON-NLS-1$ >+ >+ /** >+ * The id of a perspective in which to show the welcome page >+ * (optional). >+ */ >+ public static final String WELCOME_PERSPECTIVE = "welcomePerspective"; //$NON-NLS-1$ >+ >+ /** >+ * The URL of the license page for the feature >+ * (optional). >+ */ >+ public static final String LICENSE_HREF = "licenseHref"; //$NON-NLS-1$ >+ >+ /** >+ * The id of the bundle group's branding bundle. >+ * @see IFeatureEntry#getFeaturePluginIdentifier() >+ * @since 3.3 >+ */ >+ public static final String BRANDING_BUNDLE_ID = "brandingBundleId"; //$NON-NLS-1$ >+ >+ /** >+ * The version of the feature branding bundle. >+ * @see IFeatureEntry#getFeaturePluginVersion() >+ * @since 3.3 >+ */ >+ public static final String BRANDING_BUNDLE_VERSION = "brandingBundleVersion"; //$NON-NLS-1$ >+} >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IProductConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IProductConstants.java >new file mode 100644 >index 0000000..12ad711 >--- /dev/null >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IProductConstants.java >@@ -0,0 +1,77 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.touchpoint.eclipse; >+ >+/** >+ * These constants define the set of properties that the UI expects to >+ * be available via <code>IProduct.getProperty(String)</code>. >+ * >+ * @since 3.0 >+ * @see org.eclipse.core.runtime.IProduct#getProperty(String) >+ */ >+public interface IProductConstants { >+ /** >+ * The application name, used to initialize the SWT Display. This >+ * value is distinct from the string displayed in the application >+ * title bar. >+ * <p> >+ * E.g., On motif, this can be used to set the name used for >+ * resource lookup. >+ * </p> >+ */ >+ public static final String APP_NAME = "appName"; //$NON-NLS-1$ >+ >+ /** >+ * The text to show in an "about" dialog for this product. >+ * Products designed to run "headless" typically would not >+ * have such text. >+ */ >+ public static final String ABOUT_TEXT = "aboutText"; //$NON-NLS-1$ >+ >+ /** >+ * An image which can be shown in an "about" dialog for this >+ * product. Products designed to run "headless" typically would not >+ * have such an image. >+ * <p> >+ * A full-sized product image (no larger than 500x330 pixels) is >+ * shown without the "aboutText" blurb. A half-sized product image >+ * (no larger than 250x330 pixels) is shown with the "aboutText" >+ * blurb beside it. >+ */ >+ public static final String ABOUT_IMAGE = "aboutImage"; //$NON-NLS-1$ >+ >+ /** >+ * An image to be used as the window icon for this product (16x16). >+ * Products designed to run "headless" typically would not have such an image. >+ * <p> >+ * If the <code>WINDOW_IMAGES</code> property is given, then it supercedes >+ * this one. >+ * </p> >+ */ >+ public static final String WINDOW_IMAGE = "windowImage"; //$NON-NLS-1$ >+ >+ /** >+ * An array of one or more images to be used for this product. The >+ * expectation is that the array will contain the same image rendered >+ * at different sizes (16x16 and 32x32). >+ * Products designed to run "headless" typically would not have such images. >+ * <p> >+ * If this property is given, then it supercedes <code>WINDOW_IMAGE</code>. >+ * </p> >+ */ >+ public static final String WINDOW_IMAGES = "windowImages"; //$NON-NLS-1$ >+ /** >+ * A URL for the products's welcome page (special XML-based format) >+ * ($nl$/ prefix to permit locale-specific translations of entire file). >+ * Products designed to run "headless" typically would not have such a page. >+ */ >+ public static final String WELCOME_PAGE = "welcomePage"; //$NON-NLS-1$ >+} >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IniFileReader.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IniFileReader.java >new file mode 100644 >index 0000000..7958573 >--- /dev/null >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/IniFileReader.java >@@ -0,0 +1,353 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.touchpoint.eclipse; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.net.URL; >+import java.text.MessageFormat; >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.util.NLS; >+import org.osgi.framework.Bundle; >+import org.osgi.framework.Constants; >+ >+// Have to use MessageFormat directly, can't use ICU, possible launch problem? >+ >+/** >+ * Reads the information found in an "INI" file. This file must be in a >+ * standard Java properties format. A properties file may also be provided >+ * to NL values in the INI file - values must start with the % prefix. A >+ * mapping file may also be provided that contains "fill-ins" for the >+ * properties file - format being "n = some text", where n is a number. >+ */ >+public class IniFileReader { >+ private static final String PID = "org.eclipse.update.configurator"; //$NON-NLS-1$ >+ private static final Status OK_STATUS = new Status(IStatus.OK, PID, 0, "", null); //$NON-NLS-1$ >+ private static final String KEY_PREFIX = "%"; //$NON-NLS-1$ >+ private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$ >+ private static final String NLS_TAG = "$nl$"; //$NON-NLS-1$ >+ >+ private String featureId; >+ private String pluginId; >+ private String iniFilename; >+ private String propertiesFilename; >+ private String mappingsFilename; >+ private Properties ini = null; >+ private PropertyResourceBundle properties = null; >+ private String[] mappings = null; >+ private Bundle bundle; >+ >+ /** >+ * Creates an INI file reader that can parse the contents into key,value pairs. >+ * >+ * @param featureId the unique identifier of the feature, must not be <code>null</code> >+ * @param pluginId the unique identifier of the feature plug-in, must not be <code>null</code> >+ * @param iniFilename the INI file name, must not be <code>null</code> >+ * @param propertiesFilename the properties filename, can be <code>null</code> if not required >+ * @param mappingsFilename the mappings filename, can be <code>null</code> if not required >+ */ >+ public IniFileReader(String featureId, String pluginId, String iniFilename, String propertiesFilename, String mappingsFilename) { >+ super(); >+ >+ if (featureId == null || pluginId == null || iniFilename == null) { >+ throw new IllegalArgumentException(); >+ } >+ >+ this.featureId = featureId; >+ this.pluginId = pluginId; >+ this.iniFilename = iniFilename; >+ this.propertiesFilename = propertiesFilename; >+ this.mappingsFilename = mappingsFilename; >+ } >+ >+ /** >+ * Read the contents of the INI, properties, and mappings files. >+ * Does nothing if the content has already been read and parsed. >+ * >+ * @return an <code>IStatus</code> indicating the success or failure >+ * of reading and parsing the INI file content >+ */ >+ public IStatus load() { >+ if (ini != null) >+ return OK_STATUS; >+ >+ // attempt to locate the corresponding plugin >+ bundle = Activator.getBundle(pluginId); >+ if (bundle == null || bundle.getState() == Bundle.UNINSTALLED || bundle.getState() == Bundle.INSTALLED) { >+ bundle = null; // make it null for other test down the road >+ String message = NLS.bind("Cannot find plug-in for feature {0}.", (new String[] {featureId})); >+ return new Status(IStatus.ERROR, PID, 0, message, null); >+ } >+ >+ // Determine the ini file location >+ URL iniURL = null; >+ IOException ioe = null; >+ iniURL = FileLocator.find(bundle, new Path(NLS_TAG).append(iniFilename), null); >+ if (iniURL == null) { >+ String message = NLS.bind("Cannot open branding file {0}.", (new String[] {iniFilename})); >+ return new Status(IStatus.ERROR, PID, 0, message, ioe); >+ } >+ >+ // Determine the properties file location >+ URL propertiesURL = null; >+ if (propertiesFilename != null & propertiesFilename.length() > 0) { >+ propertiesURL = FileLocator.find(bundle, new Path(NLS_TAG).append(propertiesFilename), null); >+ } >+ >+ // Determine the mappings file location >+ URL mappingsURL = null; >+ if (mappingsFilename != null && mappingsFilename.length() > 0) { >+ mappingsURL = FileLocator.find(bundle, new Path(NLS_TAG).append(mappingsFilename), null); >+ } >+ >+ // OK to pass null properties and/or mapping file >+ return load(iniURL, propertiesURL, mappingsURL); >+ } >+ >+ /** >+ * Returns the string value for the given key, or <code>null</code>. >+ * The string value is NLS if requested. >+ * >+ * @return the string value for the given key, or <code>null</code> >+ */ >+ public String getString(String key, boolean doNls, Hashtable<String, String> runtimeMappings) { >+ if (ini == null) >+ return null; >+ String value = ini.getProperty(key); >+ if (value != null && doNls) >+ return getResourceString(value, runtimeMappings); >+ return value; >+ } >+ >+ /** >+ * Returns a URL for the given key, or <code>null</code>. >+ * >+ * @return a URL for the given key, or <code>null</code> >+ */ >+ public URL getURL(String key) { >+ if (ini == null) >+ return null; >+ >+ URL url = null; >+ String fileName = ini.getProperty(key); >+ if (fileName != null) { >+ if (bundle == null) >+ return null; >+ url = FileLocator.find(bundle, new Path(fileName), null); >+ } >+ return url; >+ } >+ >+ /** >+ * Returns a array of URL for the given key, or <code>null</code>. The >+ * property value should be a comma separated list of urls, tokens for >+ * which bundle cannot build an url will have a null entry. >+ * >+ * @param key name of the property containing the requested urls >+ * @return a URL for the given key, or <code>null</code> >+ * @since 3.0 >+ */ >+ public URL[] getURLs(String key) { >+ if (ini == null || bundle == null) >+ return null; >+ >+ String value = ini.getProperty(key); >+ if (value == null) >+ return null; >+ >+ StringTokenizer tokens = new StringTokenizer(value, ","); //$NON-NLS-1$ >+ ArrayList<URL> array = new ArrayList<URL>(10); >+ while (tokens.hasMoreTokens()) { >+ String str = tokens.nextToken().trim(); >+ array.add(FileLocator.find(bundle, new Path(str), null)); >+ } >+ return array.toArray(new URL[array.size()]); >+ } >+ >+ /** >+ * Returns the feature plugin label, or <code>null</code>. >+ * >+ * @return the feature plugin lable, or <code>null</code> if none. >+ */ >+ public String getFeaturePluginLabel() { >+ return bundle == null ? null : bundle.getHeaders().get(Constants.BUNDLE_NAME); >+ } >+ >+ /** >+ * Returns the provider name for this feature, or <code>null</code>. >+ * >+ * @return the provider name for this feature, or <code>null</code> >+ */ >+ public String getProviderName() { >+ return bundle == null ? null : bundle.getHeaders().get(Constants.BUNDLE_VENDOR); >+ } >+ >+ /* >+ * Returns a resource string corresponding to the given argument >+ * value and bundle. >+ * If the argument value specifies a resource key, the string >+ * is looked up in the given resource bundle. If the argument does not >+ * specify a valid key, the argument itself is returned as the >+ * resource string. The key lookup is performed against the >+ * specified resource bundle. If a resource string >+ * corresponding to the key is not found in the resource bundle >+ * the key value, or any default text following the key in the >+ * argument value is returned as the resource string. >+ * A key is identified as a string begining with the "%" character. >+ * Note that the "%" character is stripped off prior to lookup >+ * in the resource bundle. >+ * <p> >+ * For example, assume resource bundle plugin.properties contains >+ * name = Project Name >+ * <pre> >+ * <li>getResourceString("Hello World") returns "Hello World"</li> >+ * <li>getResourceString("%name") returns "Project Name"</li> >+ * <li>getResourceString("%name Hello World") returns "Project Name"</li> >+ * <li>getResourceString("%abcd Hello World") returns "Hello World"</li> >+ * <li>getResourceString("%abcd") returns "%abcd"</li> >+ * <li>getResourceString("%%name") returns "%name"</li> >+ * <li>getResourceString(<code>null</code>) returns <code>null</code></li> >+ * </pre> >+ * </p> >+ * >+ * @param value the value or <code>null</code> >+ * @param runtimeMappings runtime mappings or <code>null</code> >+ * @return the resource string >+ */ >+ public String getResourceString(String value, Hashtable<String, String> runtimeMappings) { >+ >+ if (value == null) >+ return null; >+ String s = value.trim(); >+ >+ if (!s.startsWith(KEY_PREFIX)) >+ return s; >+ >+ if (s.startsWith(KEY_DOUBLE_PREFIX)) >+ return s.substring(1); >+ >+ int ix = s.indexOf(" "); //$NON-NLS-1$ >+ String key = ix == -1 ? s : s.substring(0, ix); >+ String dflt = ix == -1 ? s : s.substring(ix + 1); >+ >+ if (properties == null) >+ return dflt; >+ >+ String result = null; >+ try { >+ result = properties.getString(key.substring(1)); >+ } catch (MissingResourceException e) { >+ return dflt; >+ } >+ if (runtimeMappings != null) { >+ for (Enumeration<String> e = runtimeMappings.keys(); e.hasMoreElements();) { >+ String keyValue = e.nextElement(); >+ int i = result.indexOf(keyValue); >+ if (i != -1) { >+ String s1 = result.substring(0, i); >+ String s2 = runtimeMappings.get(keyValue); >+ String s3 = result.substring(i + keyValue.length()); >+ result = s1 + s2 + s3; >+ } >+ } >+ } >+ >+ if (result.indexOf('{') != -1) { >+ // We test for the curly braces since due to NL issues we do not >+ // want to use MessageFormat unless we have to. >+ try { >+ result = MessageFormat.format(result, mappings); >+ } catch (IllegalArgumentException e) { >+ //ignore and return string without bound parameters >+ } >+ } >+ >+ return result; >+ } >+ >+ /* >+ * Read the contents of the ini, properties, and mappings files. >+ */ >+ private IStatus load(URL iniURL, URL propertiesURL, URL mappingsURL) { >+ >+ InputStream is = null; >+ try { >+ is = iniURL.openStream(); >+ ini = new Properties(); >+ ini.load(is); >+ } catch (IOException e) { >+ ini = null; >+ String message = NLS.bind("Error reading branding file {0}.", (new String[] {iniURL.toExternalForm()})); >+ return new Status(IStatus.ERROR, PID, 0, message, e); >+ } finally { >+ try { >+ if (is != null) >+ is.close(); >+ } catch (IOException e) { >+ } >+ } >+ >+ if (propertiesURL != null) { >+ is = null; >+ try { >+ is = propertiesURL.openStream(); >+ properties = new PropertyResourceBundle(is); >+ } catch (IOException e) { >+ properties = null; >+ String message = NLS.bind("Error reading branding properties file {0}.", (new String[] {propertiesURL.toExternalForm()})); >+ return new Status(IStatus.ERROR, PID, 0, message, e); >+ } finally { >+ try { >+ if (is != null) >+ is.close(); >+ } catch (IOException e) { >+ } >+ } >+ } >+ >+ PropertyResourceBundle bundle = null; >+ if (mappingsURL != null) { >+ is = null; >+ try { >+ is = mappingsURL.openStream(); >+ bundle = new PropertyResourceBundle(is); >+ } catch (IOException e) { >+ bundle = null; >+ String message = NLS.bind("Error reading branding mapping file {0}.", (new String[] {mappingsURL.toExternalForm()})); >+ return new Status(IStatus.ERROR, PID, 0, message, e); >+ } finally { >+ try { >+ if (is != null) >+ is.close(); >+ } catch (IOException e) { >+ } >+ } >+ } >+ >+ ArrayList mappingsList = new ArrayList(); >+ if (bundle != null) { >+ boolean found = true; >+ int i = 0; >+ while (found) { >+ try { >+ mappingsList.add(bundle.getString(Integer.toString(i))); >+ } catch (MissingResourceException e) { >+ found = false; >+ } >+ i++; >+ } >+ } >+ mappings = (String[]) mappingsList.toArray(new String[mappingsList.size()]); >+ >+ return OK_STATUS; >+ } >+} >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java >index 22f91b5..038b40c 100644 >--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Messages.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >+ * Copyright (c) 2008, 2011 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 >@@ -28,6 +28,7 @@ public class Messages extends NLS { > public static String artifact_file_not_found; > public static String artifact_retrieval_unsupported; > public static String bundle_pool_not_writeable; >+ public static String bundleGroupComponentName; > public static String cannot_calculate_extension_location; > public static String parent_dir_features; > public static String platform_config_unavailable; >diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties >index 81f1ab0..360b4a2 100644 >--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties >+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/messages.properties >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2008, 2009 IBM Corporation and others. >+# Copyright (c) 2008, 2011 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 >@@ -21,6 +21,7 @@ artifact_write_unsupported=Repository not writeable. > artifact_file_not_found=The artifact file for {0} was not found. > artifact_retrieval_unsupported=Repository does not support artifact retrieval > bundle_pool_not_writeable=Bundle pool repository not writeable: {0} >+bundleGroupComponentName=Equinox p2 Bundle Group Provider > BundlePool=Bundle pool > cannot_calculate_extension_location=Unable to calculate extension location for: {0}. > parent_dir_features=Parent directory should be "features": {0}.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 236709
:
205648
| 209697 |
209698