Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
dd7a449
Reduce log level after an orphan perspective got fixed.
Mailaender Feb 4, 2026
5c89bb8
Migrate org.eclipse.ui.workbench.texteditor.tests to JUnit 5
vogella Feb 3, 2026
730daf6
Migrate org.eclipse.jface.tests to JUnit 5
vogella Feb 2, 2026
ea1b693
Migrate org.eclipse.ltk.core.refactoring.tests to JUnit 5
vogella Feb 4, 2026
de0e232
Version bump(s) for 4.39 stream
eclipse-platform-bot Feb 11, 2026
676351a
Migrate org.eclipse.jface.tests to JUnit 5
vogella Feb 11, 2026
b53775d
Replace GIF icons with SVGs in example.navigator project
vogella Feb 17, 2026
8aef950
Replace GIF icons with SVGs in org.eclipse.ui.examples.job
vogella Feb 17, 2026
54a333a
Replace GIF icons with SVGs in org.eclipse.e4.ui.examples.job
vogella Feb 17, 2026
c0d5e68
Replace GIF icons with SVGs in org.eclipse.ui.examples.contributions
vogella Feb 17, 2026
f6d7f42
Replace GIF icons with SVGs in org.eclipse.ui.examples.undo
vogella Feb 17, 2026
db6812d
Replace GIF icons with SVGs in org.eclipse.ui.examples.views.properti…
vogella Feb 17, 2026
69a3fd3
Replace some GIF icons with SVGs in org.eclipse.ui.forms.examples
vogella Feb 17, 2026
5f45a66
Replace GIF icons with SVGs in org.eclipse.ui.examples.javaeditor
vogella Feb 17, 2026
8d56753
Replace GIF icon with SVG in org.eclipse.ui.examples.multipageeditor
vogella Feb 17, 2026
d71fe8a
Replace GIF icon with SVG in org.eclipse.e4.demo.cssbridge
vogella Feb 17, 2026
ab945c7
Replace GIF icon with SVG in org.eclipse.ui.examples.propertysheet
vogella Feb 17, 2026
42da72a
Replace some GIF icons with SVGs in org.eclipse.ui.examples.readmetool
vogella Feb 17, 2026
0c0dbd5
Add CSS functionality for setting the color of SVG icons
vogella Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bundles/org.eclipse.e4.ui.css.swt/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,27 @@
name="swt-link-foreground-color">
</property-name>
</handler>
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.ControlElement"
handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertySVGFilterSWTHandler">
<property-name
name="-eclipse-svg-filter">
</property-name>
</handler>
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.ToolItemElement"
handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertySVGFilterSWTHandler">
<property-name
name="-eclipse-svg-filter">
</property-name>
</handler>
<handler
adapter="org.eclipse.e4.ui.css.swt.dom.CTabItemElement"
handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertySVGFilterSWTHandler">
<property-name
name="-eclipse-svg-filter">
</property-name>
</handler>
<handler
adapter="org.eclipse.e4.ui.css.core.dom.ElementAdapter"
handler="org.eclipse.e4.ui.css.swt.properties.custom.CSSPropertyLinesVisibleSWTHandler">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public class CSSSWTConstants {

public static final String BUTTON_SELECTED_LISTENER = "org.eclipse.e4.ui.css.swt.BUTTON_SELECTED_LISTENER";



/**
* Constant used to store color for SVG filter into SWT widget data.
*/
public static final String CSS_SVG_FILTER_COLOR = "org.eclipse.e4.ui.css.swt.svg.filter.color";

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import java.net.URL;
import org.eclipse.e4.ui.css.core.util.resources.IResourcesLocatorManager;
import org.eclipse.e4.ui.css.core.utils.StringUtils;
import org.eclipse.e4.ui.css.swt.CSSSWTConstants;
import org.eclipse.jface.resource.ColorMatrix;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
Expand All @@ -38,25 +41,39 @@ public class CSSSWTImageHelper {

public static Image getImage(CSSValue value,
IResourcesLocatorManager manager, Display display) throws Exception {
return getImage(value, manager, display, null);
}

public static Image getImage(CSSValue value, IResourcesLocatorManager manager, Display display, Widget widget)
throws Exception {
if (value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE) {
return null;
}
CSSPrimitiveValue primitiveValue = (CSSPrimitiveValue) value;
switch (primitiveValue.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_URI:
String path = primitiveValue.getStringValue();
return loadImageFromURL(path, manager);
return loadImageFromURL(path, manager, widget);
}
return null;
}

private static Image loadImageFromURL(String path,
IResourcesLocatorManager manager) throws Exception {
private static Image loadImageFromURL(String path, IResourcesLocatorManager manager, Widget widget)
throws Exception {
Image result = null;

String s = manager.resolve(path);
if (!StringUtils.isEmpty(s)) {
result = ImageDescriptor.createFromURL(new URL(s)).createImage();
ImageDescriptor desc = ImageDescriptor.createFromURL(new URL(s));
if (widget != null && s.endsWith(".svg")) { //$NON-NLS-1$
RGB filterColor = (RGB) widget.getData(CSSSWTConstants.CSS_SVG_FILTER_COLOR);
if (filterColor != null) {
desc = ImageDescriptor.createWithColorMatrix(desc,
new ColorMatrix(new float[] { 0, 0, 0, 0, filterColor.red / 255f, 0, 0, 0, 0,
filterColor.green / 255f, 0, 0, 0, 0, filterColor.blue / 255f, 0, 0, 0, 1, 0 }));
}
}
result = desc.createImage();
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.e4.ui.css.swt.helpers.CSSSWTImageHelper;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Widget;
import org.w3c.dom.css.CSSValue;

public class CSSValueSWTImageConverterImpl extends AbstractCSSValueConverter {
Expand All @@ -33,9 +34,19 @@ public CSSValueSWTImageConverterImpl() {
@Override
public Object convert(CSSValue value, CSSEngine engine, Object context)
throws Exception {
Display display = (Display) context;
Display display = null;
Widget widget = null;
if (context instanceof Display) {
display = (Display) context;
} else if (context instanceof Widget) {
widget = (Widget) context;
display = widget.getDisplay();
}
if (display == null) {
return null;
}
return CSSSWTImageHelper.getImage(value, engine
.getResourcesLocatorManager(), display);
.getResourcesLocatorManager(), display, widget);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public void applyCSSPropertyBackgroundImage(Object element, CSSValue value,
String pseudo, CSSEngine engine) throws Exception {
// Widget control = (Widget) element;
Widget widget = (Widget) ((WidgetElement) element).getNativeWidget();
Image image = (Image) engine.convert(value, Image.class,
widget.getDisplay());
Image image = (Image) engine.convert(value, Image.class, widget);
if (widget instanceof CTabFolder && "selected".equals(pseudo)) {
((CTabFolder) widget).setSelectionBackground(image);
} else if (widget instanceof Button button) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2021, 2025 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.dom.properties.ICSSPropertyHandler;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.swt.CSSSWTConstants;
import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Widget;
import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSValue;
import org.w3c.dom.css.CSSValueList;

public class CSSPropertySVGFilterSWTHandler implements ICSSPropertyHandler {

@Override
public boolean applyCSSProperty(Object element, String property, CSSValue value, String pseudo, CSSEngine engine)
throws Exception {
Widget widget = SWTElementHelpers.getWidget(element);
if (widget == null) {
return false;
}
if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
CSSValueList list = (CSSValueList) value;
if (list.getLength() == 2) {
CSSValue first = list.item(0);
if (first instanceof CSSPrimitiveValue) {
String text = ((CSSPrimitiveValue) first).getStringValue();
if ("color".equalsIgnoreCase(text)) { //$NON-NLS-1$
CSSValue second = list.item(1);
Color color = (Color) engine.convert(second, Color.class, widget.getDisplay());
if (color != null) {
widget.setData(CSSSWTConstants.CSS_SVG_FILTER_COLOR, color.getRGB());
return true;
}
}
}
}
}
if (value instanceof CSSPrimitiveValue) {
String text = ((CSSPrimitiveValue) value).getStringValue();
if ("none".equalsIgnoreCase(text)) { //$NON-NLS-1$
widget.setData(CSSSWTConstants.CSS_SVG_FILTER_COLOR, null);
return true;
}
// Handle single color value as well, just in case
Color color = (Color) engine.convert(value, Color.class, widget.getDisplay());
if (color != null) {
widget.setData(CSSSWTConstants.CSS_SVG_FILTER_COLOR, color.getRGB());
return true;
}
}
return false;
}

@Override
public String retrieveCSSProperty(Object element, String property, String pseudo, CSSEngine engine)
throws Exception {
Widget widget = SWTElementHelpers.getWidget(element);
if (widget != null) {
Object data = widget.getData(CSSSWTConstants.CSS_SVG_FILTER_COLOR);
if (data != null) {
return "color " + data.toString(); //$NON-NLS-1$
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The toString() method of an RGB object returns a string representation like RGB {r, g, b}, which is not a valid CSS color value. This will likely cause parsing errors when the CSS engine attempts to use this retrieved value. The property value should be formatted as a standard CSS color, such as rgb(r, g, b) or a hex string.

Suggested change
return "color " + data.toString(); //$NON-NLS-1$
return "color rgb(" + ((RGB) data).red + ", " + ((RGB) data).green + ", " + ((RGB) data).blue + ")"; //$NON-NLS-1$

}
}
return "none"; //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2021, 2025 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.jface.resource;

import java.util.Arrays;

/**
* A color matrix is a 5x4 matrix that can be used to transform colors of an
* image.
*
* @since 3.24
*/
public final class ColorMatrix {
private final float[] matrix;

/**
* Creates a new color matrix from the given 20 elements.
*
* @param matrix the 20 elements of the matrix
* @throws IllegalArgumentException if the matrix does not have 20 elements
*/
public ColorMatrix(float[] matrix) {
if (matrix.length != 20) {
throw new IllegalArgumentException("Matrix must have 20 elements"); //$NON-NLS-1$
}
this.matrix = Arrays.copyOf(matrix, 20);
}

/**
* Returns the 20 elements of the matrix.
*
* @return the matrix elements
*/
public float[] getMatrix() {
return Arrays.copyOf(matrix, 20);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ColorMatrix other)) {
return false;
}
return Arrays.equals(matrix, other.matrix);
}

@Override
public int hashCode() {
return Arrays.hashCode(matrix);
}

@Override
public String toString() {
return "ColorMatrix " + Arrays.toString(matrix); //$NON-NLS-1$
}
}
Loading
Loading