-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e00d427
commit d03be1a
Showing
12 changed files
with
269 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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 de.tinycodecrank.l4j.ui.search; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
import javax.swing.JTextField; | ||
|
||
import de.tinycodecrank.l4j.startup.Localizer4J; | ||
import de.tinycodecrank.util.swing.DialogLogicTemplate; | ||
|
||
final class BL extends DialogLogicTemplate<SearchGui, SearchKeyData> | ||
{ | ||
private SearchKeyData data; | ||
|
||
BL(SearchGui gui, SearchKeyData data) | ||
{ | ||
super(gui); | ||
this.data = data; | ||
} | ||
|
||
ActionListener search(JTextField text) | ||
{ | ||
return ae -> data.setSelection().accept(text.getText()); | ||
} | ||
|
||
void abort(ActionEvent ae) | ||
{ | ||
gui.if_(gui -> gui.setVisible(false)); | ||
} | ||
|
||
@Override | ||
protected void disposeAction() | ||
{ | ||
gui.if_(gui -> | ||
{ | ||
Localizer4J.prefs.searchWindow.posX = gui.getX(); | ||
Localizer4J.prefs.searchWindow.posY = gui.getY(); | ||
Localizer4J.prefs.searchWindow.width = gui.getWidth(); | ||
Localizer4J.prefs.searchWindow.height = gui.getHeight(); | ||
}); | ||
} | ||
} |
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,54 @@ | ||
package de.tinycodecrank.l4j.ui.search; | ||
|
||
import static de.tinycodecrank.l4j.ui.search.SearchGui.*; | ||
|
||
import java.awt.BorderLayout; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
import javax.swing.Box; | ||
import javax.swing.JCheckBox; | ||
import javax.swing.JPanel; | ||
import javax.swing.JTextField; | ||
|
||
import de.tinycodecrank.l4j.prefs.GuiPrefs; | ||
import de.tinycodecrank.monads.opt.Opt; | ||
import de.tinycodecrank.util.swing.ApplyAbortPanel; | ||
|
||
final class KeyTab | ||
{ | ||
static JPanel buildKeyTab( | ||
SearchGui gui, | ||
Opt<BL> bL, | ||
GuiPrefs guiPrefs, | ||
BiConsumer<String, Consumer<String>> reg) | ||
{ | ||
final var panelContent = Box.createVerticalBox(); | ||
|
||
final var txtSearch = new JTextField(); | ||
panelContent.add(txtSearch, BorderLayout.CENTER); | ||
|
||
final var panelSettings = Box.createVerticalBox(); | ||
final var chckbxCaseSensitive = new JCheckBox(); | ||
chckbxCaseSensitive.setRolloverEnabled(true); | ||
reg.accept("Search.Checkbox.Case Sensitive", chckbxCaseSensitive::setText); | ||
panelSettings.add(chckbxCaseSensitive); | ||
|
||
final var panel = new JPanel(new BorderLayout()); | ||
panel.add(panelContent, BorderLayout.CENTER); | ||
panel.add(panelSettings, BorderLayout.EAST); | ||
|
||
bL.if_(bl -> | ||
{ | ||
final var applyAbortPanel = new ApplyAbortPanel( | ||
buttonSearch, | ||
bl.search(txtSearch), | ||
buttonCancel, | ||
bl::abort); | ||
reg.accept(buttonSearch, applyAbortPanel.btnButton1::setText); | ||
reg.accept(buttonCancel, applyAbortPanel.btnButton2::setText); | ||
panel.add(applyAbortPanel, BorderLayout.SOUTH); | ||
}); | ||
return panel; | ||
} | ||
} |
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,49 @@ | ||
package de.tinycodecrank.l4j.ui.search; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Window; | ||
import java.util.function.Consumer; | ||
|
||
import javax.swing.JTabbedPane; | ||
|
||
import de.tinycodecrank.i18n.Localizer; | ||
import de.tinycodecrank.l4j.startup.Localizer4J; | ||
import de.tinycodecrank.l4j.util.ObservableLangDialog; | ||
import de.tinycodecrank.util.swing.events.GuiCloseEvent; | ||
|
||
@SuppressWarnings("serial") | ||
public final class SearchGui extends ObservableLangDialog<BL, Void, SearchKeyData> | ||
{ | ||
static final String buttonSearch = "Search.button.search"; | ||
static final String buttonCancel = "Search.button.cancel"; | ||
|
||
public SearchGui( | ||
Window owner, | ||
ModalityType modality, | ||
Consumer<GuiCloseEvent<Void>> closeListener, | ||
Localizer localizer, | ||
SearchKeyData data) | ||
{ | ||
super(owner, modality, closeListener, localizer, data); | ||
this.setDefaultCloseOperation(HIDE_ON_CLOSE); | ||
|
||
final var guiPrefs = Localizer4J.prefs.searchWindow; | ||
|
||
reg("Search.title", this::setTitle); | ||
setMinimumSize(new Dimension(300, 175)); | ||
guiPrefs.setBounds(this); | ||
|
||
final var tabbedPane = new JTabbedPane(JTabbedPane.TOP); | ||
setContentPane(tabbedPane); | ||
|
||
tabbedPane.addTab(null, KeyTab.buildKeyTab(this, businessLogic, guiPrefs, this::reg)); | ||
reg("Search.Tab.Key", s -> tabbedPane.setTitleAt(0, s)); | ||
tabbedPane.setEnabledAt(0, true); | ||
} | ||
|
||
@Override | ||
protected BL createBusinessLogic(SearchKeyData data) | ||
{ | ||
return new BL(this, data); | ||
} | ||
} |
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,8 @@ | ||
package de.tinycodecrank.l4j.ui.search; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import javax.swing.JTable; | ||
|
||
public record SearchKeyData(JTable table, Consumer<String> setSelection) | ||
{} |
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
Oops, something went wrong.