From a9762c41ca230abe371be6039b54939bdb8a5328 Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Wed, 30 Jul 2025 11:51:56 -0700 Subject: [PATCH 01/11] Started working on the StyleProcessor class and the methods for it. --- .../.settings/.api_filters | 7 ++ .../win32/org/eclipse/swt/widgets/Button.java | 11 +++ .../eclipse/swt/widgets/StyleProcessor.java | 85 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java diff --git a/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters b/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters index 8b82f39681d..35d38ae3de1 100644 --- a/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters +++ b/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters @@ -144,4 +144,11 @@ + + + + + + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index f0c0180359b..8bca7da3f61 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -22,6 +22,7 @@ import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.internal.win32.version.*; + /** * Instances of this class represent a selectable user interface object that * issues notification when pressed and released. @@ -264,8 +265,16 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) { if (handle == 0) return 0; return OS.CallWindowProc (ButtonProc, hwnd, msg, wParam, lParam); } +//COMMAND_LINK ? SWT.COMMAND : 0 +private static final StyleProcessor STYLE_PROCESSOR = new StyleProcessor() +.oneOf("PUSH, ARROW, CHECK, RADIO, TOGGLE") +.ifOneOf("PUSH, TOGGLE").thenOneOf("CENTER, LEFT, RIGHT") +.ifOneOf("CHECK, RADIO").thenOneOf("LEFT, RIGHT, CENTER") +.ifOneOf("ARROW").thenOneOf("UP, DOWN, LEFT, RIGHT"); static int checkStyle (int style) { + System.out.println("Testing the Style Processor"); + System.out.println(STYLE_PROCESSOR.process(style)); style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, COMMAND_LINK ? SWT.COMMAND : 0); if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) { return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0); @@ -278,6 +287,8 @@ static int checkStyle (int style) { return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0); } return style; + + } void click () { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java new file mode 100644 index 00000000000..cf77ac45524 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -0,0 +1,85 @@ +package org.eclipse.swt.widgets; + +import java.util.*; + +import org.eclipse.swt.*; + +public class StyleProcessor { + private ArrayList oneOfArr = new ArrayList<>(); + private ArrayList> ifOneArr = new ArrayList<>(); + private ArrayList> thenOneArr = new ArrayList<>(); + + + // Just add styles you want to detect — no validation + public StyleProcessor oneOf(String styles) { + String[] tempHolder = styles.split(", "); + + oneOfArr.addAll(Arrays.asList(tempHolder)); + + return this; + } + + public StyleProcessor ifOneOf(String styles) { + String[] tempHolder = styles.split(", "); + ArrayList tempList = new ArrayList<>(Arrays.asList(tempHolder)); + + ifOneArr.add(tempList); + + return this; + } + + public StyleProcessor thenOneOf(String styles) { + if (ifOneArr.isEmpty()) { + throw new IllegalStateException("No 'ifOneOf' condition defined before 'thenOneOf'"); + } + + String[] tempHolder = styles.split(", "); + ArrayList tempList = new ArrayList<>(Arrays.asList(tempHolder)); + + thenOneArr.add(tempList); + + return this; + } + +// Given a style bitmask, return or print the styles that are set + public ArrayList process(int style) { + System.out.println("Int Style" + style); + ArrayList finalList = new ArrayList<>(); + + for (String s: oneOfArr) { + try { + if ((style & SWT.class.getField(s).getInt(null)) != 0) { + finalList.add(s); + break; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); // or handle gracefully + } + } + + for (int i = 0; i < ifOneArr.size(); i++) { + + for (String s2: ifOneArr.get(i)) { + try { + if ((style & SWT.class.getField(s2).getInt(null)) != 0) { + for (String s3: thenOneArr.get(i)) { + if ((style & SWT.class.getField(s3).getInt(null)) != 0) { + finalList.add(s3); + break; + } + } + break; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + } + + + return finalList; + + } + +} From f9f0471d73846af3b764554ec1a6debbf4903c3c Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Fri, 1 Aug 2025 10:18:35 -0700 Subject: [PATCH 02/11] Added print statements to the catch method in StyleProcessor. --- .../win32/org/eclipse/swt/widgets/Button.java | 36 ++++++++++++++----- .../eclipse/swt/widgets/StyleProcessor.java | 28 ++++++++++----- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index 8bca7da3f61..392b71291b4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -15,6 +15,8 @@ package org.eclipse.swt.widgets; +import java.util.*; + import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; @@ -265,16 +267,25 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) { if (handle == 0) return 0; return OS.CallWindowProc (ButtonProc, hwnd, msg, wParam, lParam); } -//COMMAND_LINK ? SWT.COMMAND : 0 -private static final StyleProcessor STYLE_PROCESSOR = new StyleProcessor() -.oneOf("PUSH, ARROW, CHECK, RADIO, TOGGLE") -.ifOneOf("PUSH, TOGGLE").thenOneOf("CENTER, LEFT, RIGHT") -.ifOneOf("CHECK, RADIO").thenOneOf("LEFT, RIGHT, CENTER") -.ifOneOf("ARROW").thenOneOf("UP, DOWN, LEFT, RIGHT"); + +private static StyleProcessor STYLE_PROCESSOR = new StyleProcessor(); + +static { + StyleProcessor processor = new StyleProcessor(); + + if (COMMAND_LINK) { + processor.oneOf("PUSH, ARROW, CHECK, RADIO, TOGGLE, SWT.COMMAND"); + } else { + processor.oneOf("PUSH, ARROW, CHECK, RADIO, TOGGLE"); + } + processor.ifOneOf("PUSH, TOGGLE").thenOneOf("CENTER, LEFT, RIGHT") + .ifOneOf("CHECK, RADIO").thenOneOf("LEFT, RIGHT, CENTER") + .ifOneOf("ARROW").thenOneOf("UP, DOWN, LEFT, RIGHT"); + + STYLE_PROCESSOR = processor; +} static int checkStyle (int style) { - System.out.println("Testing the Style Processor"); - System.out.println(STYLE_PROCESSOR.process(style)); style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, COMMAND_LINK ? SWT.COMMAND : 0); if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) { return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0); @@ -288,7 +299,14 @@ static int checkStyle (int style) { } return style; - +} +/** + * test + * @return ArrayList styles + * @since 3.131 + */ +public ArrayList getStyles() { + return STYLE_PROCESSOR.process(this.style); } void click () { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java index cf77ac45524..1f175cbaa96 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -9,7 +9,6 @@ public class StyleProcessor { private ArrayList> ifOneArr = new ArrayList<>(); private ArrayList> thenOneArr = new ArrayList<>(); - // Just add styles you want to detect — no validation public StyleProcessor oneOf(String styles) { String[] tempHolder = styles.split(", "); @@ -41,9 +40,9 @@ public StyleProcessor thenOneOf(String styles) { return this; } -// Given a style bitmask, return or print the styles that are set + public ArrayList process(int style) { - System.out.println("Int Style" + style); +// System.out.println("Int Style" + style); ArrayList finalList = new ArrayList<>(); for (String s: oneOfArr) { @@ -53,6 +52,7 @@ public ArrayList process(int style) { break; } } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid Style: " + s); e.printStackTrace(); // or handle gracefully } } @@ -61,16 +61,26 @@ public ArrayList process(int style) { for (String s2: ifOneArr.get(i)) { try { - if ((style & SWT.class.getField(s2).getInt(null)) != 0) { - for (String s3: thenOneArr.get(i)) { - if ((style & SWT.class.getField(s3).getInt(null)) != 0) { - finalList.add(s3); - break; + //Made it into a variable to make the it easy to read + int flag = SWT.class.getField(s2).getInt(null); + + if ((style & flag) != 0 ) { + //Checks if the s2 (String) is inside the oneOfArr + if (oneOfArr.contains(s2)) { + + for (String s3: thenOneArr.get(i)) { + if ((style & SWT.class.getField(s3).getInt(null)) != 0) { + finalList.add(s3); + break; + } } + break; + } else { + System.out.println("Not inside the oneArr: " + s2); } - break; } } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid Style: " + s2); e.printStackTrace(); } } From 4222a50aae1fe6910626765aac4ee65b80fe80f4 Mon Sep 17 00:00:00 2001 From: WillPeltz Date: Fri, 1 Aug 2025 12:33:53 -0700 Subject: [PATCH 03/11] Modified styleProcessor to use rule class, added thenSomeOf --- .../eclipse/swt/widgets/StyleProcessor.java | 160 +++++++++++------- 1 file changed, 95 insertions(+), 65 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java index 1f175cbaa96..dacdb3aa9da 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -5,11 +5,24 @@ import org.eclipse.swt.*; public class StyleProcessor { + + + private static class Rule { + ArrayList ifOneOf; + ArrayList thenOneOf; + ArrayList thenSomeOf; + + Rule(ArrayList ifOneOf) { + this.ifOneOf = ifOneOf; + this.thenOneOf = new ArrayList<>(); + this.thenSomeOf = new ArrayList<>(); + } + } + + private ArrayList rules = new ArrayList<>(); private ArrayList oneOfArr = new ArrayList<>(); - private ArrayList> ifOneArr = new ArrayList<>(); - private ArrayList> thenOneArr = new ArrayList<>(); + private Rule currentRule = null; - // Just add styles you want to detect — no validation public StyleProcessor oneOf(String styles) { String[] tempHolder = styles.split(", "); @@ -19,77 +32,94 @@ public StyleProcessor oneOf(String styles) { } public StyleProcessor ifOneOf(String styles) { - String[] tempHolder = styles.split(", "); - ArrayList tempList = new ArrayList<>(Arrays.asList(tempHolder)); - - ifOneArr.add(tempList); - - return this; + String[] tempHolder = styles.split(", "); + ArrayList tempList = new ArrayList<>(Arrays.asList(tempHolder)); + currentRule = new Rule(tempList); + rules.add(currentRule); + return this; } - public StyleProcessor thenOneOf(String styles) { - if (ifOneArr.isEmpty()) { - throw new IllegalStateException("No 'ifOneOf' condition defined before 'thenOneOf'"); - } - String[] tempHolder = styles.split(", "); - ArrayList tempList = new ArrayList<>(Arrays.asList(tempHolder)); + public StyleProcessor thenOneOf(String styles) { + if (currentRule == null) { + throw new IllegalStateException("No 'ifOneOf' defined before 'thenOneOf'"); + } + currentRule.thenOneOf.addAll(Arrays.asList(styles.split(", "))); + return this; + } - thenOneArr.add(tempList); - return this; + public StyleProcessor thenSomeOf(String styles) { + if (currentRule == null) { + throw new IllegalStateException("No 'ifOneOf' defined before 'thenSomeOf'"); + } + currentRule.thenSomeOf.addAll(Arrays.asList(styles.split(", "))); + return this; } - public ArrayList process(int style) { -// System.out.println("Int Style" + style); - ArrayList finalList = new ArrayList<>(); - - for (String s: oneOfArr) { - try { - if ((style & SWT.class.getField(s).getInt(null)) != 0) { - finalList.add(s); - break; - } - } catch (NoSuchFieldException | IllegalAccessException e) { - System.out.println("Invalid Style: " + s); - e.printStackTrace(); // or handle gracefully - } - } - - for (int i = 0; i < ifOneArr.size(); i++) { - - for (String s2: ifOneArr.get(i)) { - try { - //Made it into a variable to make the it easy to read - int flag = SWT.class.getField(s2).getInt(null); - - if ((style & flag) != 0 ) { - //Checks if the s2 (String) is inside the oneOfArr - if (oneOfArr.contains(s2)) { - - for (String s3: thenOneArr.get(i)) { - if ((style & SWT.class.getField(s3).getInt(null)) != 0) { - finalList.add(s3); - break; - } - } - break; - } else { - System.out.println("Not inside the oneArr: " + s2); - } - } - } catch (NoSuchFieldException | IllegalAccessException e) { - System.out.println("Invalid Style: " + s2); - e.printStackTrace(); - } - } - - } - - - return finalList; + public ArrayList process(int style) { + ArrayList finalList = new ArrayList<>(); + + for (String s : oneOfArr) { + try { + if ((style & SWT.class.getField(s).getInt(null)) != 0) { + finalList.add(s); + break; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid Style: " + s); + e.printStackTrace(); + } + } + + for (Rule rule : rules) { + boolean matched = false; + + for (String condition : rule.ifOneOf) { + try { + int flag = SWT.class.getField(condition).getInt(null); + if ((style & flag) != 0) { + matched = true; + break; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid condition: " + condition); + e.printStackTrace(); + } + } + + if (matched) { + for (String s : rule.thenOneOf) { + try { + int flag = SWT.class.getField(s).getInt(null); + if ((style & flag) != 0) { + finalList.add(s); + break; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid thenOneOf: " + s); + e.printStackTrace(); + } + } + + for (String s : rule.thenSomeOf) { + try { + int flag = SWT.class.getField(s).getInt(null); + if ((style & flag) != 0) { + finalList.add(s); + } + } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid thenSomeOf: " + s); + e.printStackTrace(); + } + } + } + } + + return finalList; } + } From 67301dfdcf3445c7729f4900ddce0cabe74810fe Mon Sep 17 00:00:00 2001 From: WillPeltz Date: Fri, 1 Aug 2025 12:58:54 -0700 Subject: [PATCH 04/11] Tentative text class implementation of styleProcessor --- .../win32/org/eclipse/swt/widgets/Text.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 537ca150583..a8414049a55 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -626,7 +626,20 @@ void applySegments () { ignoreVerify = oldIgnoreVerify; } +private static StyleProcessor STYLE_PROCESSOR = new StyleProcessor(); + +static { + StyleProcessor processor = new StyleProcessor(); + + processor.oneof("SINGLE, MULTI").oneof("LEFT, CENTER, RIGHT").ifOneOf("SEARCH") + .thenSomeOf("SINGLE, BORDER").ifOneOf("MULTI").thenSomeOf("H_SCROLL, V_SCROLL, WRAP") + .ifOneOf("SINGLE").thenSomeOf("PASSWORD"); + + STYLE_PROCESSOR = processor; +} + static int checkStyle (int style) { + System.out.println(STYLE_PROCESSOR.process(style)); if ((style & SWT.SINGLE) != 0 && (style & SWT.MULTI) != 0) { style &= ~SWT.MULTI; } From eefecfc73958b6d42328526a2011e247580ff04c Mon Sep 17 00:00:00 2001 From: WillPeltz Date: Mon, 4 Aug 2025 11:47:48 -0700 Subject: [PATCH 05/11] Added someOf method for non-mutually-exclusive checks, used to fix text --- .../eclipse/swt/widgets/StyleProcessor.java | 20 +++++++++++++++++++ .../win32/org/eclipse/swt/widgets/Text.java | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java index dacdb3aa9da..356a5c990fe 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -21,6 +21,7 @@ private static class Rule { private ArrayList rules = new ArrayList<>(); private ArrayList oneOfArr = new ArrayList<>(); + private ArrayList someOfArr = new ArrayList<>(); private Rule currentRule = null; public StyleProcessor oneOf(String styles) { @@ -31,6 +32,14 @@ public StyleProcessor oneOf(String styles) { return this; } + public StyleProcessor someOf(String styles) { + String[] tempHolder = styles.split(", "); + + someOfArr.addAll(Arrays.asList(tempHolder)); + + return this; + } + public StyleProcessor ifOneOf(String styles) { String[] tempHolder = styles.split(", "); ArrayList tempList = new ArrayList<>(Arrays.asList(tempHolder)); @@ -74,6 +83,17 @@ public ArrayList process(int style) { } } + for (String s : someOfArr) { + try { + if ((style & SWT.class.getField(s).getInt(null)) != 0) { + finalList.add(s); + } + } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid Style: " + s); + e.printStackTrace(); + } + } + for (Rule rule : rules) { boolean matched = false; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index a8414049a55..98bad205088 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -631,8 +631,8 @@ void applySegments () { static { StyleProcessor processor = new StyleProcessor(); - processor.oneof("SINGLE, MULTI").oneof("LEFT, CENTER, RIGHT").ifOneOf("SEARCH") - .thenSomeOf("SINGLE, BORDER").ifOneOf("MULTI").thenSomeOf("H_SCROLL, V_SCROLL, WRAP") + processor.oneof("SINGLE, MULTI").oneof("LEFT, CENTER, RIGHT") + .someOf("BORDER, SEARCH").ifOneOf("MULTI").thenSomeOf("H_SCROLL, V_SCROLL, WRAP") .ifOneOf("SINGLE").thenSomeOf("PASSWORD"); STYLE_PROCESSOR = processor; From 29a95f46fb69186d12979263074d5b2201ec5907 Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Mon, 4 Aug 2025 13:51:13 -0700 Subject: [PATCH 06/11] Changed the process method in StyleProcees w/ @WillPeltz --- .../win32/org/eclipse/swt/widgets/Button.java | 2 +- .../eclipse/swt/widgets/StyleProcessor.java | 27 ++++++++++--------- .../win32/org/eclipse/swt/widgets/Text.java | 14 ++++++++-- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index 392b71291b4..b0f3ed3b786 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -274,7 +274,7 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) { StyleProcessor processor = new StyleProcessor(); if (COMMAND_LINK) { - processor.oneOf("PUSH, ARROW, CHECK, RADIO, TOGGLE, SWT.COMMAND"); + processor.someOf("COMMAND"); } else { processor.oneOf("PUSH, ARROW, CHECK, RADIO, TOGGLE"); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java index 356a5c990fe..8b9931473e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -20,14 +20,14 @@ private static class Rule { } private ArrayList rules = new ArrayList<>(); - private ArrayList oneOfArr = new ArrayList<>(); + private ArrayList> oneOfArr = new ArrayList<>(); private ArrayList someOfArr = new ArrayList<>(); private Rule currentRule = null; public StyleProcessor oneOf(String styles) { String[] tempHolder = styles.split(", "); - oneOfArr.addAll(Arrays.asList(tempHolder)); + oneOfArr.add(new ArrayList<>(Arrays.asList(tempHolder))); return this; } @@ -70,17 +70,18 @@ public StyleProcessor thenSomeOf(String styles) { public ArrayList process(int style) { ArrayList finalList = new ArrayList<>(); - - for (String s : oneOfArr) { - try { - if ((style & SWT.class.getField(s).getInt(null)) != 0) { - finalList.add(s); - break; - } - } catch (NoSuchFieldException | IllegalAccessException e) { - System.out.println("Invalid Style: " + s); - e.printStackTrace(); - } + for (ArrayList a: oneOfArr) { + for (String s: a) { + try { + if ((style & SWT.class.getField(s).getInt(null)) != 0) { + finalList.add(s); + break; + } + } catch (NoSuchFieldException | IllegalAccessException e) { + System.out.println("Invalid Style: " + s); + e.printStackTrace(); + } + } } for (String s : someOfArr) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 98bad205088..ba2332c7a7c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -631,10 +631,11 @@ void applySegments () { static { StyleProcessor processor = new StyleProcessor(); - processor.oneof("SINGLE, MULTI").oneof("LEFT, CENTER, RIGHT") + processor.oneOf("SINGLE, MULTI") + .oneOf("LEFT, CENTER, RIGHT") .someOf("BORDER, SEARCH").ifOneOf("MULTI").thenSomeOf("H_SCROLL, V_SCROLL, WRAP") .ifOneOf("SINGLE").thenSomeOf("PASSWORD"); - + STYLE_PROCESSOR = processor; } @@ -664,6 +665,15 @@ static int checkStyle (int style) { return style | SWT.SINGLE; } +/** + * test + * @return ArrayList styles + * @since 3.131 + */ +public ArrayList getStyles() { + return STYLE_PROCESSOR.process(this.style); +} + void clearSegments (boolean applyText) { if (clearSegmentsCount++ != 0) return; if (segments == null) return; From 48ac14efa1f228dd95b0069ba19db6188e4eba66 Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Tue, 5 Aug 2025 10:54:49 -0700 Subject: [PATCH 07/11] Removed the StackTrace in the catch block (process method) w/ @WillPeltz --- .../win32/org/eclipse/swt/widgets/StyleProcessor.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java index 8b9931473e8..b8309cecb66 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -79,7 +79,6 @@ public ArrayList process(int style) { } } catch (NoSuchFieldException | IllegalAccessException e) { System.out.println("Invalid Style: " + s); - e.printStackTrace(); } } } @@ -91,7 +90,6 @@ public ArrayList process(int style) { } } catch (NoSuchFieldException | IllegalAccessException e) { System.out.println("Invalid Style: " + s); - e.printStackTrace(); } } @@ -107,7 +105,6 @@ public ArrayList process(int style) { } } catch (NoSuchFieldException | IllegalAccessException e) { System.out.println("Invalid condition: " + condition); - e.printStackTrace(); } } @@ -121,7 +118,6 @@ public ArrayList process(int style) { } } catch (NoSuchFieldException | IllegalAccessException e) { System.out.println("Invalid thenOneOf: " + s); - e.printStackTrace(); } } @@ -132,8 +128,7 @@ public ArrayList process(int style) { finalList.add(s); } } catch (NoSuchFieldException | IllegalAccessException e) { - System.out.println("Invalid thenSomeOf: " + s); - e.printStackTrace(); + System.out.println("Invalid thenSomeOf: " + s);; } } } From e56c367c94a35d0b71d0b53533e85439697864f2 Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Tue, 12 Aug 2025 22:34:19 -0700 Subject: [PATCH 08/11] Removed the public keywords & changed to package-private. --- .../.settings/.api_filters | 7 ------- .../win32/org/eclipse/swt/widgets/Button.java | 12 +++++------- .../org/eclipse/swt/widgets/StyleProcessor.java | 2 +- .../win32/org/eclipse/swt/widgets/Text.java | 4 ++-- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters b/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters index d0c57f487f3..14db311f18f 100644 --- a/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters +++ b/binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters @@ -160,11 +160,4 @@ - - - - - - - diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index b0f3ed3b786..4be12372681 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -15,7 +15,7 @@ package org.eclipse.swt.widgets; -import java.util.*; +import java.util.List; import org.eclipse.swt.*; import org.eclipse.swt.events.*; @@ -300,12 +300,10 @@ static int checkStyle (int style) { return style; } -/** - * test - * @return ArrayList styles - * @since 3.131 - */ -public ArrayList getStyles() { + + +@SuppressWarnings("unused") +List getStyles() { return STYLE_PROCESSOR.process(this.style); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java index b8309cecb66..81de65495d1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/StyleProcessor.java @@ -4,7 +4,7 @@ import org.eclipse.swt.*; -public class StyleProcessor { +class StyleProcessor { private static class Rule { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index ba2332c7a7c..8669c3b6e45 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -14,7 +14,7 @@ package org.eclipse.swt.widgets; -import java.util.*; +import java.util.List; import org.eclipse.swt.*; import org.eclipse.swt.events.*; @@ -670,7 +670,7 @@ static int checkStyle (int style) { * @return ArrayList styles * @since 3.131 */ -public ArrayList getStyles() { +List getStyles() { return STYLE_PROCESSOR.process(this.style); } From 10793590b1504b5a8f982d65f42fc22a545d65ea Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Tue, 12 Aug 2025 22:48:46 -0700 Subject: [PATCH 09/11] Removed the comments on getStyles for Text & Button --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java | 2 -- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index 4be12372681..f14cb53fbd2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -301,8 +301,6 @@ static int checkStyle (int style) { } - -@SuppressWarnings("unused") List getStyles() { return STYLE_PROCESSOR.process(this.style); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 8669c3b6e45..c28cf910a12 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -665,11 +665,7 @@ static int checkStyle (int style) { return style | SWT.SINGLE; } -/** - * test - * @return ArrayList styles - * @since 3.131 - */ + List getStyles() { return STYLE_PROCESSOR.process(this.style); } From 8df355101b9b26459ad281d49d4ae0fbb038eb5f Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Wed, 13 Aug 2025 06:27:04 -0700 Subject: [PATCH 10/11] Fixed error w/ @WillPeltz of NoSuchMethod in Text class, not showing getStyles(). # Conflicts: # bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java # bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java | 2 -- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java | 7 ++----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index f14cb53fbd2..5baabfcf753 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -13,8 +13,6 @@ * Conrad Groth - Bug 23837 [FEEP] Button, do not respect foreground and background color on Windows *******************************************************************************/ package org.eclipse.swt.widgets; - - import java.util.List; import org.eclipse.swt.*; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index c28cf910a12..3f016b81938 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -12,8 +12,6 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.widgets; - - import java.util.List; import org.eclipse.swt.*; @@ -630,12 +628,12 @@ void applySegments () { static { StyleProcessor processor = new StyleProcessor(); - + processor.oneOf("SINGLE, MULTI") .oneOf("LEFT, CENTER, RIGHT") .someOf("BORDER, SEARCH").ifOneOf("MULTI").thenSomeOf("H_SCROLL, V_SCROLL, WRAP") .ifOneOf("SINGLE").thenSomeOf("PASSWORD"); - + STYLE_PROCESSOR = processor; } @@ -665,7 +663,6 @@ static int checkStyle (int style) { return style | SWT.SINGLE; } - List getStyles() { return STYLE_PROCESSOR.process(this.style); } From 34a0672c77107060d30979e6cdf6fa8ab27ab9df Mon Sep 17 00:00:00 2001 From: NeilCabanilla Date: Mon, 18 Aug 2025 22:27:20 -0700 Subject: [PATCH 11/11] FIx error regarding, "Graphic is disposed" w/ WillPeltz --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java | 1 + .../Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java | 1 + 2 files changed, 2 insertions(+) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index 5baabfcf753..08b8a1b045b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -14,6 +14,7 @@ *******************************************************************************/ package org.eclipse.swt.widgets; import java.util.List; +import java.util.*; import org.eclipse.swt.*; import org.eclipse.swt.events.*; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 3f016b81938..ecb17c36c20 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.swt.widgets; import java.util.List; +import java.util.*; import org.eclipse.swt.*; import org.eclipse.swt.events.*;