- move org.eclipse.core.runtime package (IProduct etc.) back to org.eclipse.core.runtime bundle
- adds relevant methods to IApplicationContext from IProduct
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index 19f2144..9923ff7 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -111,10 +111,11 @@
private ServiceTracker debugTracker = null;
private ServiceTracker contentTracker = null;
private ServiceTracker preferencesTracker = null;
- private ServiceTracker productTracker = null;
private ServiceTracker userLocation = null;
private ServiceTracker groupProviderTracker = null;
+ private IProduct product;
+
public static InternalPlatform getDefault() {
return singleton;
}
@@ -510,8 +511,17 @@
}
public IProduct getProduct() {
+ if (product != null)
+ return product;
EclipseAppContainer container = Activator.getContainer();
- return container == null ? null : container.getProduct();
+ IBranding branding = container == null ? null : container.getBranding();
+ if (branding == null)
+ return null;
+ Object brandingProduct = branding.getProduct();
+ if (!(brandingProduct instanceof IProduct))
+ brandingProduct = new Product(branding);
+ product = (IProduct) brandingProduct;
+ return product;
}
public IExtensionRegistry getRegistry() {
@@ -817,10 +827,6 @@
}
private void closeOSGITrackers() {
- if (productTracker != null) {
- productTracker.close();
- productTracker = null;
- }
if (preferencesTracker != null) {
preferencesTracker.close();
preferencesTracker = null;
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Product.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Product.java
index 9024f0f..af27a0f 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Product.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Product.java
@@ -1,76 +1,46 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2006 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.core.internal.runtime;
-import java.util.HashMap;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IProduct;
+import org.eclipse.equinox.internal.app.IBranding;
import org.osgi.framework.Bundle;
public class Product implements IProduct {
- private static final String ATTR_DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String ATTR_NAME = "name"; //$NON-NLS-1$
- private static final String ATTR_APPLICATION = "application"; //$NON-NLS-1$
- private static final String ATTR_VALUE = "value"; //$NON-NLS-1$
-
- String application = null;
- String name = null;
- String id = null;
- String description = null;
- HashMap properties;
- Bundle definingBundle = null;
-
- public Product(String id, IConfigurationElement element) {
- this.id = id;
- if (element == null)
- return;
- application = element.getAttribute(ATTR_APPLICATION);
- name = element.getAttribute(ATTR_NAME);
- description = element.getAttribute(ATTR_DESCRIPTION);
- loadProperties(element);
- }
-
- private void loadProperties(IConfigurationElement element) {
- IConfigurationElement[] children = element.getChildren();
- properties = new HashMap(children.length);
- for (int i = 0; i < children.length; i++) {
- IConfigurationElement child = children[i];
- String key = child.getAttribute(ATTR_NAME);
- String value = child.getAttribute(ATTR_VALUE);
- if (key != null && value != null)
- properties.put(key, value);
- }
- definingBundle = Platform.getBundle(element.getContributor().getName());
- }
-
- public Bundle getDefiningBundle() {
- return definingBundle;
+ IBranding branding;
+ public Product(IBranding branding) {
+ this.branding = branding;
}
public String getApplication() {
- return application;
+ return branding.getApplication();
}
- public String getName() {
- return name;
+ public Bundle getDefiningBundle() {
+ return branding.getDefiningBundle();
}
public String getDescription() {
- return description;
+ return branding.getDescription();
}
public String getId() {
- return id;
+ return branding.getId();
+ }
+
+ public String getName() {
+ return branding.getName();
}
public String getProperty(String key) {
- return (String) properties.get(key);
+ return branding.getProperty(key);
}
}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPlatformRunnable.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPlatformRunnable.java
new file mode 100644
index 0000000..c1bce35
--- /dev/null
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPlatformRunnable.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 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.core.runtime;
+
+import org.eclipse.equinox.app.IApplication;
+
+/**
+ * Bootstrap type for the platform. Platform runnables represent executable
+ * entry points into plug-ins. Runnables can be configured into the Platform's
+ * <code>org.eclipse.core.runtime.applications</code> extension-point
+ * or be made available through code or extensions on other plug-in's extension-points.
+ *
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ *
+ * @since 3.0
+ * @deprecated use {@link IApplication}
+ */
+public interface IPlatformRunnable {
+
+ /**
+ * Exit object indicating normal termination
+ */
+ public static final Integer EXIT_OK = new Integer(0);
+
+ /**
+ * Exit object requesting platform restart
+ */
+ public static final Integer EXIT_RESTART = new Integer(23);
+
+ /**
+ * Exit object requesting that the command passed back be executed. Typically
+ * this is used to relaunch Eclipse with different command line arguments. When the executable is
+ * relaunched the command line will be retrieved from the <code>eclipse.exit</code> system property.
+ */
+ public static final Integer EXIT_RELAUNCH = new Integer(24);
+
+ /**
+ * Runs this runnable with the given args and returns a result.
+ * The content of the args is unchecked and should conform to the expectations of
+ * the runnable being invoked. Typically this is a <code>String</code> array.
+ * Applications can return any object they like. If an <code>Integer</code> is returned
+ * it is treated as the program exit code if Eclipse is exiting.
+ *
+ * @param args the argument(s) to pass to the application
+ * @return the return value of the application
+ * @exception Exception if there is a problem running this runnable.
+ * @see #EXIT_OK
+ * @see #EXIT_RESTART
+ * @see #EXIT_RELAUNCH
+ */
+ public Object run(Object args) throws Exception;
+}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IProduct.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IProduct.java
new file mode 100644
index 0000000..246be33
--- /dev/null
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IProduct.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 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.core.runtime;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * Products are the Eclipse unit of branding. From the runtime point of view they have
+ * a name, id and description and identify the Eclipse application to run.
+ * <p>
+ * Since the bulk of the branding related information is
+ * specific to the UI, products also carry an arbitrary set of properties. The valid set of
+ * key-value pairs and their interpretation defined by the UI of the target environment.
+ * For example, in the standard Eclipse UI, <code>org.eclipse.ui.branding.IProductConstants</code>
+ * the properties of interest to the UI. Other clients may specify additional properties.
+ * </p><p>
+ * Products can be defined directly using extensions to the <code>org.eclipse.core.runtime.products</code>
+ * extension point or by using facilities provided by IProductProvider implementations.
+ * </p><p>
+ * For readers familiar with Eclipse 2.1 and earlier, products are roughly equivalent to
+ * <i>primary features</i>.
+ * </p>
+ *
+ * @see IProductProvider
+ * @see org.eclipse.ui.branding.IProductConstants
+ * @since 3.0
+ */
+public interface IProduct {
+ /**
+ * Returns the application associated with this product. This information is used
+ * to guide the runtime as to what application extension to create and execute.
+ *
+ * @return this product's application or <code>null</code> if none
+ */
+ public String getApplication();
+
+ /**
+ * Returns the name of this product. The name is typically used in the title
+ * bar of UI windows.
+ *
+ * @return the name of this product or <code>null</code> if none
+ */
+ public String getName();
+
+ /**
+ * Returns the text description of this product
+ *
+ * @return the description of this product or <code>null</code> if none
+ */
+ public String getDescription();
+
+ /** Returns the unique product id of this product.
+ *
+ * @return the id of this product
+ */
+ public String getId();
+
+ /**
+ * Returns the property of this product with the given key.
+ * <code>null</code> is returned if there is no such key/value pair.
+ *
+ * @param key the name of the property to return
+ * @return the value associated with the given key or <code>null</code> if none
+ */
+ public String getProperty(String key);
+
+ /**
+ * Returns the bundle which is responsible for the definition of this product.
+ * Typically this is used as a base for searching for images and other files
+ * that are needed in presenting the product.
+ *
+ * @return the bundle which defines this product or <code>null</code> if none
+ */
+ public Bundle getDefiningBundle();
+}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IProductProvider.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IProductProvider.java
new file mode 100644
index 0000000..5e72785
--- /dev/null
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IProductProvider.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 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.core.runtime;
+
+/**
+ * Product providers define products (units of branding) which have been installed in
+ * the current system. Typically, a configuration agent (i.e., plug-in installer) will
+ * define a product provider so that it can report to the system the products it has installed.
+ * <p>
+ * Products are normally defined and installed in the system using extensions to the
+ * <code>org.eclipse.core.runtime.products</code> extension point. In cases where
+ * the notion of product is defined by alternate means (e.g., primary feature), an <code>IProductProvider</code>
+ * can be installed in this extension point using an executable extension. The provider
+ * then acts as a proxy for the product extensions that represent the products installed.
+ * </p>
+ *
+ * @see IProduct
+ * @since 3.0
+ */
+public interface IProductProvider {
+ /**
+ * Returns the human-readable name of this product provider.
+ *
+ * @return the name of this product provider
+ */
+ public String getName();
+
+ /**
+ * Returns the products provided by this provider.
+ *
+ * @return the products provided by this provider
+ */
+ public IProduct[] getProducts();
+}