diff --git a/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF index 459c82913a4..a911add12a5 100644 --- a/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-SymbolicName: org.eclipse.e4.ui.css.core;singleton:=true Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin -Bundle-Version: 0.14.600.qualifier +Bundle-Version: 0.14.700.qualifier Export-Package: org.eclipse.e4.ui.css.core;x-internal:=true, org.eclipse.e4.ui.css.core.css2;x-friends:="org.eclipse.e4.ui.css.swt.theme,org.eclipse.e4.ui.css.swt,org.eclipse.e4.ui.css.jface", org.eclipse.e4.ui.css.core.dom;x-friends:="org.eclipse.e4.ui.css.swt,org.eclipse.ui.views.properties.tabbed,org.eclipse.ui.forms", @@ -34,7 +34,6 @@ Export-Package: org.eclipse.e4.ui.css.core;x-internal:=true, org.eclipse.e4.ui.css.core.impl.sac;x-internal:=true, org.eclipse.e4.ui.css.core.resources;x-friends:="org.eclipse.e4.ui.css.swt,org.eclipse.e4.ui.workbench.renderers.swt", org.eclipse.e4.ui.css.core.sac;x-internal:=true, - org.eclipse.e4.ui.css.core.serializers;x-friends:="org.eclipse.e4.ui.css.swt", org.eclipse.e4.ui.css.core.util.impl.resources;x-friends:="org.eclipse.e4.ui.css.swt.theme,org.eclipse.e4.ui.workbench.swt", org.eclipse.e4.ui.css.core.util.resources;x-friends:="org.eclipse.e4.ui.css.swt,org.eclipse.e4.ui.css.swt.theme,org.eclipse.e4.ui.workbench.swt", org.eclipse.e4.ui.css.core.utils;x-friends:="org.eclipse.e4.ui.css.swt" diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2ColorHelper.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2ColorHelper.java index b2346dcaa2b..b0e9b930184 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2ColorHelper.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2ColorHelper.java @@ -16,8 +16,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverterColorConfig; -import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverterConfig; import org.w3c.dom.css.CSSPrimitiveValue; import org.w3c.dom.css.RGBColor; @@ -68,33 +66,12 @@ public static RGBColor getRGBColor(String value) { } /** - * Return color string form w3c rgbColor instance. The format - * (Hexa, color name or rgb format) of the color string is managed with - * config {@link ICSSValueConverterConfig}. + * Return the hex string representation of the given w3c {@code rgbColor}. * - * @param rgbColor the color to get string representation for - * @param config optional config to influence string format - * @return string representation of rgbColor + * @param rgbColor the color to get a string representation for + * @return the hex string representation of {@code rgbColor} */ - public static String getColorStringValue(RGBColor rgbColor, ICSSValueConverterConfig config) { - if (config instanceof ICSSValueConverterColorConfig colorConfig) { - switch (colorConfig.getFormat()) { - case ICSSValueConverterColorConfig.COLOR_HEXA_FORMAT: - return getHexaColorStringValue(rgbColor); - case ICSSValueConverterColorConfig.COLOR_RGB_FORMAT: - return getRGBColorStringValue(rgbColor); - case ICSSValueConverterColorConfig.COLOR_NAME_FORMAT: - // Get the Hexa color string value - String hexaColor = getHexaColorStringValue(rgbColor); - // Search into hexa map the color name - String colorName = getColorNameFromHexaColor(hexaColor); - if (colorName != null) { - return colorName; - } - // Color name is not found, return the Hexa value - return hexaColor; - } - } + public static String getColorStringValue(RGBColor rgbColor) { return getHexaColorStringValue(rgbColor); } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/CSSValueConverterConfigColorImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/CSSValueConverterConfigColorImpl.java deleted file mode 100644 index d891d13a2f5..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/CSSValueConverterConfigColorImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.dom.properties.converters; - -/** - * CSS Value converter color config to format the CSSValue string color. - * - * @version 1.0.0 - * @author Angelo ZERR - */ -public class CSSValueConverterConfigColorImpl implements - ICSSValueConverterColorConfig { - - public static final ICSSValueConverterConfig COLOR_HEXA_FORMAT_CONFIG = new CSSValueConverterConfigColorImpl( - COLOR_HEXA_FORMAT); - - public static final ICSSValueConverterConfig COLOR_NAME_FORMAT_CONFIG = new CSSValueConverterConfigColorImpl( - COLOR_NAME_FORMAT); - - public static final ICSSValueConverterConfig COLOR_RGB_FORMAT_CONFIG = new CSSValueConverterConfigColorImpl( - COLOR_RGB_FORMAT); - - private final int format; - - public CSSValueConverterConfigColorImpl(int format) { - this.format = format; - } - - @Override - public int getFormat() { - return format; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/ICSSValueConverterColorConfig.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/ICSSValueConverterColorConfig.java deleted file mode 100644 index 4c0dfc53ead..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/converters/ICSSValueConverterColorConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.dom.properties.converters; - -import org.w3c.dom.css.RGBColor; - -/** - * {@link ICSSValueConverterConfig} to manage format String of the - * {@link RGBColor}. - * - * @version 1.0.0 - * @author Angelo ZERR - */ -public interface ICSSValueConverterColorConfig extends ICSSValueConverterConfig { - - /* - * Format CSSValue string color into Hexadecimal. - */ - public static final int COLOR_HEXA_FORMAT = 0; - - /* - * Format CSSValue string color into Color Name. - */ - public static final int COLOR_NAME_FORMAT = 1; - - /* - * Format CSSValue string color into RGB. - */ - public static final int COLOR_RGB_FORMAT = 2; - - /** - * Return format (Hexadecimal color, Color name, RGB color). - */ - public int getFormat(); -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSHTMLSerializerConfiguration.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSHTMLSerializerConfiguration.java deleted file mode 100644 index 827a66493d9..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSHTMLSerializerConfiguration.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.serializers; - -/** - * CSS HTML Serializer configuration used by {@link CSSSerializer} to filter the - * attribute type of the HTML widget like input[type='text']. - */ -public class CSSHTMLSerializerConfiguration extends CSSSerializerConfiguration { - - public static final CSSSerializerConfiguration INSTANCE = new CSSHTMLSerializerConfiguration(); - - public CSSHTMLSerializerConfiguration() { - super.addAttributeFilter("type"); - } -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializer.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializer.java deleted file mode 100644 index e2acc472c6c..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializer.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.serializers; - -import java.io.IOException; -import java.io.Writer; -import java.util.HashMap; -import java.util.Map; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.w3c.dom.css.CSSStyleDeclaration; - -/** - * CSS Serializer to retrieve default CSSStyleDeclaration of the SWT Widgets. - */ - -public class CSSSerializer { - - public CSSSerializer() { - - } - - /** - * Build CSS Style Sheet content of the element Object by - * using {@link CSSEngine} engine configuration. The serialization result is - * stored into the writer. If - * serializeChildNodes is true, the method will serialize too - * the child nodes of the element. - */ - public void serialize(Writer writer, CSSEngine engine, Object element, boolean serializeChildNodes) throws IOException { - serialize(writer, engine, element, serializeChildNodes, null); - } - - /** - * Build CSS Style Sheet content of the element Object by - * using {@link CSSEngine} engine configuration. The serialization result is - * stored into the writer. If - * serializeChildNodes is true, the method will serialize too - * the child nodes of the element. The - * {@link CSSSerializerConfiguration} configuration is used - * to generate selector with condition like Text[style='SWT.MULTI']. - */ - public void serialize(Writer writer, CSSEngine engine, Object element, boolean serializeChildNodes, CSSSerializerConfiguration configuration) throws IOException { - Map selectors = new HashMap<>(); - serialize(writer, engine, element, serializeChildNodes, selectors, configuration); - boolean firstSelector = true; - for (Map.Entry entry : selectors.entrySet()) { - String selectorName = entry.getKey(); - CSSStyleDeclaration styleDeclaration = entry.getValue(); - if (styleDeclaration != null) { - int length = styleDeclaration.getLength(); - // Start selector - startSelector(writer, selectorName, firstSelector); - firstSelector = false; - for (int i = 0; i < length; i++) { - String propertyName = styleDeclaration.item(i); - String propertyValue = styleDeclaration.getPropertyValue(propertyName); - property(writer, propertyName, propertyValue); - } - // End selector - endSelector(writer, selectorName); - } - } - } - - /** - * Build CSS Style Sheet content of the element Object by - * using {@link CSSEngine} engine configuration. The serialization result is - * stored into the writer. If - * serializeChildNodes is true, the method will serialize too - * the child nodes of the element. The - * {@link CSSSerializerConfiguration} configuration is used - * to generate selector with condition like Text[style='SWT.MULTI']. - * - * Map of selectors contains the selector already built. - */ - protected void serialize(Writer writer, CSSEngine engine, Object element, boolean serializeChildNodes, Map selectors, - CSSSerializerConfiguration configuration) throws IOException { - Element elt = engine.getElement(element); - if (elt != null) { - StringBuilder selectorName = new StringBuilder(elt.getLocalName()); - CSSStyleDeclaration styleDeclaration = engine.getDefaultStyleDeclaration(element, null); - - if (configuration != null) { - String[] attributesFilter = configuration.getAttributesFilter(); - for (String attributeFilter : attributesFilter) { - String value = elt.getAttribute(attributeFilter); - if (value != null && value.length() > 0) { - selectorName.append("["); - selectorName.append(attributeFilter); - selectorName.append("="); - if (value.indexOf('.') != -1) { - value = "'" + value + "'"; - } - selectorName.append(value); - selectorName.append("]"); - break; - } - } - } - - selectors.put(selectorName.toString(), styleDeclaration); - if (serializeChildNodes) { - NodeList nodes = elt.getChildNodes(); - if (nodes != null) { - for (int k = 0; k < nodes.getLength(); k++) { - serialize(writer, engine, nodes.item(k), - serializeChildNodes, selectors, configuration); - } - } - } - } - } - - /** - * Generate start selector. - */ - protected void startSelector(Writer writer, String selectorName, boolean firstSelector) throws IOException { - if (!firstSelector) { - writer.write("\n\n"); - } - writer.write(selectorName + " {"); - } - - /** - * Generate end selector. - */ - protected void endSelector(Writer writer, String selectorName) throws IOException { - writer.write("\n}"); - } - - /** - * Generate CSS Property. - */ - private void property(Writer writer, String propertyName, String propertyValue) throws IOException { - writer.write("\n\t" + propertyName + ":" + propertyValue + ";"); - } -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java deleted file mode 100644 index 40c3d09df2f..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/serializers/CSSSerializerConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.serializers; - -import java.util.ArrayList; -import java.util.List; - -/** - * CSS Serializer configuration used by {@link CSSSerializer} to filter the - * attribute of the widget like Text[style='SWT.MULTI']. - */ -public class CSSSerializerConfiguration { - - private static final String[] EMPTY_STRING = new String[0]; - - private List attributesFilter; - - /** - * Add attribute name attributeName to filter. - */ - public void addAttributeFilter(String attributeName) { - if (attributesFilter == null) { - attributesFilter = new ArrayList<>(); - } - attributesFilter.add(attributeName); - } - - /** - * Return list of attribute name to filter. - */ - public String[] getAttributesFilter() { - if (attributesFilter != null) { - return attributesFilter.toArray(EMPTY_STRING); - } - return EMPTY_STRING; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF index 34ec0bac1ed..5e0d5acbcdb 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF @@ -27,7 +27,6 @@ Export-Package: org.eclipse.e4.ui.css.swt;x-friends:="org.eclipse.ui.workbench", org.eclipse.e4.ui.css.swt.properties.definition;x-internal:=true, org.eclipse.e4.ui.css.swt.properties.preference;x-internal:=true, org.eclipse.e4.ui.css.swt.resources;x-friends:="org.eclipse.e4.ui.workbench.renderers.swt", - org.eclipse.e4.ui.css.swt.serializers;x-internal:=true, org.eclipse.e4.ui.internal.css.swt;x-internal:=true, org.eclipse.e4.ui.internal.css.swt.definition;x-friends:="org.eclipse.ui.workbench" Require-Bundle: org.eclipse.e4.ui.css.core;bundle-version="0.12.200", diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java index 02791d3572f..34c13f62958 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java @@ -60,6 +60,6 @@ public String convert(Object value, CSSEngine engine, Object context, ICSSValueConverterConfig config) throws Exception { Color color = (Color) value; RGBColor rgbColor = CSSSWTColorHelper.getRGBColor(color); - return CSS2ColorHelper.getColorStringValue(rgbColor, config); + return CSS2ColorHelper.getColorStringValue(rgbColor); } } diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTRGBConverterImpl.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTRGBConverterImpl.java index 3d9ffb60214..c951aa8ee87 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTRGBConverterImpl.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTRGBConverterImpl.java @@ -53,7 +53,7 @@ public String convert(Object value, CSSEngine engine, Object context, ICSSValueConverterConfig config) throws Exception { RGB color = (RGB) value; RGBColor rgbColor = CSSSWTColorHelper.getRGBColor(color); - return CSS2ColorHelper.getColorStringValue(rgbColor, config); + return CSS2ColorHelper.getColorStringValue(rgbColor); } } diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/serializers/CSSSWTSerializerConfiguration.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/serializers/CSSSWTSerializerConfiguration.java deleted file mode 100644 index d0c82843922..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/serializers/CSSSWTSerializerConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.serializers; - -import org.eclipse.e4.ui.css.core.serializers.CSSSerializerConfiguration; - -/** - * {@link CSSSerializerConfiguration} configuration used to get style of SWT control. - */ -public class CSSSWTSerializerConfiguration extends CSSSerializerConfiguration { - - public static final CSSSerializerConfiguration INSTANCE = new CSSSWTSerializerConfiguration(); - - public CSSSWTSerializerConfiguration() { - super.addAttributeFilter("style"); - } - -}