diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler.java index c7cef57e669..c7279da95be 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler.java @@ -63,4 +63,23 @@ public default String retrieveCSSProperty(Object element, String property, Strin return null; } + /** + * Callback method called once after all CSS properties of a single + * declaration have been applied. Handlers that need to perform a final + * step (re-layout, redraw, batched commit, ...) override this method; + * the default is a no-op. + */ + default void onAllCSSPropertiesApplied(Object element, CSSEngine engine) throws Exception { + // do nothing + } + + /** + * Variant of {@link #onAllCSSPropertiesApplied(Object, CSSEngine)} that + * also receives the pseudo class. Defaults to delegating to the + * pseudo-less form. + */ + default void onAllCSSPropertiesApplied(Object element, CSSEngine engine, String pseudo) throws Exception { + onAllCSSPropertiesApplied(element, engine); + } + } diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler2.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler2.java deleted file mode 100644 index 7461186491f..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler2.java +++ /dev/null @@ -1,39 +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; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; - -/** - * CSS Property Handler to intercept when all CSS Properties are applied. - * - * @version 1.0.0 - * @author Angelo ZERR - */ -public interface ICSSPropertyHandler2 { - - /** - * Callback method called when all CSS properties are applied. - */ - default void onAllCSSPropertiesApplyed(Object element, CSSEngine engine) throws Exception { - // do nothing - } - - /** - * Callback method called when all CSS properties are applied. - */ - default void onAllCSSPropertiesApplyed(Object element, CSSEngine engine, String pseudo) throws Exception { - onAllCSSPropertiesApplyed(element, engine); - } -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler2Delegate.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler2Delegate.java deleted file mode 100644 index db26da9c36e..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/dom/properties/ICSSPropertyHandler2Delegate.java +++ /dev/null @@ -1,30 +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; - -/** - * - * {@link ICSSPropertyHandler2} delegate. - * - * @version 1.0.0 - * @author Angelo ZERR - */ -public interface ICSSPropertyHandler2Delegate { - - /** - * Return {@link ICSSPropertyHandler2} to call when all CSS Properties are - * applied . - */ - public ICSSPropertyHandler2 getCSSPropertyHandler2(); -} 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 bfa459895e9..2fb2d1829de 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 @@ -49,8 +49,6 @@ import org.eclipse.e4.ui.css.core.dom.parsers.ICSSParserFactory; import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyCompositeHandler; import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; -import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2; -import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2Delegate; import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandlerProvider; import org.eclipse.e4.ui.css.core.dom.properties.converters.CSSValueBooleanConverterImpl; import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter; @@ -155,7 +153,7 @@ public abstract class CSSEngineImpl implements CSSEngine { */ protected List propertyHandlerProviders = new ArrayList<>(); // for performance hold a map of handlers to singleton list - private final Map> propertyHandler2InstanceMap = new HashMap<>(); + private final Map> propertyHandlerInstanceMap = new HashMap<>(); private Map currentCSSPropertiesApplied; @@ -559,31 +557,25 @@ public void applyStyleDeclaration(Object element, CSSStyleDeclaration style, Str if (avoidanceCacheInstalled) { currentCSSPropertiesApplied = new HashMap<>(); } - List handlers2 = Collections.emptyList(); + List appliedHandlers = Collections.emptyList(); for (int i = 0; i < style.getLength(); i++) { String property = style.item(i); CSSValue value = style.getPropertyCSSValue(property); try { ICSSPropertyHandler handler = this.applyCSSProperty(element, property, value, pseudo); - ICSSPropertyHandler2 propertyHandler2 = null; - if (handler instanceof ICSSPropertyHandler2) { - propertyHandler2 = (ICSSPropertyHandler2) handler; - } else if (handler instanceof ICSSPropertyHandler2Delegate) { - propertyHandler2 = ((ICSSPropertyHandler2Delegate) handler).getCSSPropertyHandler2(); - } - if (propertyHandler2 != null) { - switch (handlers2.size()) { + if (handler != null) { + switch (appliedHandlers.size()) { case 0: - handlers2 = propertyHandler2InstanceMap.computeIfAbsent(propertyHandler2, + appliedHandlers = propertyHandlerInstanceMap.computeIfAbsent(handler, Collections::singletonList); break; case 1: - handlers2 = new ArrayList<>(handlers2); - handlers2.add(propertyHandler2); + appliedHandlers = new ArrayList<>(appliedHandlers); + appliedHandlers.add(handler); break; default: - if (!handlers2.contains(propertyHandler2)) { - handlers2.add(propertyHandler2); + if (!appliedHandlers.contains(handler)) { + appliedHandlers.add(handler); } } } @@ -593,9 +585,9 @@ public void applyStyleDeclaration(Object element, CSSStyleDeclaration style, Str } } } - for (ICSSPropertyHandler2 handler2 : handlers2) { + for (ICSSPropertyHandler handler : appliedHandlers) { try { - handler2.onAllCSSPropertiesApplyed(element, this, pseudo); + handler.onAllCSSPropertiesApplied(element, this, pseudo); } catch (Exception e) { handleExceptions(e); } diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBorderSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBorderSWTHandler.java index f8a46ac2858..e7a4c6d0802 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBorderSWTHandler.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBorderSWTHandler.java @@ -14,7 +14,6 @@ package org.eclipse.e4.ui.css.swt.properties.css2; import org.eclipse.e4.ui.css.core.dom.properties.CSSBorderProperties; -import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2; import org.eclipse.e4.ui.css.core.dom.properties.css2.AbstractCSSPropertyBorderHandler; import org.eclipse.e4.ui.css.core.dom.properties.css2.ICSSPropertyBorderHandler; import org.eclipse.e4.ui.css.core.engine.CSSEngine; @@ -28,8 +27,7 @@ import org.w3c.dom.css.CSSPrimitiveValue; import org.w3c.dom.css.CSSValue; -public class CSSPropertyBorderSWTHandler extends -AbstractCSSPropertyBorderHandler implements ICSSPropertyHandler2 { +public class CSSPropertyBorderSWTHandler extends AbstractCSSPropertyBorderHandler { public static final ICSSPropertyBorderHandler INSTANCE = new CSSPropertyBorderSWTHandler(); @@ -70,7 +68,7 @@ public boolean applyCSSProperty(Object element, String property, } @Override - public void onAllCSSPropertiesApplyed(Object element, CSSEngine engine) + public void onAllCSSPropertiesApplied(Object element, CSSEngine engine) throws Exception { Control control = SWTElementHelpers.getControl(element); if (control != null) { diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyFontSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyFontSWTHandler.java index 886c70f8051..a5a6afe595b 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyFontSWTHandler.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyFontSWTHandler.java @@ -16,7 +16,6 @@ *******************************************************************************/ package org.eclipse.e4.ui.css.swt.properties.css2; -import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler2; import org.eclipse.e4.ui.css.core.dom.properties.css2.AbstractCSSPropertyFontHandler; import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties; import org.eclipse.e4.ui.css.core.dom.properties.css2.ICSSPropertyFontHandler; @@ -39,8 +38,7 @@ import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSValue; -public class CSSPropertyFontSWTHandler extends AbstractCSSPropertyFontHandler -implements ICSSPropertyHandler2 { +public class CSSPropertyFontSWTHandler extends AbstractCSSPropertyFontHandler { public static final ICSSPropertyFontHandler INSTANCE = new CSSPropertyFontSWTHandler(); @@ -232,7 +230,7 @@ public String retrieveCSSPropertyFontWeight(Object element, String pseudo, } @Override - public void onAllCSSPropertiesApplyed(Object element, CSSEngine engine) + public void onAllCSSPropertiesApplied(Object element, CSSEngine engine) throws Exception { final Widget widget = SWTElementHelpers.getWidget(element); if (widget == null || widget instanceof CTabItem) {