This is an automated email from the ASF dual-hosted git repository.
bamaer 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 2c08ed5bcf Issue #9022 : Show the sampler options in the Execution
Data Profile editor (#9023)
2c08ed5bcf is described below
commit 2c08ed5bcfd26cc2b1bec27cf888cc7e5076961d
Author: Matt Casters <[email protected]>
AuthorDate: Mon Oct 19 21:04:38 2026 +0200
Issue #9022 : Show the sampler options in the Execution Data Profile editor
(#9023)
The Large values box stretched to the bottom of the editor and covered the
sampler list. Size the box to its fields so the samplers sit underneath.
---
.../ui/core/gui/GuiCompositeWidgetsGroupTest.java | 48 ++++++++++++++++++++++
.../hop/ui/core/gui/GuiCompositeWidgets.java | 38 +++++++++++++++++
.../profiling/ExecutionDataProfileEditor.java | 20 +++------
3 files changed, 91 insertions(+), 15 deletions(-)
diff --git
a/rcp/src/test/java/org/apache/hop/ui/core/gui/GuiCompositeWidgetsGroupTest.java
b/rcp/src/test/java/org/apache/hop/ui/core/gui/GuiCompositeWidgetsGroupTest.java
index fec3a18bb2..4a2c7ce431 100644
---
a/rcp/src/test/java/org/apache/hop/ui/core/gui/GuiCompositeWidgetsGroupTest.java
+++
b/rcp/src/test/java/org/apache/hop/ui/core/gui/GuiCompositeWidgetsGroupTest.java
@@ -474,6 +474,54 @@ class GuiCompositeWidgetsGroupTest extends SwtBotTestBase {
}
}
+ @Test
+ void fittedBoxesLeaveRoomForControlsUnderThem() {
+ Shell shell = new Shell(display);
+ shell.setLayout(new FormLayout());
+ shell.setSize(700, 600);
+ try {
+ Label header = new Label(shell, SWT.LEFT);
+ header.setText("Header");
+ FormData fdHeader = new FormData();
+ fdHeader.left = new FormAttachment(0, 0);
+ fdHeader.top = new FormAttachment(0, 0);
+ fdHeader.right = new FormAttachment(100, 0);
+ header.setLayoutData(fdHeader);
+
+ GuiCompositeWidgets widgets = new GuiCompositeWidgets(new Variables());
+ widgets.createCompositeWidgets(new SingleBoxSample(), null, shell,
SINGLE_BOX_PARENT, header);
+ Control host = widgets.fitContainerToContent();
+ assertNotNull(host);
+ assertInstanceOf(FormData.class, host.getLayoutData());
+ FormData hostData = (FormData) host.getLayoutData();
+ assertNull(hostData.bottom, "the box column must stop stretching to the
parent bottom");
+ assertTrue(hostData.height > 0, "height " + hostData.height);
+
+ Label below = new Label(shell, SWT.LEFT);
+ below.setText("Samplers");
+ FormData fdBelow = new FormData();
+ fdBelow.left = new FormAttachment(0, 0);
+ fdBelow.top = new FormAttachment(host, 8);
+ below.setLayoutData(fdBelow);
+
+ shell.layout(true, true);
+
+ Rectangle hostBounds = host.getBounds();
+ Rectangle belowBounds = below.getBounds();
+ Rectangle box = findGroups(shell).get(0).getBounds();
+ assertTrue(hostBounds.height < 400, "host " + hostBounds.height);
+ assertTrue(
+ belowBounds.y >= hostBounds.y + hostBounds.height,
+ "below " + belowBounds.y + " host " + hostBounds);
+ assertTrue(box.y + box.height <= belowBounds.y + 2, "box " + box + "
below " + belowBounds.y);
+ assertTrue(
+ hostBounds.y + hostBounds.height < shell.getClientArea().height - 50,
+ "host " + hostBounds + " client " + shell.getClientArea().height);
+ } finally {
+ shell.dispose();
+ }
+ }
+
@Test
void singleBoxFillsTheSpaceBetweenHeaderAndButtons() {
Shell shell = new Shell(display);
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 557927ba31..5b51d9659f 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
@@ -129,6 +129,13 @@ public class GuiCompositeWidgets {
/** The control the first row was hung below, null when it is the top of the
composite. */
private Control widgetsFirstLastControl;
+ /**
+ * Boxes or tabs created by the last {@link #createCompositeWidgets} call.
That container is
+ * attached to the bottom of its parent. {@link #fitContainerToContent()}
drops the attachment
+ * when the caller still has controls to place under it.
+ */
+ private Control widgetsGroupContainer;
+
/**
* The {@link FormData#height} a row had before {@link #setWidgetsHidden}
collapsed it, so that
* showing it again restores the size it was created with rather than a
default one.
@@ -167,6 +174,7 @@ public class GuiCompositeWidgets {
Composite parent,
String parentGuiElementId,
Control lastControl) {
+ this.widgetsGroupContainer = null;
if (sourceData == null) {
// Nothing to do here. We can't detect widgets without an object.
return;
@@ -317,6 +325,7 @@ public class GuiCompositeWidgets {
: new FormAttachment(widgetsFirstLastControl, PropsUi.getMargin());
fdFiller.bottom = new FormAttachment(100, 0);
filler.setLayoutData(fdFiller);
+ this.widgetsGroupContainer = filler;
for (WidgetGroup group : groups) {
Group box = new Group(filler, SWT.SHADOW_ETCHED_IN);
@@ -353,6 +362,7 @@ public class GuiCompositeWidgets {
fdFolder.right = new FormAttachment(100, 0);
fdFolder.bottom = new FormAttachment(100, 0);
folder.setLayoutData(fdFolder);
+ this.widgetsGroupContainer = folder;
for (WidgetGroup group : groups) {
CTabItem item = new CTabItem(folder, SWT.NONE);
@@ -387,6 +397,34 @@ public class GuiCompositeWidgets {
}
}
+ /**
+ * Boxes and tabs stretch to the bottom of their parent so a dialog can fill
the space under a
+ * header. When the caller still has controls to place under that container,
this keeps the
+ * container at the height of its fields and returns the control to attach
the next row to.
+ *
+ * @return the container, or the control the widgets were hung below when
there is no container
+ */
+ public Control fitContainerToContent() {
+ Control container = widgetsGroupContainer;
+ if (container == null || container.isDisposed()) {
+ return widgetsFirstLastControl;
+ }
+ if (container.getLayoutData() instanceof FormData formData &&
formData.bottom != null) {
+ int widthHint = SWT.DEFAULT;
+ Composite parent = container.getParent();
+ if (parent != null && !parent.isDisposed()) {
+ int clientWidth = parent.getClientArea().width;
+ if (clientWidth > 50) {
+ widthHint = clientWidth;
+ }
+ }
+ Point preferred = container.computeSize(widthHint, SWT.DEFAULT, true);
+ formData.height = Math.max(preferred.y, 1);
+ formData.bottom = null;
+ }
+ return container;
+ }
+
/**
* Scrollable form inside a tab or a box. The returned composite is the
parent for fields and
* extra-group contents; its parent is the {@link ScrolledComposite}.
diff --git
a/ui/src/main/java/org/apache/hop/ui/execution/profiling/ExecutionDataProfileEditor.java
b/ui/src/main/java/org/apache/hop/ui/execution/profiling/ExecutionDataProfileEditor.java
index 2ac60109e2..4502f383fa 100644
---
a/ui/src/main/java/org/apache/hop/ui/execution/profiling/ExecutionDataProfileEditor.java
+++
b/ui/src/main/java/org/apache/hop/ui/execution/profiling/ExecutionDataProfileEditor.java
@@ -44,7 +44,6 @@ import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
@@ -146,9 +145,11 @@ public class ExecutionDataProfileEditor extends
MetadataEditor<ExecutionDataProf
parent,
ExecutionDataProfile.GUI_PLUGIN_LIMITS_PARENT_ID,
wDescription);
- Control limitsGroup = findGroup(parent);
- if (limitsGroup != null) {
- lastControl = limitsGroup;
+ // The limits box stretches to the bottom of the editor and covers the
sampler list.
+ // Keep it at the height of its fields so the samplers sit under it.
+ Control limitsHost = limitsWidgets.fitContainerToContent();
+ if (limitsHost != null) {
+ lastControl = limitsHost;
}
Label wlSamplers = new Label(parent, SWT.LEFT);
@@ -228,17 +229,6 @@ public class ExecutionDataProfileEditor extends
MetadataEditor<ExecutionDataProf
});
}
- /** The limits group is created on the editor composite, so the sampler list
can sit under it. */
- private static Control findGroup(Composite parent) {
- Control group = null;
- for (Control child : parent.getChildren()) {
- if (child instanceof Group) {
- group = child;
- }
- }
- return group;
- }
-
private IExecutionDataSampler previousSampler;
private void addSamplerPluginWidgets() {