diff --git a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml index b75274de640..4d472068c51 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/plugin.xml +++ b/bundles/org.eclipse.e4.ui.css.swt/plugin.xml @@ -136,33 +136,36 @@ - - - - - - + handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyCTabFolderSWTHandler"> + + + + + + + + + + + + - - + handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyCTabFolderRendererSWTHandler"> + + + + + - + handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyTabPositionSWTHandler"> + name="swt-tab-position"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - initial API and implementation + *******************************************************************************/ +package org.eclipse.e4.ui.css.swt.properties.custom; + +import java.util.Map; +import java.util.function.BiConsumer; + +import org.eclipse.e4.ui.css.core.engine.CSSEngine; +import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive; +import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; +import org.eclipse.e4.ui.internal.css.swt.ICTabRendering; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Control; +import org.w3c.dom.css.CSSValue; + +/** + * Applies the CSS properties that map directly onto a single + * {@link ICTabRendering} setter of a {@link CTabFolder} renderer. + */ +public class CSSPropertyCTabFolderRendererSWTHandler extends AbstractCSSPropertySWTHandler { + + private static final Map> COLOR_SETTERS = Map.of( + "swt-inner-keyline-color", ICTabRendering::setInnerKeyline, //$NON-NLS-1$ + "swt-outer-keyline-color", ICTabRendering::setOuterKeyline, //$NON-NLS-1$ + "swt-tab-outline", ICTabRendering::setTabOutline, //$NON-NLS-1$ + "swt-unselected-hot-tab-color-background", ICTabRendering::setUnselectedHotTabsColorBackground); //$NON-NLS-1$ + + private static final Map> BOOLEAN_SETTERS = Map.of( + "swt-draw-custom-tab-content-background", ICTabRendering::setDrawCustomTabContentBackground); //$NON-NLS-1$ + + @Override + protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) + throws Exception { + if (!(control instanceof CTabFolder folder) || !(value instanceof CssPrimitive)) { + return; + } + BiConsumer colorSetter = COLOR_SETTERS.get(property); + if (colorSetter != null) { + Color color = (Color) engine.convert(value, Color.class, control.getDisplay()); + if (folder.getRenderer() instanceof ICTabRendering renderer) { + colorSetter.accept(renderer, color); + } + return; + } + BiConsumer booleanSetter = BOOLEAN_SETTERS.get(property); + if (booleanSetter != null) { + Boolean enabled = (Boolean) engine.convert(value, Boolean.class, control.getDisplay()); + if (folder.getRenderer() instanceof ICTabRendering renderer) { + booleanSetter.accept(renderer, enabled); + } + } + } + + @Override + protected String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine) + throws Exception { + return null; + } +} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCTabFolderSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCTabFolderSWTHandler.java new file mode 100644 index 00000000000..605ef499a32 --- /dev/null +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCTabFolderSWTHandler.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2026 Lars Vogel 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: + * Lars Vogel - initial API and implementation + *******************************************************************************/ +package org.eclipse.e4.ui.css.swt.properties.custom; + +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.ToIntFunction; + +import org.eclipse.e4.ui.css.core.engine.CSSEngine; +import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssNumber; +import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssNumeric; +import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssUnit; +import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.widgets.Control; +import org.w3c.dom.css.CSSValue; + +/** + * Applies the CSS properties that map directly onto a single + * {@link CTabFolder} setter. + */ +public class CSSPropertyCTabFolderSWTHandler extends AbstractCSSPropertySWTHandler { + + private record BooleanProperty(BiConsumer setter, Predicate getter) { + } + + private record IntProperty(Function parser, BiConsumer setter, + ToIntFunction getter) { + } + + private static final Map BOOLEAN_PROPERTIES = Map.ofEntries( + Map.entry("border-visible", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setBorderVisible, CTabFolder::getBorderVisible)), + Map.entry("swt-maximize-visible", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setMaximizeVisible, CTabFolder::getMaximizeVisible)), + Map.entry("swt-minimize-visible", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setMinimizeVisible, CTabFolder::getMinimizeVisible)), + Map.entry("swt-maximized", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setMaximized, CTabFolder::getMaximized)), + Map.entry("swt-minimized", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setMinimized, CTabFolder::getMinimized)), + Map.entry("swt-simple", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setSimple, CTabFolder::getSimple)), + Map.entry("swt-single", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setSingle, CTabFolder::getSingle)), + Map.entry("swt-unselected-close-visible", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setUnselectedCloseVisible, CTabFolder::getUnselectedCloseVisible)), + Map.entry("swt-unselected-image-visible", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setUnselectedImageVisible, CTabFolder::getUnselectedImageVisible)), + Map.entry("swt-selected-image-visible", //$NON-NLS-1$ + new BooleanProperty(CTabFolder::setSelectedImageVisible, CTabFolder::getSelectedImageVisible))); + + private static final Map INT_PROPERTIES = Map.of( + "swt-tab-height", //$NON-NLS-1$ + new IntProperty( + value -> value instanceof CssNumeric numeric && numeric.unit() == CssUnit.PX + ? Integer.valueOf((int) numeric.value()) + : null, + CTabFolder::setTabHeight, CTabFolder::getTabHeight), + "swt-tab-text-minimum-characters", //$NON-NLS-1$ + new IntProperty( + value -> value instanceof CssNumber number ? Integer.valueOf((int) number.value()) : null, + CTabFolder::setMinimumCharacters, CTabFolder::getMinimumCharacters)); + + @Override + protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) + throws Exception { + if (!(control instanceof CTabFolder folder)) { + return; + } + BooleanProperty booleanProperty = BOOLEAN_PROPERTIES.get(property); + if (booleanProperty != null) { + booleanProperty.setter().accept(folder, (Boolean) engine.convert(value, Boolean.class, null)); + return; + } + IntProperty intProperty = INT_PROPERTIES.get(property); + if (intProperty != null) { + Integer parsed = intProperty.parser().apply(value); + if (parsed != null) { + intProperty.setter().accept(folder, parsed); + } + } + } + + @Override + protected String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine) + throws Exception { + if (!(control instanceof CTabFolder folder)) { + return null; + } + BooleanProperty booleanProperty = BOOLEAN_PROPERTIES.get(property); + if (booleanProperty != null) { + return Boolean.toString(booleanProperty.getter().test(folder)); + } + IntProperty intProperty = INT_PROPERTIES.get(property); + if (intProperty != null) { + return Integer.toString(intProperty.getter().applyAsInt(folder)); + } + return null; + } +} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCustomTabContentBackgroundSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCustomTabContentBackgroundSWTHandler.java deleted file mode 100644 index e36c94495db..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCustomTabContentBackgroundSWTHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020 Red Hat Inc. 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 - *******************************************************************************/ - -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.e4.ui.internal.css.swt.ICTabRendering; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyCustomTabContentBackgroundSWTHandler extends -AbstractCSSPropertySWTHandler { - - @Override - protected void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - if (!(control instanceof CTabFolder tabFolder) || !(value instanceof CssPrimitive)) { - return; - } - - Boolean custom = (Boolean) engine.convert(value, Boolean.class, control.getDisplay()); - if (tabFolder.getRenderer() instanceof ICTabRendering) { - ((ICTabRendering) tabFolder.getRenderer()).setDrawCustomTabContentBackground(custom); - } - } - - @Override - protected String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine) - throws Exception { - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java deleted file mode 100644 index 12febe5d802..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2016 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.e4.ui.internal.css.swt.ICTabRendering; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolderRenderer; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyInnerKeylineSWTHandler extends AbstractCSSPropertySWTHandler { - - @Override - protected void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - if (!(control instanceof CTabFolder)) { - return; - } - if (value instanceof CssPrimitive) { - Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay()); - CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); - if (renderer instanceof ICTabRendering) { - ((ICTabRendering) renderer).setInnerKeyline(newColor); - } - } - } - - - @Override - protected String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMaximizeVisibleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMaximizeVisibleSWTHandler.java deleted file mode 100644 index 65ef5c3b677..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMaximizeVisibleSWTHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyMaximizeVisibleSWTHandler extends AbstractCSSPropertySWTHandler { - - @Override - public void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception{ - boolean isMaxVisible = (Boolean) engine.convert(value, Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setMaximizeVisible(isMaxVisible); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine) { - if (control instanceof CTabFolder folder) { - return Boolean.toString(folder.getMaximizeVisible()); - } - return null; - } -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMaximizedSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMaximizedSWTHandler.java deleted file mode 100644 index 68469ff7bc5..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMaximizedSWTHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyMaximizedSWTHandler extends AbstractCSSPropertySWTHandler{ - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isMaximized = (Boolean)engine.convert(value, Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setMaximized(isMaximized); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString( folder.getMaximized() ); - } - return null; - } - - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMinimizeVisibleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMinimizeVisibleSWTHandler.java deleted file mode 100644 index b1cd9709774..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMinimizeVisibleSWTHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyMinimizeVisibleSWTHandler extends -AbstractCSSPropertySWTHandler { - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isMinVisible = (Boolean) engine.convert(value, Boolean.class, - null); - if (control instanceof CTabFolder folder) { - folder.setMinimizeVisible(isMinVisible); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString(folder.getMinimizeVisible()); - } - return null; - } -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMinimizedSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMinimizedSWTHandler.java deleted file mode 100644 index 613e715949f..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyMinimizedSWTHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyMinimizedSWTHandler extends AbstractCSSPropertySWTHandler{ - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isMinimized = (Boolean)engine.convert(value, Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setMinimized(isMinimized); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString( folder.getMinimized() ); - } - return null; - } - - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java deleted file mode 100644 index c7626a40afe..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2016 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.e4.ui.internal.css.swt.ICTabRendering; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolderRenderer; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyOuterKeylineSWTHandler extends AbstractCSSPropertySWTHandler { - - @Override - protected void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - if (!(control instanceof CTabFolder)) { - return; - } - if (value instanceof CssPrimitive) { - Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay()); - CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); - if (renderer instanceof ICTabRendering) { - ((ICTabRendering) renderer).setOuterKeyline(newColor); - } - } - } - - - @Override - protected String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySelectedImageVisibleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySelectedImageVisibleSWTHandler.java deleted file mode 100644 index cb2868a5af9..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySelectedImageVisibleSWTHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 SAP SE. - * - * 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: SAP SE - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertySelectedImageVisibleSWTHandler extends AbstractCSSPropertySWTHandler { - - @Override - public void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) - throws Exception { - boolean isImageVisibleForSelectedTab = (Boolean) engine.convert(value, Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setSelectedImageVisible(isImageVisibleForSelectedTab); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine) - throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString(folder.getSelectedImageVisible()); - } - return null; - } -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySimpleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySimpleSWTHandler.java deleted file mode 100644 index f436cf81ab4..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySimpleSWTHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2016 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertySimpleSWTHandler extends AbstractCSSPropertySWTHandler { - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isSimple = (Boolean) engine.convert(value, Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setSimple(isSimple); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString(folder.getSimple()); - } - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySingleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySingleSWTHandler.java deleted file mode 100644 index e5e6d79c563..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertySingleSWTHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2016 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertySingleSWTHandler extends AbstractCSSPropertySWTHandler{ - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isSingle = (Boolean)engine.convert(value, Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setSingle(isSingle); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString( folder.getSingle() ); - } - return null; - } - - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabHeightHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabHeightHandler.java deleted file mode 100644 index 223cd054a37..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabHeightHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2016 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssNumeric; -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssUnit; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyTabHeightHandler extends -AbstractCSSPropertySWTHandler { - - @Override - protected void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - if (! (control instanceof CTabFolder)) { - return; - } - - if (value instanceof CssNumeric numeric && numeric.unit() == CssUnit.PX) { - int height = (int) numeric.value(); - ((CTabFolder) control).setTabHeight(height); - } - } - - @Override - protected String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Integer.toString( folder.getTabHeight()); - } - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabTextMinimumCharactersSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabTextMinimumCharactersSWTHandler.java deleted file mode 100644 index acf837a68e7..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabTextMinimumCharactersSWTHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 SAP SE. - * - * 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: SAP SE - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssNumber; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -/** - * CSS property to influence the minimum number of characters for rendering tab text and size - * - * Can be used in CSS Scratch Pad with the property name "swt-tab-text-minimum-characters", for example: - * CTabFolder { swt-tab-text-minimum-characters: 20 } - * - * Default value for the property is 1. - */ -public class CSSPropertyTabTextMinimumCharactersSWTHandler extends AbstractCSSPropertySWTHandler { - - @Override - protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) - throws Exception { - if (!(control instanceof CTabFolder folder)) { - return; - } - - if (value instanceof CssNumber number) { - int minimumCharacters = (int) number.value(); - folder.setMinimumCharacters(minimumCharacters); - } - } - - @Override - protected String retrieveCSSProperty(Control control, String property, String pseudo, CSSEngine engine) - throws Exception { - if (control instanceof CTabFolder folder) { - return Integer.toString(folder.getMinimumCharacters()); - } - return null; - } - -} \ No newline at end of file diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectHotTabsColorBackgroundHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectHotTabsColorBackgroundHandler.java deleted file mode 100644 index d076b719eb7..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectHotTabsColorBackgroundHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015, 2016 Fabio Zadrozny 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: - * Fabio Zadrozny - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.e4.ui.internal.css.swt.ICTabRendering; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolderRenderer; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyUnselectHotTabsColorBackgroundHandler extends AbstractCSSPropertySWTHandler { - - public static final String UNSELECTED_HOT_TAB_COLOR_BACKGROUND = "swt-unselected-hot-tab-color-background"; - - @Override - protected void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - if (!(control instanceof CTabFolder) || !(value instanceof CssPrimitive)) { - return; - } - - if (UNSELECTED_HOT_TAB_COLOR_BACKGROUND.equals(property)) { - Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay()); - CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); - if (renderer instanceof ICTabRendering) { - ((ICTabRendering) renderer).setUnselectedHotTabsColorBackground(newColor); - } - } - } - - @Override - protected String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedCloseVisibleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedCloseVisibleSWTHandler.java deleted file mode 100644 index f125e2f3ea7..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedCloseVisibleSWTHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyUnselectedCloseVisibleSWTHandler extends -AbstractCSSPropertySWTHandler { - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isUnselectedClose = (Boolean) engine.convert(value, - Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setUnselectedCloseVisible(isUnselectedClose); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString(folder.getUnselectedCloseVisible()); - } - - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedImageVisibleSWTHandler.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedImageVisibleSWTHandler.java deleted file mode 100644 index 2462e0a3502..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedImageVisibleSWTHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2016 IBM Corporation 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: IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertyUnselectedImageVisibleSWTHandler extends -AbstractCSSPropertySWTHandler { - - @Override - public void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - boolean isUnselectedImage = (Boolean) engine.convert(value, - Boolean.class, null); - if (control instanceof CTabFolder folder) { - folder.setUnselectedImageVisible(isUnselectedImage); - } - } - - @Override - public String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - if (control instanceof CTabFolder folder) { - return Boolean.toString(folder.getUnselectedImageVisible()); - } - - return null; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertye4TabOutline.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertye4TabOutline.java deleted file mode 100644 index 0b779f4c132..00000000000 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertye4TabOutline.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2014 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.ui.css.swt.properties.custom; - -import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; -import org.eclipse.e4.ui.internal.css.swt.ICTabRendering; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolderRenderer; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Control; -import org.w3c.dom.css.CSSValue; - -public class CSSPropertye4TabOutline extends AbstractCSSPropertySWTHandler { - - @Override - protected void applyCSSProperty(Control control, String property, - CSSValue value, String pseudo, CSSEngine engine) throws Exception { - if (!(control instanceof CTabFolder)) { - return; - } - if (value instanceof CssPrimitive) { - Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay()); - CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); - if (renderer instanceof ICTabRendering) { - ((ICTabRendering) renderer).setTabOutline(newColor); - } - } - } - - @Override - protected String retrieveCSSProperty(Control control, String property, - String pseudo, CSSEngine engine) throws Exception { - // TODO Auto-generated method stub - return null; - } - -}