Skip to content

Commit e3bc9db

Browse files
Merge branch 'master' into master
2 parents fb64305 + 8059976 commit e3bc9db

167 files changed

Lines changed: 1076 additions & 7034 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2020

2121
- name: Set up JDK 21
22-
uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0
22+
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
2323
with:
2424
java-version: '21'
2525
distribution: 'temurin'

bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Export-Package: org.eclipse.e4.ui.css.core.css2;x-friends:="org.eclipse.e4.ui.cs
2525
org.eclipse.ui.views.properties.tabbed,
2626
org.eclipse.ui.forms",
2727
org.eclipse.e4.ui.css.core.exceptions;x-friends:="org.eclipse.e4.ui.css.swt",
28-
org.eclipse.e4.ui.css.core.impl.dom;x-internal:=true,
28+
org.eclipse.e4.ui.css.core.impl.dom;x-friends:="org.eclipse.e4.ui.css.swt",
2929
org.eclipse.e4.ui.css.core.impl.dom.properties;x-friends:="org.eclipse.e4.ui.css.swt",
3030
org.eclipse.e4.ui.css.core.impl.engine;x-friends:="org.eclipse.e4.ui.css.swt,org.eclipse.e4.ui.workbench.swt",
3131
org.eclipse.e4.ui.css.core.impl.engine.selector;x-friends:="org.eclipse.e4.ui.tests.css.core",

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2ColorHelper.java

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import java.util.HashMap;
1717
import java.util.Map;
1818
import java.util.Map.Entry;
19-
import org.w3c.dom.css.CSSPrimitiveValue;
20-
import org.w3c.dom.css.RGBColor;
19+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssColor;
20+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssNumber;
2121

