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 6cbf3f0893 issue #6748 (Add easy way to create a scrolled composite 
over GUI widgets) (#6749)
6cbf3f0893 is described below

commit 6cbf3f0893b2fcbce0761d5d32b9f8b6bfc153fb
Author: Matt Casters <[email protected]>
AuthorDate: Mon Mar 9 19:27:59 2026 +0100

    issue #6748 (Add easy way to create a scrolled composite over GUI widgets) 
(#6749)
---
 .../hop/pipeline/transforms/ddl/DdlDialog.java     | 11 ++--
 .../hop/ui/core/gui/GuiCompositeWidgets.java       | 76 ++++++++++++++++++++++
 2 files changed, 80 insertions(+), 7 deletions(-)

diff --git 
a/plugins/transforms/ddl/src/main/java/org/apache/hop/pipeline/transforms/ddl/DdlDialog.java
 
b/plugins/transforms/ddl/src/main/java/org/apache/hop/pipeline/transforms/ddl/DdlDialog.java
index ac25471ae2..0ac33b1e48 100644
--- 
a/plugins/transforms/ddl/src/main/java/org/apache/hop/pipeline/transforms/ddl/DdlDialog.java
+++ 
b/plugins/transforms/ddl/src/main/java/org/apache/hop/pipeline/transforms/ddl/DdlDialog.java
@@ -44,13 +44,10 @@ public class DdlDialog extends BaseTransformDialog {
 
     buildButtonBar().ok(e -> ok()).cancel(e -> cancel()).build();
 
-    // Add the widgets from metadata...
-    //
-    widgets = new GuiCompositeWidgets(variables);
-    widgets.createCompositeWidgets(
-        input, null, shell, DdlMeta.GUI_PLUGIN_ELEMENT_PARENT_ID, 
wTransformName);
-    widgets.setWidgetsContents(input, shell, 
DdlMeta.GUI_PLUGIN_ELEMENT_PARENT_ID);
-
+    // Add the widgets from metadata.
+    widgets =
+        GuiCompositeWidgets.addScrolledComposite(
+            shell, variables, wTransformName, wOk, 
DdlMeta.GUI_PLUGIN_ELEMENT_PARENT_ID, input);
     setFieldNamesOnComboWidgets();
 
     focusTransformName();
diff --git 
a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java 
b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java
index 04ba0e5564..936534b0de 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java
@@ -46,8 +46,11 @@ import org.apache.hop.ui.core.widget.MetaSelectionLine;
 import org.apache.hop.ui.core.widget.TextVar;
 import org.apache.hop.ui.hopgui.HopGui;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
@@ -1114,4 +1117,77 @@ public class GuiCompositeWidgets {
       comboVar.setItems(fieldNames);
     }
   }
+
+  /**
+   * This adds a scrolled composite on a new Composite that will contain all 
the widgets with the
+   * specified parent ID as its parent.
+   *
+   * @param parent The parent to add the scrolled composite to
+   * @param top The top control to layout with. Null means top of the parent.
+   * @param bottom The bottom control to layout with. Null means the bottom of 
the parent.
+   * @param guiParentId The GUI parent ID to use to look up the widgets to 
place on the composite.
+   * @param sourceData The source data to use to populate the data on the 
widgets.
+   */
+  public static GuiCompositeWidgets addScrolledComposite(
+      Composite parent,
+      IVariables variables,
+      Control top,
+      Control bottom,
+      String guiParentId,
+      Object sourceData) {
+    ScrolledComposite scrolledComposite =
+        new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
+    scrolledComposite.setMinSize(SWT.DEFAULT, SWT.DEFAULT);
+
+    // The composite grabs the whole scrolled composite size
+    //
+    Composite composite = new Composite(scrolledComposite, SWT.NONE);
+    FormLayout compositeLayout = new FormLayout();
+
+    // Leave some room at the bottom and right for the scroll bars if they 
show up.
+    //
+    compositeLayout.marginRight = 2 * PropsUi.getFormMargin();
+    compositeLayout.marginBottom = 2 * PropsUi.getFormMargin();
+    composite.setLayout(compositeLayout);
+    FormData fdComposite = new FormData();
+    fdComposite.left = new FormAttachment(0, 0);
+    fdComposite.top = new FormAttachment(0, 0);
+    fdComposite.right = new FormAttachment(100, 0);
+    fdComposite.bottom = new FormAttachment(100, 0);
+    composite.setLayoutData(fdComposite);
+
+    // We add all the widgets...
+    //
+    GuiCompositeWidgets widgets = new GuiCompositeWidgets(variables);
+    widgets.createCompositeWidgets(sourceData, null, composite, guiParentId, 
null);
+    widgets.setWidgetsContents(sourceData, composite, guiParentId);
+    scrolledComposite.setContent(composite);
+
+    // Layout the scrolled composite.
+    //
+    FormData fdScrolled = new FormData();
+    if (top != null) {
+      fdScrolled.top = new FormAttachment(top, PropsUi.getMargin());
+    } else {
+      fdScrolled.top = new FormAttachment(0, 0);
+    }
+    if (bottom != null) {
+      fdScrolled.bottom = new FormAttachment(bottom, -2 * PropsUi.getMargin());
+    } else {
+      fdScrolled.bottom = new FormAttachment(100, 0);
+    }
+    fdScrolled.left = new FormAttachment(0, 0);
+    fdScrolled.right = new FormAttachment(100, 0);
+    scrolledComposite.setLayoutData(fdScrolled);
+
+    composite.pack();
+    Rectangle bounds = composite.getBounds();
+    scrolledComposite.setContent(composite);
+    scrolledComposite.setExpandHorizontal(true);
+    scrolledComposite.setExpandVertical(true);
+    scrolledComposite.setMinWidth(bounds.width);
+    scrolledComposite.setMinHeight(bounds.height);
+
+    return widgets;
+  }
 }

Reply via email to