Bug 375262 - [CSS] Fix the CSS extension points
diff --git a/bundles/org.eclipse.e4.ui.css.core/plugin.properties b/bundles/org.eclipse.e4.ui.css.core/plugin.properties
index c3187d8..f2d8eec 100644
--- a/bundles/org.eclipse.e4.ui.css.core/plugin.properties
+++ b/bundles/org.eclipse.e4.ui.css.core/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2010 IBM Corporation and others.
+# Copyright (c) 2010, 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
@@ -11,4 +11,5 @@
pluginName = Eclipse CSS Core Support
providerName = Eclipse.org
-extension-point.elementprovider.name = element_provider
\ No newline at end of file
+extension-point.elementprovider.name = CSS Element Provider
+extension-point.properties.name = CSS Property Handler
diff --git a/bundles/org.eclipse.e4.ui.css.core/plugin.xml b/bundles/org.eclipse.e4.ui.css.core/plugin.xml
index 666f9e0..abad901 100644
--- a/bundles/org.eclipse.e4.ui.css.core/plugin.xml
+++ b/bundles/org.eclipse.e4.ui.css.core/plugin.xml
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension-point id="org.eclipse.e4.u.css.core.elementProvider" name="%extension-point.elementprovider.name" schema="schema/org.eclipse.e4.u.css.core.elementProvider.exsd"/>
+ <extension-point id="org.eclipse.e4.ui.css.core.elementProvider" name="%extension-point.elementprovider.name" schema="schema/org.eclipse.e4.ui.css.core.elementProvider.exsd"/>
+ <extension-point id="org.eclipse.e4.ui.css.core.propertyHandler" name="%extension-point.properties.name" schema="schema/org.eclipse.e4.ui.css.core.propertyHandler.exsd"/>
+ <!-- Following extension points are deprecated and will be removed -->
+ <extension-point id="org.eclipse.e4.u.css.core.elementProvider" name="DEPRECATED: use org.eclipse.e4.ui.css.core.elementProvider"/>
+ <extension-point id="org.eclipse.e4.ui.css.swt.property.handler" name="DEPRECATED: use org.eclipse.e4.ui.css.core.propertyHandler"/>
</plugin>
diff --git a/bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.u.css.core.elementProvider.exsd b/bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.ui.css.core.elementProvider.exsd
similarity index 96%
rename from bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.u.css.core.elementProvider.exsd
rename to bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.ui.css.core.elementProvider.exsd
index 9ce463e..89f40d8 100644
--- a/bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.u.css.core.elementProvider.exsd
+++ b/bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.ui.css.core.elementProvider.exsd
@@ -3,10 +3,10 @@
<schema targetNamespace="org.eclipse.e4.ui.css.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
- <meta.schema plugin="org.eclipse.e4.ui.css.core" id="org.eclipse.e4.u.css.core.elementProvider" name="element_provider"/>
+ <meta.schema plugin="org.eclipse.e4.ui.css.core" id="org.eclipse.e4.ui.css.core.elementProvider" name="element_provider"/>
</appinfo>
<documentation>
- [Enter description of this extension point.]
+ Maps widgets or objects to an element provider.
</documentation>
</annotation>
diff --git a/bundles/org.eclipse.e4.ui.css.swt/schema/org.eclipse.e4.ui.css.swt.property.handler.exsd b/bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.ui.css.core.propertyHandler.exsd
similarity index 93%
rename from bundles/org.eclipse.e4.ui.css.swt/schema/org.eclipse.e4.ui.css.swt.property.handler.exsd
rename to bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.ui.css.core.propertyHandler.exsd
index b104005..3c58df6 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/schema/org.eclipse.e4.ui.css.swt.property.handler.exsd
+++ b/bundles/org.eclipse.e4.ui.css.core/schema/org.eclipse.e4.ui.css.core.propertyHandler.exsd
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.e4.ui.css.swt" xmlns="http://www.w3.org/2001/XMLSchema">
+<schema targetNamespace="org.eclipse.e4.ui.css.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
- <meta.schema plugin="org.eclipse.e4.ui.css.swt" id="org.eclipse.e4.ui.css.swt.property.handler" name="Properties"/>
+ <meta.schema plugin="org.eclipse.e4.ui.css.core" id="org.eclipse.e4.ui.css.core.propertyHandler" name="Properties"/>
</appinfo>
<documentation>
This extension point binds a handler class for a set of properties for a particular type of DOM elements.
@@ -112,7 +112,7 @@
<meta.section type="examples"/>
</appinfo>
<documentation>
- <extension point="org.eclipse.e4.ui.css.swt.property.handler">
+ <extension point="org.eclipse.e4.ui.css.core.propertyHandler">
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.ControlElement"
composite="true"
diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java
index 32f84c6..cdc6d68 100644
--- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java
+++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/CSSEngineImpl.java
@@ -30,20 +30,44 @@
public abstract class CSSEngineImpl extends AbstractCSSEngine {
+ /* the original extension point was misspelled */
+ private static final String DEPRECATED_ELEMENT_PROVIDER_EXTPOINT = "org.eclipse.e4.u.css.core.elementProvider";
+ private static final String ELEMENT_PROVIDER_EXTPOINT = "org.eclipse.e4.ui.css.core.elementProvider";
+
public static final ConditionFactory CONDITIONFACTORY_INSTANCE = new CSSConditionFactoryImpl(
null, "class", null, "id");
private CSSPropertyHandlerSimpleProviderImpl handlerProvider = null;
private CSSPropertyHandlerLazyProviderImpl lazyHandlerProvider = null;
+ private IExtensionRegistry registry;
public CSSEngineImpl() {
super();
- //Get Extension points
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- IExtensionPoint extPoint = registry
- .getExtensionPoint("org.eclipse.e4.u.css.core.elementProvider");
- for (IExtension e : extPoint.getExtensions()) {
+
+ registry = RegistryFactory.getRegistry();
+ if (configureElementProviders(DEPRECATED_ELEMENT_PROVIDER_EXTPOINT)) {
+ System.err.println("Extension point "
+ + DEPRECATED_ELEMENT_PROVIDER_EXTPOINT
+ + " is deprecated; use " + ELEMENT_PROVIDER_EXTPOINT);
+ }
+ configureElementProviders(ELEMENT_PROVIDER_EXTPOINT);
+
+ // Register SWT Boolean CSSValue Converter
+ super.registerCSSValueConverter(CSSValueBooleanConverterImpl.INSTANCE);
+ }
+
+ /** @return true if some providers were found */
+ private boolean configureElementProviders(String extensionPointId) {
+ IExtensionPoint extPoint = registry.getExtensionPoint(extensionPointId);
+ if (extPoint == null) {
+ return false;
+ }
+ IExtension[] extensions = extPoint.getExtensions();
+ if (extensions.length == 0) {
+ return false;
+ }
+ for (IExtension e : extensions) {
for (IConfigurationElement ce : e.getConfigurationElements()) {
String tmp = ce.getName();
if (tmp.equals("provider")) {
@@ -60,8 +84,7 @@
}
}
}
- // Register SWT Boolean CSSValue Converter
- super.registerCSSValueConverter(CSSValueBooleanConverterImpl.INSTANCE);
+ return true;
}
public CSSEngineImpl(ExtendedDocumentCSS documentCSS) {
diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/RegistryCSSPropertyHandlerProvider.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/RegistryCSSPropertyHandlerProvider.java
index 5f7e9d6..4c44ba3 100644
--- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/RegistryCSSPropertyHandlerProvider.java
+++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/RegistryCSSPropertyHandlerProvider.java
@@ -43,29 +43,46 @@
private static final String ATTR_HANDLER = "handler";
private static final String ATTR_DEPRECATED = "deprecated";
- private static final String PROPERTY_HANDLERS_EXTENSION_POINT = "org.eclipse.e4.ui.css.swt.property.handler";
+ private static final String PROPERTY_HANDLERS_EXTPOINT = "org.eclipse.e4.ui.css.core.propertyHandler";
+
+ /* the handlers extension point was originally in .swt */
+ private static final String DEPRECATED_PROPERTY_HANDLERS_EXTPOINT = "org.eclipse.e4.ui.css.swt.property.handler";
private IExtensionRegistry registry;
private boolean hasDeprecatedProperties = false; // mild optimization for
// getCSSProperties()
- private Map<String, Map<String, ICSSPropertyHandler>> propertyHandlerMap;
+ private Map<String, Map<String, ICSSPropertyHandler>> propertyHandlerMap = new HashMap<String, Map<String, ICSSPropertyHandler>>();;
public RegistryCSSPropertyHandlerProvider(IExtensionRegistry registry) {
- this(registry, PROPERTY_HANDLERS_EXTENSION_POINT);
+ this.registry = registry;
+ if (configure(DEPRECATED_PROPERTY_HANDLERS_EXTPOINT)) {
+ System.err.println("Extension point "
+ + DEPRECATED_PROPERTY_HANDLERS_EXTPOINT
+ + " is deprecated; use " + PROPERTY_HANDLERS_EXTPOINT);
+ }
+ configure(PROPERTY_HANDLERS_EXTPOINT);
}
public RegistryCSSPropertyHandlerProvider(IExtensionRegistry registry,
String extensionPointId) {
this.registry = registry;
// FIXME: should install a registry listener to make this dynamic
- initialize(extensionPointId);
+ configure(extensionPointId);
}
- protected void initialize(String extensionPointId) {
- Map<String, Map<String, ICSSPropertyHandler>> handlersMap = new HashMap<String, Map<String, ICSSPropertyHandler>>();
+ /** @return true if some extensions were found */
+ protected boolean configure(String extensionPointId) {
IExtensionPoint extPoint = registry.getExtensionPoint(extensionPointId);
- for (IExtension e : extPoint.getExtensions()) {
+ if (extPoint == null) {
+ return false;
+ }
+ IExtension[] extensions = extPoint.getExtensions();
+ if (extensions.length == 0) {
+ return false;
+ }
+ Map<String, Map<String, ICSSPropertyHandler>> handlersMap = new HashMap<String, Map<String, ICSSPropertyHandler>>();
+ for (IExtension e : extensions) {
for (IConfigurationElement ce : e.getConfigurationElements()) {
if (ce.getName().equals(ATTR_HANDLER)) {
// a single handler may implement a number of properties
@@ -117,7 +134,8 @@
}
}
}
- propertyHandlerMap = handlersMap;
+ propertyHandlerMap.putAll(handlersMap);
+ return true;
}
public Collection<ICSSPropertyHandler> getCSSPropertyHandlers(
diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.properties b/bundles/org.eclipse.e4.ui.css.swt/plugin.properties
index 061714e..857372d 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/plugin.properties
+++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.properties
@@ -10,5 +10,3 @@
###############################################################################
pluginName = Eclipse CSS SWT Support
providerName = Eclipse.org
-
-extension-point.properties.name = Properties
\ No newline at end of file
diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
index ee683da..56bf824 100644
--- a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
+++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension-point id="org.eclipse.e4.ui.css.swt.property.handler" name="%extension-point.properties.name" schema="schema/org.eclipse.e4.ui.css.swt.property.handler.exsd"/>
<extension
- point="org.eclipse.e4.u.css.core.elementProvider">
+ point="org.eclipse.e4.ui.css.core.elementProvider">
<provider
class="org.eclipse.e4.ui.css.swt.dom.SWTElementProvider">
<widget
@@ -39,7 +38,7 @@
<extension
- point="org.eclipse.e4.ui.css.swt.property.handler">
+ point="org.eclipse.e4.ui.css.core.propertyHandler">
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.ControlElement"
composite="true"
diff --git a/bundles/org.eclipse.ui.workbench/plugin.xml b/bundles/org.eclipse.ui.workbench/plugin.xml
index d707b43..48fa5d5 100644
--- a/bundles/org.eclipse.ui.workbench/plugin.xml
+++ b/bundles/org.eclipse.ui.workbench/plugin.xml
@@ -24,7 +24,7 @@
</processor>
</extension>
<extension
- point="org.eclipse.e4.ui.css.swt.property.handler">
+ point="org.eclipse.e4.ui.css.core.property.handler">
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.CompositeElement"
composite="false"