2222
/**
2323
* CSS2 Color Helper.
@@ -38,20 +38,21 @@ public class CSS2ColorHelper {
3838
private static Map<String, String> colorHexasMap = new HashMap<>();
3939

4040
/**
41-
* Return w3c {@link RGBColor} from string value. Format String value is
41+
* Return a {@link CssColor} from string value. Format String value is
4242
* hexadecimal like #FFFFFF or color name like white.
4343
*
4444
* @param value string representation of color
4545
* @return parsed color
4646
*/
47-
public static RGBColor getRGBColor(String value) {
47+
public static CssColor getRGBColor(String value) {
4848
if (value.startsWith("#") && value.length() == 7) {
4949
// Color is like #FFFFFF
5050
try {
5151
int redValue = Integer.decode("0x" + value.substring(1, 3)).intValue();
5252
int greenValue = Integer.decode("0x" + value.substring(3, 5)).intValue();
5353
int blueValue = Integer.decode("0x" + value.substring(5)).intValue();
54-
return new CSS2RGBColorImpl(redValue, greenValue, blueValue);
54+
return new CssColor(new CssNumber(redValue, true), new CssNumber(greenValue, true),
55+
new CssNumber(blueValue, true));
5556
} catch (Exception e) {
5657
return null;
5758
}
@@ -66,61 +67,53 @@ public static RGBColor getRGBColor(String value) {
6667
}
6768

6869
/**
69-
* Return the hex string representation of the given w3c {@code rgbColor}.
70+
* Return the hex string representation of the given <code>color</code>.
7071
*
71-
* @param rgbColor the color to get a string representation for
72-
* @return the hex string representation of {@code rgbColor}
72+
* @param color the color to get a string representation for
73+
* @return the hex string representation of {@code color}
7374
*/
74-
public static String getColorStringValue(RGBColor rgbColor) {
75-
return getHexaColorStringValue(rgbColor);
75+
public static String getColorStringValue(CssColor color) {
76+
return getHexaColorStringValue(color);
7677
}
7778

7879
/**
79-
* Return rgb (ex : rgb(0,0,0)) color string value from w3c
80-
* <code>rgbColor</code> instance.
80+
* Return rgb (ex : rgb(0,0,0)) color string value from the given
81+
* <code>color</code>.
8182
*
82-
* @param rgbColor the color to get string representation for
83-
* @return rgbColor as rgb(r, g, b) string
83+
* @param color the color to get string representation for
84+
* @return color as rgb(r, g, b) string
8485
*/
85-
public static String getRGBColorStringValue(RGBColor rgbColor) {
86+
public static String getRGBColorStringValue(CssColor color) {
8687
StringBuilder result = new StringBuilder("rgb(");
87-
int red = (int) rgbColor.getRed().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
88-
result.append(red);
88+
result.append((int) color.red().value());
8989
result.append(",");
90-
int green = (int) rgbColor.getGreen().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
91-
result.append(green);
90+
result.append((int) color.green().value());
9291
result.append(",");
93-
int blue = (int) rgbColor.getBlue().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
94-
result.append(blue);
92+
result.append((int) color.blue().value());
9593
result.append(")");
9694
return result.toString();
9795
}
9896

9997
/**
100-
* Return hexadecimal (ex : #FFFFFF) color string value from w3c
101-
* <code>rgbColor</code> instance.
98+
* Return hexadecimal (ex : #FFFFFF) color string value from the given
99+
* <code>color</code>.
102100
*
103-
* @param rgbColor the color to get string representation for
104-
* @return rgbColor as hexa string
101+
* @param color the color to get string representation for
102+
* @return color as hexa string
105103
*/
106-
public static String getHexaColorStringValue(RGBColor rgbColor) {
104+
public static String getHexaColorStringValue(CssColor color) {
107105
StringBuilder result = new StringBuilder("#");
108-
int red = (int) rgbColor.getRed().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
109-
if (red < 16) {
110-
result.append("0");
111-
}
112-
result.append(Integer.toHexString(red));
113-
int green = (int) rgbColor.getGreen().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
114-
if (green < 16) {
115-
result.append("0");
116-
}
117-
result.append(Integer.toHexString(green));
118-
int blue = (int) rgbColor.getBlue().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
119-
if (blue < 16) {
106+
appendHexPair(result, (int) color.red().value());
107+
appendHexPair(result, (int) color.green().value());
108+
appendHexPair(result, (int) color.blue().value());
109+
return result.toString();
110+
}
111+
112+
private static void appendHexPair(StringBuilder result, int component) {
113+
if (component < 16) {
120114
result.append("0");
121115
}
122-
result.append(Integer.toHexString(blue));
123-
return result.toString();
116+
result.append(Integer.toHexString(component));
124117
}
125118

126119
/**

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2FontHelper.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
*******************************************************************************/
1414
package org.eclipse.e4.ui.css.core.css2;
1515

16-
import org.w3c.dom.css.CSSPrimitiveValue;
16+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssNumeric;
17+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive;
18+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssText;
19+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssUnit;
1720

1821
/**
1922
* CSS2 Font Helper.
@@ -65,14 +68,11 @@ public static String getFontWeight(boolean isBold) {
6568

6669
/**
6770
* Return the CSS Font Property name (font-style, font-weight, font-size,
68-
* font-family) switch the {@link CSSPrimitiveValue} <code>value</code>.
71+
* font-family) for the given <code>value</code>.
6972
*/
70-
public static String getCSSFontPropertyName(CSSPrimitiveValue value) {
71-
short type = value.getPrimitiveType();
72-
switch (type) {
73-
case CSSPrimitiveValue.CSS_STRING:
74-
case CSSPrimitiveValue.CSS_IDENT:
75-
switch (value.getStringValue()) {
73+
public static String getCSSFontPropertyName(CssPrimitive value) {
74+
if (value instanceof CssText text && (text.kind() == CssText.Kind.STRING || text.kind() == CssText.Kind.IDENT)) {
75+
switch (text.value()) {
7676
case "italic":
7777
case "oblique":
7878
return "font-style";
@@ -83,9 +83,9 @@ public static String getCSSFontPropertyName(CSSPrimitiveValue value) {
8383
default:
8484
return "font-family";
8585
}
86-
case CSSPrimitiveValue.CSS_PT:
87-
case CSSPrimitiveValue.CSS_NUMBER:
88-
case CSSPrimitiveValue.CSS_PX:
86+
}
87+
if (value instanceof CssNumeric numeric
88+
&& (numeric.unit() == CssUnit.PT || numeric.unit() == CssUnit.NUMBER || numeric.unit() == CssUnit.PX)) {
8989
return "font-size";
9090
}
9191
return null;

bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/css2/CSS2FontPropertiesHelpers.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties;
1717
import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontPropertiesImpl;
1818
import org.eclipse.e4.ui.css.core.engine.CSSElementContext;
19-
import org.w3c.dom.css.CSSPrimitiveValue;
19+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssList;
20+
import org.eclipse.e4.ui.css.core.impl.dom.CssValues.CssPrimitive;
2021
import org.w3c.dom.css.CSSValue;
21-
import org.w3c.dom.css.CSSValueList;
2222

2323
/**
2424
*
@@ -90,19 +90,15 @@ public static void updateCSSPropertyFont(CSS2FontProperties fontProperties, Stri
9090

9191
/**
9292
* Update <code>fontProperties</code> instance with the {@link CSSValue}
93-
* <code>value</code>. value can be {@link CSSPrimitiveValue} or
94-
* {@link CSSValueList}.
93+
* <code>value</code>. value can be a single value or a value list.
9594
*/
9695
public static void updateCSSPropertyFontComposite(CSS2FontProperties font, CSSValue value) {
97-
if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
98-
CSSValueList valueList = (CSSValueList) value;
99-
int length = valueList.getLength();
100-
for (int i = 0; i < length; i++) {
101-
CSSValue value2 = valueList.item(i);
102-
updateCSSPropertyFontComposite(font, value2);
96+
if (value instanceof CssList list) {
97+
for (CSSValue item : list.values()) {
98+
updateCSSPropertyFontComposite(font, item);
10399
}
104-
} else if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
105-
String property = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value);
100+
} else if (value instanceof CssPrimitive primitive) {
101+
String property = CSS2FontHelper.getCSSFontPropertyName(primitive);
106102
updateCSSPropertyFont(font, property, value);
107103
}
108104
}
@@ -111,35 +107,36 @@ public static void updateCSSPropertyFontComposite(CSS2FontProperties font, CSSVa
111107
* Update CSS2FontProperties instance with font-family.
112108
*/
113109
public static void updateCSSPropertyFontFamily(CSS2FontProperties font, CSSValue value) {
114-
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
115-
font.setFamily((CSSPrimitiveValue) value);
110+
if (value instanceof CssPrimitive primitive) {
111+
font.setFamily(primitive);
116112
}
117113
}
118114

119115
/**
120116
* Update CSS2FontProperties instance with font-size.
121117
*/
122118
public static void updateCSSPropertyFontSize(CSS2FontProperties font, CSSValue value) {
123-
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
124-
font.setSize((CSSPrimitiveValue) value);
119+
if (value instanceof CssPrimitive primitive) {
120+
font.setSize(primitive);
121+
font.setSizeFromCSS(true);
125122
}
126123
}
127124

128125
/**
129126
* Update CSS2FontProperties instance with font-style.
130127
*/
131128
public static void updateCSSPropertyFontStyle(CSS2FontProperties font, CSSValue value) {
132-
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
133-
font.setStyle((CSSPrimitiveValue) value);
129+
if (value instanceof CssPrimitive primitive) {
130+
font.setStyle(primitive);
134131
}
135132
}
136133

137134
/**
138135
* Update CSS2FontProperties instance with font-weight.
139136
*/
140137
public static void updateCSSPropertyFontWeight(CSS2FontProperties font, CSSValue value) {
141-
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
142-
font.setWeight((CSSPrimitiveValue) value);
138+
if (value instanceof CssPrimitive primitive) {
139+
font.setWeight(primitive);
143140
}
144141
}
145142
}

0 commit comments

Comments
 (0)