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

hansva 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 e4b4fe65fe Hop web does not show project name next to icon, fix  #6282 
(#6283)
e4b4fe65fe is described below

commit e4b4fe65feaf49e0ad36c05cc6b15bc8fb7384a3
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Thu Jan 1 14:24:03 2026 +0100

    Hop web does not show project name next to icon, fix  #6282 (#6283)
    
    * Hop web does not show project name next to icon, fix  #6282
    
    * minor fix for macOS
---
 .../main/java/org/apache/hop/git/GitGuiPlugin.java |   6 +-
 .../apache/hop/projects/gui/ProjectsGuiPlugin.java |  15 ++-
 .../main/java/org/apache/hop/ui/core/PropsUi.java  |  39 +------
 .../org/apache/hop/ui/core/gui/GuiResource.java    |   6 +-
 .../apache/hop/ui/core/gui/GuiToolbarWidgets.java  | 129 ++++++++++++++++++---
 .../main/java/org/apache/hop/ui/hopgui/HopGui.java |   2 +-
 6 files changed, 133 insertions(+), 64 deletions(-)

diff --git 
a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java 
b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
index ae233199e2..6815b69c51 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
@@ -864,10 +864,12 @@ public class GitGuiPlugin
   }
 
   private void setBranchLabel(String branch) {
-    // Set the branch name
+    // Set the branch name using the new method that handles both SWT and RWT
     ToolItem item = getGitToolItem();
     if (item != null && !item.isDisposed()) {
-      item.setText(Const.NVL(branch, ""));
+      HopGui.getInstance()
+          .getStatusToolbarWidgets()
+          .setToolbarItemText(ID_TOOLBAR_ITEM_GIT, Const.NVL(branch, ""));
     }
   }
 }
