You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gr...@apache.org on 2023/10/01 17:29:50 UTC
[logging-chainsaw] branch master updated: extract smallbutton factory methods to their own class
This is an automated email from the ASF dual-hosted git repository.
grobmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git
The following commit(s) were added to refs/heads/master by this push:
new 21a1e25 extract smallbutton factory methods to their own class
21a1e25 is described below
commit 21a1e258d401acc291d7d6e3ae5859accf31136c
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sun Oct 1 19:29:44 2023 +0200
extract smallbutton factory methods to their own class
---
.../components/logpanel/ElementFactory.java | 42 ++++++++++++++++++++++
.../chainsaw/components/logpanel/LogPanel.java | 34 ++----------------
2 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/src/main/java/org/apache/log4j/chainsaw/components/logpanel/ElementFactory.java b/src/main/java/org/apache/log4j/chainsaw/components/logpanel/ElementFactory.java
new file mode 100644
index 0000000..b7ab57d
--- /dev/null
+++ b/src/main/java/org/apache/log4j/chainsaw/components/logpanel/ElementFactory.java
@@ -0,0 +1,42 @@
+package org.apache.log4j.chainsaw.components.logpanel;
+
+import org.apache.log4j.chainsaw.components.elements.SmallButton;
+import org.apache.log4j.chainsaw.icons.ChainsawIcons;
+
+import javax.swing.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class ElementFactory {
+ public static SmallButton createFindNextButton(Runnable action) {
+ SmallButton button = new SmallButton.Builder()
+ .action(action)
+ .name("Find next")
+ .text("")
+ .smallIconUrl(ChainsawIcons.DOWN)
+ .shortDescription("Find the next occurrence of the rule from the current row")
+ .keyStroke(KeyStroke.getKeyStroke("F3"))
+ .build();
+
+ button.getActionMap().put(button.getActionName(), button.getAction());
+ button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
+ .put(button.getActionAcceleratorKey(), button.getActionName());
+ return button;
+ }
+
+ public static SmallButton createFindPreviousButton(Runnable action) {
+ SmallButton button = new SmallButton.Builder()
+ .action(action)
+ .name("Find previous")
+ .text("")
+ .smallIconUrl(ChainsawIcons.UP)
+ .shortDescription("Find the previous occurrence of the rule from the current row")
+ .keyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_MASK))
+ .build();
+
+ button.getActionMap().put(button.getActionName(), button.getAction());
+ button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
+ .put(button.getActionAcceleratorKey(), button.getActionName());
+ return button;
+ }
+}
diff --git a/src/main/java/org/apache/log4j/chainsaw/components/logpanel/LogPanel.java b/src/main/java/org/apache/log4j/chainsaw/components/logpanel/LogPanel.java
index bf4bab1..4970d5b 100644
--- a/src/main/java/org/apache/log4j/chainsaw/components/logpanel/LogPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/components/logpanel/LogPanel.java
@@ -1728,8 +1728,8 @@ public class LogPanel extends DockablePanel implements ChainsawEventBatchListene
upperPanel.add(Box.createHorizontalStrut(3));
//add up & down search
- upperPanel.add(createFindNextButton());
- upperPanel.add(createFindPreviousButton());
+ upperPanel.add(ElementFactory.createFindNextButton(this::findNext));
+ upperPanel.add(ElementFactory.createFindPreviousButton(this::findPrevious));
upperPanel.add(Box.createHorizontalStrut(3));
@@ -1806,37 +1806,7 @@ public class LogPanel extends DockablePanel implements ChainsawEventBatchListene
return upperPanel;
}
- private SmallButton createFindNextButton() {
- SmallButton button = new SmallButton.Builder()
- .action(this::findNext)
- .name("Find next")
- .text("")
- .smallIconUrl(ChainsawIcons.DOWN)
- .shortDescription("Find the next occurrence of the rule from the current row")
- .keyStroke(KeyStroke.getKeyStroke("F3"))
- .build();
-
- button.getActionMap().put(button.getActionName(), button.getAction());
- button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
- .put(button.getActionAcceleratorKey(), button.getActionName());
- return button;
- }
- private SmallButton createFindPreviousButton() {
- SmallButton button = new SmallButton.Builder()
- .action(this::findPrevious)
- .name("Find previous")
- .text("")
- .smallIconUrl(ChainsawIcons.UP)
- .shortDescription("Find the previous occurrence of the rule from the current row")
- .keyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_MASK))
- .build();
-
- button.getActionMap().put(button.getActionName(), button.getAction());
- button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
- .put(button.getActionAcceleratorKey(), button.getActionName());
- return button;
- }
private String getValueOf(int row, int column) {
if (currentTable == null) {