Skip to content

Commit 995d710

Browse files
author
Jan Schraff
committed
changed drop down in edit work to display colored text on default background to solve contrast issues
1 parent 64c01c8 commit 995d710

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ protected void updateItem(final Project project, final boolean empty) {
146146
if (project == null || empty) {
147147
setGraphic(null);
148148
} else {
149-
setColor(this, project.getColor());
149+
setColor(this, model.defaultBackgroundColor.get());
150+
151+
setTextFill(project.getColor());
150152
setText(project.getName());
153+
151154
setUnderline(project.isWork());
152155
}
153156
}
@@ -185,7 +188,8 @@ public Project fromString(final String string) {
185188
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
186189
Platform.runLater(() -> {
187190
projectComboBox.getEditor().selectAll();
188-
setColor(projectComboBox, newValue.getColor());
191+
setTextColor(projectComboBox.getEditor(), newValue.getColor());
192+
189193
});
190194
}
191195

@@ -210,6 +214,10 @@ public void changed(final ObservableValue<? extends String> observable, final St
210214
if (isValidProject) {
211215
isValidProject = false;
212216
projectComboBox.getSelectionModel().clearSelection();
217+
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
218+
Platform.runLater(() -> {
219+
setTextColor(projectComboBox.getEditor(), model.defaultFontColor.get());
220+
});
213221
}
214222

215223
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
@@ -255,7 +263,10 @@ public void initializeWith(final Work work) {
255263

256264
projectComboBox.getSelectionModel().select(work.getProject());
257265

258-
setColor(projectComboBox, work.getProject().getColor());
266+
setColor(projectComboBox, model.defaultBackgroundColor.get());
267+
setColor(projectComboBox.getEditor(), model.defaultBackgroundColor.get());
268+
269+
setTextColor(projectComboBox.getEditor(), model.defaultFontColor.get());
259270

260271
}
261272

@@ -265,6 +276,12 @@ private void setColor(final Node object, final Color color) {
265276
object.setStyle(style);
266277
}
267278

279+
private void setTextColor(final Node object, final Color color) {
280+
final String style = StyleUtils.changeStyleAttribute(object.getStyle(), "fx-text-fill",
281+
"rgba(" + ColorHelper.colorToCssRgba(color) + ")");
282+
object.setStyle(style);
283+
}
284+
268285
public Work getWorkFromUserInput() {
269286

270287
return new Work(startDatePicker.getValue(),

0 commit comments

Comments
 (0)