This is an automated email from the ASF dual-hosted git repository.

mcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new e22adb338a Issue#2989 (#6447)
e22adb338a is described below

commit e22adb338afbcf70cf77fbbed0496175434030c3
Author: samcasters <[email protected]>
AuthorDate: Mon Jan 26 13:20:25 2026 +0100

    Issue#2989 (#6447)
    
    * issue #6295
    
    * issue #6295 notePad light and dark mode default collors
    
    * removed unused variable and imports in basepainter
    
    * maven fail removed unused method
---
 .../main/java/org/apache/hop/core/NotePadMeta.java | 228 +++------------------
 .../main/java/org/apache/hop/ui/core/PropsUi.java  |   4 +-
 .../apache/hop/ui/hopgui/dialog/NotePadDialog.java | 125 +++++++++--
 3 files changed, 142 insertions(+), 215 deletions(-)

diff --git a/engine/src/main/java/org/apache/hop/core/NotePadMeta.java 
b/engine/src/main/java/org/apache/hop/core/NotePadMeta.java
index e6d11bb2ac..e0cd4e3239 100644
--- a/engine/src/main/java/org/apache/hop/core/NotePadMeta.java
+++ b/engine/src/main/java/org/apache/hop/core/NotePadMeta.java
@@ -44,44 +44,70 @@ public class NotePadMeta implements Cloneable, 
IGuiPosition, IGuiSize {
   public static final int COLOR_RGB_DEFAULT_BORDER_GREEN = 58;
   public static final int COLOR_RGB_DEFAULT_BORDER_BLUE = 90;
 
-  @HopMetadataProperty private String note;
+  @Setter @Getter @HopMetadataProperty private String note;
 
+  @Setter
+  @Getter
   @HopMetadataProperty(key = "fontname")
   private String fontName;
 
+  @Setter
+  @Getter
   @HopMetadataProperty(key = "fontsize")
   private int fontSize;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "fontbold")
   private boolean fontBold;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "fontitalic")
   private boolean fontItalic;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "fontcolorred")
   private int fontColorRed;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "fontcolorgreen")
   private int fontColorGreen;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "fontcolorblue")
   private int fontColorBlue;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "backgroundcolorred")
   private int backGroundColorRed;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "backgroundcolorgreen")
   private int backGroundColorGreen;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "backgroundcolorblue")
   private int backGroundColorBlue;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "bordercolorred")
   private int borderColorRed;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "bordercolorgreen")
   private int borderColorGreen;
 
+  @Getter
+  @Setter
   @HopMetadataProperty(key = "bordercolorblue")
   private int borderColorBlue;
 
@@ -104,10 +130,6 @@ public class NotePadMeta implements Cloneable, 
IGuiPosition, IGuiSize {
     this.height = -1;
     this.selected = false;
 
-    this.backGroundColorRed = COLOR_RGB_DEFAULT_BG_RED;
-    this.backGroundColorGreen = COLOR_RGB_DEFAULT_BG_GREEN;
-    this.backGroundColorBlue = COLOR_RGB_DEFAULT_BG_BLUE;
-
     setDefaultFont();
   }
 
@@ -227,83 +249,6 @@ public class NotePadMeta implements Cloneable, 
IGuiPosition, IGuiSize {
     return location;
   }
 
