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 45c45c5a23 add separate log layout and font zoom to hop-gui, resolves
#5927 (#5928)
45c45c5a23 is described below
commit 45c45c5a23b3c52b33af4a8ada2521ef07a81397
Author: Alex Mueller <[email protected]>
AuthorDate: Mon Nov 10 17:38:10 2025 +0100
add separate log layout and font zoom to hop-gui, resolves #5927 (#5928)
---
.../hop/core/logging/FixedWidthLogLayout.java | 92 ++++++++++++++++++++++
.../ui/hopgui/file/pipeline/HopGuiLogBrowser.java | 4 +-
.../delegates/HopGuiPipelineLogDelegate.java | 39 +++++++++
.../apache/hop/ui/hopgui/file/shared/TextZoom.java | 66 ++++++++++++++++
.../delegates/HopGuiWorkflowLogDelegate.java | 39 +++++++++
.../ui/hopgui/messages/messages_de_DE.properties | 4 +-
.../ui/hopgui/messages/messages_en_US.properties | 5 +-
7 files changed, 244 insertions(+), 5 deletions(-)
diff --git
a/core/src/main/java/org/apache/hop/core/logging/FixedWidthLogLayout.java
b/core/src/main/java/org/apache/hop/core/logging/FixedWidthLogLayout.java
new file mode 100644
index 0000000000..4d76d74d6f
--- /dev/null
+++ b/core/src/main/java/org/apache/hop/core/logging/FixedWidthLogLayout.java
@@ -0,0 +1,92 @@
+/*
+ * 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.core.logging;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import org.apache.hop.core.Const;
+
+public class FixedWidthLogLayout {
+ private static final ThreadLocal<SimpleDateFormat> LOCAL_SIMPLE_DATE_PARSER =
+ ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy/MM/dd
HH:mm:ss"));
+
+ private static final int MAX_LOG_LEVEL_LENGTH =
+ Arrays.stream(LogLevel.getLogLevelCodes()).map(String::length).reduce(0,
Integer::max);
+
+ private boolean timeAdded;
+
+ public FixedWidthLogLayout() {
+ this(true);
+ }
+
+ public FixedWidthLogLayout(boolean addTime) {
+ this.timeAdded = addTime;
+ }
+
+ public String format(HopLoggingEvent event) {
+ StringBuilder line = new StringBuilder();
+
+ String dateTimeString = "";
+
+ if (timeAdded) {
+ dateTimeString = LOCAL_SIMPLE_DATE_PARSER.get().format(new
Date(event.timeStamp)) + " ";
+ }
+
+ Object object = event.getMessage();
+
+ if (object instanceof LogMessage message) {
+
+ String logLevel = getLogLevelPadded(message.getLevel());
+
+ String[] parts =
+ message.getMessage() == null ? new String[] {} :
message.getMessage().split(Const.CR);
+
+ for (int i = 0; i < parts.length; i++) {
+ if (!message.isSimplified()) {
+ line.append(dateTimeString);
+ line.append(logLevel);
+
+ // Include the subject too on every line...
+ if (message.getSubject() != null) {
+ line.append(message.getSubject());
+ if (message.getCopy() != null) {
+ line.append(".").append(message.getCopy());
+ }
+ line.append(" - ");
+ }
+ }
+
+ line.append(parts[i]);
+ if (i < parts.length - 1) {
+ line.append(Const.CR); // put the CR's back in there!
+ }
+ }
+ } else {
+ line.append(dateTimeString);
+ line.append((object != null ? object.toString() : "<null>"));
+ }
+
+ return line.toString();
+ }
+
+ private String getLogLevelPadded(LogLevel logLevel) {
+ String code = logLevel.getCode();
+ return "[" + code + "] " + " ".repeat(Math.max(MAX_LOG_LEVEL_LENGTH -
code.length(), 0));
+ }
+}
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
index a4bbae3b70..432e0ad340 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiLogBrowser.java
@@ -28,7 +28,7 @@ import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.apache.hop.core.Const;
import org.apache.hop.core.config.HopConfig;
-import org.apache.hop.core.logging.HopLogLayout;
+import org.apache.hop.core.logging.FixedWidthLogLayout;
import org.apache.hop.core.logging.HopLogStore;
import org.apache.hop.core.logging.HopLoggingEvent;
import org.apache.hop.core.logging.IHasLogChannel;
@@ -76,7 +76,7 @@ public class HopGuiLogBrowser {
//
final AtomicInteger lastLogId = new AtomicInteger(-1);
final AtomicBoolean busy = new AtomicBoolean(false);
- final HopLogLayout logLayout = new HopLogLayout(true);
+ final FixedWidthLogLayout logLayout = new FixedWidthLogLayout(true);
// Refresh the log every second or so
//
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineLogDelegate.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineLogDelegate.java
index ca6047c521..aa7d9feb5a 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineLogDelegate.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineLogDelegate.java
@@ -38,6 +38,7 @@ import org.apache.hop.ui.hopgui.HopGui;
import org.apache.hop.ui.hopgui.file.IHopFileTypeHandler;
import org.apache.hop.ui.hopgui.file.pipeline.HopGuiLogBrowser;
import org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph;
+import org.apache.hop.ui.hopgui.file.shared.TextZoom;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.FormAttachment;
@@ -58,6 +59,9 @@ public class HopGuiPipelineLogDelegate {
public static final String TOOLBAR_ICON_LOG_COPY_TO_CLIPBOARD =
"ToolbarIcon-10020-LogCopyToClipboard";
public static final String TOOLBAR_ICON_LOG_PAUSE_RESUME =
"ToolbarIcon-10030-LogPauseResume";
+ public static final String TOOLBAR_ICON_LOG_INCREASE_FONT =
"ToolbarIcon-10040-LogIncreaseFont";
+ public static final String TOOLBAR_ICON_LOG_DECREASE_FONT =
"ToolbarIcon-10050-LogDecreaseFont";
+ public static final String TOOLBAR_ICON_LOG_RESET_FONT =
"ToolbarIcon-10060-LogResetFont";
private final HopGuiPipelineGraph pipelineGraph;
@@ -66,6 +70,7 @@ public class HopGuiPipelineLogDelegate {
@Getter private CTabItem pipelineLogTab;
private Text pipelineLogText;
+ private TextZoom textZoom;
private ToolBar toolbar;
private GuiToolbarWidgets toolBarWidgets;
@@ -119,6 +124,10 @@ public class HopGuiPipelineLogDelegate {
fdText.top = new FormAttachment(toolbar, 0);
fdText.bottom = new FormAttachment(100, 0);
pipelineLogText.setLayoutData(fdText);
+
+ this.textZoom = new TextZoom(pipelineLogText,
GuiResource.getInstance().getFontFixed());
+ this.textZoom.resetFont();
+
// add a CR to avoid fontStyle from getting lost on macos HOP-2583
if (OsHelper.isMac()) {
pipelineLogText.setText(Const.CR);
@@ -306,6 +315,36 @@ public class HopGuiPipelineLogDelegate {
}
}
+ @GuiToolbarElement(
+ root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
+ id = TOOLBAR_ICON_LOG_INCREASE_FONT,
+ toolTip =
"i18n:org.apache.hop.ui.hopgui:WorkflowLog.Button.IncreaseFont",
+ image = "ui/images/zoom-in.svg",
+ separator = true)
+ public void increaseFont() {
+ this.textZoom.increaseFont();
+ }
+
+ @GuiToolbarElement(
+ root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
+ id = TOOLBAR_ICON_LOG_DECREASE_FONT,
+ toolTip =
"i18n:org.apache.hop.ui.hopgui:WorkflowLog.Button.DecreaseFont",
+ image = "ui/images/zoom-out.svg",
+ separator = false)
+ public void decreaseFont() {
+ this.textZoom.decreaseFont();
+ }
+
+ @GuiToolbarElement(
+ root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
+ id = TOOLBAR_ICON_LOG_RESET_FONT,
+ toolTip = "i18n:org.apache.hop.ui.hopgui:WorkflowLog.Button.ResetFont",
+ image = "ui/images/zoom-100.svg",
+ separator = false)
+ public void resetFont() {
+ this.textZoom.resetFont();
+ }
+
public boolean hasSelectedText() {
return pipelineLogText != null
&& !pipelineLogText.isDisposed()
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/TextZoom.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/TextZoom.java
new file mode 100644
index 0000000000..a9df64417d
--- /dev/null
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/TextZoom.java
@@ -0,0 +1,66 @@
+/*
+ * 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.hopgui.file.shared;
+
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Text;
+
+public class TextZoom {
+ public static final int STEP_DEFAULT = 1;
+ public static final int MIN_HEIGHT = 4;
+
+ private Text widget;
+ private Font font;
+ private int step;
+ private int minHeight;
+
+ public TextZoom(Text widget, Font font) {
+ this(widget, font, TextZoom.STEP_DEFAULT);
+ }
+
+ public TextZoom(Text widget, Font font, int step) {
+ this(widget, font, step, MIN_HEIGHT);
+ }
+
+ public TextZoom(Text widget, Font font, int step, int minHeight) {
+ this.widget = widget;
+ this.font = font;
+ this.step = step;
+ this.minHeight = minHeight;
+ }
+
+ public void increaseFont() {
+ increaseHeightBy(step);
+ }
+
+ public void decreaseFont() {
+ increaseHeightBy(-step);
+ }
+
+ public void resetFont() {
+ widget.setFont(font);
+ }
+
+ private void increaseHeightBy(int points) {
+ FontData fontData = widget.getFont().getFontData()[0];
+ int newHeight = Math.max(minHeight, fontData.getHeight() + points);
+ fontData.setHeight(newHeight);
+ widget.setFont(new Font(widget.getDisplay(), fontData));
+ }
+}
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowLogDelegate.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowLogDelegate.java
index b4f22ab7af..6b8b34149b 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowLogDelegate.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowLogDelegate.java
@@ -33,6 +33,7 @@ import org.apache.hop.ui.core.widget.OsHelper;
import org.apache.hop.ui.hopgui.HopGui;
import org.apache.hop.ui.hopgui.file.IHopFileTypeHandler;
import org.apache.hop.ui.hopgui.file.pipeline.HopGuiLogBrowser;
+import org.apache.hop.ui.hopgui.file.shared.TextZoom;
import org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.action.ActionMeta;
@@ -57,6 +58,9 @@ public class HopGuiWorkflowLogDelegate {
public static final String TOOLBAR_ICON_LOG_COPY_TO_CLIPBOARD =
"ToolbarIcon-10020-LogCopyToClipboard";
public static final String TOOLBAR_ICON_LOG_PAUSE_RESUME =
"ToolbarIcon-10030-LogPauseResume";
+ public static final String TOOLBAR_ICON_LOG_INCREASE_FONT =
"ToolbarIcon-10040-LogIncreaseFont";
+ public static final String TOOLBAR_ICON_LOG_DECREASE_FONT =
"ToolbarIcon-10050-LogDecreaseFont";
+ public static final String TOOLBAR_ICON_LOG_RESET_FONT =
"ToolbarIcon-10060-LogResetFont";
private HopGui hopGui;
private HopGuiWorkflowGraph workflowGraph;
@@ -64,6 +68,7 @@ public class HopGuiWorkflowLogDelegate {
private CTabItem workflowLogTab;
private Text workflowLogText;
+ private TextZoom textZoom;
/** The number of lines in the log tab */
private Composite workflowLogComposite;
@@ -121,6 +126,10 @@ public class HopGuiWorkflowLogDelegate {
fdText.top = new FormAttachment((Control) toolbar, 0);
fdText.bottom = new FormAttachment(100, 0);
workflowLogText.setLayoutData(fdText);
+
+ this.textZoom = new TextZoom(workflowLogText,
GuiResource.getInstance().getFontFixed());
+ this.textZoom.resetFont();
+
// add a CR to avoid fontStyle from getting lost on macos HOP-2583
if (OsHelper.isMac()) {
workflowLogText.setText(Const.CR);
@@ -284,6 +293,36 @@ public class HopGuiWorkflowLogDelegate {
}
}
+ @GuiToolbarElement(
+ root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
+ id = TOOLBAR_ICON_LOG_INCREASE_FONT,
+ toolTip =
"i18n:org.apache.hop.ui.hopgui:WorkflowLog.Button.IncreaseFont",
+ image = "ui/images/zoom-in.svg",
+ separator = true)
+ public void increaseFont() {
+ this.textZoom.increaseFont();
+ }
+
+ @GuiToolbarElement(
+ root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
+ id = TOOLBAR_ICON_LOG_DECREASE_FONT,
+ toolTip =
"i18n:org.apache.hop.ui.hopgui:WorkflowLog.Button.DecreaseFont",
+ image = "ui/images/zoom-out.svg",
+ separator = false)
+ public void decreaseFont() {
+ this.textZoom.decreaseFont();
+ }
+
+ @GuiToolbarElement(
+ root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
+ id = TOOLBAR_ICON_LOG_RESET_FONT,
+ toolTip = "i18n:org.apache.hop.ui.hopgui:WorkflowLog.Button.ResetFont",
+ image = "ui/images/zoom-100.svg",
+ separator = false)
+ public void resetFont() {
+ this.textZoom.resetFont();
+ }
+
public boolean hasSelectedText() {
return workflowLogText != null
&& !workflowLogText.isDisposed()
diff --git
a/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_de_DE.properties
b/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_de_DE.properties
index 76a3d01b15..a61a310151 100644
---
a/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_de_DE.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_de_DE.properties
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
HopGui.Application.Name=Hop
HopGui.Dialog.ActionCanNotBeChanged.Message=Die Workflow-Action kann nicht
ge\u00E4ndert werden!
HopGui.Dialog.ActionCanNotBeChanged.Title=Sorry...
@@ -241,6 +240,9 @@ WorkflowGraph.Dialog.HopCausesLoop.Message=Dieser Hop
verursacht eine unerlaubte
WorkflowGraph.Dialog.HopCausesLoop.Title=Endlosschleife!
WorkflowLog.Button.LogSettings=Log Einstellungen
WorkflowLog.Button.Pause=Workflow Log pausieren
+WorkflowLog.Button.IncreaseFont=Schrift vergr\u00F6\u00DFern
+WorkflowLog.Button.DecreaseFont=Schrift verkleinern
+WorkflowLog.Button.ResetFont=Schriftgr\u00F6\u00DFe zur\u00FCcksetzen
WorkflowLog.Button.ShowErrorLines=Fehlerzeilen anzeigen
WorkflowLog.Dialog.SaveJobBeforeRunning.Message=Den Workflow speichern, bevor
er gestartet wird.
WorkflowLog.Dialog.SaveJobBeforeRunning.Title=Workflow speichern
diff --git
a/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
b/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
index c4cca29786..dd7820a9d6 100644
---
a/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
@@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-
HopGui.Application.Name=Hop
HopGui.Dialog.ActionCanNotBeChanged.Message=This action can''t be changed\!
HopGui.Dialog.ActionCanNotBeChanged.Title=Sorry...
@@ -271,6 +269,9 @@ WorkflowLog.Button.ClearLog=Clear log
WorkflowLog.Button.LogCopyToClipboard=Copy workflow log to clipboard
WorkflowLog.Button.LogSettings=Log settings
WorkflowLog.Button.Pause=Pause workflow log
+WorkflowLog.Button.IncreaseFont=Increase font size
+WorkflowLog.Button.DecreaseFont=Decrease font size
+WorkflowLog.Button.ResetFont=Reset font size
WorkflowLog.Button.ShowErrorLines=Show error lines
WorkflowLog.Dialog.SaveJobBeforeRunning.Message=Please save the workflow
before running it.
WorkflowLog.Dialog.SaveJobBeforeRunning.Title=Save workflow