Update file upload dependencies (bundle renaming in RAP since file
upload has been promoted from incubator)
+
backport remote service support
diff --git a/bundles/org.eclipse.rap.pde.runtime/META-INF/MANIFEST.MF b/bundles/org.eclipse.rap.pde.runtime/META-INF/MANIFEST.MF
index 56f3beb..ededcfe 100644
--- a/bundles/org.eclipse.rap.pde.runtime/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.rap.pde.runtime/META-INF/MANIFEST.MF
@@ -6,11 +6,11 @@
Bundle-Activator: org.eclipse.pde.internal.runtime.PDERuntimePlugin
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.help;bundle-version="[3.3.0,4.0.0)";resolution:=optional,
org.eclipse.rap.ui;bundle-version="[2.0.0,4.0.0)",
org.eclipse.rap.ui.forms;bundle-version="[2.0.0,4.0.0)",
- org.eclipse.rap.addons.filedialog;bundle-version="[0.5.0,1.0.0)"
+ org.eclipse.rap.filedialog;bundle-version="[3.0.0,4.0.0)"
Eclipse-LazyStart: true
Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true,
org.eclipse.pde.internal.runtime.registry;x-internal:=true,
diff --git a/bundles/org.eclipse.rap.pde.runtime/icons/obj16/rsvcproxy_obj.gif b/bundles/org.eclipse.rap.pde.runtime/icons/obj16/rsvcproxy_obj.gif
new file mode 100644
index 0000000..ef2c5fd
--- /dev/null
+++ b/bundles/org.eclipse.rap.pde.runtime/icons/obj16/rsvcproxy_obj.gif
Binary files differ
diff --git a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java
index 728fa7d..6f62865 100644
--- a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java
+++ b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java
@@ -1,127 +1,132 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2013 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
- * Arnaud Mergey <a_mergey@yahoo.fr> - RAP port
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime;
-
-import java.net.URL;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-
-
-public class PDERuntimePluginImages {
-
- // private static ImageRegistry PLUGIN_REGISTRY;
- public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$
- private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$
- private static final String PATH_DCL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$
- private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$
- private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$
- // Plug-in Spy related images
- public static final String IMG_CLASS_OBJ = "class_obj.gif"; //$NON-NLS-1$
- public static final String IMG_INTERFACE_OBJ = "int_obj.gif"; //$NON-NLS-1$
- public static final String IMG_PLUGIN_OBJ = "plugin_obj.gif"; //$NON-NLS-1$
- public static final String IMG_SPY_OBJ = "pdespy_obj.gif"; //$NON-NLS-1$
- public static final String IMG_MENU_OBJ = "menu_obj.gif"; //$NON-NLS-1$
- public static final String IMG_ID_OBJ = "generic_xml_obj.gif"; //$NON-NLS-1$
- public static final String IMG_MENUSPY_OBJ = "menuspy_obj.gif"; //$NON-NLS-1$
- public static final String IMG_CONTEXTID_OBJ = "contextid_obj.gif"; //$NON-NLS-1$
- public static final String IMG_SAVE_IMAGE_AS_OBJ = "save_image_as_obj.gif"; //$NON-NLS-1$
- public static final String IMG_COPY_QNAME = "cpyqual_menu.gif"; //$NON-NLS-1$
- public static final ImageDescriptor CLASS_OBJ = create( PATH_OBJ, IMG_CLASS_OBJ );
- public static final ImageDescriptor INTERFACE_OBJ = create( PATH_OBJ, IMG_INTERFACE_OBJ );
- public static final ImageDescriptor PLUGIN_OBJ = create( PATH_OBJ, IMG_PLUGIN_OBJ );
- public static final ImageDescriptor SPY_OBJ = create( PATH_OBJ, IMG_SPY_OBJ );
- public static final ImageDescriptor MENU_OBJ = create( PATH_OBJ, IMG_MENU_OBJ );
- public static final ImageDescriptor ID_OBJ = create( PATH_OBJ, IMG_ID_OBJ );
- public static final ImageDescriptor MENUSPY_OBJ = create( PATH_OBJ, IMG_MENUSPY_OBJ );
- public static final ImageDescriptor CONTEXTID_OBJ = create( PATH_OBJ, IMG_CONTEXTID_OBJ );
- public static final ImageDescriptor SAVE_IMAGE_AS_OBJ = create( PATH_OBJ, IMG_SAVE_IMAGE_AS_OBJ );
- public static final ImageDescriptor COPY_QNAME = create( PATH_LCL, IMG_COPY_QNAME );
- public static final ImageDescriptor DESC_REFRESH_DISABLED = create( PATH_DCL, "refresh.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_REFRESH = create( PATH_LCL, "refresh.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_COLLAPSE_ALL = create( PATH_LCL, "collapseall.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ERROR_ST_OBJ = create( PATH_OBJ, "error_st_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ERROR_STACK_OBJ = create( PATH_OBJ, "error_stack.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_EXT_POINT_OBJ = create( PATH_OBJ, "ext_point_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_EXT_POINTS_OBJ = create( PATH_OBJ, "ext_points_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_EXTENSION_OBJ = create( PATH_OBJ, "extension_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_EXTENSIONS_OBJ = create( PATH_OBJ, "extensions_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_GENERIC_XML_OBJ = create( PATH_OBJ,
- "generic_xml_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ATTR_XML_OBJ = create( PATH_OBJ, "attr_xml_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_INFO_ST_OBJ = create( PATH_OBJ, "info_st_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_JAVA_LIB_OBJ = create( PATH_OBJ, "java_lib_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_NATIVE_LIB_OBJ = create( PATH_OBJ, "native_lib_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OK_ST_OBJ = create( PATH_OBJ, "ok_st_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_PLUGIN_OBJ = create( PATH_OBJ, "plugin_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = create( PATH_OBJ, "req_plugin_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = create( PATH_OBJ,
- "req_plugins_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_RUNTIME_OBJ = create( PATH_OBJ, "runtime_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_WARNING_ST_OBJ = create( PATH_OBJ, "warning_st_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_LOCATION = create( PATH_OBJ, "location_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_IMP_OBJ = create( PATH_OBJ, "bundle-importer.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_EXP_OBJ = create( PATH_OBJ, "bundle-exporter.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_SERVICE_OBJ = create( PATH_OBJ, "int_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_PROPERTY_OBJ = create( PATH_OBJ, "property_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_PLUGINS_OBJ = create( PATH_OBJ, "plugins_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_FRAGMENT_OBJ = create( PATH_OBJ, "frgmt_obj.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_PACKAGE_OBJ = create( PATH_OBJ, "package_obj.gif" ); //$NON-NLS-1$
- /*
- * Overlays
- */
- public static final ImageDescriptor DESC_RUN_CO = create( PATH_OVR, "run_co.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_EXPORT_CO = create( PATH_OVR, "export_co.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_ERROR_CO = create( PATH_OVR, "error_co.gif" ); //$NON-NLS-1$
- public static final ImageDescriptor DESC_DEFAULT_CO = create( PATH_OVR, "default_co.gif" ); //$NON-NLS-1$
-
- private static final void initialize() {
- // PLUGIN_REGISTRY = PDERuntimePlugin.getDefault().getImageRegistry();
- manage( IMG_CLASS_OBJ, CLASS_OBJ );
- manage( IMG_INTERFACE_OBJ, INTERFACE_OBJ );
- manage( IMG_PLUGIN_OBJ, PLUGIN_OBJ );
- manage( IMG_SPY_OBJ, SPY_OBJ );
- manage( IMG_MENU_OBJ, MENU_OBJ );
- manage( IMG_ID_OBJ, ID_OBJ );
- manage( IMG_MENUSPY_OBJ, MENUSPY_OBJ );
- manage( IMG_CONTEXTID_OBJ, CONTEXTID_OBJ );
- manage( IMG_SAVE_IMAGE_AS_OBJ, SAVE_IMAGE_AS_OBJ );
- manage( IMG_COPY_QNAME, COPY_QNAME );
- }
-
- private static ImageDescriptor create( String prefix, String name ) {
- return ImageDescriptor.createFromURL( makeIconURL( prefix, name ) );
- }
-
- public static Image get( String key ) {
- ImageRegistry registry = PDERuntimePlugin.getDefault().getImageRegistry();
- Image image = registry.get( key );
- if( image == null ) {
- initialize();
- image = registry.get( key );
- }
- return image;
- }
-
- private static URL makeIconURL( String prefix, String name ) {
- String path = "$nl$/" + prefix + name; //$NON-NLS-1$
- return FileLocator.find( PDERuntimePlugin.getDefault().getBundle(), new Path( path ), null );
- }
-
- public static Image manage( String key, ImageDescriptor desc ) {
- Image image = desc.createImage();
- PDERuntimePlugin.getDefault().getImageRegistry().put( key, image );
- return image;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2000, 2015 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
+ * Arnaud Mergey <a_mergey@yahoo.fr> - RAP port
+ *******************************************************************************/
+package org.eclipse.pde.internal.runtime;
+
+import java.net.URL;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+
+public class PDERuntimePluginImages {
+
+ //private static ImageRegistry PLUGIN_REGISTRY;
+
+ public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$
+
+ private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$
+ private static final String PATH_DCL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$
+ private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$
+ private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$
+
+ // Plug-in Spy related images
+ public static final String IMG_CLASS_OBJ = "class_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_INTERFACE_OBJ = "int_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_PLUGIN_OBJ = "plugin_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_SPY_OBJ = "pdespy_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_MENU_OBJ = "menu_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_ID_OBJ = "generic_xml_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_MENUSPY_OBJ = "menuspy_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_CONTEXTID_OBJ = "contextid_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_SAVE_IMAGE_AS_OBJ = "save_image_as_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_COPY_QNAME = "cpyqual_menu.gif"; //$NON-NLS-1$
+
+ public static final ImageDescriptor CLASS_OBJ = create(PATH_OBJ, IMG_CLASS_OBJ);
+ public static final ImageDescriptor INTERFACE_OBJ = create(PATH_OBJ, IMG_INTERFACE_OBJ);
+ public static final ImageDescriptor PLUGIN_OBJ = create(PATH_OBJ, IMG_PLUGIN_OBJ);
+ public static final ImageDescriptor SPY_OBJ = create(PATH_OBJ, IMG_SPY_OBJ);
+ public static final ImageDescriptor MENU_OBJ = create(PATH_OBJ, IMG_MENU_OBJ);
+ public static final ImageDescriptor ID_OBJ = create(PATH_OBJ, IMG_ID_OBJ);
+ public static final ImageDescriptor MENUSPY_OBJ = create(PATH_OBJ, IMG_MENUSPY_OBJ);
+ public static final ImageDescriptor CONTEXTID_OBJ = create(PATH_OBJ, IMG_CONTEXTID_OBJ);
+ public static final ImageDescriptor SAVE_IMAGE_AS_OBJ = create(PATH_OBJ, IMG_SAVE_IMAGE_AS_OBJ);
+ public static final ImageDescriptor COPY_QNAME = create(PATH_LCL, IMG_COPY_QNAME);
+
+ public static final ImageDescriptor DESC_REFRESH_DISABLED = create(PATH_DCL, "refresh.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_REFRESH = create(PATH_LCL, "refresh.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_COLLAPSE_ALL = create(PATH_LCL, "collapseall.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ERROR_ST_OBJ = create(PATH_OBJ, "error_st_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ERROR_STACK_OBJ = create(PATH_OBJ, "error_stack.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EXT_POINT_OBJ = create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EXT_POINTS_OBJ = create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EXTENSION_OBJ = create(PATH_OBJ, "extension_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EXTENSIONS_OBJ = create(PATH_OBJ, "extensions_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_GENERIC_XML_OBJ = create(PATH_OBJ, "generic_xml_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ATTR_XML_OBJ = create(PATH_OBJ, "attr_xml_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_INFO_ST_OBJ = create(PATH_OBJ, "info_st_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_JAVA_LIB_OBJ = create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_NATIVE_LIB_OBJ = create(PATH_OBJ, "native_lib_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OK_ST_OBJ = create(PATH_OBJ, "ok_st_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_RUNTIME_OBJ = create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_WARNING_ST_OBJ = create(PATH_OBJ, "warning_st_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_LOCATION = create(PATH_OBJ, "location_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_IMP_OBJ = create(PATH_OBJ, "bundle-importer.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EXP_OBJ = create(PATH_OBJ, "bundle-exporter.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_SERVICE_OBJ = create(PATH_OBJ, "int_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_PROPERTY_OBJ = create(PATH_OBJ, "property_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_PLUGINS_OBJ = create(PATH_OBJ, "plugins_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_FRAGMENT_OBJ = create(PATH_OBJ, "frgmt_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_PACKAGE_OBJ = create(PATH_OBJ, "package_obj.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_REMOTE_SERVICE_PROXY_OBJ = create(PATH_OBJ, "rsvcproxy_obj.gif"); //$NON-NLS-1$
+
+ /*
+ * Overlays
+ */
+ public static final ImageDescriptor DESC_RUN_CO = create(PATH_OVR, "run_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_EXPORT_CO = create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ERROR_CO = create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_DEFAULT_CO = create(PATH_OVR, "default_co.gif"); //$NON-NLS-1$
+
+ private static final void initialize() {
+ //PLUGIN_REGISTRY = PDERuntimePlugin.getDefault().getImageRegistry();
+ manage(IMG_CLASS_OBJ, CLASS_OBJ);
+ manage(IMG_INTERFACE_OBJ, INTERFACE_OBJ);
+ manage(IMG_PLUGIN_OBJ, PLUGIN_OBJ);
+ manage(IMG_SPY_OBJ, SPY_OBJ);
+ manage(IMG_MENU_OBJ, MENU_OBJ);
+ manage(IMG_ID_OBJ, ID_OBJ);
+ manage(IMG_MENUSPY_OBJ, MENUSPY_OBJ);
+ manage(IMG_CONTEXTID_OBJ, CONTEXTID_OBJ);
+ manage(IMG_SAVE_IMAGE_AS_OBJ, SAVE_IMAGE_AS_OBJ);
+ manage(IMG_COPY_QNAME, COPY_QNAME);
+ }
+
+ private static ImageDescriptor create(String prefix, String name) {
+ return ImageDescriptor.createFromURL(makeIconURL(prefix, name));
+ }
+
+ public static Image get(String key) {
+ ImageRegistry registry = PDERuntimePlugin.getDefault().getImageRegistry();
+ Image image = registry.get( key );
+ if( image == null ) {
+ initialize();
+ image = registry.get( key );
+ }
+ return image;
+ }
+
+ private static URL makeIconURL(String prefix, String name) {
+ String path = "$nl$/" + prefix + name; //$NON-NLS-1$
+ return FileLocator.find(PDERuntimePlugin.getDefault().getBundle(), new Path(path), null);
+ }
+
+ public static Image manage(String key, ImageDescriptor desc) {
+ Image image = desc.createImage();
+ PDERuntimePlugin.getDefault().getImageRegistry().put(key, image);
+ return image;
+ }
+
+}
diff --git a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java
index be8fca7..72de8c7 100644
--- a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java
+++ b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java
@@ -1,383 +1,400 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2013 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
- * Arnaud Mergey <a_mergey@yahoo.fr> - RAP port
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry;
-
-import java.util.Arrays;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.pde.internal.runtime.*;
-import org.eclipse.pde.internal.runtime.registry.model.*;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.Constants;
-
-
-public class RegistryBrowserLabelProvider extends LabelProvider {
-
- private Image fPluginImage;
- private Image fActivePluginImage;
- private Image fUnresolvedPluginImage;
- private Image fLibraryImage;
- private Image fRuntimeImage;
- private Image fGenericTagImage;
- private Image fGenericAttrImage;
- private Image fExtensionImage;
- private Image fExtensionsImage;
- private Image fExtensionPointImage;
- private Image fExtensionPointsImage;
- private Image fRequiresImage;
- private Image fExpReqPluginImage;
- private Image fReqPluginImage;
- private Image fPluginsImage;
- private Image fLocationImage;
- private Image fDisabledImage;
- private Image fExporterImage;
- private Image fImporterImage;
- private Image fServiceImage;
- private Image fPropertyImage;
- private Image fServicePropertyImage;
- private Image fFragmentImage;
- private Image fPackageImage;
- private RegistryBrowser fRegistryBrowser;
-
- public RegistryBrowserLabelProvider( RegistryBrowser browser ) {
- fRegistryBrowser = browser;
- fPluginImage = PDERuntimePluginImages.DESC_PLUGIN_OBJ.createImage();
- fReqPluginImage = PDERuntimePluginImages.DESC_REQ_PLUGIN_OBJ.createImage();
- fExtensionPointImage = PDERuntimePluginImages.DESC_EXT_POINT_OBJ.createImage();
- fExtensionPointsImage = PDERuntimePluginImages.DESC_EXT_POINTS_OBJ.createImage();
- fExtensionImage = PDERuntimePluginImages.DESC_EXTENSION_OBJ.createImage();
- fExtensionsImage = PDERuntimePluginImages.DESC_EXTENSIONS_OBJ.createImage();
- fRequiresImage = PDERuntimePluginImages.DESC_REQ_PLUGINS_OBJ.createImage();
- fLibraryImage = PDERuntimePluginImages.DESC_JAVA_LIB_OBJ.createImage();
- fGenericTagImage = PDERuntimePluginImages.DESC_GENERIC_XML_OBJ.createImage();
- fGenericAttrImage = PDERuntimePluginImages.DESC_ATTR_XML_OBJ.createImage();
- fRuntimeImage = PDERuntimePluginImages.DESC_RUNTIME_OBJ.createImage();
- fLocationImage = PDERuntimePluginImages.DESC_LOCATION.createImage();
- fExporterImage = PDERuntimePluginImages.DESC_EXP_OBJ.createImage();
- fImporterImage = PDERuntimePluginImages.DESC_IMP_OBJ.createImage();
- fServiceImage = PDERuntimePluginImages.DESC_SERVICE_OBJ.createImage();
- fPropertyImage = PDERuntimePluginImages.DESC_PROPERTY_OBJ.createImage();
- fPluginsImage = PDERuntimePluginImages.DESC_PLUGINS_OBJ.createImage();
- fFragmentImage = PDERuntimePluginImages.DESC_FRAGMENT_OBJ.createImage();
- fPackageImage = PDERuntimePluginImages.DESC_PACKAGE_OBJ.createImage();
- ImageDescriptor activePluginDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PLUGIN_OBJ,
- new ImageDescriptor[][] {
- {
- PDERuntimePluginImages.DESC_RUN_CO
- }
- } );
- fActivePluginImage = activePluginDesc.createImage();
- ImageDescriptor disabledPluginDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PLUGIN_OBJ,
- new ImageDescriptor[][] {
- {
- PDERuntimePluginImages.DESC_ERROR_CO
- }
- } );
- fDisabledImage = disabledPluginDesc.createImage();
- ImageDescriptor unresolvedPluginDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PLUGIN_OBJ,
- new ImageDescriptor[][] {
- {
- PDERuntimePluginImages.DESC_ERROR_CO
- }
- } );
- fUnresolvedPluginImage = unresolvedPluginDesc.createImage();
- ImageDescriptor exportedRequiresDesc = new OverlayIcon( PDERuntimePluginImages.DESC_REQ_PLUGIN_OBJ,
- new ImageDescriptor[][] {
- {
- PDERuntimePluginImages.DESC_EXPORT_CO
- }
- } );
- fExpReqPluginImage = exportedRequiresDesc.createImage();
- ImageDescriptor servicePropertyDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PROPERTY_OBJ,
- new ImageDescriptor[][] {
- {
- PDERuntimePluginImages.DESC_DEFAULT_CO
- }
- } );
- fServicePropertyImage = servicePropertyDesc.createImage();
- }
-
- public void dispose() {
- fPluginImage.dispose();
- fActivePluginImage.dispose();
- fUnresolvedPluginImage.dispose();
- fReqPluginImage.dispose();
- fExtensionPointImage.dispose();
- fExtensionPointsImage.dispose();
- fExtensionImage.dispose();
- fExtensionsImage.dispose();
- fRequiresImage.dispose();
- fExpReqPluginImage.dispose();
- fLibraryImage.dispose();
- fGenericTagImage.dispose();
- fGenericAttrImage.dispose();
- fRuntimeImage.dispose();
- fLocationImage.dispose();
- fDisabledImage.dispose();
- fImporterImage.dispose();
- fExporterImage.dispose();
- fServiceImage.dispose();
- fPropertyImage.dispose();
- fServicePropertyImage.dispose();
- fPluginsImage.dispose();
- fFragmentImage.dispose();
- fPackageImage.dispose();
- }
-
- public Image getImage( Object element ) {
- if( element instanceof Bundle ) {
- Bundle bundle = ( Bundle )element;
- if( bundle.getFragmentHost() != null )
- return fFragmentImage;
- if( !bundle.isEnabled() )
- return fDisabledImage;
- switch( bundle.getState() ) {
- case Bundle.ACTIVE:
- return fActivePluginImage;
- case Bundle.UNINSTALLED:
- return fUnresolvedPluginImage;
- case Bundle.INSTALLED:
- if( !bundle.isEnabled() )
- return fUnresolvedPluginImage;
- default:
- return fPluginImage;
- }
- }
- if( element instanceof ServiceName ) {
- return fServiceImage;
- }
- if( element instanceof ServiceRegistration ) {
- return fPluginImage;
- }
- if( element instanceof Property ) {
- Property property = ( Property )element;
- // special handling for property objectClass
- if( property.getName().equals( Constants.OBJECTCLASS ) ) {
- return PDERuntimePluginImages.get( PDERuntimePluginImages.IMG_CLASS_OBJ );
- }
- // special handling for builtin service properties
- if( property.getName().startsWith( "service." ) || property.getName().startsWith( "component." ) ) { //$NON-NLS-1$ //$NON-NLS-2$
- return fServicePropertyImage;
- }
- return fPropertyImage;
- }
- if( element instanceof Folder ) {
- int id = ( ( Folder )element ).getId();
- switch( id ) {
- case Folder.F_EXTENSIONS:
- return fExtensionsImage;
- case Folder.F_EXTENSION_POINTS:
- return fExtensionPointsImage;
- case Folder.F_IMPORTS:
- return fRequiresImage;
- case Folder.F_LIBRARIES:
- return fRuntimeImage;
- case Folder.F_REGISTERED_SERVICES:
- return fExporterImage;
- case Folder.F_SERVICES_IN_USE:
- return fImporterImage;
- case Folder.F_PROPERTIES:
- return fPropertyImage;
- case Folder.F_USING_BUNDLES:
- return fPluginsImage;
- case Folder.F_FRAGMENTS:
- return fPluginsImage;
- case Folder.F_EXPORTED_PACKAGES:
- case Folder.F_IMPORTED_PACKAGES:
- return fPackageImage;
- }
- return null;
- }
- if( element instanceof Extension )
- return fExtensionImage;
- if( element instanceof ExtensionPoint )
- return fExtensionPointImage;
- if( element instanceof BundlePrerequisite ) {
- BundlePrerequisite prereq = ( BundlePrerequisite )element;
- if( prereq.isPackage() )
- return fPackageImage;
- return prereq.isExported()
- ? fExpReqPluginImage
- : fReqPluginImage;
- }
- if( element instanceof BundleLibrary )
- return fLibraryImage;
- if( element instanceof ConfigurationElement )
- return fGenericTagImage;
- if( element instanceof Attribute ) {
- Attribute attr = ( Attribute )element;
- if( Attribute.F_LOCATION.equals( attr.getName() ) ) {
- return fLocationImage;
- }
- if( Attribute.F_BUNDLE.equals( attr.getName() ) ) {
- return fPluginImage;
- }
- return fGenericAttrImage;
- }
- return null;
- }
-
- protected String getStyledText( Object element ) {
- if( element instanceof Bundle ) {
- Bundle bundle = ( ( Bundle )element );
- // StyledString sb = new StyledString(bundle.getSymbolicName());
- StringBuilder sb = new StringBuilder( bundle.getSymbolicName() );
- String version = bundle.getVersion();
- if( version != null ) {
- sb.append( " ("/* , StyledString.DECORATIONS_STYLER */); //$NON-NLS-1$
- sb.append( version/* , StyledString.DECORATIONS_STYLER */);
- sb.append( ")"/* , StyledString.DECORATIONS_STYLER */); //$NON-NLS-1$
- }
- String host = bundle.getFragmentHost();
- if( host != null ) {
- sb.append( " ["/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
- sb.append( host/* , StyledString.QUALIFIER_STYLER */);
- sb.append( "]"/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
- }
- return sb.toString();
- }
- if( element instanceof ServiceRegistration ) {
- ServiceRegistration ref = ( ServiceRegistration )element;
- String identifier = " (id=" + ref.getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- // StyledString ss = new StyledString();
- StringBuilder ss = new StringBuilder();
- if( fRegistryBrowser.getGroupBy() == RegistryBrowser.BUNDLES ) {
- String[] classes = ref.getName().getClasses();
- ss.append( Arrays.asList( classes ).toString() );
- } else {
- ss.append( PDERuntimeMessages.get().RegistryBrowserLabelProvider_RegisteredBy );
- ss.append( ref.getBundle() );
- }
- ss.append( identifier/* , StyledString.DECORATIONS_STYLER */);
- return ss.toString();
- }
- if( element instanceof ServiceName ) {
- return Arrays.asList( ( ( ServiceName )element ).getClasses() ).toString();
- }
- if( element instanceof Folder ) {
- String text = null;
- switch( ( ( Folder )element ).getId() ) {
- case Folder.F_IMPORTS:
- text = PDERuntimeMessages.get().RegistryView_folders_imports;
- break;
- case Folder.F_IMPORTED_PACKAGES:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_ImportedPackages;
- break;
- case Folder.F_EXPORTED_PACKAGES:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_ExportedPackages;
- break;
- case Folder.F_LIBRARIES:
- text = PDERuntimeMessages.get().RegistryView_folders_libraries;
- break;
- case Folder.F_EXTENSION_POINTS:
- text = PDERuntimeMessages.get().RegistryView_folders_extensionPoints;
- break;
- case Folder.F_EXTENSIONS:
- text = PDERuntimeMessages.get().RegistryView_folders_extensions;
- break;
- case Folder.F_REGISTERED_SERVICES:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_registeredServices;
- break;
- case Folder.F_SERVICES_IN_USE:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_usedServices;
- break;
- case Folder.F_PROPERTIES:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_Properties;
- break;
- case Folder.F_USING_BUNDLES:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_UsingBundles;
- break;
- case Folder.F_FRAGMENTS:
- text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_Fragments;
- break;
- }
- if( text != null ) {
- return text;
- }
- }
- if( element instanceof Extension ) {
- if( ( ( RegistryBrowserContentProvider )fRegistryBrowser.getAdapter( IContentProvider.class ) ).isInExtensionSet )
- {
- Extension extension = ( ( Extension )element );
- // StyledString ss = new StyledString(
- StringBuilder ss = new StringBuilder( extension.getExtensionPointUniqueIdentifier() );
- String name = extension.getLabel();
- if( name != null && name.length() > 0 ) {
- ss.append( "[ "/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
- ss.append( name/* , StyledString.QUALIFIER_STYLER */);
- ss.append( ']'/* , StyledString.QUALIFIER_STYLER */);
- }
- return ss.toString();
- }
- String contributor = ( ( Extension )element ).getNamespaceIdentifier();
- return NLS.bind( PDERuntimeMessages.get().RegistryBrowserLabelProvider_contributedBy,
- contributor );
- }
- if( element instanceof ExtensionPoint ) {
- ExtensionPoint extPoint = ( ExtensionPoint )element;
- // StyledString ss = new
- // StyledString(extPoint.getUniqueIdentifier());
- StringBuilder ss = new StringBuilder( extPoint.getUniqueIdentifier() );
- String name = extPoint.getLabel();
- if( name != null && name.length() > 0 ) {
- ss.append( " ["/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
- ss.append( name/* , StyledString.QUALIFIER_STYLER */);
- ss.append( ']'/* , StyledString.QUALIFIER_STYLER */);
- }
- return ss.toString();
- }
- if( element instanceof BundlePrerequisite ) {
- BundlePrerequisite prereq = ( BundlePrerequisite )element;
- // StyledString ss = new StyledString(prereq.getName());
- StringBuilder ss = new StringBuilder( prereq.getName() );
- String version = prereq.getVersion();
- if( version != null ) {
- if( Character.isDigit( version.charAt( 0 ) ) )
- version = '(' + version + ')';
- ss.append( ' ' ).append( version/* , StyledString.DECORATIONS_STYLER */);
- }
- return ss.toString();
- }
- if( element instanceof BundleLibrary ) {
- return ( ( BundleLibrary )element ).getLibrary();
- }
- if( element instanceof ConfigurationElement ) {
- return ( ( ConfigurationElement )element ).getName();
- }
- if( element instanceof Attribute ) {
- Attribute attribute = ( Attribute )element;
- if( Attribute.F_BUNDLE.equals( attribute.getName() ) ) {
- return attribute.getValue();
- }
- return attribute.getName() + " = " + attribute.getValue(); //$NON-NLS-1$
- }
- if( element instanceof Property ) {
- Property property = ( Property )element;
- return property.getName() + " = " + property.getValue(); //$NON-NLS-1$
- }
- return element == null
- ? "" : element.toString(); //$NON-NLS-1$
- }
-
- // public void update(ViewerCell cell) {
- // StyledString string = getStyledText(cell.getElement());
- // cell.setText(string.getString());
- // cell.setStyleRanges(string.getStyleRanges());
- // cell.setImage(getImage(cell.getElement()));
- // super.update(cell);
- // }
- public String getText( Object element ) {
- return getStyledText( element );
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2000, 2015 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
+ * Arnaud Mergey <a_mergey@yahoo.fr> - RAP port
+ *******************************************************************************/
+package org.eclipse.pde.internal.runtime.registry;
+
+import java.util.Arrays;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.internal.runtime.*;
+import org.eclipse.pde.internal.runtime.registry.model.*;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+
+public class RegistryBrowserLabelProvider extends LabelProvider {
+
+ private Image fPluginImage;
+ private Image fActivePluginImage;
+ private Image fUnresolvedPluginImage;
+ private Image fLibraryImage;
+ private Image fRuntimeImage;
+ private Image fGenericTagImage;
+ private Image fGenericAttrImage;
+ private Image fExtensionImage;
+ private Image fExtensionsImage;
+ private Image fExtensionPointImage;
+ private Image fExtensionPointsImage;
+ private Image fRequiresImage;
+ private Image fExpReqPluginImage;
+ private Image fReqPluginImage;
+ private Image fPluginsImage;
+ private Image fLocationImage;
+ private Image fDisabledImage;
+ private Image fExporterImage;
+ private Image fImporterImage;
+ private Image fServiceImage;
+ private Image fPropertyImage;
+ private Image fServicePropertyImage;
+ private Image fFragmentImage;
+ private Image fPackageImage;
+ private Image fRemoteServiceProxyImage;
+ private RegistryBrowser fRegistryBrowser;
+
+ public RegistryBrowserLabelProvider( RegistryBrowser browser ) {
+ fRegistryBrowser = browser;
+ fPluginImage = PDERuntimePluginImages.DESC_PLUGIN_OBJ.createImage();
+ fReqPluginImage = PDERuntimePluginImages.DESC_REQ_PLUGIN_OBJ.createImage();
+ fExtensionPointImage = PDERuntimePluginImages.DESC_EXT_POINT_OBJ.createImage();
+ fExtensionPointsImage = PDERuntimePluginImages.DESC_EXT_POINTS_OBJ.createImage();
+ fExtensionImage = PDERuntimePluginImages.DESC_EXTENSION_OBJ.createImage();
+ fExtensionsImage = PDERuntimePluginImages.DESC_EXTENSIONS_OBJ.createImage();
+ fRequiresImage = PDERuntimePluginImages.DESC_REQ_PLUGINS_OBJ.createImage();
+ fLibraryImage = PDERuntimePluginImages.DESC_JAVA_LIB_OBJ.createImage();
+ fGenericTagImage = PDERuntimePluginImages.DESC_GENERIC_XML_OBJ.createImage();
+ fGenericAttrImage = PDERuntimePluginImages.DESC_ATTR_XML_OBJ.createImage();
+ fRuntimeImage = PDERuntimePluginImages.DESC_RUNTIME_OBJ.createImage();
+ fLocationImage = PDERuntimePluginImages.DESC_LOCATION.createImage();
+ fExporterImage = PDERuntimePluginImages.DESC_EXP_OBJ.createImage();
+ fImporterImage = PDERuntimePluginImages.DESC_IMP_OBJ.createImage();
+ fServiceImage = PDERuntimePluginImages.DESC_SERVICE_OBJ.createImage();
+ fPropertyImage = PDERuntimePluginImages.DESC_PROPERTY_OBJ.createImage();
+ fPluginsImage = PDERuntimePluginImages.DESC_PLUGINS_OBJ.createImage();
+ fFragmentImage = PDERuntimePluginImages.DESC_FRAGMENT_OBJ.createImage();
+ fPackageImage = PDERuntimePluginImages.DESC_PACKAGE_OBJ.createImage();
+ fRemoteServiceProxyImage = PDERuntimePluginImages.DESC_REMOTE_SERVICE_PROXY_OBJ.createImage();
+ ImageDescriptor activePluginDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PLUGIN_OBJ,
+ new ImageDescriptor[][] {
+ {
+ PDERuntimePluginImages.DESC_RUN_CO
+ }
+ } );
+ fActivePluginImage = activePluginDesc.createImage();
+ ImageDescriptor disabledPluginDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PLUGIN_OBJ,
+ new ImageDescriptor[][] {
+ {
+ PDERuntimePluginImages.DESC_ERROR_CO
+ }
+ } );
+ fDisabledImage = disabledPluginDesc.createImage();
+ ImageDescriptor unresolvedPluginDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PLUGIN_OBJ,
+ new ImageDescriptor[][] {
+ {
+ PDERuntimePluginImages.DESC_ERROR_CO
+ }
+ } );
+ fUnresolvedPluginImage = unresolvedPluginDesc.createImage();
+ ImageDescriptor exportedRequiresDesc = new OverlayIcon( PDERuntimePluginImages.DESC_REQ_PLUGIN_OBJ,
+ new ImageDescriptor[][] {
+ {
+ PDERuntimePluginImages.DESC_EXPORT_CO
+ }
+ } );
+ fExpReqPluginImage = exportedRequiresDesc.createImage();
+ ImageDescriptor servicePropertyDesc = new OverlayIcon( PDERuntimePluginImages.DESC_PROPERTY_OBJ,
+ new ImageDescriptor[][] {
+ {
+ PDERuntimePluginImages.DESC_DEFAULT_CO
+ }
+ } );
+ fServicePropertyImage = servicePropertyDesc.createImage();
+ }
+
+ public void dispose() {
+ fPluginImage.dispose();
+ fActivePluginImage.dispose();
+ fUnresolvedPluginImage.dispose();
+ fReqPluginImage.dispose();
+ fExtensionPointImage.dispose();
+ fExtensionPointsImage.dispose();
+ fExtensionImage.dispose();
+ fExtensionsImage.dispose();
+ fRequiresImage.dispose();
+ fExpReqPluginImage.dispose();
+ fLibraryImage.dispose();
+ fGenericTagImage.dispose();
+ fGenericAttrImage.dispose();
+ fRuntimeImage.dispose();
+ fLocationImage.dispose();
+ fDisabledImage.dispose();
+ fImporterImage.dispose();
+ fExporterImage.dispose();
+ fServiceImage.dispose();
+ fPropertyImage.dispose();
+ fServicePropertyImage.dispose();
+ fPluginsImage.dispose();
+ fFragmentImage.dispose();
+ fPackageImage.dispose();
+ }
+
+ private boolean isProxyService( ServiceReference ref ) {
+ if( ref == null )
+ return false;
+ Object o = ref.getProperty( Constants.SERVICE_IMPORTED );
+ return( o != null );
+ }
+
+ private boolean isProxyService( ServiceRegistration reg ) {
+ if( reg == null )
+ return false;
+ Object o = reg.getProperty( Constants.SERVICE_IMPORTED );
+ return( o != null );
+ }
+
+ public Image getImage( Object element ) {
+ if( element instanceof Bundle ) {
+ Bundle bundle = ( Bundle )element;
+ if( bundle.getFragmentHost() != null )
+ return fFragmentImage;
+ if( !bundle.isEnabled() )
+ return fDisabledImage;
+ switch( bundle.getState() ) {
+ case Bundle.ACTIVE:
+ return fActivePluginImage;
+ case Bundle.UNINSTALLED:
+ return fUnresolvedPluginImage;
+ case Bundle.INSTALLED:
+ if( !bundle.isEnabled() )
+ return fUnresolvedPluginImage;
+ default:
+ return fPluginImage;
+ }
+ }
+ if( element instanceof ServiceName ) {
+ ServiceName serviceName = ( ServiceName )element;
+ if( isProxyService( serviceName.getServiceReference() ) )
+ return fRemoteServiceProxyImage;
+ return fServiceImage;
+ }
+ if( element instanceof ServiceRegistration ) {
+ ServiceRegistration reg = ( ServiceRegistration )element;
+ if( isProxyService( reg ) )
+ return fRemoteServiceProxyImage;
+ return fPluginImage;
+ }
+ if( element instanceof Property ) {
+ Property property = ( Property )element;
+ // special handling for property objectClass
+ if( property.getName().equals( Constants.OBJECTCLASS ) ) {
+ return PDERuntimePluginImages.get( PDERuntimePluginImages.IMG_CLASS_OBJ );
+ }
+ // special handling for builtin service properties
+ if( property.getName().startsWith( "service." ) || property.getName().startsWith( "component." ) ) { //$NON-NLS-1$ //$NON-NLS-2$
+ return fServicePropertyImage;
+ }
+ return fPropertyImage;
+ }
+ if( element instanceof Folder ) {
+ int id = ( ( Folder )element ).getId();
+ switch( id ) {
+ case Folder.F_EXTENSIONS:
+ return fExtensionsImage;
+ case Folder.F_EXTENSION_POINTS:
+ return fExtensionPointsImage;
+ case Folder.F_IMPORTS:
+ return fRequiresImage;
+ case Folder.F_LIBRARIES:
+ return fRuntimeImage;
+ case Folder.F_REGISTERED_SERVICES:
+ return fExporterImage;
+ case Folder.F_SERVICES_IN_USE:
+ return fImporterImage;
+ case Folder.F_PROPERTIES:
+ return fPropertyImage;
+ case Folder.F_USING_BUNDLES:
+ return fPluginsImage;
+ case Folder.F_FRAGMENTS:
+ return fPluginsImage;
+ case Folder.F_EXPORTED_PACKAGES:
+ case Folder.F_IMPORTED_PACKAGES:
+ return fPackageImage;
+ }
+ return null;
+ }
+ if( element instanceof Extension )
+ return fExtensionImage;
+ if( element instanceof ExtensionPoint )
+ return fExtensionPointImage;
+ if( element instanceof BundlePrerequisite ) {
+ BundlePrerequisite prereq = ( BundlePrerequisite )element;
+ if( prereq.isPackage() )
+ return fPackageImage;
+ return prereq.isExported()
+ ? fExpReqPluginImage
+ : fReqPluginImage;
+ }
+ if( element instanceof BundleLibrary )
+ return fLibraryImage;
+ if( element instanceof ConfigurationElement )
+ return fGenericTagImage;
+ if( element instanceof Attribute ) {
+ Attribute attr = ( Attribute )element;
+ if( Attribute.F_LOCATION.equals( attr.getName() ) ) {
+ return fLocationImage;
+ }
+ if( Attribute.F_BUNDLE.equals( attr.getName() ) ) {
+ return fPluginImage;
+ }
+ return fGenericAttrImage;
+ }
+ return null;
+ }
+
+ protected String getStyledText( Object element ) {
+ if( element instanceof Bundle ) {
+ Bundle bundle = ( ( Bundle )element );
+ StringBuilder sb = new StringBuilder( bundle.getSymbolicName() );
+ String version = bundle.getVersion();
+ if( version != null ) {
+ sb.append( " ("/* ,StyledString.DECORATIONS_STYLER */); //$NON-NLS-1$
+ sb.append( version/* , StyledString.DECORATIONS_STYLER */);
+ sb.append( ")"/* , StyledString.DECORATIONS_STYLER */); //$NON-NLS-1$
+ }
+ String host = bundle.getFragmentHost();
+ if( host != null ) {
+ sb.append( " ["/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
+ sb.append( host/* , StyledString.QUALIFIER_STYLER */);
+ sb.append( "]"/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+ if( element instanceof ServiceRegistration ) {
+ ServiceRegistration ref = ( ServiceRegistration )element;
+ String identifier = " (id=" + ref.getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ StringBuilder ss = new StringBuilder();
+ if( fRegistryBrowser.getGroupBy() == RegistryBrowser.BUNDLES ) {
+ String[] classes = ref.getName().getClasses();
+ ss.append( Arrays.asList( classes ).toString() );
+ } else {
+ ss.append( PDERuntimeMessages.get().RegistryBrowserLabelProvider_RegisteredBy );
+ ss.append( ref.getBundle() );
+ }
+ ss.append( identifier/* , StyledString.DECORATIONS_STYLER */);
+ return ss.toString();
+ }
+ if( element instanceof ServiceName ) {
+ return Arrays.asList( ( ( ServiceName )element ).getClasses() ).toString();
+ }
+ if( element instanceof Folder ) {
+ String text = null;
+ switch( ( ( Folder )element ).getId() ) {
+ case Folder.F_IMPORTS:
+ text = PDERuntimeMessages.get().RegistryView_folders_imports;
+ break;
+ case Folder.F_IMPORTED_PACKAGES:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_ImportedPackages;
+ break;
+ case Folder.F_EXPORTED_PACKAGES:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_ExportedPackages;
+ break;
+ case Folder.F_LIBRARIES:
+ text = PDERuntimeMessages.get().RegistryView_folders_libraries;
+ break;
+ case Folder.F_EXTENSION_POINTS:
+ text = PDERuntimeMessages.get().RegistryView_folders_extensionPoints;
+ break;
+ case Folder.F_EXTENSIONS:
+ text = PDERuntimeMessages.get().RegistryView_folders_extensions;
+ break;
+ case Folder.F_REGISTERED_SERVICES:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_registeredServices;
+ break;
+ case Folder.F_SERVICES_IN_USE:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_usedServices;
+ break;
+ case Folder.F_PROPERTIES:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_Properties;
+ break;
+ case Folder.F_USING_BUNDLES:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_UsingBundles;
+ break;
+ case Folder.F_FRAGMENTS:
+ text = PDERuntimeMessages.get().RegistryBrowserLabelProvider_Fragments;
+ break;
+ }
+ if( text != null ) {
+ return text;
+ }
+ }
+ if( element instanceof Extension ) {
+ if( ( ( RegistryBrowserContentProvider )fRegistryBrowser.getAdapter( IContentProvider.class ) ).isInExtensionSet )
+ {
+ Extension extension = ( ( Extension )element );
+ StringBuilder ss = new StringBuilder( extension.getExtensionPointUniqueIdentifier() );
+ String name = extension.getLabel();
+ if( name != null && name.length() > 0 ) {
+ ss.append( "[ "/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
+ ss.append( name/* , StyledString.QUALIFIER_STYLER */);
+ ss.append( ']'/* , StyledString.QUALIFIER_STYLER */);
+ }
+ return ss.toString();
+ }
+ String contributor = ( ( Extension )element ).getNamespaceIdentifier();
+ return NLS.bind( PDERuntimeMessages.get().RegistryBrowserLabelProvider_contributedBy,
+ contributor );
+ }
+ if( element instanceof ExtensionPoint ) {
+ ExtensionPoint extPoint = ( ExtensionPoint )element;
+ StringBuilder ss = new StringBuilder( extPoint.getUniqueIdentifier() );
+ String name = extPoint.getLabel();
+ if( name != null && name.length() > 0 ) {
+ ss.append( " ["/* , StyledString.QUALIFIER_STYLER */); //$NON-NLS-1$
+ ss.append( name/* , StyledString.QUALIFIER_STYLER */);
+ ss.append( ']'/* , StyledString.QUALIFIER_STYLER */);
+ }
+ return ss.toString();
+ }
+ if( element instanceof BundlePrerequisite ) {
+ BundlePrerequisite prereq = ( BundlePrerequisite )element;
+ StringBuilder ss = new StringBuilder( prereq.getName() );
+ String version = prereq.getVersion();
+ if( version != null ) {
+ if( Character.isDigit( version.charAt( 0 ) ) )
+ version = '(' + version + ')';
+ ss.append( ' ' ).append( version/* , StyledString.DECORATIONS_STYLER */);
+ }
+ return ss.toString();
+ }
+ if( element instanceof BundleLibrary ) {
+ return ( ( BundleLibrary )element ).getLibrary();
+ }
+ if( element instanceof ConfigurationElement ) {
+ return ( ( ConfigurationElement )element ).getName();
+ }
+ if( element instanceof Attribute ) {
+ Attribute attribute = ( Attribute )element;
+ if( Attribute.F_BUNDLE.equals( attribute.getName() ) ) {
+ return attribute.getValue();
+ }
+ return attribute.getName() + " = " + attribute.getValue(); //$NON-NLS-1$
+ }
+ if( element instanceof Property ) {
+ Property property = ( Property )element;
+ return property.getName() + " = " + property.getValue(); //$NON-NLS-1$
+ }
+ return element == null
+ ? "" : element.toString(); //$NON-NLS-1$
+ }
+
+// public void update( ViewerCell cell ) {
+// StyledString string = getStyledText( cell.getElement() );
+// cell.setText( string.getString() );
+// cell.setStyleRanges( string.getStyleRanges() );
+// cell.setImage( getImage( cell.getElement() ) );
+// super.update( cell );
+// }
+ public String getText( Object element ) {
+ return getStyledText( element );
+ }
+}
diff --git a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java
index a6b0aa2..dde9b18 100644
--- a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java
+++ b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java
@@ -1,506 +1,516 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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
- * Wolfgang Schell <ws@jetztgrad.net> - bug 259348
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.service.resolver.*;
-import org.eclipse.osgi.util.ManifestElement;
-import org.eclipse.pde.internal.runtime.*;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-
-public class LocalRegistryBackend
- implements IRegistryEventListener, BundleListener, ServiceListener, RegistryBackend
-{
-
- private BackendChangeListener listener;
-
- public void setRegistryListener( BackendChangeListener listener ) {
- this.listener = listener;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend #connect()
- */
- public void connect( IProgressMonitor monitor ) {
- if( monitor.isCanceled() )
- return;
- PDERuntimePlugin.getDefault().getBundleContext().addBundleListener( this );
- Platform.getExtensionRegistry().addListener( this );
- PDERuntimePlugin.getDefault().getBundleContext().addServiceListener( this );
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend #disconnect()
- */
- public void disconnect() {
- Platform.getExtensionRegistry().removeListener( this );
- PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener( this );
- PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener( this );
- }
-
- protected static boolean isRegisteredService( org.osgi.framework.Bundle bundle,
- ServiceReference ref )
- {
- return bundle.equals( ref.getBundle() );
- }
-
- protected static boolean isServiceInUse( org.osgi.framework.Bundle bundle, ServiceReference ref )
- {
- org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles();
- return( usingBundles != null && Arrays.asList( usingBundles ).contains( bundle ) );
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend
- * #start(org.osgi.framework.Bundle)
- */
- public void start( long id ) throws BundleException {
- PDERuntimePlugin.getDefault().getBundleContext().getBundle( id ).start();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend
- * #stop(org.osgi.framework.Bundle)
- */
- public void stop( long id ) throws BundleException {
- PDERuntimePlugin.getDefault().getBundleContext().getBundle( id ).stop();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend
- * #diagnose(org.osgi.framework.Bundle)
- */
- public MultiStatus diagnose( long id ) {
- PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- State state = plaformAdmin.getState( false );
- BundleDescription desc = state.getBundle( id );
- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- VersionConstraint[] unsatisfied = platformAdmin.getStateHelper()
- .getUnsatisfiedConstraints( desc );
- ResolverError[] resolverErrors = platformAdmin.getState( false ).getResolverErrors( desc );
- MultiStatus problems = new MultiStatus( PDERuntimePlugin.ID,
- IStatus.INFO,
- PDERuntimeMessages.get().RegistryView_found_problems,
- null );
- for( int i = 0; i < resolverErrors.length; i++ ) {
- if( ( resolverErrors[ i ].getType() & ( ResolverError.MISSING_FRAGMENT_HOST
- | ResolverError.MISSING_GENERIC_CAPABILITY
- | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE ) ) != 0 )
- continue;
- IStatus status = new Status( IStatus.WARNING,
- PDERuntimePlugin.ID,
- resolverErrors[ i ].toString() );
- problems.add( status );
- }
- for( int i = 0; i < unsatisfied.length; i++ ) {
- IStatus status = new Status( IStatus.WARNING,
- PDERuntimePlugin.ID,
- MessageHelper.getResolutionFailureMessage( unsatisfied[ i ] ) );
- problems.add( status );
- }
- return problems;
- }
-
- public void initializeBundles( IProgressMonitor monitor ) {
- if( monitor.isCanceled() )
- return;
- org.osgi.framework.Bundle[] newBundles = PDERuntimePlugin.getDefault()
- .getBundleContext()
- .getBundles();
- for( int i = 0; i < newBundles.length; i++ ) {
- if( monitor.isCanceled() )
- return;
- Bundle ba = createBundleAdapter( newBundles[ i ] );
- listener.addBundle( ba );
- }
- }
-
- public void initializeExtensionPoints( IProgressMonitor monitor ) {
- if( monitor.isCanceled() )
- return;
- IExtensionPoint[] extPoints = Platform.getExtensionRegistry().getExtensionPoints();
- ExtensionPoint[] extPts = new ExtensionPoint[ extPoints.length ];
- for( int i = 0; i < extPoints.length; i++ ) {
- if( monitor.isCanceled() )
- return;
- extPts[ i ] = createExtensionPointAdapter( extPoints[ i ] );
- }
- listener.addExtensionPoints( extPts );
- }
-
- public void initializeServices( IProgressMonitor monitor ) {
- if( monitor.isCanceled() )
- return;
- ServiceReference[] references = null;
- try {
- references = PDERuntimePlugin.getDefault()
- .getBundleContext()
- .getAllServiceReferences( null, null );
- } catch( InvalidSyntaxException e ) { // nothing
- }
- if( references == null ) {
- return;
- }
- for( int i = 0; i < references.length; i++ ) {
- if( monitor.isCanceled() )
- return;
- ServiceRegistration service = createServiceReferenceAdapter( references[ i ] );
- // The list of registered services is volatile, avoid adding unregistered services to the
-// listener
- if( service.getBundle() != null ) {
- listener.addService( service );
- }
- }
- }
-
- private Bundle createBundleAdapter( org.osgi.framework.Bundle bundle ) {
- Bundle adapter = new Bundle();
- adapter.setSymbolicName( bundle.getSymbolicName() );
- adapter.setVersion( ( String )bundle.getHeaders()
- .get( org.osgi.framework.Constants.BUNDLE_VERSION ) );
- adapter.setState( bundle.getState() );
- adapter.setId( bundle.getBundleId() );
- adapter.setEnabled( getIsEnabled( bundle ) );
- adapter.setLocation( createLocation( bundle ) );
- String fragmentHost = ( String )bundle.getHeaders().get( Constants.FRAGMENT_HOST );
- if( fragmentHost != null ) {
- ManifestElement[] header;
- try {
- header = ManifestElement.parseHeader( Constants.FRAGMENT_HOST, fragmentHost );
- if( header.length > 0 ) {
- ManifestElement host = header[ 0 ];
- adapter.setFragmentHost( host.getValue() );
- String version = host.getAttribute( Constants.BUNDLE_VERSION_ATTRIBUTE );
- if( version != null ) {
- adapter.setFragmentHostVersion( version );
- }
- }
- } catch( BundleException e ) {
- PDERuntimePlugin.log( e );
- }
- }
- BundlePrerequisite[] imports = ( BundlePrerequisite[] )getManifestHeaderArray( bundle,
- Constants.REQUIRE_BUNDLE );
- if( imports != null )
- adapter.setImports( imports );
- BundleLibrary[] libraries = ( BundleLibrary[] )getManifestHeaderArray( bundle,
- Constants.BUNDLE_CLASSPATH );
- if( libraries != null )
- adapter.setLibraries( libraries );
- BundlePrerequisite[] importPackages = ( BundlePrerequisite[] )getManifestHeaderArray( bundle,
- Constants.IMPORT_PACKAGE );
- if( importPackages != null )
- adapter.setImportedPackages( importPackages );
- BundlePrerequisite[] exportPackages = ( BundlePrerequisite[] )getManifestHeaderArray( bundle,
- Constants.EXPORT_PACKAGE );
- if( exportPackages != null )
- adapter.setExportedPackages( exportPackages );
- return adapter;
- }
-
- private Extension createExtensionAdapter( IExtension extension ) {
- Extension adapter = new Extension();
- adapter.setNamespaceIdentifier( extension.getNamespaceIdentifier() );
- adapter.setLabel( extension.getLabel() );
- adapter.setExtensionPointUniqueIdentifier( extension.getExtensionPointUniqueIdentifier() );
- adapter.setContributor( getBundleId( extension.getContributor().getName() ) );
- IConfigurationElement[] elements = extension.getConfigurationElements();
- if( elements.length > 0 ) {
- ConfigurationElement[] configurationElements = new ConfigurationElement[ elements.length ];
- for( int i = 0; i < elements.length; i++ ) {
- configurationElements[ i ] = createConfigurationElement( elements[ i ] );
- }
- adapter.setConfigurationElements( configurationElements );
- }
- return adapter;
- }
-
- private ConfigurationElement createConfigurationElement( IConfigurationElement config ) {
- ConfigurationElement element = new ConfigurationElement();
- element.setName( createName( config ) );
- Attribute[] attributes = createConfigurationElementAttributes( config );
- if( attributes != null )
- element.setElements( attributes );
- return element;
- }
-
- private static Long getBundleId( String name ) {
- BundleDescription descr = PDERuntimePlugin.getDefault()
- .getPlatformAdmin()
- .getState( false )
- .getBundle( name, null );
- return descr == null
- ? null
- : new Long( descr.getBundleId() );
- }
-
- private ExtensionPoint createExtensionPointAdapter( IExtensionPoint extensionPoint ) {
- ExtensionPoint adapter = new ExtensionPoint();
- adapter.setLabel( extensionPoint.getLabel() );
- adapter.setUniqueIdentifier( extensionPoint.getUniqueIdentifier() );
- adapter.setNamespaceIdentifier( extensionPoint.getNamespaceIdentifier() );
- adapter.setContributor( getBundleId( extensionPoint.getContributor().getName() ) );
- Extension[] extensions = createExtensionAdapters( extensionPoint.getExtensions() );
- adapter.getExtensions().addAll( Arrays.asList( extensions ) );
- return adapter;
- }
-
- private ServiceRegistration createServiceReferenceAdapter( ServiceReference ref ) {
- ServiceRegistration service = new ServiceRegistration();
- service.setId( ( ( Long )ref.getProperty( org.osgi.framework.Constants.SERVICE_ID ) ).longValue() );
- org.osgi.framework.Bundle bundle = ref.getBundle();
- if( bundle != null ) {
- service.setBundle( bundle.getSymbolicName() );
- }
- org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles();
- long[] usingBundlesIds = null;
- if( usingBundles != null ) {
- usingBundlesIds = new long[ usingBundles.length ];
- for( int i = 0; i < usingBundles.length; i++ ) {
- usingBundlesIds[ i ] = usingBundles[ i ].getBundleId();
- }
- }
- if( usingBundlesIds != null )
- service.setUsingBundles( usingBundlesIds );
- String[] classes = ( String[] )ref.getProperty( org.osgi.framework.Constants.OBJECTCLASS );
- String[] propertyKeys = ref.getPropertyKeys();
- Property[] properties = null;
- if( propertyKeys != null ) {
- properties = new Property[ propertyKeys.length ];
- for( int p = 0; p < propertyKeys.length; p++ ) {
- String key = propertyKeys[ p ];
- Object value = ref.getProperty( key );
- properties[ p ] = new Property( key, ServiceRegistration.toString( value ) );
- }
- }
- if( classes != null ) {
- Arrays.sort( classes );
- service.setName( new ServiceName( classes ) );
- service.setProperties( properties );
- }
- return service;
- }
-
- private static boolean getIsEnabled( org.osgi.framework.Bundle bundle ) {
- PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- State state = plaformAdmin.getState( false );
- BundleDescription description = state.getBundle( bundle.getBundleId() );
- return ( state.getDisabledInfos( description ) ).length == 0;
- }
-
- private static String createLocation( org.osgi.framework.Bundle bundle ) {
- URL bundleEntry = null;
- try {
- bundleEntry = bundle.getEntry( "/" ); //$NON-NLS-1$
- } catch( IllegalStateException e ) {
- return null;
- }
- try {
- bundleEntry = FileLocator.resolve( bundleEntry );
- } catch( IOException e ) { // do nothing
- }
- IPath path = new Path( bundleEntry.getFile() );
- String pathString = path.removeTrailingSeparator().toOSString();
- if( pathString.startsWith( "file:" ) ) //$NON-NLS-1$
- pathString = pathString.substring( 5 );
- if( pathString.endsWith( "!" ) ) //$NON-NLS-1$
- pathString = pathString.substring( 0, pathString.length() - 1 );
- return pathString;
- }
-
- private Object[] getManifestHeaderArray( org.osgi.framework.Bundle bundle, String headerKey ) {
- String libraries = ( String )bundle.getHeaders().get( headerKey );
- try {
- ManifestElement[] elements = ManifestElement.parseHeader( headerKey, libraries );
- if( elements == null )
- return null;
- if( headerKey.equals( Constants.BUNDLE_CLASSPATH ) ) {
- BundleLibrary[] array = new BundleLibrary[ elements.length ];
- for( int i = 0; i < elements.length; i++ ) {
- BundleLibrary library = new BundleLibrary();
- library.setLibrary( elements[ i ].getValue() );
- array[ i ] = library;
- }
- return array;
- } else if( headerKey.equals( Constants.REQUIRE_BUNDLE )
- || headerKey.equals( Constants.IMPORT_PACKAGE )
- || headerKey.equals( Constants.EXPORT_PACKAGE ) )
- {
- BundlePrerequisite[] array = new BundlePrerequisite[ elements.length ];
- for( int i = 0; i < elements.length; i++ ) {
- ManifestElement element = elements[ i ];
- BundlePrerequisite prereq = new BundlePrerequisite();
- prereq.setName( element.getValue() );
- if( headerKey.equals( Constants.REQUIRE_BUNDLE ) ) {
- prereq.setVersion( element.getAttribute( Constants.BUNDLE_VERSION_ATTRIBUTE ) );
- String visibility = element.getDirective( Constants.VISIBILITY_DIRECTIVE );
- prereq.setExported( Constants.VISIBILITY_REEXPORT.equals( visibility ) );
- } else {
- prereq.setVersion( element.getAttribute( Constants.VERSION_ATTRIBUTE ) );
- prereq.setPackage( true );
- }
- array[ i ] = prereq;
- }
- return array;
- }
- } catch( BundleException e ) { // do nothing
- }
- return null;
- }
-
- private Attribute[] createConfigurationElementAttributes( IConfigurationElement config ) {
- String[] atts = config.getAttributeNames();
- Attribute[] catts = new Attribute[ atts.length ];
- for( int i = 0; i < atts.length; i++ )
- catts[ i ] = new Attribute( atts[ i ], config.getAttribute( atts[ i ] ) );
- IConfigurationElement[] children = config.getChildren();
- Attribute[] result = new Attribute[ children.length + catts.length ];
- for( int i = 0; i < children.length; i++ ) {
- IConfigurationElement child = children[ i ];
- result[ i ] = createConfigurationElement( child );
- }
- for( int i = 0; i < catts.length; i++ ) {
- result[ children.length + i ] = catts[ i ];
- }
- return result;
- }
-
- private static String createName( IConfigurationElement config ) {
- String label = config.getAttribute( "label" ); //$NON-NLS-1$
- if( label == null )
- label = config.getName();
- if( label == null )
- label = config.getAttribute( "name" ); //$NON-NLS-1$
- if( label == null && config.getAttribute( "id" ) != null ) { //$NON-NLS-1$
- String[] labelSplit = config.getAttribute( "id" ).split( "\\." ); //$NON-NLS-1$ //$NON-NLS-2$
- label = labelSplit.length == 0
- ? null
- : labelSplit[ labelSplit.length - 1 ];
- }
- return label;
- }
-
- private Extension[] createExtensionAdapters( IExtension[] extensions ) {
- Extension[] extensionAdapters = new Extension[ extensions.length ];
- for( int i = 0; i < extensions.length; i++ ) {
- extensionAdapters[ i ] = createExtensionAdapter( extensions[ i ] );
- }
- return extensionAdapters;
- }
-
- public void bundleChanged( BundleEvent event ) {
- Bundle adapter = createBundleAdapter( event.getBundle() );
- switch( event.getType() ) {
- case BundleEvent.INSTALLED:
- listener.addBundle( adapter );
- break;
- case BundleEvent.UNINSTALLED:
- listener.removeBundle( adapter );
- break;
- case BundleEvent.UPDATED:
- listener.updateBundle( adapter, ModelChangeDelta.UPDATED );
- break;
- case BundleEvent.RESOLVED:
- listener.updateBundle( adapter, ModelChangeDelta.RESOLVED );
- break;
- case BundleEvent.UNRESOLVED:
- listener.updateBundle( adapter, ModelChangeDelta.UNRESOLVED );
- break;
- case BundleEvent.STARTING:
- listener.updateBundle( adapter, ModelChangeDelta.STARTING );
- break;
- case BundleEvent.STARTED:
- listener.updateBundle( adapter, ModelChangeDelta.STARTED );
- break;
- case BundleEvent.STOPPING:
- listener.updateBundle( adapter, ModelChangeDelta.STOPPING );
- break;
- case BundleEvent.STOPPED:
- listener.updateBundle( adapter, ModelChangeDelta.STOPPED );
- break;
- default:
- listener.updateBundle( adapter, ModelChangeDelta.UPDATED );
- }
- }
-
- public void serviceChanged( ServiceEvent event ) {
- ServiceReference ref = event.getServiceReference();
- ServiceRegistration adapter = createServiceReferenceAdapter( ref );
- switch( event.getType() ) {
- case ServiceEvent.REGISTERED:
- listener.addService( adapter );
- break;
- case ServiceEvent.UNREGISTERING:
- listener.removeService( adapter );
- break;
- case ServiceEvent.MODIFIED:
- default:
- listener.updateService( adapter );
- break;
- }
- }
-
- private ExtensionPoint[] createExtensionPointAdapters( IExtensionPoint[] extensionPoints ) {
- ExtensionPoint[] result = new ExtensionPoint[ extensionPoints.length ];
- for( int i = 0; i < extensionPoints.length; i++ ) {
- result[ i ] = createExtensionPointAdapter( extensionPoints[ i ] );
- }
- return result;
- }
-
- public void added( IExtension[] extensions ) {
- listener.addExtensions( createExtensionAdapters( extensions ) );
- }
-
- public void removed( IExtension[] extensions ) {
- listener.removeExtensions( createExtensionAdapters( extensions ) );
- }
-
- public void added( IExtensionPoint[] extensionPoints ) {
- listener.addExtensionPoints( createExtensionPointAdapters( extensionPoints ) );
- }
-
- public void removed( IExtensionPoint[] extensionPoints ) {
- listener.removeExtensionPoints( createExtensionPointAdapters( extensionPoints ) );
- }
-
- public void setEnabled( long id, boolean enabled ) {
- State state = PDERuntimePlugin.getDefault().getState();
- BundleDescription desc = state.getBundle( id );
- if( enabled ) {
- DisabledInfo[] infos = state.getDisabledInfos( desc );
- for( int i = 0; i < infos.length; i++ ) {
- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- platformAdmin.removeDisabledInfo( infos[ i ] );
- }
- } else {
- DisabledInfo info = new DisabledInfo( "org.eclipse.pde.ui", "Disabled via PDE", desc ); //$NON-NLS-1$ //$NON-NLS-2$
- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- platformAdmin.addDisabledInfo( info );
- }
- org.osgi.framework.Bundle b = PDERuntimePlugin.getDefault().getBundleContext().getBundle( id );
- PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
- packageAdmin.refreshPackages( new org.osgi.framework.Bundle[] {
- b
- } );
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008, 2015 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
+ * Wolfgang Schell <ws@jetztgrad.net> - bug 259348
+ *******************************************************************************/
+package org.eclipse.pde.internal.runtime.registry.model;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import org.eclipse.core.runtime.*;
+import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.pde.internal.runtime.*;
+import org.osgi.framework.*;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+
+public class LocalRegistryBackend
+ implements IRegistryEventListener, BundleListener, ServiceListener, RegistryBackend
+{
+
+ private BackendChangeListener listener;
+
+ public void setRegistryListener( BackendChangeListener listener ) {
+ this.listener = listener;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#connect()
+ */
+ public void connect( IProgressMonitor monitor ) {
+ if( monitor.isCanceled() )
+ return;
+ PDERuntimePlugin.getDefault().getBundleContext().addBundleListener( this );
+ Platform.getExtensionRegistry().addListener( this );
+ PDERuntimePlugin.getDefault().getBundleContext().addServiceListener( this );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#disconnect()
+ */
+ public void disconnect() {
+ Platform.getExtensionRegistry().removeListener( this );
+ PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener( this );
+ PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener( this );
+ }
+
+ protected static boolean isRegisteredService( org.osgi.framework.Bundle bundle,
+ ServiceReference ref )
+ {
+ return bundle.equals( ref.getBundle() );
+ }
+
+ protected static boolean isServiceInUse( org.osgi.framework.Bundle bundle, ServiceReference ref )
+ {
+ org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles();
+ return( usingBundles != null && Arrays.asList( usingBundles ).contains( bundle ) );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#start(org.osgi.framework
+ * .Bundle)
+ */
+ public void start( long id ) throws BundleException {
+ PDERuntimePlugin.getDefault().getBundleContext().getBundle( id ).start();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#stop(org.osgi.framework
+ * .Bundle)
+ */
+ public void stop( long id ) throws BundleException {
+ PDERuntimePlugin.getDefault().getBundleContext().getBundle( id ).stop();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#diagnose(org.osgi.framework
+ * .Bundle)
+ */
+ public MultiStatus diagnose( long id ) {
+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
+ State state = plaformAdmin.getState( false );
+ BundleDescription desc = state.getBundle( id );
+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
+ VersionConstraint[] unsatisfied = platformAdmin.getStateHelper()
+ .getUnsatisfiedConstraints( desc );
+ ResolverError[] resolverErrors = platformAdmin.getState( false ).getResolverErrors( desc );
+ MultiStatus problems = new MultiStatus( PDERuntimePlugin.ID,
+ IStatus.INFO,
+ PDERuntimeMessages.get().RegistryView_found_problems,
+ null );
+ for( int i = 0; i < resolverErrors.length; i++ ) {
+ if( ( resolverErrors[ i ].getType() & ( ResolverError.MISSING_FRAGMENT_HOST
+ | ResolverError.MISSING_GENERIC_CAPABILITY
+ | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE ) ) != 0 )
+ continue;
+ IStatus status = new Status( IStatus.WARNING,
+ PDERuntimePlugin.ID,
+ resolverErrors[ i ].toString() );
+ problems.add( status );
+ }
+ for( int i = 0; i < unsatisfied.length; i++ ) {
+ IStatus status = new Status( IStatus.WARNING,
+ PDERuntimePlugin.ID,
+ MessageHelper.getResolutionFailureMessage( unsatisfied[ i ] ) );
+ problems.add( status );
+ }
+ return problems;
+ }
+
+ public void initializeBundles( IProgressMonitor monitor ) {
+ if( monitor.isCanceled() )
+ return;
+ org.osgi.framework.Bundle[] newBundles = PDERuntimePlugin.getDefault()
+ .getBundleContext()
+ .getBundles();
+ for( int i = 0; i < newBundles.length; i++ ) {
+ if( monitor.isCanceled() )
+ return;
+ Bundle ba = createBundleAdapter( newBundles[ i ] );
+ listener.addBundle( ba );
+ }
+ }
+
+ public void initializeExtensionPoints( IProgressMonitor monitor ) {
+ if( monitor.isCanceled() )
+ return;
+ IExtensionPoint[] extPoints = Platform.getExtensionRegistry().getExtensionPoints();
+ ExtensionPoint[] extPts = new ExtensionPoint[ extPoints.length ];
+ for( int i = 0; i < extPoints.length; i++ ) {
+ if( monitor.isCanceled() )
+ return;
+ extPts[ i ] = createExtensionPointAdapter( extPoints[ i ] );
+ }
+ listener.addExtensionPoints( extPts );
+ }
+
+ public void initializeServices( IProgressMonitor monitor ) {
+ if( monitor.isCanceled() )
+ return;
+ ServiceReference[] references = null;
+ try {
+ references = PDERuntimePlugin.getDefault()
+ .getBundleContext()
+ .getAllServiceReferences( null, null );
+ } catch( InvalidSyntaxException e ) { // nothing
+ }
+ if( references == null ) {
+ return;
+ }
+ for( int i = 0; i < references.length; i++ ) {
+ if( monitor.isCanceled() )
+ return;
+ ServiceRegistration service = createServiceReferenceAdapter( references[ i ] );
+ // The list of registered services is volatile, avoid adding unregistered services to the
+// listener
+ if( service.getBundle() != null ) {
+ listener.addService( service );
+ }
+ }
+ }
+
+ private Bundle createBundleAdapter( org.osgi.framework.Bundle bundle ) {
+ Bundle adapter = new Bundle();
+ adapter.setSymbolicName( bundle.getSymbolicName() );
+ adapter.setVersion( ( String )bundle.getHeaders()
+ .get( org.osgi.framework.Constants.BUNDLE_VERSION ) );
+ adapter.setState( bundle.getState() );
+ adapter.setId( bundle.getBundleId() );
+ adapter.setEnabled( getIsEnabled( bundle ) );
+ adapter.setLocation( createLocation( bundle ) );
+ String fragmentHost = ( String )bundle.getHeaders().get( Constants.FRAGMENT_HOST );
+ if( fragmentHost != null ) {
+ ManifestElement[] header;
+ try {
+ header = ManifestElement.parseHeader( Constants.FRAGMENT_HOST, fragmentHost );
+ if( header.length > 0 ) {
+ ManifestElement host = header[ 0 ];
+ adapter.setFragmentHost( host.getValue() );
+ String version = host.getAttribute( Constants.BUNDLE_VERSION_ATTRIBUTE );
+ if( version != null ) {
+ adapter.setFragmentHostVersion( version );
+ }
+ }
+ } catch( BundleException e ) {
+ PDERuntimePlugin.log( e );
+ }
+ }
+ BundlePrerequisite[] imports = ( BundlePrerequisite[] )getManifestHeaderArray( bundle,
+ Constants.REQUIRE_BUNDLE );
+ if( imports != null )
+ adapter.setImports( imports );
+ BundleLibrary[] libraries = ( BundleLibrary[] )getManifestHeaderArray( bundle,
+ Constants.BUNDLE_CLASSPATH );
+ if( libraries != null )
+ adapter.setLibraries( libraries );
+ BundlePrerequisite[] importPackages = ( BundlePrerequisite[] )getManifestHeaderArray( bundle,
+ Constants.IMPORT_PACKAGE );
+ if( importPackages != null )
+ adapter.setImportedPackages( importPackages );
+ BundlePrerequisite[] exportPackages = ( BundlePrerequisite[] )getManifestHeaderArray( bundle,
+ Constants.EXPORT_PACKAGE );
+ if( exportPackages != null )
+ adapter.setExportedPackages( exportPackages );
+ return adapter;
+ }
+
+ private Extension createExtensionAdapter( IExtension extension ) {
+ Extension adapter = new Extension();
+ adapter.setNamespaceIdentifier( extension.getNamespaceIdentifier() );
+ adapter.setLabel( extension.getLabel() );
+ adapter.setExtensionPointUniqueIdentifier( extension.getExtensionPointUniqueIdentifier() );
+ adapter.setContributor( getBundleId( extension.getContributor().getName() ) );
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ if( elements.length > 0 ) {
+ ConfigurationElement[] configurationElements = new ConfigurationElement[ elements.length ];
+ for( int i = 0; i < elements.length; i++ ) {
+ configurationElements[ i ] = createConfigurationElement( elements[ i ] );
+ }
+ adapter.setConfigurationElements( configurationElements );
+ }
+ return adapter;
+ }
+
+ private ConfigurationElement createConfigurationElement( IConfigurationElement config ) {
+ ConfigurationElement element = new ConfigurationElement();
+ element.setName( createName( config ) );
+ Attribute[] attributes = createConfigurationElementAttributes( config );
+ if( attributes != null )
+ element.setElements( attributes );
+ return element;
+ }
+
+ private static Long getBundleId( String name ) {
+ BundleDescription descr = PDERuntimePlugin.getDefault()
+ .getPlatformAdmin()
+ .getState( false )
+ .getBundle( name, null );
+ return descr == null
+ ? null
+ : new Long( descr.getBundleId() );
+ }
+
+ private ExtensionPoint createExtensionPointAdapter( IExtensionPoint extensionPoint ) {
+ ExtensionPoint adapter = new ExtensionPoint();
+ adapter.setLabel( extensionPoint.getLabel() );
+ adapter.setUniqueIdentifier( extensionPoint.getUniqueIdentifier() );
+ adapter.setNamespaceIdentifier( extensionPoint.getNamespaceIdentifier() );
+ adapter.setContributor( getBundleId( extensionPoint.getContributor().getName() ) );
+ Extension[] extensions = createExtensionAdapters( extensionPoint.getExtensions() );
+ adapter.getExtensions().addAll( Arrays.asList( extensions ) );
+ return adapter;
+ }
+
+ /**
+ * Returns a new {@link ServiceRegistration} for the given service reference. If the service being
+ * referenced is unregistered, the returned service registration will not have a bundle set.
+ *
+ * @param ref the service reference to get the registration for
+ * @return a new service registration containing information from the service reference
+ */
+ private ServiceRegistration createServiceReferenceAdapter( ServiceReference ref ) {
+ ServiceRegistration service = new ServiceRegistration();
+ service.setId( ( ( Long )ref.getProperty( org.osgi.framework.Constants.SERVICE_ID ) ).longValue() );
+ org.osgi.framework.Bundle bundle = ref.getBundle();
+ if( bundle != null ) {
+ service.setBundle( bundle.getSymbolicName() );
+ }
+ org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles();
+ long[] usingBundlesIds = null;
+ if( usingBundles != null ) {
+ usingBundlesIds = new long[ usingBundles.length ];
+ for( int i = 0; i < usingBundles.length; i++ ) {
+ usingBundlesIds[ i ] = usingBundles[ i ].getBundleId();
+ }
+ }
+ if( usingBundlesIds != null )
+ service.setUsingBundles( usingBundlesIds );
+ String[] classes = ( String[] )ref.getProperty( org.osgi.framework.Constants.OBJECTCLASS );
+ String[] propertyKeys = ref.getPropertyKeys();
+ Property[] properties = null;
+ if( propertyKeys != null ) {
+ properties = new Property[ propertyKeys.length ];
+ for( int p = 0; p < propertyKeys.length; p++ ) {
+ String key = propertyKeys[ p ];
+ Object value = ref.getProperty( key );
+ properties[ p ] = new Property( key, ServiceRegistration.toString( value ) );
+ }
+ }
+ if( classes != null ) {
+ Arrays.sort( classes );
+ service.setName( new ServiceName( classes, ref ) );
+ service.setProperties( properties );
+ }
+ return service;
+ }
+
+ private static boolean getIsEnabled( org.osgi.framework.Bundle bundle ) {
+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
+ State state = plaformAdmin.getState( false );
+ BundleDescription description = state.getBundle( bundle.getBundleId() );
+ return ( state.getDisabledInfos( description ) ).length == 0;
+ }
+
+ private static String createLocation( org.osgi.framework.Bundle bundle ) {
+ URL bundleEntry = null;
+ try {
+ bundleEntry = bundle.getEntry( "/" ); //$NON-NLS-1$
+ } catch( IllegalStateException e ) {
+ return null;
+ }
+ try {
+ bundleEntry = FileLocator.resolve( bundleEntry );
+ } catch( IOException e ) { // do nothing
+ }
+ IPath path = new Path( bundleEntry.getFile() );
+ String pathString = path.removeTrailingSeparator().toOSString();
+ if( pathString.startsWith( "file:" ) ) //$NON-NLS-1$
+ pathString = pathString.substring( 5 );
+ if( pathString.endsWith( "!" ) ) //$NON-NLS-1$
+ pathString = pathString.substring( 0, pathString.length() - 1 );
+ return pathString;
+ }
+
+ private Object[] getManifestHeaderArray( org.osgi.framework.Bundle bundle, String headerKey ) {
+ String libraries = ( String )bundle.getHeaders().get( headerKey );
+ try {
+ ManifestElement[] elements = ManifestElement.parseHeader( headerKey, libraries );
+ if( elements == null )
+ return null;
+ if( headerKey.equals( Constants.BUNDLE_CLASSPATH ) ) {
+ BundleLibrary[] array = new BundleLibrary[ elements.length ];
+ for( int i = 0; i < elements.length; i++ ) {
+ BundleLibrary library = new BundleLibrary();
+ library.setLibrary( elements[ i ].getValue() );
+ array[ i ] = library;
+ }
+ return array;
+ } else if( headerKey.equals( Constants.REQUIRE_BUNDLE )
+ || headerKey.equals( Constants.IMPORT_PACKAGE )
+ || headerKey.equals( Constants.EXPORT_PACKAGE ) )
+ {
+ BundlePrerequisite[] array = new BundlePrerequisite[ elements.length ];
+ for( int i = 0; i < elements.length; i++ ) {
+ ManifestElement element = elements[ i ];
+ BundlePrerequisite prereq = new BundlePrerequisite();
+ prereq.setName( element.getValue() );
+ if( headerKey.equals( Constants.REQUIRE_BUNDLE ) ) {
+ prereq.setVersion( element.getAttribute( Constants.BUNDLE_VERSION_ATTRIBUTE ) );
+ String visibility = element.getDirective( Constants.VISIBILITY_DIRECTIVE );
+ prereq.setExported( Constants.VISIBILITY_REEXPORT.equals( visibility ) );
+ } else {
+ prereq.setVersion( element.getAttribute( Constants.VERSION_ATTRIBUTE ) );
+ prereq.setPackage( true );
+ }
+ array[ i ] = prereq;
+ }
+ return array;
+ }
+ } catch( BundleException e ) { // do nothing
+ }
+ return null;
+ }
+
+ private Attribute[] createConfigurationElementAttributes( IConfigurationElement config ) {
+ String[] atts = config.getAttributeNames();
+ Attribute[] catts = new Attribute[ atts.length ];
+ for( int i = 0; i < atts.length; i++ )
+ catts[ i ] = new Attribute( atts[ i ], config.getAttribute( atts[ i ] ) );
+ IConfigurationElement[] children = config.getChildren();
+ Attribute[] result = new Attribute[ children.length + catts.length ];
+ for( int i = 0; i < children.length; i++ ) {
+ IConfigurationElement child = children[ i ];
+ result[ i ] = createConfigurationElement( child );
+ }
+ for( int i = 0; i < catts.length; i++ ) {
+ result[ children.length + i ] = catts[ i ];
+ }
+ return result;
+ }
+
+ private static String createName( IConfigurationElement config ) {
+ String label = config.getAttribute( "label" ); //$NON-NLS-1$
+ if( label == null )
+ label = config.getName();
+ if( label == null )
+ label = config.getAttribute( "name" ); //$NON-NLS-1$
+ if( label == null && config.getAttribute( "id" ) != null ) { //$NON-NLS-1$
+ String[] labelSplit = config.getAttribute( "id" ).split( "\\." ); //$NON-NLS-1$ //$NON-NLS-2$
+ label = labelSplit.length == 0
+ ? null
+ : labelSplit[ labelSplit.length - 1 ];
+ }
+ return label;
+ }
+
+ private Extension[] createExtensionAdapters( IExtension[] extensions ) {
+ Extension[] extensionAdapters = new Extension[ extensions.length ];
+ for( int i = 0; i < extensions.length; i++ ) {
+ extensionAdapters[ i ] = createExtensionAdapter( extensions[ i ] );
+ }
+ return extensionAdapters;
+ }
+
+ public void bundleChanged( BundleEvent event ) {
+ Bundle adapter = createBundleAdapter( event.getBundle() );
+ switch( event.getType() ) {
+ case BundleEvent.INSTALLED:
+ listener.addBundle( adapter );
+ break;
+ case BundleEvent.UNINSTALLED:
+ listener.removeBundle( adapter );
+ break;
+ case BundleEvent.UPDATED:
+ listener.updateBundle( adapter, ModelChangeDelta.UPDATED );
+ break;
+ case BundleEvent.RESOLVED:
+ listener.updateBundle( adapter, ModelChangeDelta.RESOLVED );
+ break;
+ case BundleEvent.UNRESOLVED:
+ listener.updateBundle( adapter, ModelChangeDelta.UNRESOLVED );
+ break;
+ case BundleEvent.STARTING:
+ listener.updateBundle( adapter, ModelChangeDelta.STARTING );
+ break;
+ case BundleEvent.STARTED:
+ listener.updateBundle( adapter, ModelChangeDelta.STARTED );
+ break;
+ case BundleEvent.STOPPING:
+ listener.updateBundle( adapter, ModelChangeDelta.STOPPING );
+ break;
+ case BundleEvent.STOPPED:
+ listener.updateBundle( adapter, ModelChangeDelta.STOPPED );
+ break;
+ default:
+ listener.updateBundle( adapter, ModelChangeDelta.UPDATED );
+ }
+ }
+
+ public void serviceChanged( ServiceEvent event ) {
+ ServiceReference ref = event.getServiceReference();
+ ServiceRegistration adapter = createServiceReferenceAdapter( ref );
+ switch( event.getType() ) {
+ case ServiceEvent.REGISTERED:
+ listener.addService( adapter );
+ break;
+ case ServiceEvent.UNREGISTERING:
+ listener.removeService( adapter );
+ break;
+ case ServiceEvent.MODIFIED:
+ default:
+ listener.updateService( adapter );
+ break;
+ }
+ }
+
+ private ExtensionPoint[] createExtensionPointAdapters( IExtensionPoint[] extensionPoints ) {
+ ExtensionPoint[] result = new ExtensionPoint[ extensionPoints.length ];
+ for( int i = 0; i < extensionPoints.length; i++ ) {
+ result[ i ] = createExtensionPointAdapter( extensionPoints[ i ] );
+ }
+ return result;
+ }
+
+ public void added( IExtension[] extensions ) {
+ listener.addExtensions( createExtensionAdapters( extensions ) );
+ }
+
+ public void removed( IExtension[] extensions ) {
+ listener.removeExtensions( createExtensionAdapters( extensions ) );
+ }
+
+ public void added( IExtensionPoint[] extensionPoints ) {
+ listener.addExtensionPoints( createExtensionPointAdapters( extensionPoints ) );
+ }
+
+ public void removed( IExtensionPoint[] extensionPoints ) {
+ listener.removeExtensionPoints( createExtensionPointAdapters( extensionPoints ) );
+ }
+
+ public void setEnabled( long id, boolean enabled ) {
+ State state = PDERuntimePlugin.getDefault().getState();
+ BundleDescription desc = state.getBundle( id );
+ if( enabled ) {
+ DisabledInfo[] infos = state.getDisabledInfos( desc );
+ for( int i = 0; i < infos.length; i++ ) {
+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
+ platformAdmin.removeDisabledInfo( infos[ i ] );
+ }
+ } else {
+ DisabledInfo info = new DisabledInfo( "org.eclipse.pde.ui", "Disabled via PDE", desc ); //$NON-NLS-1$ //$NON-NLS-2$
+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
+ platformAdmin.addDisabledInfo( info );
+ }
+ org.osgi.framework.Bundle b = PDERuntimePlugin.getDefault().getBundleContext().getBundle( id );
+ PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
+ packageAdmin.refreshPackages( new org.osgi.framework.Bundle[] {
+ b
+ } );
+ }
+}
diff --git a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java
index 97111f5..ec8bbf1 100644
--- a/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java
+++ b/bundles/org.eclipse.rap.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java
@@ -1,73 +1,79 @@
-/*******************************************************************************
- * Copyright (c) 2009, 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
- * Wolfgang Schell <ws@jetztgrad.net> - bug 260055
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.util.Arrays;
-
-
-public class ServiceName extends ModelObject implements Comparable {
-
- private String[] classes;
-
- public ServiceName( String[] classes ) {
- this.classes = classes;
- }
-
- public String[] getClasses() {
- return classes;
- }
-
- public ModelObject[] getChildren() {
- if( model == null ) {
- return new ModelObject[ 0 ];
- }
- return model.getServices( classes );
- }
-
- private static int hashCode( Object[] array ) {
- int prime = 31;
- if( array == null )
- return 0;
- int result = 1;
- for( int index = 0; index < array.length; index++ ) {
- result = prime * result + ( array[ index ] == null
- ? 0
- : array[ index ].hashCode() );
- }
- return result;
- }
-
- public int hashCode() {
- final int prime = 31;
- return prime * ServiceName.hashCode( classes );
- }
-
- public boolean equals( Object obj ) {
- if( this == obj )
- return true;
- if( getClass() != obj.getClass() )
- return false;
- ServiceName other = ( ServiceName )obj;
- return Arrays.equals( classes, other.classes );
- }
-
- public int compareTo( Object obj ) {
- if( obj instanceof ServiceName ) {
- // compare first class
- ServiceName other = ( ServiceName )obj;
- String myClass = classes[ 0 ];
- String otherClass = other.getClasses()[ 0 ];
- return myClass.compareTo( otherClass );
- }
- return 0;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2015 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
+ * Wolfgang Schell <ws@jetztgrad.net> - bug 260055
+ *******************************************************************************/
+package org.eclipse.pde.internal.runtime.registry.model;
+
+import java.util.Arrays;
+import org.osgi.framework.ServiceReference;
+
+public class ServiceName extends ModelObject implements Comparable {
+
+ private String[] classes;
+ private ServiceReference reference;
+
+ public ServiceName(String[] classes, ServiceReference ref) {
+ this.classes = classes;
+ this.reference = ref;
+ }
+
+ public ServiceReference getServiceReference() {
+ return this.reference;
+ }
+
+ public String[] getClasses() {
+ return classes;
+ }
+
+ public ModelObject[] getChildren() {
+ if (model == null) {
+ return new ModelObject[0];
+ }
+ return model.getServices(classes);
+ }
+
+ private static int hashCode(Object[] array) {
+ int prime = 31;
+ if (array == null)
+ return 0;
+ int result = 1;
+ for (int index = 0; index < array.length; index++) {
+ result = prime * result + (array[index] == null ? 0 : array[index].hashCode());
+ }
+ return result;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ return prime * ServiceName.hashCode(classes);
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (getClass() != obj.getClass())
+ return false;
+ ServiceName other = (ServiceName) obj;
+ return Arrays.equals(classes, other.classes);
+ }
+
+ public int compareTo(Object obj) {
+ if (obj instanceof ServiceName) {
+ // compare first class
+ ServiceName other = (ServiceName) obj;
+ String myClass = classes[0];
+ String otherClass = other.getClasses()[0];
+
+ return myClass.compareTo(otherClass);
+ }
+ return 0;
+
+ }
+}
diff --git a/bundles/org.eclipse.rap.ui.views.log/META-INF/MANIFEST.MF b/bundles/org.eclipse.rap.ui.views.log/META-INF/MANIFEST.MF
index a50f887..f349336 100644
--- a/bundles/org.eclipse.rap.ui.views.log/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.rap.ui.views.log/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@
Bundle-Vendor: %provider-name
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.rap.ui;bundle-version="[2.0.0,4.0.0)",
- org.eclipse.rap.addons.filedialog;bundle-version="[0.5.0,1.0.0)"
+ org.eclipse.rap.filedialog;bundle-version="[3.0.0,4.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Localization: plugin