diff --git 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
index b3d34b988f..afb70be66b 100644
--- 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
+++ 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
@@ -289,7 +289,10 @@ public class ProjectsGuiPlugin {
       if (projectConfig != null) {
         String projectHome = projectConfig.getProjectHome();
         if (StringUtils.isNotEmpty(projectHome)) {
-          item.setText(projectName);
+          // Use the new method that handles both SWT and RWT
+          HopGui.getInstance()
+              .getStatusToolbarWidgets()
+              .setToolbarItemText(ID_TOOLBAR_ITEM_PROJECT, projectName);
           item.setToolTipText(
               BaseMessages.getString(
                   PKG,
@@ -306,7 +309,10 @@ public class ProjectsGuiPlugin {
     ToolItem item = getEnvironmentToolItem();
     if (item != null && !item.isDisposed()) {
       if (Utils.isEmpty(environmentName)) {
-        item.setText("");
+        // Use the new method that handles both SWT and RWT
+        HopGui.getInstance()
+            .getStatusToolbarWidgets()
+            .setToolbarItemText(ID_TOOLBAR_ITEM_ENVIRONMENT, "");
         item.setToolTipText(
             BaseMessages.getString(PKG, 
"HopGui.Toolbar.Environment.Select.Tooltip"));
         return;
@@ -315,7 +321,10 @@ public class ProjectsGuiPlugin {
       ProjectsConfig config = ProjectsConfigSingleton.getConfig();
       LifecycleEnvironment environment = 
config.findEnvironment(environmentName);
       if (environment != null) {
-        item.setText(environmentName);
+        // Use the new method that handles both SWT and RWT
+        HopGui.getInstance()
+            .getStatusToolbarWidgets()
+            .setToolbarItemText(ID_TOOLBAR_ITEM_ENVIRONMENT, environmentName);
         item.setToolTipText(
             BaseMessages.getString(
                 PKG,
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 2c292f7fcf..d14d956727 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
@@ -37,14 +37,12 @@ import org.apache.hop.ui.hopgui.TextSizeUtilFacade;
 import org.apache.hop.ui.util.EnvironmentUtils;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
@@ -52,7 +50,6 @@ import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Layout;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.Widget;
@@ -570,7 +567,6 @@ public class PropsUi extends Props {
     final GuiResource gui = GuiResource.getInstance();
     Font font = gui.getFontDefault();
     Color background = GuiResource.getInstance().getWidgetBackGroundColor();
-    ;
     Color foreground = gui.getColorBlack();
 
     if (widget instanceof Shell shell) {
@@ -642,21 +638,16 @@ public class PropsUi extends Props {
   protected static void setLookOnMac(final Widget widget, int style) {
     final GuiResource gui = GuiResource.getInstance();
     Font font = gui.getFontDefault();
-    Color background = GuiResource.getInstance().getWidgetBackGroundColor();
+    Color background = null;
 
     Display display = Display.getCurrent();
     if (display == null) {
       return;
     }
 
-    Color systemListBackground = 
display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
-    Color systemListForeground = 
display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
-
     // Handle Shell windows with system background, but let macOS handle text 
color
     if (widget instanceof Shell shell) {
-      shell.setBackground(background);
       shell.setBackgroundMode(SWT.INHERIT_FORCE);
-      // Don't set foreground - let macOS handle it natively
       return;
     }
 
@@ -668,7 +659,8 @@ public class PropsUi extends Props {
       case WIDGET_STYLE_OSX_GROUP:
         font = gui.getFontDefault();
         Group group = ((Group) widget);
-        final Color groupBg = background;
+        // Use system background color for macOS groups
+        final Color groupBg = 
display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
         group.addPaintListener(
             paintEvent -> {
               // Use system colors in paint listener
@@ -680,33 +672,26 @@ public class PropsUi extends Props {
         break;
       case WIDGET_STYLE_FIXED:
         font = gui.getFontFixed();
-        background = background;
         break;
       case WIDGET_STYLE_TABLE:
-        background = background;
         Table table = (Table) widget;
         table.setHeaderBackground(background);
         // Don't set foreground colors - let macOS handle them
         break;
       case WIDGET_STYLE_TREE:
-        background = background;
         break;
       case WIDGET_STYLE_TOOLBAR:
-        background = background;
         break;
       case WIDGET_STYLE_TAB:
         CTabFolder tabFolder = (CTabFolder) widget;
         tabFolder.setBorderVisible(true);
         tabFolder.setBackground(background);
         tabFolder.setSelectionBackground(background);
-        // Don't set foreground colors - let macOS handle them
         ensureSafeRenderer(tabFolder);
         break;
       case WIDGET_STYLE_PUSH_BUTTON:
-        background = null;
         break;
       default:
-        background = gui.getColorBackground();
         font = null;
         break;
     }
@@ -720,24 +705,6 @@ public class PropsUi extends Props {
         && (widget instanceof Control controlWidget)) {
       controlWidget.setBackground(background);
     }
-
-    // Only set backgrounds and foregrounds for text input widgets to ensure 
visibility
-    // with the new glass look in modern macOS versions.
-    // Use system list colors for text fields which provide proper contrast
-    if (widget instanceof Combo combo) {
-      combo.setBackground(systemListBackground);
-      combo.setForeground(systemListForeground);
-    }
-
-    if (widget instanceof Text text) {
-      text.setBackground(systemListBackground);
-      text.setForeground(systemListForeground);
-    }
-
-    if (widget instanceof StyledText styledText) {
-      styledText.setBackground(systemListBackground);
-      styledText.setForeground(systemListForeground);
-    }
   }
 
   protected static void setLookOnLinux(final Widget widget, int style) {
diff --git a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java 
b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
index c3c7804542..40d3d1f160 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
@@ -1605,12 +1605,10 @@ public class GuiResource {
   }
 
   public Color getWidgetBackGroundColor() {
-    if (OsHelper.isWindows()) {
-      return colorWhite;
-    } else if (OsHelper.isMac()) {
+    if (OsHelper.isMac()) {
       return display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
     } else {
-      return colorLightGray;
+      return colorWhite;
     }
   }
 }
diff --git a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiToolbarWidgets.java 
b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiToolbarWidgets.java
index 1ab1d4d989..25443f212e 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiToolbarWidgets.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiToolbarWidgets.java
@@ -46,6 +46,8 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CLabel;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
@@ -63,6 +65,7 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
   private Map<String, GuiToolbarItem> guiToolBarMap;
   @Getter private Map<String, Control> widgetsMap;
   private Map<String, ToolItem> toolItemMap;
+  private Map<String, Label> textLabelMap; // For web/RWT: stores text labels 
separately
   private List<String> removeToolItems;
   private Color itemBackgroundColor;
 
@@ -71,6 +74,7 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
     guiToolBarMap = new HashMap<>();
     widgetsMap = new HashMap<>();
     toolItemMap = new HashMap<>();
+    textLabelMap = new HashMap<>();
     removeToolItems = new ArrayList<>();
   }
 
@@ -317,18 +321,33 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
   private void addWebToolbarButton(GuiToolbarItem toolbarItem, ToolBar 
toolBar) {
     ToolItem item = new ToolItem(toolBar, SWT.SEPARATOR);
 
-    Label label = new Label(toolBar, SWT.NONE);
+    // Create a Composite to hold both the image and text label
+    Composite composite = new Composite(toolBar, SWT.NONE);
+    GridLayout layout = new GridLayout(2, false);
+    layout.marginWidth = 0;
+    layout.marginHeight = 0;
+    layout.horizontalSpacing = 4;
+    layout.verticalSpacing = 0;
+    composite.setLayout(layout);
+
+    // Create the image label
+    Label imageLabel = new Label(composite, SWT.NONE);
     if (StringUtils.isNotEmpty(toolbarItem.getToolTip())) {
-      label.setToolTipText(toolbarItem.getToolTip());
+      imageLabel.setToolTipText(toolbarItem.getToolTip());
+      composite.setToolTipText(toolbarItem.getToolTip());
     }
     Listener listener = SvgLabelListener.getInstance();
-    label.addListener(SWT.MouseDown, listener);
-    label.addListener(SWT.Hide, listener);
-    label.addListener(SWT.Show, listener);
-    label.addListener(SWT.MouseEnter, listener);
-    label.addListener(SWT.MouseExit, listener);
-    label.addListener(SWT.MouseDown, getListener(toolbarItem));
-    label.pack();
+    Listener toolbarListener = getListener(toolbarItem);
+
+    // Add SVG listeners to image label
+    imageLabel.addListener(SWT.MouseDown, listener);
+    imageLabel.addListener(SWT.Hide, listener);
+    imageLabel.addListener(SWT.Show, listener);
+    imageLabel.addListener(SWT.MouseEnter, listener);
+    imageLabel.addListener(SWT.MouseExit, listener);
+
+    // Make the entire composite clickable (image + text)
+    composite.addListener(SWT.MouseDown, toolbarListener);
 
     // Take into account zooming and the extra room for widget decorations
     //
@@ -337,11 +356,32 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
             (ConstUi.SMALL_ICON_SIZE * PropsUi.getNativeZoomFactor() + 
toolbarItem.getExtraWidth());
 
     String imageFilename = findImageFilename(toolbarItem);
-    SvgLabelFacade.setData(toolbarItem.getId(), label, imageFilename, size);
-    item.setWidth(size);
-    item.setControl(label);
+    SvgLabelFacade.setData(toolbarItem.getId(), imageLabel, imageFilename, 
size);
 
-    widgetsMap.put(toolbarItem.getId(), label);
+    GridData imageData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
+    imageData.widthHint = size;
+    imageData.heightHint = size;
+    imageLabel.setLayoutData(imageData);
+
+    // Create the text label (initially empty, will be set later if needed)
+    Label textLabel = new Label(composite, SWT.NONE);
+    textLabel.setText("");
+    PropsUi.setLook(textLabel, Props.WIDGET_STYLE_TOOLBAR);
+    if (StringUtils.isNotEmpty(toolbarItem.getToolTip())) {
+      textLabel.setToolTipText(toolbarItem.getToolTip());
+    }
+    // Make text label part of the clickable button
+    textLabel.addListener(SWT.MouseDown, toolbarListener);
+    GridData textData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
+    textLabel.setLayoutData(textData);
+    textLabel.setVisible(false); // Hidden until text is set
+
+    composite.pack();
+    item.setWidth(composite.getSize().x);
+    item.setControl(composite);
+
+    widgetsMap.put(toolbarItem.getId(), composite);
+    textLabelMap.put(toolbarItem.getId(), textLabel);
     toolItemMap.put(toolbarItem.getId(), item);
   }
 
@@ -395,9 +435,15 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
       return;
     }
     if (EnvironmentUtils.getInstance().isWeb()) {
-      //
-      Label label = (Label) widgetsMap.get(id);
-      SvgLabelFacade.enable(toolItem, id, label, enabled);
+      // In web/RWT, the widget is a Composite containing the image label
+      Control control = widgetsMap.get(id);
+      if (control instanceof Composite composite) {
+        // Find the image label (first child)
+        Control[] children = composite.getChildren();
+        if (children.length > 0 && children[0] instanceof Label imageLabel) {
+          SvgLabelFacade.enable(toolItem, id, imageLabel, enabled);
+        }
+      }
     } else {
       if (enabled != toolItem.isEnabled()) {
         toolItem.setEnabled(enabled);
@@ -439,8 +485,15 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
     if (enabled != item.isEnabled()) {
       boolean enable = hasCapability && active;
       if (EnvironmentUtils.getInstance().isWeb()) {
-        Label label = (Label) widgetsMap.get(id);
-        SvgLabelFacade.enable(null, id, label, enable);
+        // In web/RWT, the widget is a Composite containing the image label
+        Control control = widgetsMap.get(id);
+        if (control instanceof Composite composite) {
+          // Find the image label (first child)
+          Control[] children = composite.getChildren();
+          if (children.length > 0 && children[0] instanceof Label imageLabel) {
+            SvgLabelFacade.enable(null, id, imageLabel, enable);
+          }
+        }
       } else {
         item.setEnabled(enable);
       }
@@ -452,6 +505,46 @@ public class GuiToolbarWidgets extends BaseGuiWidgets {
     return toolItemMap.get(id);
   }
 
+  /**
+   * Set text on a toolbar item. Handles both SWT (desktop) and RWT (web) 
environments. In SWT, sets
+   * text directly on the ToolItem. In RWT, updates the separate text Label 
next to the image.
+   *
+   * @param id The ID of the toolbar item
+   * @param text The text to set
+   */
+  public void setToolbarItemText(String id, String text) {
+    ToolItem toolItem = toolItemMap.get(id);
+    if (toolItem == null || toolItem.isDisposed()) {
+      return;
+    }
+
+    if (EnvironmentUtils.getInstance().isWeb()) {
+      // In web/RWT, update the separate text label
+      Label textLabel = textLabelMap.get(id);
+      if (textLabel != null && !textLabel.isDisposed()) {
+        String textToSet = Const.NVL(text, "");
+        textLabel.setText(textToSet);
+        textLabel.setVisible(!Utils.isEmpty(textToSet));
+
+        // Update the composite width to accommodate the text
+        Composite composite = (Composite) widgetsMap.get(id);
+        if (composite != null && !composite.isDisposed()) {
+          composite.pack();
+          toolItem.setWidth(composite.getSize().x);
+
+          // Force layout update
+          ToolBar toolbar = (ToolBar) toolItem.getParent();
+          if (toolbar != null && !toolbar.isDisposed()) {
+            toolbar.layout(true, true);
+          }
+        }
+      }
+    } else {
+      // In SWT, set text directly on the ToolItem
+      toolItem.setText(Const.NVL(text, ""));
+    }
+  }
+
   public void refreshComboItemList(String id) {
     GuiToolbarItem item = guiToolBarMap.get(id);
     if (item != null) {
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java 
b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
index 5b0d965386..2dd23eb19f 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
@@ -1257,7 +1257,7 @@ public class HopGui
   protected void addStatusToolbar() {
     statusToolbar = new ToolBar(shell, SWT.WRAP | SWT.RIGHT | SWT.HORIZONTAL);
     FormData fdToolBar = new FormData();
-    fdToolBar.left = new FormAttachment(0, 0);
+    fdToolBar.left = new FormAttachment(0, 10);
     fdToolBar.right = new FormAttachment(100, 0);
     fdToolBar.bottom = new FormAttachment(100, 0);
     statusToolbar.setLayoutData(fdToolBar);

Reply via email to