-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract smallbutton factory methods to their own class
- Loading branch information
Showing
2 changed files
with
44 additions
and
32 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/java/org/apache/log4j/chainsaw/components/logpanel/ElementFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters