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 4b040819c6 avoid treeview making dialog go out of bounds, fixes #7373
(#7440)
4b040819c6 is described below
commit 4b040819c6535e0e5bd5c7aed8098af7fa384246
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Mon Jul 6 16:52:51 2026 +0200
avoid treeview making dialog go out of bounds, fixes #7373 (#7440)
---
.../actions/getpop/SelectFolderDialog.java | 3 +-
.../transforms/fake/FakerBrowserDialog.java | 3 +-
.../UserDefinedJavaClassDialog.java | 3 +-
.../transforms/javascript/ScriptValuesDialog.java | 3 +-
.../pipeline/transforms/script/ScriptDialog.java | 3 +-
.../xml/advancedxmloutput/XmlTreeDesigner.java | 3 +-
.../database/dialog/DatabaseExplorerDialog.java | 3 +-
.../apache/hop/ui/core/vfs/HopVfsFileDialog.java | 3 +-
.../org/apache/hop/ui/core/widget/FileTree.java | 2 +-
.../org/apache/hop/ui/core/widget/HopTree.java | 65 ++++++++++++++++++++++
10 files changed, 82 insertions(+), 9 deletions(-)
diff --git
a/plugins/misc/mail/src/main/java/org/apache/hop/mail/workflow/actions/getpop/SelectFolderDialog.java
b/plugins/misc/mail/src/main/java/org/apache/hop/mail/workflow/actions/getpop/SelectFolderDialog.java
index fb377e719a..8426581c47 100644
---
a/plugins/misc/mail/src/main/java/org/apache/hop/mail/workflow/actions/getpop/SelectFolderDialog.java
+++
b/plugins/misc/mail/src/main/java/org/apache/hop/mail/workflow/actions/getpop/SelectFolderDialog.java
@@ -24,6 +24,7 @@ import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.gui.WindowProperty;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
@@ -72,7 +73,7 @@ public class SelectFolderDialog extends Dialog {
shell.setLayout(formLayout);
// Tree
- wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER);
+ wTree = new HopTree(shell, SWT.SINGLE | SWT.BORDER);
PropsUi.setLook(wTree);
// Double click in tree: select the value
wTree.addListener(SWT.DefaultSelection, e -> ok());
diff --git
a/plugins/transforms/fake/src/main/java/org/apache/hop/pipeline/transforms/fake/FakerBrowserDialog.java
b/plugins/transforms/fake/src/main/java/org/apache/hop/pipeline/transforms/fake/FakerBrowserDialog.java
index ca34d4113b..bff62ef1b0 100644
---
a/plugins/transforms/fake/src/main/java/org/apache/hop/pipeline/transforms/fake/FakerBrowserDialog.java
+++
b/plugins/transforms/fake/src/main/java/org/apache/hop/pipeline/transforms/fake/FakerBrowserDialog.java
@@ -30,6 +30,7 @@ import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.pipeline.transforms.fake.FakerCatalog.Generator;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
@@ -290,7 +291,7 @@ public class FakerBrowserDialog extends Dialog {
gParams.setLayoutData(fdParams);
// Generator tree: categories expand to their functions.
- wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+ wTree = new HopTree(shell, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
PropsUi.setLook(wTree);
FormData fdTree = new FormData();
fdTree.left = new FormAttachment(0, 0);
diff --git
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
index 2377d09de1..0e211d3ab3 100644
---
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
+++
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
@@ -58,6 +58,7 @@ import org.apache.hop.ui.core.dialog.MessageDialogWithToggle;
import org.apache.hop.ui.core.dialog.PreviewRowsDialog;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.core.widget.JavaStyledTextComp;
import org.apache.hop.ui.core.widget.StyledTextComp;
import org.apache.hop.ui.core.widget.TableView;
@@ -278,7 +279,7 @@ public class UserDefinedJavaClassDialog extends
BaseTransformDialog {
wlScriptFunctions.setLayoutData(fdlScriptFunctions);
// Tree View Test
- wTree = new Tree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ wTree = new HopTree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
PropsUi.setLook(wTree);
FormData fdlTree = new FormData();
fdlTree.left = new FormAttachment(0, 0);
diff --git
a/plugins/transforms/javascript/src/main/java/org/apache/hop/pipeline/transforms/javascript/ScriptValuesDialog.java
b/plugins/transforms/javascript/src/main/java/org/apache/hop/pipeline/transforms/javascript/ScriptValuesDialog.java
index 960a7c316e..7e0f71cd69 100644
---
a/plugins/transforms/javascript/src/main/java/org/apache/hop/pipeline/transforms/javascript/ScriptValuesDialog.java
+++
b/plugins/transforms/javascript/src/main/java/org/apache/hop/pipeline/transforms/javascript/ScriptValuesDialog.java
@@ -50,6 +50,7 @@ import org.apache.hop.ui.core.dialog.MessageDialogWithToggle;
import org.apache.hop.ui.core.dialog.PreviewRowsDialog;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.core.widget.JavaScriptStyledTextComp;
import org.apache.hop.ui.core.widget.StyledTextComp;
import org.apache.hop.ui.core.widget.TableView;
@@ -248,7 +249,7 @@ public class ScriptValuesDialog extends BaseTransformDialog
{
wlScriptFunctions.setLayoutData(fdlScriptFunctions);
// Tree View Test
- wTree = new Tree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ wTree = new HopTree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
PropsUi.setLook(wTree);
FormData fdlTree = new FormData();
fdlTree.left = new FormAttachment(0, 0);
diff --git
a/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/ScriptDialog.java
b/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/ScriptDialog.java
index accb534a8b..0eb0075101 100644
---
a/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/ScriptDialog.java
+++
b/plugins/transforms/script/src/main/java/org/apache/hop/pipeline/transforms/script/ScriptDialog.java
@@ -36,6 +36,7 @@ import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.core.widget.ScriptStyledTextComp;
import org.apache.hop.ui.core.widget.StyledTextComp;
import org.apache.hop.ui.core.widget.TableView;
@@ -219,7 +220,7 @@ public class ScriptDialog extends BaseTransformDialog {
wlScriptFunctions.setLayoutData(fdlScriptFunctions);
// Tree View Test
- wTree = new Tree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ wTree = new HopTree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
PropsUi.setLook(wTree);
FormData fdlTree = new FormData();
fdlTree.left = new FormAttachment(0, 0);
diff --git
a/plugins/transforms/xml/src/main/java/org/apache/hop/pipeline/transforms/xml/advancedxmloutput/XmlTreeDesigner.java
b/plugins/transforms/xml/src/main/java/org/apache/hop/pipeline/transforms/xml/advancedxmloutput/XmlTreeDesigner.java
index cd3e10b24b..7d6b70308b 100644
---
a/plugins/transforms/xml/src/main/java/org/apache/hop/pipeline/transforms/xml/advancedxmloutput/XmlTreeDesigner.java
+++
b/plugins/transforms/xml/src/main/java/org/apache/hop/pipeline/transforms/xml/advancedxmloutput/XmlTreeDesigner.java
@@ -25,6 +25,7 @@ import org.apache.hop.core.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.widget.HopTree;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.SashForm;
@@ -235,7 +236,7 @@ public class XmlTreeDesigner extends Composite {
addToolItem(tb, "ToggleLoop", e -> toggleSelectedFlag(true, false));
addToolItem(tb, "ToggleGroupBy", e -> toggleSelectedFlag(false, true));
- wTree = new Tree(top, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL |
SWT.H_SCROLL);
+ wTree = new HopTree(top, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL |
SWT.H_SCROLL);
PropsUi.setLook(wTree);
FormData fdTree = new FormData();
fdTree.left = new FormAttachment(0, 0);
diff --git
a/ui/src/main/java/org/apache/hop/ui/core/database/dialog/DatabaseExplorerDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/database/dialog/DatabaseExplorerDialog.java
index 0ba95d9808..a89e83a143 100644
---
a/ui/src/main/java/org/apache/hop/ui/core/database/dialog/DatabaseExplorerDialog.java
+++
b/ui/src/main/java/org/apache/hop/ui/core/database/dialog/DatabaseExplorerDialog.java
@@ -50,6 +50,7 @@ import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.gui.GuiToolbarWidgets;
import org.apache.hop.ui.core.gui.IToolbarContainer;
import org.apache.hop.ui.core.gui.WindowProperty;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.hopgui.HopGui;
import org.apache.hop.ui.hopgui.ToolbarFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
@@ -249,7 +250,7 @@ public class DatabaseExplorerDialog extends Dialog {
refreshButtons(null);
// Tree
- wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER /*|
(multiple?SWT.CHECK:SWT.NONE)*/);
+ wTree = new HopTree(shell, SWT.SINGLE | SWT.BORDER /*|
(multiple?SWT.CHECK:SWT.NONE)*/);
PropsUi.setLook(wTree);
FormData fdTree = new FormData();
fdTree.left = new FormAttachment(0, 0); // To the right of the label
diff --git a/ui/src/main/java/org/apache/hop/ui/core/vfs/HopVfsFileDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/vfs/HopVfsFileDialog.java
index 7b0f75a6d2..248696bd19 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/vfs/HopVfsFileDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/vfs/HopVfsFileDialog.java
@@ -61,6 +61,7 @@ import org.apache.hop.ui.core.gui.GuiToolbarWidgets;
import org.apache.hop.ui.core.gui.HopNamespace;
import org.apache.hop.ui.core.gui.IToolbarContainer;
import org.apache.hop.ui.core.gui.WindowProperty;
+import org.apache.hop.ui.core.widget.HopTree;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.core.widget.TreeUtil;
import org.apache.hop.ui.hopgui.HopGui;
@@ -500,7 +501,7 @@ public class HopVfsFileDialog implements IFileDialog,
IDirectoryDialog {
SashForm browseSash = new SashForm(browserComposite, SWT.VERTICAL);
- wBrowser = new Tree(browseSash, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ wBrowser = new HopTree(browseSash, SWT.SINGLE | SWT.H_SCROLL |
SWT.V_SCROLL);
PropsUi.setLook(wBrowser);
wBrowser.setHeaderVisible(true);
wBrowser.setLinesVisible(false); // TODO needed?
diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/FileTree.java
b/ui/src/main/java/org/apache/hop/ui/core/widget/FileTree.java
index 8b89eff4c0..de7150104d 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/FileTree.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/FileTree.java
@@ -80,7 +80,7 @@ public class FileTree extends Composite {
SWT.Selection, event ->
findDependencies.set(btnFindDependencies.getSelection()));
btnFindDependencies.setLayoutData(new
FormDataBuilder().left().fullWidth().bottom().result());
- tree = new Tree(this, SWT.CHECK | SWT.MULTI | SWT.BORDER);
+ tree = new HopTree(this, SWT.CHECK | SWT.MULTI | SWT.BORDER);
PropsUi.setLook(tree);
tree.setLayoutData(
new FormDataBuilder()
diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/HopTree.java
b/ui/src/main/java/org/apache/hop/ui/core/widget/HopTree.java
new file mode 100644
index 0000000000..7811b1c558
--- /dev/null
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/HopTree.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.core.widget;
+
+import org.apache.hop.ui.core.PropsUi;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+
+/**
+ * A drop-in replacement for SWT {@link Tree} that caps its <em>preferred</em>
height.
+ *
+ * <p>A plain {@link Tree} reports a {@link #computeSize(int, int, boolean)
computeSize} height that
+ * grows with the number of (visible) items. When such a tree is placed in a
dialog that sizes
+ * itself to its content (i.e. {@code shell.pack()} on first open, before any
geometry is
+ * remembered), a long list makes the whole shell grow taller than the screen.
This mirrors the
+ * problem that {@link TableView} already solves for tables (issue #7220).
+ *
+ * <p>This widget only ever <em>shrinks</em> an oversized preferred height
down to {@link
+ * TableView#HEIGHT_HINT_MAX_PX} (scaled by the native zoom factor); it never
enlarges a small tree.
+ * Because the cap applies to {@code computeSize} only, the tree still
stretches to fill whatever
+ * space its layout gives it (e.g. a {@code FormAttachment} to the bottom of
the shell, or a manual
+ * resize) — exactly like {@link TableView}.
+ */
+public class HopTree extends Tree {
+
+ public HopTree(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ @Override
+ public Point computeSize(int wHint, int hHint, boolean changed) {
+ Point size = super.computeSize(wHint, hHint, changed);
+ if (hHint == SWT.DEFAULT) {
+ int maxHeight =
+ (int) Math.round(TableView.HEIGHT_HINT_MAX_PX *
PropsUi.getNativeZoomFactor());
+ if (size.y > maxHeight) {
+ size.y = maxHeight;
+ }
+ }
+ return size;
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Allow subclassing of the SWT Tree widget: this is a thin,
behaviour-only wrapper that adds
+ // no native resources and overrides nothing but computeSize.
+ }
+}