diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java deleted file mode 100644 index ec2bf4774bc..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java +++ /dev/null @@ -1,70 +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\ - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.exceptions; - -import java.util.Locale; -import java.util.ResourceBundle; - -import org.w3c.dom.DOMException; - -/** - * DOM exception implementation. - */ -public class DOMExceptionImpl extends DOMException { - - private static final long serialVersionUID = 4001374962941459011L; - - public static final int SYNTAX_ERROR = 0; - public static final int ARRAY_OUT_OF_BOUNDS = 1; - public static final int READ_ONLY_STYLE_SHEET = 2; - public static final int EXPECTING_UNKNOWN_RULE = 3; - public static final int EXPECTING_STYLE_RULE = 4; - public static final int EXPECTING_CHARSET_RULE = 5; - public static final int EXPECTING_IMPORT_RULE = 6; - public static final int EXPECTING_MEDIA_RULE = 7; - public static final int EXPECTING_FONT_FACE_RULE = 8; - public static final int EXPECTING_PAGE_RULE = 9; - public static final int FLOAT_ERROR = 10; - public static final int STRING_ERROR = 11; - public static final int COUNTER_ERROR = 12; - public static final int RECT_ERROR = 13; - public static final int RGBCOLOR_ERROR = 14; - public static final int CHARSET_NOT_FIRST = 15; - public static final int CHARSET_NOT_UNIQUE = 16; - public static final int IMPORT_NOT_FIRST = 17; - public static final int NOT_FOUND = 18; - public static final int NOT_IMPLEMENTED = 19; - public static final int NO_MODIFICATION_ALLOWED_ERROR = 20; - - private static ResourceBundle exceptionResource = ResourceBundle.getBundle( - ExceptionResource.class.getName(), Locale.getDefault()); - - public DOMExceptionImpl(short code, int messageKey) { - super(code, exceptionResource.getString(keyString(messageKey))); - } - - public DOMExceptionImpl(int code, int messageKey) { - super((short) code, exceptionResource.getString(keyString(messageKey))); - } - - public DOMExceptionImpl(short code, int messageKey, String info) { - super(code, exceptionResource.getString(keyString(messageKey))); - } - - private static String keyString(int key) { - return "s" + key; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java deleted file mode 100644 index ef5fc5124bf..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2014 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 - * IBM Corporation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.exceptions; - -import java.util.ListResourceBundle; - -/** - * DOM Exception resource. - */ -public class ExceptionResource extends ListResourceBundle { - - @Override - public Object[][] getContents() { - return contents; - } - - static final Object[][] contents = { - {"s0", "Syntax error"}, - {"s1", "Array out of bounds error"}, - {"s2", "This style sheet is read only"}, - {"s3", "The text does not represent an unknown rule"}, - {"s4", "The text does not represent a style rule"}, - {"s5", "The text does not represent a charset rule"}, - {"s6", "The text does not represent an import rule"}, - {"s7", "The text does not represent a media rule"}, - {"s8", "The text does not represent a font face rule"}, - {"s9", "The text does not represent a page rule"}, - {"s10", "This isn't a Float type"}, - {"s11", "This isn't a String type"}, - {"s12", "This isn't a Counter type"}, - {"s13", "This isn't a Rect type"}, - {"s14", "This isn't an RGBColor type"}, - {"s15", "A charset rule must be the first rule"}, - {"s16", "A charset rule already exists"}, - {"s17", "An import rule must preceed all other rules"}, - {"s18", "The specified type was not found"}, - {"s19", "Not implemented"}, - {"s20", "Attempt to change a readonly object"} - }; -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java index 541e223b475..939e32ee1d9 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java @@ -18,15 +18,12 @@ import java.util.List; import org.eclipse.e4.ui.css.core.dom.CSSProperty; import org.eclipse.e4.ui.css.core.dom.CSSPropertyList; -import org.w3c.dom.css.CSSStyleDeclaration; - /** - * CSS computed style which concatenate list of CSSComputedStyleImpl to manage - * styles coming from Condition Selector (ex : Label#MyId) and other selectors - * (ex : Label). + * Computed style merging the declarations of all rules that match an element, + * ordered by specificity and source position. */ -public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl implements CSSStyleDeclaration { +public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl { private final List styleRules; diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java index 4f440d2b081..d80d510a40f 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java @@ -20,12 +20,16 @@ import java.util.List; import org.eclipse.e4.ui.css.core.dom.CSSProperty; import org.eclipse.e4.ui.css.core.dom.CSSPropertyList; -import org.eclipse.e4.ui.css.core.exceptions.DOMExceptionImpl; import org.w3c.dom.DOMException; import org.w3c.dom.css.CSSRule; import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSValue; +/** + * W3C {@link CSSStyleDeclaration} view over the internal property list; part of + * the permanent compatibility facade returned by {@code IStylingEngine.getStyle} + * and {@code IThemeEngine.getStyle}. + */ public class CSSStyleDeclarationImpl implements CSSStyleDeclaration { private boolean readOnly; @@ -97,8 +101,8 @@ public String item(int index) { @Override public String removeProperty(String propertyName) throws DOMException { if (readOnly) { - throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, - DOMExceptionImpl.NO_MODIFICATION_ALLOWED_ERROR); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + "Attempt to change a readonly object"); //$NON-NLS-1$ } for (int i = 0; i < properties.size(); i++) { CSSProperty property = properties.get(i); @@ -113,8 +117,8 @@ public String removeProperty(String propertyName) throws DOMException { @Override public void setCssText(String cssText) throws DOMException { if (readOnly) { - throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, - DOMExceptionImpl.NO_MODIFICATION_ALLOWED_ERROR); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + "Attempt to change a readonly object"); //$NON-NLS-1$ } // TODO Auto-generated method stub // TODO throws SYNTAX_ERR if cssText is unparsable @@ -124,8 +128,8 @@ public void setCssText(String cssText) throws DOMException { @Override public void setProperty(String propertyName, String value, String priority) throws DOMException { if (readOnly) { - throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, - DOMExceptionImpl.NO_MODIFICATION_ALLOWED_ERROR); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + "Attempt to change a readonly object"); //$NON-NLS-1$ } // TODO Auto-generated method stub // TODO throws SYNTAX_ERR if value is unparsable diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java deleted file mode 100644 index 967244d15d9..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java +++ /dev/null @@ -1,92 +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 - * IBM Corporation - ongoing development - *******************************************************************************/ - -package org.eclipse.e4.ui.css.core.impl.dom; - -import org.eclipse.e4.ui.css.core.exceptions.DOMExceptionImpl; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSPrimitiveValue; -import org.w3c.dom.css.CSSValue; -import org.w3c.dom.css.Counter; -import org.w3c.dom.css.RGBColor; -import org.w3c.dom.css.Rect; - -public abstract class CSSValueImpl implements CSSPrimitiveValue, CSSValue { - - private static final String NOT_YET_IMPLEMENTED = "NOT YET IMPLEMENTED"; //$NON-NLS-1$ - - // W3C CSSValue API methods - - @Override - public String getCssText() { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public short getCssValueType() { - return CSS_PRIMITIVE_VALUE; - } - - @Override - public void setCssText(String cssText) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - // W3C CSSPrimitiveValue API methods - - @Override - public short getPrimitiveType() { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public Counter getCounterValue() throws DOMException { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.COUNTER_ERROR); - } - - @Override - public RGBColor getRGBColorValue() throws DOMException { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.RGBCOLOR_ERROR); - } - - @Override - public Rect getRectValue() throws DOMException { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.RECT_ERROR); - } - - @Override - public String getStringValue() throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public void setFloatValue(short arg0, float arg1) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public void setStringValue(short arg0, String arg1) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - // Additional methods - - @Override - public float getFloatValue(short valueType) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - -} \ No newline at end of file diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java index 2f4d2bb046d..a31160542ba 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java @@ -31,9 +31,10 @@ *

* Consumers pattern-match on the record variants ({@link CssNumber}, * {@link CssDimension}, {@link CssText}, {@link CssColor}, {@link CssList}) - * and read their components. The variants still implement the W3C DOM-CSS - * interfaces as a transitional bridge; the bridge goes away once the - * computed-style cascade is internal as well. + * and read their components. The variants also implement the W3C DOM-CSS value + * interfaces as a permanent compatibility facade: {@code IStylingEngine.getStyle} + * and {@code IThemeEngine.getStyle} return W3C types, and {@code propertyHandler} + * contributions receive values as W3C {@code CSSValue}, so the facade must stay. *

*/ public final class CssValues { 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 4b197feab29..0c7d50c8e4d 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 @@ -19,7 +19,6 @@ import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter; import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverterConfig; import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.core.exceptions.DOMExceptionImpl; import org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; @@ -48,8 +47,8 @@ public Color convert(CSSValue value, CSSEngine engine, Object context) Display display = (Display) context; Color color = CSSSWTColorHelper.getSWTColor(value, display); if (color == null) { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, - DOMExceptionImpl.RGBCOLOR_ERROR); + throw new DOMException(DOMException.INVALID_ACCESS_ERR, + "This isn't an RGBColor type"); } return color;