Skip to content

Commit ccb8a5a

Browse files
committed
PTBAS-738: Combine SearchField and Button into one ComboBox
1 parent f4a0b09 commit ccb8a5a

File tree

3 files changed

+65
-13
lines changed

3 files changed

+65
-13
lines changed

src/main/java/de/doubleslash/keeptime/view/ExternalProjectsSyncController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ public void initForDate(LocalDate currentReportDate, List<Work> currentWorkItems
236236
mappingTableView.scrollTo(items.size() - 1);
237237
});
238238

239-
heimatTaskSearchContainer.getChildren().add(heimatTaskSearchPopup.getTextField());
240-
heimatTaskSearchContainer.getChildren().add(heimatTaskSearchPopup.getSuggestionsButton());
241-
heimatTaskSearchContainer.setSpacing(3);
239+
heimatTaskSearchContainer.getChildren().add(heimatTaskSearchPopup.getComboBox());
240+
HBox.setHgrow(heimatTaskSearchPopup.getComboBox(), Priority.ALWAYS);
242241
}
243242

244243
@FXML

src/main/java/de/doubleslash/keeptime/viewpopup/SearchPopup.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class SearchPopup<T> {
2626
private ObservableList<T> allItems = FXCollections.observableArrayList();
2727
private Consumer<T> selectionHandler;
2828
private Function<T, String> displayTextFunction = Object::toString;
29+
private final HBox comboBox;
2930

3031
private ObservableList<T> observedItemsForListener = null;
3132
private final ListChangeListener<T> listChangeListener = c -> filterList(searchField.getText());
@@ -34,6 +35,8 @@ public SearchPopup() {
3435
popup.setAutoHide(true);
3536
popup.getContent().add(suggestionList);
3637

38+
comboBox = new HBox(searchField, showSuggestionsButton);
39+
3740
setupStyle();
3841

3942
showSuggestionsButton.setOnAction(ae -> {
@@ -116,10 +119,10 @@ private void handleSelection(T selected) {
116119
}
117120

118121
private void setupStyle() {
119-
HBox.setHgrow(searchField, Priority.ALWAYS);
120122
searchField.setPromptText("Select project…");
121-
searchField.getStyleClass().add("combo-box");
122-
123+
searchField.getStyleClass().add("search-popup");
124+
HBox.setHgrow(searchField, Priority.ALWAYS);
125+
searchField.setMaxWidth(Double.MAX_VALUE); // Allow growing
123126
suggestionList.getStyleClass().add("scroll-pane");
124127
suggestionList.setMaxHeight(200);
125128

@@ -147,7 +150,10 @@ protected void updateItem(T item, boolean empty) {
147150
}
148151
});
149152

150-
showSuggestionsButton.getStyleClass().add("secondary-button");
153+
showSuggestionsButton.getStyleClass().add("search-popup-button");
154+
155+
comboBox.getStyleClass().add("search-popup-container");
156+
comboBox.setAlignment(Pos.CENTER_LEFT);
151157
}
152158

153159

@@ -171,12 +177,8 @@ public void setDisplayTextFunction(Function<T, String> func) {
171177
filterList(searchField.getText());
172178
}
173179

174-
public TextField getTextField() {
175-
return searchField;
176-
}
177-
178-
public Button getSuggestionsButton() {
179-
return showSuggestionsButton;
180+
public HBox getComboBox() {
181+
return comboBox;
180182
}
181183

182184
public void show(Node owner) {

src/main/resources/css/dsStyles.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,55 @@
205205
.tree-table-row-cell:selected .tree-table-cell {
206206
-fx-border-color: #C6C6C6;
207207
-fx-border-width: 0 0.5px 0 0;
208+
}
209+
210+
.search-popup-container {
211+
-fx-background-color: transparent;
212+
}
213+
214+
.search-popup {
215+
-fx-background-radius: 8 0 0 8;
216+
-fx-border-radius: 8 0 0 8;
217+
-fx-border-color: #00759E transparent #00759E #00759E;
218+
-fx-border-width: 1px 0 1px 1px;
219+
-fx-background-color: white;
220+
-fx-pref-height: 32px;
221+
-fx-min-height: 32px;
222+
-fx-max-height: 32px;
223+
-fx-font-size: 13px;
224+
-fx-text-fill: #00759E;
225+
-fx-padding: 0 0 0 8;
226+
}
227+
228+
.search-popup:focused {
229+
-fx-border-color: #0056b3 transparent #0056b3 #0056b3;
230+
}
231+
232+
.search-popup:hover {
233+
-fx-border-color: #00A5E1;
234+
}
235+
236+
.search-popup-button {
237+
-fx-background-radius: 0 8 8 0;
238+
-fx-border-radius: 0 8 8 0;
239+
-fx-border-color: #00759E #00759E #00759E transparent;
240+
-fx-border-width: 1px 1px 1px 0;
241+
-fx-background-color: white;
242+
-fx-pref-height: 32px;
243+
-fx-min-height: 32px;
244+
-fx-max-height: 32px;
245+
-fx-pref-width: 32px;
246+
-fx-font-size: 13px;
247+
-fx-cursor: hand;
248+
-fx-text-fill: #00759E;
249+
-fx-padding: 0;
250+
-fx-content-display: center;
251+
-fx-alignment: center;
252+
}
253+
254+
.search-popup-button:hover {
255+
-fx-text-fill: #00A5E1;
256+
}
257+
.search-popup-button:pressed {
258+
-fx-text-fill: #77DDFF;
208259
}

0 commit comments

Comments
 (0)