Skip to content

Commit bd3e146

Browse files
committed
Move WholeWord, RegExp, Hightlight buttons from FindBase to FindPanel
1 parent a6ba5e4 commit bd3e146

10 files changed

Lines changed: 331 additions & 232 deletions

‎shellfx-shared/src/main/java/com/techsenger/shellfx/shared/find/AbstractFindBaseView.java‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ public abstract class AbstractFindBaseView<VM extends AbstractFindBaseViewModel<
6464

6565
private final Button findNextButton = new Button(null, new FontIconView(SharedIcons.CHEVRON_DOWN));
6666

67-
private final ToggleButton wholeWordButton = new ToggleButton(null, new FontIconView(SharedIcons.WHOLE_WORD));
68-
69-
private final ToggleButton regExpButton = new ToggleButton(null, new FontIconView(SharedIcons.REG_EXP));
70-
71-
private final ToggleButton highlightButton = new ToggleButton(null, new FontIconView(SharedIcons.HIGHLIGHT));
72-
7367
private final BooleanProperty notFound = new SimpleBooleanProperty();
7468

7569
/*
@@ -135,18 +129,6 @@ protected void build() {
135129
this.findPreviousButton.setTooltip(new Tooltip("Previous"));
136130
this.findPreviousButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
137131
this.findPreviousButton.setFocusTraversable(false);
138-
139-
this.wholeWordButton.setTooltip(new Tooltip("Whole Word"));
140-
this.wholeWordButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
141-
this.wholeWordButton.setFocusTraversable(false);
142-
143-
this.highlightButton.setTooltip(new Tooltip("Highlight All"));
144-
this.highlightButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
145-
this.highlightButton.setFocusTraversable(false);
146-
147-
this.regExpButton.setTooltip(new Tooltip("Regular Expression"));
148-
this.regExpButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
149-
this.regExpButton.setFocusTraversable(false);
150132
}
151133

152134
@Override
@@ -157,12 +139,6 @@ protected void bind() {
157139
matchesLabel.textProperty().bind(viewModel.matchesTextProperty());
158140
matchCaseButton.selectedProperty().bindBidirectional(viewModel.matchCaseSelectedProperty());
159141
matchCaseButton.disableProperty().bind(viewModel.matchCaseDisabledProperty());
160-
wholeWordButton.selectedProperty().bindBidirectional(viewModel.wholeWordSelectedProperty());
161-
wholeWordButton.disableProperty().bind(viewModel.wholeWordDisabledProperty());
162-
regExpButton.selectedProperty().bindBidirectional(viewModel.regExpSelectedProperty());
163-
regExpButton.disableProperty().bind(viewModel.regExpDisabledProperty());
164-
highlightButton.selectedProperty().bindBidirectional(viewModel.highlightSelectedProperty());
165-
highlightButton.disableProperty().bind(viewModel.highlightDisabledProperty());
166142
findNextButton.disableProperty().bind(viewModel.findNextDisabledProperty());
167143
findPreviousButton.disableProperty().bind(viewModel.findPreviousDisabledProperty());
168144
findComboBox.getEditor().textProperty().bindBidirectional(viewModel.findTextProperty());
@@ -226,6 +202,7 @@ protected void addHandlers() {
226202
clearButton.setOnAction(e -> viewModel.onClearFindText());
227203
findPreviousButton.setOnAction(e -> viewModel.onFindPrevious());
228204
findNextButton.setOnAction(e -> viewModel.onFindNext());
205+
matchCaseButton.setOnAction(e -> viewModel.onMatchCase());
229206
}
230207

231208
/**
@@ -305,18 +282,6 @@ protected Button getFindNextButton() {
305282
return findNextButton;
306283
}
307284

308-
protected ToggleButton getHighlightButton() {
309-
return highlightButton;
310-
}
311-
312-
protected ToggleButton getWholeWordButton() {
313-
return wholeWordButton;
314-
}
315-
316-
protected ToggleButton getRegExpButton() {
317-
return regExpButton;
318-
}
319-
320285
private void updateMatchesVisible(boolean visible) {
321286
var visibleNow = this.matchesLabel.getParent() != null;
322287
if (visible && !visibleNow) {

‎shellfx-shared/src/main/java/com/techsenger/shellfx/shared/find/AbstractFindBaseViewModel.java‎

Lines changed: 4 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ public abstract class AbstractFindBaseViewModel<C extends ChildComposer> extends
5959

6060
private final BooleanProperty findPreviousDisabled = new SimpleBooleanProperty();
6161

62-
private final BooleanProperty wholeWordSelected = new SimpleBooleanProperty();
63-
64-
private final BooleanProperty wholeWordDisabled = new SimpleBooleanProperty();
65-
66-
private final BooleanProperty regExpSelected = new SimpleBooleanProperty();
67-
68-
private final BooleanProperty regExpDisabled = new SimpleBooleanProperty();
69-
70-
private final BooleanProperty highlightSelected = new SimpleBooleanProperty();
71-
72-
private final BooleanProperty highlightDisabled = new SimpleBooleanProperty();
73-
7462
public AbstractFindBaseViewModel(AreaParams params) {
7563
super(params);
7664
findText.addListener((obs, oldV, newV) -> onFindTextChanged(newV));
@@ -216,96 +204,6 @@ public BooleanProperty findPreviousDisabledProperty() {
216204
return findPreviousDisabled;
217205
}
218206

219-
@Override
220-
public boolean isWholeWordSelected() {
221-
return wholeWordSelected.get();
222-
}
223-
224-
@Override
225-
public void setWholeWordSelected(boolean wholeWordSelected) {
226-
this.wholeWordSelected.set(wholeWordSelected);
227-
}
228-
229-
@Override
230-
public BooleanProperty wholeWordSelectedProperty() {
231-
return wholeWordSelected;
232-
}
233-
234-
@Override
235-
public boolean isWholeWordDisabled() {
236-
return wholeWordDisabled.get();
237-
}
238-
239-
@Override
240-
public void setWholeWordDisabled(boolean wholeWordDisabled) {
241-
this.wholeWordDisabled.set(wholeWordDisabled);
242-
}
243-
244-
@Override
245-
public BooleanProperty wholeWordDisabledProperty() {
246-
return wholeWordDisabled;
247-
}
248-
249-
@Override
250-
public boolean isRegExpSelected() {
251-
return regExpSelected.get();
252-
}
253-
254-
@Override
255-
public void setRegExpSelected(boolean regExpSelected) {
256-
this.regExpSelected.set(regExpSelected);
257-
}
258-
259-
@Override
260-
public BooleanProperty regExpSelectedProperty() {
261-
return regExpSelected;
262-
}
263-
264-
@Override
265-
public boolean isRegExpDisabled() {
266-
return regExpDisabled.get();
267-
}
268-
269-
@Override
270-
public void setRegExpDisabled(boolean regExpDisabled) {
271-
this.regExpDisabled.set(regExpDisabled);
272-
}
273-
274-
@Override
275-
public BooleanProperty regExpDisabledProperty() {
276-
return regExpDisabled;
277-
}
278-
279-
@Override
280-
public boolean isHighlightSelected() {
281-
return highlightSelected.get();
282-
}
283-
284-
@Override
285-
public void setHighlightSelected(boolean highlightSelected) {
286-
this.highlightSelected.set(highlightSelected);
287-
}
288-
289-
@Override
290-
public BooleanProperty highlightSelectedProperty() {
291-
return highlightSelected;
292-
}
293-
294-
@Override
295-
public boolean isHighlightDisabled() {
296-
return highlightDisabled.get();
297-
}
298-
299-
@Override
300-
public void setHighlightDisabled(boolean highlightDisabled) {
301-
this.highlightDisabled.set(highlightDisabled);
302-
}
303-
304-
@Override
305-
public BooleanProperty highlightDisabledProperty() {
306-
return highlightDisabled;
307-
}
308-
309207
/**
310208
* Shows search result information in the Find component using total match count only.
311209
*
@@ -381,6 +279,10 @@ protected void onFindPrevious() {
381279

382280
}
383281

282+
protected void onMatchCase() {
283+
284+
}
285+
384286
protected abstract void onFind();
385287

386288
protected abstract void onFindCleared();
@@ -390,9 +292,6 @@ protected void restorePersistentState() {
390292
super.restorePersistentState();
391293
var h = getHistory();
392294
setMatchCaseSelected(h.isMatchCaseSelected());
393-
setWholeWordSelected(h.isWholeWordSelected());
394-
setRegExpSelected(h.isRegExpSelected());
395-
setHighlightSelected(h.isHighlightSelected());
396295
modifiableFindTexts.setAll(h.getFindTexts());
397296
}
398297

@@ -401,9 +300,6 @@ protected void savePersistentState() {
401300
super.savePersistentState();
402301
var h = getHistory();
403302
h.setMatchCaseSelected(isMatchCaseSelected());
404-
h.setWholeWordSelected(isWholeWordSelected());
405-
h.setRegExpSelected(isRegExpSelected());
406-
h.setHighlightSelected(isHighlightSelected());
407303
h.setFindTexts(new ArrayList<>(getFindTexts()));
408304
}
409305

‎shellfx-shared/src/main/java/com/techsenger/shellfx/shared/find/AbstractFindPanelView.java‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@
1616

1717
package com.techsenger.shellfx.shared.find;
1818

19+
import atlantafx.base.theme.Styles;
20+
import com.techsenger.shellfx.material.icon.FontIconView;
1921
import com.techsenger.shellfx.material.style.Spacing;
2022
import com.techsenger.shellfx.material.style.StyleClasses;
23+
import com.techsenger.shellfx.shared.style.SharedIcons;
2124
import com.techsenger.toolkit.fx.FocusTrap;
2225
import com.techsenger.toolkit.fx.Spacer;
2326
import com.techsenger.toolkit.fx.utils.NodeUtils;
2427
import javafx.geometry.Insets;
2528
import javafx.geometry.Pos;
2629
import javafx.scene.control.Button;
2730
import javafx.scene.control.Label;
31+
import javafx.scene.control.ToggleButton;
32+
import javafx.scene.control.Tooltip;
2833
import javafx.scene.layout.ColumnConstraints;
2934
import javafx.scene.layout.GridPane;
3035
import javafx.scene.layout.HBox;
@@ -46,6 +51,12 @@ public abstract class AbstractFindPanelView<VM extends AbstractFindPanelViewMode
4651

4752
private final HBox findLabelWrapper = new HBox(findLabel);
4853

54+
private final ToggleButton wholeWordButton = new ToggleButton(null, new FontIconView(SharedIcons.WHOLE_WORD));
55+
56+
private final ToggleButton regExpButton = new ToggleButton(null, new FontIconView(SharedIcons.REG_EXP));
57+
58+
private final ToggleButton highlightButton = new ToggleButton(null, new FontIconView(SharedIcons.HIGHLIGHT));
59+
4960
private final Button closeButton = new Button();
5061

5162
private final HBox toolBox = new HBox();
@@ -92,12 +103,24 @@ protected void build() {
92103
GridPane.setVgrow(this.findLabelWrapper, Priority.ALWAYS);
93104
GridPane.setVgrow(getFindComboBoxWrapper(), Priority.ALWAYS);
94105

106+
this.wholeWordButton.setTooltip(new Tooltip("Whole Word"));
107+
this.wholeWordButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
108+
this.wholeWordButton.setFocusTraversable(false);
109+
110+
this.regExpButton.setTooltip(new Tooltip("Regular Expression"));
111+
this.regExpButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
112+
this.regExpButton.setFocusTraversable(false);
113+
114+
this.highlightButton.setTooltip(new Tooltip("Highlight All"));
115+
this.highlightButton.getStyleClass().addAll(Styles.FLAT, StyleClasses.SIZE_M);
116+
this.highlightButton.setFocusTraversable(false);
117+
95118
this.closeButton.getStyleClass().addAll(StyleClasses.CROSS_BUTTON, StyleClasses.SIZE_XXS,
96119
StyleClasses.SQUARE);
97120
this.closeButton.setFocusTraversable(false);
98121

99122
this.toolBox.getChildren().addAll(getFindPreviousButton(), getFindNextButton(), getMatchCaseButton(),
100-
getWholeWordButton(), getRegExpButton(), getHighlightButton(),
123+
this.wholeWordButton, this.regExpButton, this.highlightButton,
101124
new Spacer(Spacing.getHorizontal() - Spacing.getHorizontalThird() * 2), this.closeButton);
102125
this.toolBox.setSpacing(Spacing.getHorizontalThird());
103126
this.toolBox.setAlignment(Pos.CENTER_LEFT);
@@ -109,16 +132,44 @@ protected void build() {
109132
gridPane.add(this.toolBox, 2, 0);
110133
}
111134

135+
@Override
136+
protected void bind() {
137+
super.bind();
138+
var viewModel = getViewModel();
139+
wholeWordButton.selectedProperty().bindBidirectional(viewModel.wholeWordSelectedProperty());
140+
wholeWordButton.disableProperty().bind(viewModel.wholeWordDisabledProperty());
141+
regExpButton.selectedProperty().bindBidirectional(viewModel.regExpSelectedProperty());
142+
regExpButton.disableProperty().bind(viewModel.regExpDisabledProperty());
143+
highlightButton.selectedProperty().bindBidirectional(viewModel.highlightSelectedProperty());
144+
highlightButton.disableProperty().bind(viewModel.highlightDisabledProperty());
145+
}
146+
112147
@Override
113148
protected void addHandlers() {
114149
super.addHandlers();
115-
closeButton.setOnAction(e -> getViewModel().onCloseRequest());
150+
var viewModel = getViewModel();
151+
closeButton.setOnAction(e -> viewModel.onCloseRequest());
152+
wholeWordButton.setOnAction(e -> viewModel.onWholeWord());
153+
regExpButton.setOnAction(e -> viewModel.onRegExp());
154+
highlightButton.setOnAction(e -> viewModel.onHighlight());
116155
}
117156

118157
protected GridPane getGridPane() {
119158
return gridPane;
120159
}
121160

161+
protected ToggleButton getWholeWordButton() {
162+
return wholeWordButton;
163+
}
164+
165+
protected ToggleButton getRegExpButton() {
166+
return regExpButton;
167+
}
168+
169+
protected ToggleButton getHighlightButton() {
170+
return highlightButton;
171+
}
172+
122173
protected FocusTrap getFocusTrap() {
123174
return focusTrap;
124175
}

0 commit comments

Comments
 (0)