-  /**
-   * @return Returns the note.
-   */
-  public String getNote() {
-    return this.note;
-  }
-
-  /**
-   * @param note The note to set.
-   */
-  public void setNote(String note) {
-    this.note = note;
-  }
-
-  /**
-   * @param red the border red color.
-   */
-  public void setBorderColorRed(int red) {
-    this.borderColorRed = red;
-  }
-
-  /**
-   * @param green the border color green.
-   */
-  public void setBorderColorGreen(int green) {
-    this.borderColorGreen = green;
-  }
-
-  /**
-   * @param blue the border blue color.
-   */
-  public void setBorderColorBlue(int blue) {
-    this.borderColorBlue = blue;
-  }
-
-  /**
-   * @param red the backGround red color.
-   */
-  public void setBackGroundColorRed(int red) {
-    this.backGroundColorRed = red;
-  }
-
-  /**
-   * @param green the backGround green color.
-   */
-  public void setBackGroundColorGreen(int green) {
-    this.backGroundColorGreen = green;
-  }
-
-  /**
-   * @param blue the backGround blue color.
-   */
-  public void setBackGroundColorBlue(int blue) {
-    this.backGroundColorBlue = blue;
-  }
-
-  /**
-   * @param red the font color red.
-   */
-  public void setFontColorRed(int red) {
-    this.fontColorRed = red;
-  }
-
-  /**
-   * @param green the font color green.
-   */
-  public void setFontColorGreen(int green) {
-    this.fontColorGreen = green;
-  }
-
-  /**
-   * @param blue the font color blue.
-   */
-  public void setFontColorBlue(int blue) {
-    this.fontColorBlue = blue;
-  }
-
   /**
    * @return Returns the selected.
    */
@@ -384,125 +329,6 @@ public class NotePadMeta implements Cloneable, 
IGuiPosition, IGuiSize {
     this.width = width;
   }
 
