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 08c0721754 Only truncate data related tableviews, fixes #8060 (#8104)
08c0721754 is described below
commit 08c0721754d1b863091b55ee491a50a00194bb9d
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Wed Aug 26 14:31:36 2026 +0200
Only truncate data related tableviews, fixes #8060 (#8104)
---
.../org/apache/hop/ui/testing/EditRowsDialog.java | 2 +
.../transforms/datagrid/DataGridDialog.java | 3 +
.../apache/hop/ui/core/dialog/EditRowsDialog.java | 2 +
.../hop/ui/core/dialog/PreviewRowsDialog.java | 3 +
.../apache/hop/ui/core/dialog/ShowRowsDialog.java | 2 +
.../org/apache/hop/ui/core/widget/TableView.java | 82 +++++++++++++++++-----
.../core/dialog/messages/messages_en_US.properties | 8 +--
7 files changed, 81 insertions(+), 21 deletions(-)
diff --git
a/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/EditRowsDialog.java
b/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/EditRowsDialog.java
index eeef5d237e..9c08df6e2c 100644
---
a/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/EditRowsDialog.java
+++
b/plugins/misc/testing/src/main/java/org/apache/hop/ui/testing/EditRowsDialog.java
@@ -207,6 +207,8 @@ public class EditRowsDialog {
null,
props);
wFields.setShowingBlueNullValues(true);
+ // Data rows, not configuration: draw long / multi-line values shortened.
+ wFields.setShortenDisplayedValues(true);
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
diff --git
a/plugins/transforms/datagrid/src/main/java/org/apache/hop/pipeline/transforms/datagrid/DataGridDialog.java
b/plugins/transforms/datagrid/src/main/java/org/apache/hop/pipeline/transforms/datagrid/DataGridDialog.java
index 50201dbcb3..5a9fedf5cf 100644
---
a/plugins/transforms/datagrid/src/main/java/org/apache/hop/pipeline/transforms/datagrid/DataGridDialog.java
+++
b/plugins/transforms/datagrid/src/main/java/org/apache/hop/pipeline/transforms/datagrid/DataGridDialog.java
@@ -262,6 +262,9 @@ public class DataGridDialog extends BaseTransformDialog {
List<DataGridDataMeta> lines = dataGridMeta.getDataLines();
wData = new TableView(variables, wDataComp, SWT.NONE, columns,
lines.size(), lsMod, props);
wData.setSortable(false);
+ // The data tab holds data rows: draw long / multi-line values shortened,
the cell keeps the
+ // full value.
+ wData.setShortenDisplayedValues(true);
for (int i = 0; i < lines.size(); i++) {
DataGridDataMeta line = lines.get(i);
diff --git a/ui/src/main/java/org/apache/hop/ui/core/dialog/EditRowsDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/dialog/EditRowsDialog.java
index cb8243ec74..70d202d09c 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/EditRowsDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/EditRowsDialog.java
@@ -207,6 +207,8 @@ public class EditRowsDialog {
null,
props);
wFields.setShowingBlueNullValues(true);
+ // Data rows, not configuration: draw long / multi-line values shortened.
+ wFields.setShortenDisplayedValues(true);
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
diff --git
a/ui/src/main/java/org/apache/hop/ui/core/dialog/PreviewRowsDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/dialog/PreviewRowsDialog.java
index e45997f780..4e5db37a60 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/PreviewRowsDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/PreviewRowsDialog.java
@@ -303,6 +303,9 @@ public class PreviewRowsDialog {
new TableView(
variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
columns, 0, null, props);
wFields.setShowingBlueNullValues(true);
+ // A preview holds data, not configuration: values can be long or
multi-line and there can be
+ // thousands of them, so draw them shortened (the full value stays in the
cell).
+ wFields.setShortenDisplayedValues(true);
// Rows stream in and are appended in load order, so sorting them would
fight with the rows
// still arriving. Keep the preview in load order.
wFields.setSortable(false);
diff --git a/ui/src/main/java/org/apache/hop/ui/core/dialog/ShowRowsDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/dialog/ShowRowsDialog.java
index 9ce9b421d1..455d42d0b4 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/ShowRowsDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/ShowRowsDialog.java
@@ -160,6 +160,8 @@ public final class ShowRowsDialog {
null,
PropsUi.getInstance());
view.setShowingBlueNullValues(true);
+ // Data rows, not configuration: draw long / multi-line values shortened.
+ view.setShortenDisplayedValues(true);
// Column sorting is enabled: items carry their full values, so a sort
reorders complete rows.
view.setSortable(true);
diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
index 7bf3d2b308..3e69167ab5 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
@@ -170,6 +170,22 @@ public class TableView extends Composite {
private final Composite composite;
private final ColumnInfo[] columns;
@Getter @Setter private boolean readonly;
+
+ /**
+ * Draw long / multi-line text cells shortened and single-lined (see {@link
+ * #formatCellValueForDisplay(String)}). Off by default: it was added to
keep the data-heavy grids
+ * responsive — the row preview and the data grids — and elsewhere it only
changes how a
+ * configuration value looks. Switch it on per grid with {@link
+ * #setShortenDisplayedValues(boolean)}.
+ */
+ private boolean shortenDisplayedValues;
+
+ /** Layout of the table itself, kept so the web footnote can be inserted
underneath it later. */
+ private FormData fdTable;
+
+ /** Hop Web only, and only for grids that shorten values: see {@link
#addWebNewlineHint()}. */
+ private Label webNewlineHint;
+
private int buttonRowNr;
private int buttonColNr;
private String buttonContent;
@@ -525,7 +541,7 @@ public class TableView extends Composite {
PropsUi.setLook(table);
table.setLinesVisible(true);
- FormData fdTable = new FormData();
+ fdTable = new FormData();
fdTable.left = new FormAttachment(0, 0);
fdTable.right = new FormAttachment(100, 0);
fdTable.width = WIDTH_HINT_PX;
@@ -537,21 +553,6 @@ public class TableView extends Composite {
fdTable.bottom = new FormAttachment(100, 0);
table.setLayoutData(fdTable);
- // Hop Web: RWT can't render line breaks in a table cell and can't
owner-draw over it (both of
- // which we use on the desktop). Add a footnote pointing users to the
editor for the full value.
- if (EnvironmentUtils.getInstance().isWeb()) {
- Label webNewlineHint = new Label(this, SWT.LEFT);
- PropsUi.setLook(webNewlineHint);
- webNewlineHint.setText(BaseMessages.getString(PKG,
"TableView.WebNewlineHint.Label"));
- FormData fdHint = new FormData();
- fdHint.left = new FormAttachment(0, 0);
- fdHint.right = new FormAttachment(100, 0);
- fdHint.bottom = new FormAttachment(100, 0);
- webNewlineHint.setLayoutData(fdHint);
- // The table now stops just above the footnote.
- fdTable.bottom = new FormAttachment(webNewlineHint,
-PropsUi.getMargin());
- }
-
tableColumn = new TableColumn[columns.length + 1];
tableColumn[0] = new TableColumn(table, SWT.RIGHT);
tableColumn[0].setResizable(true);
@@ -2250,6 +2251,50 @@ public class TableView extends Composite {
});
}
+ /**
+ * Shorten long / multi-line text cells for display in this grid: the cell
is drawn cut to {@link
+ * PropsUi#getMaxPreviewCellLength()} characters and on a single line, while
the stored value —
+ * what is copied, exported and saved — stays complete.
+ *
+ * <p>Off by default. Switch it on for grids that show data rather than
configuration (the row
+ * preview, the data grids), where values are long, numerous, or multi-line
and drawing them in
+ * full costs real time.
+ */
+ public void setShortenDisplayedValues(boolean shortenDisplayedValues) {
+ this.shortenDisplayedValues = shortenDisplayedValues;
+ if (shortenDisplayedValues) {
+ addWebNewlineHint();
+ }
+ if (table != null && !table.isDisposed()) {
+ table.redraw();
+ }
+ }
+
+ public boolean isShortenDisplayedValues() {
+ return shortenDisplayedValues;
+ }
+
+ /**
+ * Hop Web: RWT can't render line breaks in a table cell and can't
owner-draw over it (both of
+ * which we use on the desktop). Add a footnote pointing users to the editor
for the full value.
+ */
+ private void addWebNewlineHint() {
+ if (webNewlineHint != null || !EnvironmentUtils.getInstance().isWeb()) {
+ return;
+ }
+ webNewlineHint = new Label(this, SWT.LEFT);
+ PropsUi.setLook(webNewlineHint);
+ webNewlineHint.setText(BaseMessages.getString(PKG,
"TableView.WebNewlineHint.Label"));
+ FormData fdHint = new FormData();
+ fdHint.left = new FormAttachment(0, 0);
+ fdHint.right = new FormAttachment(100, 0);
+ fdHint.bottom = new FormAttachment(100, 0);
+ webNewlineHint.setLayoutData(fdHint);
+ // The table now stops just above the footnote.
+ fdTable.bottom = new FormAttachment(webNewlineHint, -PropsUi.getMargin());
+ layout(true, true);
+ }
+
/**
* Format a cell value for display in a grid: keep it single-line and short
so the native table
* stays fast. Honors the Look & Feel settings {@link
PropsUi#getMaxPreviewCellLength()} and
@@ -2331,7 +2376,10 @@ public class TableView extends Composite {
* desktop owner-draw so {@link TableItem#getText(int)} keeps returning the
full, saved value.
*/
private String customCellText(TableItem item, int columnIndex) {
- if (item == null || columnIndex < 1 || columnIndex - 1 >= columns.length) {
+ if (!shortenDisplayedValues
+ || item == null
+ || columnIndex < 1
+ || columnIndex - 1 >= columns.length) {
return null;
}
ColumnInfo colinfo = columns[columnIndex - 1];
diff --git
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
index 9ec9ef0477..45936bfa78 100644
---
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
@@ -206,10 +206,10 @@ FindReplaceDialog.Shell.ReplaceTitle=Find and replace
FindReplaceDialog.Status.EmptyFind=Enter text to find
FindReplaceDialog.Status.NotFound=Text not found
FindReplaceDialog.Status.ReplaceAllCount={0} occurrence(s) replaced
-EnterOptionsDialog.MaxPreviewCellLength.Label=Maximum grid cell length
-EnterOptionsDialog.MaxPreviewCellLength.ToolTip=The maximum number of
characters shown in a single grid cell. Longer values are only shortened for
display\: click a cell to see its full value in place, or use the expand icon
to open it in the multi-line editor. Copying, exporting and saving always use
the full value. Set to 0 to disable shortening. This has no effect in the web
version.
-EnterOptionsDialog.ShowPreviewLineBreaks.Label=Show line breaks as symbols in
grid cells
-EnterOptionsDialog.ShowPreviewLineBreaks.ToolTip=When enabled, line breaks and
tabs in grid cells are shown as symbols on a single line. When disabled
(default), a value that contains a line break is cut at the first break and
marked with an ellipsis. Either way this only affects how the cell is drawn\:
click a cell to see its full value, and copying or exporting keeps every line
break. This has no effect in the web version.
+EnterOptionsDialog.MaxPreviewCellLength.Label=Maximum data grid cell length
+EnterOptionsDialog.MaxPreviewCellLength.ToolTip=The maximum number of
characters shown in a single cell of a data grid (the row preview, the data
grid transform, the rows viewers). Longer values are only shortened for
display\: click a cell to see its full value in place, or use the expand icon
to open it in the multi-line editor. Copying, exporting and saving always use
the full value. Set to 0 to disable shortening. Configuration grids are never
shortened, and this has no effect in the [...]
+EnterOptionsDialog.ShowPreviewLineBreaks.Label=Show line breaks as symbols in
data grid cells
+EnterOptionsDialog.ShowPreviewLineBreaks.ToolTip=When enabled, line breaks and
tabs in data grid cells are shown as symbols on a single line. When disabled
(default), a value that contains a line break is cut at the first break and
marked with an ellipsis. Either way this only affects how the cell is drawn\:
click a cell to see its full value, and copying or exporting keeps every line
break. Configuration grids are never shortened, and this has no effect in the
web version.
EnterOptionsDialog.ShowViewport.Label=Show viewport
EnterOptionsDialog.ShowViewport.ToolTip=If enabled, the viewport in the bottom
right will be shown
EnterOptionsDialog.SortFieldByName.Label=Sort field names alphabetically in
dropdowns