-  /**
-   * @return Returns the font name.
-   */
-  public String getFontName() {
-    return this.fontName;
-  }
-
-  /**
-   * @param fontname The font name.
-   */
-  public void setFontName(String fontname) {
-    this.fontName = fontname;
-  }
-
-  /**
-   * @return Returns the font size.
-   */
-  public int getFontSize() {
-    return this.fontSize;
-  }
-
-  /**
-   * @param fontbold The font bold.
-   */
-  public void setFontBold(boolean fontbold) {
-    this.fontBold = fontbold;
-  }
-
-  /**
-   * @return Returns the font bold.
-   */
-  public boolean isFontBold() {
-    return this.fontBold;
-  }
-
-  /**
-   * @param fontitalic The font italic.
-   */
-  public void setFontItalic(boolean fontitalic) {
-    this.fontItalic = fontitalic;
-  }
-
-  /**
-   * @return Returns the font italic.
-   */
-  public boolean isFontItalic() {
-    return this.fontItalic;
-  }
-
-  /**
-   * @return Returns the backGround color red.
-   */
-  public int getBorderColorRed() {
-    return this.borderColorRed;
-  }
-
-  /**
-   * @return Returns the backGround color green.
-   */
-  public int getBorderColorGreen() {
-    return this.borderColorGreen;
-  }
-
-  /**
-   * @return Returns the backGround color blue.
-   */
-  public int getBorderColorBlue() {
-    return this.borderColorBlue;
-  }
-
-  /**
-   * @return Returns the backGround color red.
-   */
-  public int getBackGroundColorRed() {
-    return this.backGroundColorRed;
-  }
-
-  /**
-   * @return Returns the backGround color green.
-   */
-  public int getBackGroundColorGreen() {
-    return this.backGroundColorGreen;
-  }
-
-  /**
-   * @return Returns the backGround color blue.
-   */
-  public int getBackGroundColorBlue() {
-    return this.backGroundColorBlue;
-  }
-
-  /**
-   * @return Returns the font color red.
-   */
-  public int getFontColorRed() {
-    return this.fontColorRed;
-  }
-
-  /**
-   * @return Returns the font color green.
-   */
-  public int getFontColorGreen() {
-    return this.fontColorGreen;
-  }
-
-  /**
-   * @return Returns the font color blue.
-   */
-  public int getFontColorBlue() {
-    return this.fontColorBlue;
-  }
-
-  /**
-   * @param fontsize The font name.
-   */
-  public void setFontSize(int fontsize) {
-    this.fontSize = fontsize;
-  }
-
   private void setDefaultFont() {
     this.fontName = null;
     this.fontSize = -1;
diff --git a/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java 
b/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
index a5a34c0e54..ffb34f25d7 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
@@ -143,11 +143,11 @@ public class PropsUi extends Props {
     if (!EnvironmentUtils.getInstance().isWeb() && !OsHelper.isWindows()) {
       if (Display.isSystemDarkTheme()) {
         if (!isDarkMode()) {
-          setDarkMode(true);
+          setDarkMode(false);
         }
       } else {
         if (isDarkMode()) {
-          setDarkMode(false);
+          setDarkMode(true);
         }
       }
     }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/NotePadDialog.java 
b/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/NotePadDialog.java
index ca8a5c9c8d..4fec12ec89 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/NotePadDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/dialog/NotePadDialog.java
@@ -489,6 +489,13 @@ public class NotePadDialog extends Dialog {
   }
 
   public void getData() {
+    PropsUi.getInstance()
+        .getDisplay()
+        .asyncExec(
+            () -> {
+              PropsUi.getInstance().getDisplay().update();
+            });
+
     if (notePadMeta != null) {
       wDesc.setText(Const.NVL(notePadMeta.getNote(), ""));
       wFontName.setText(
@@ -567,7 +574,11 @@ public class NotePadDialog extends Dialog {
   }
 
   private void ok() {
+    PropsUi propsUi = PropsUi.getInstance();
+    boolean isDark = propsUi.isDarkMode();
+
     notePadMeta = new NotePadMeta();
+
     if (wDesc.getText() != null) {
       notePadMeta.setNote(wDesc.getText());
     }
@@ -577,21 +588,111 @@ public class NotePadDialog extends Dialog {
     notePadMeta.setFontSize(wFontSize.getSelection());
     notePadMeta.setFontBold(wFontBold.getSelection());
     notePadMeta.setFontItalic(wFontItalic.getSelection());
-    // font color
-    notePadMeta.setFontColorRed(wFontColor.getBackground().getRed());
-    notePadMeta.setFontColorGreen(wFontColor.getBackground().getGreen());
-    notePadMeta.setFontColorBlue(wFontColor.getBackground().getBlue());
-    // background color
-    
notePadMeta.setBackGroundColorRed(wBackGroundColor.getBackground().getRed());
-    
notePadMeta.setBackGroundColorGreen(wBackGroundColor.getBackground().getGreen());
-    
notePadMeta.setBackGroundColorBlue(wBackGroundColor.getBackground().getBlue());
-    // border color
-    notePadMeta.setBorderColorRed(wBorderColor.getBackground().getRed());
-    notePadMeta.setBorderColorGreen(wBorderColor.getBackground().getGreen());
-    notePadMeta.setBorderColorBlue(wBorderColor.getBackground().getBlue());
+
+    RGB fontRGB =
+        new RGB(
+            wFontColor.getBackground().getRed(),
+            wFontColor.getBackground().getGreen(),
+            wFontColor.getBackground().getBlue());
+    RGB bgRGB =
+        new RGB(
+            wBackGroundColor.getBackground().getRed(),
+            wBackGroundColor.getBackground().getGreen(),
+            wBackGroundColor.getBackground().getBlue());
+    RGB borderRGB =
+        new RGB(
+            wBorderColor.getBackground().getRed(),
+            wBorderColor.getBackground().getGreen(),
+            wBorderColor.getBackground().getBlue());
+
+    if (this.notePadMeta != null) { // Editing existing note
+      RGB originalFont =
+          new RGB(
+              this.notePadMeta.getFontColorRed(),
+              this.notePadMeta.getFontColorGreen(),
+              this.notePadMeta.getFontColorBlue());
+      RGB originalBg =
+          new RGB(
+              this.notePadMeta.getBackGroundColorRed(),
+              this.notePadMeta.getBackGroundColorGreen(),
+              this.notePadMeta.getBackGroundColorBlue());
+      RGB originalBorder =
+          new RGB(
+              this.notePadMeta.getBorderColorRed(),
+              this.notePadMeta.getBorderColorGreen(),
+              this.notePadMeta.getBorderColorBlue());
+
+      if (isDark
+          && (isLightDefault(originalFont)
+              || isLightDefault(originalBg)
+              || isLightDefault(originalBorder))) {
+        // Save dark contrasted
+        fontRGB = propsUi.contrastColor(originalFont);
+        bgRGB = propsUi.contrastColor(originalBg);
+        borderRGB = propsUi.contrastColor(originalBorder);
+      } else if (!isDark
+          && (isDarkDefault(originalFont)
+              || isDarkDefault(originalBg)
+              || isDarkDefault(originalBorder))) {
+        // Save light defaults
+        if (isDarkDefault(originalFont)) fontRGB = originalFont; // Already 
light
+        if (isDarkDefault(originalBg)) bgRGB = originalBg;
+        if (isDarkDefault(originalBorder)) borderRGB = originalBorder;
+      }
+    }
+
+    notePadMeta.setFontColorRed(fontRGB.red);
+    notePadMeta.setFontColorGreen(fontRGB.green);
+    notePadMeta.setFontColorBlue(fontRGB.blue);
+
+    notePadMeta.setBackGroundColorRed(bgRGB.red);
+    notePadMeta.setBackGroundColorGreen(bgRGB.green);
+    notePadMeta.setBackGroundColorBlue(bgRGB.blue);
+
+    notePadMeta.setBorderColorRed(borderRGB.red);
+    notePadMeta.setBorderColorGreen(borderRGB.green);
+    notePadMeta.setBorderColorBlue(borderRGB.blue);
+
     dispose();
   }
 
+  private boolean isDarkDefault(RGB rgb) {
+    PropsUi propsUi = PropsUi.getInstance();
+
+    // Check if RGB matches contrastColor() of each light default
+    RGB blackLight =
+        new RGB(
+            NotePadMeta.COLOR_RGB_BLACK_RED,
+            NotePadMeta.COLOR_RGB_BLACK_GREEN,
+            NotePadMeta.COLOR_RGB_BLACK_BLUE);
+    RGB bgLight =
+        new RGB(
+            NotePadMeta.COLOR_RGB_DEFAULT_BG_RED,
+            NotePadMeta.COLOR_RGB_DEFAULT_BG_GREEN,
+            NotePadMeta.COLOR_RGB_DEFAULT_BG_BLUE);
+    RGB borderLight =
+        new RGB(
+            NotePadMeta.COLOR_RGB_DEFAULT_BORDER_RED,
+            NotePadMeta.COLOR_RGB_DEFAULT_BORDER_GREEN,
+            NotePadMeta.COLOR_RGB_DEFAULT_BORDER_BLUE);
+
+    return rgb.equals(propsUi.contrastColor(blackLight))
+        || rgb.equals(propsUi.contrastColor(bgLight))
+        || rgb.equals(propsUi.contrastColor(borderLight));
+  }
+
+  private boolean isLightDefault(RGB rgb) {
+    return (rgb.red == NotePadMeta.COLOR_RGB_BLACK_RED
+            && rgb.green == NotePadMeta.COLOR_RGB_BLACK_GREEN
+            && rgb.blue == NotePadMeta.COLOR_RGB_BLACK_BLUE)
+        || (rgb.red == NotePadMeta.COLOR_RGB_DEFAULT_BG_RED
+            && rgb.green == NotePadMeta.COLOR_RGB_DEFAULT_BG_GREEN
+            && rgb.blue == NotePadMeta.COLOR_RGB_DEFAULT_BG_BLUE)
+        || (rgb.red == NotePadMeta.COLOR_RGB_DEFAULT_BORDER_RED
+            && rgb.green == NotePadMeta.COLOR_RGB_DEFAULT_BORDER_GREEN
+            && rgb.blue == NotePadMeta.COLOR_RGB_DEFAULT_BORDER_BLUE);
+  }
+
   private void refreshTextNote() {
     int swt = SWT.NORMAL;
     if (wFontBold.getSelection()) {

Reply via email to