Skip to content

Commit 794c0e7

Browse files
committed
changed manuel background-color edit to use StyleUtils
1 parent b5d1b43 commit 794c0e7

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

27+
import de.doubleslash.keeptime.common.ColorHelper;
28+
import de.doubleslash.keeptime.common.StyleUtils;
2729
import de.doubleslash.keeptime.model.Model;
2830
import de.doubleslash.keeptime.model.Project;
2931
import de.doubleslash.keeptime.model.Work;
@@ -185,9 +187,13 @@ protected void updateItem(final Project item, final boolean empty) {
185187
setGraphic(null);
186188
} else {
187189
final Color color = item.getColor();
188-
final String hexColor = String.format("#%02X%02X%02X", (int) (color.getRed() * 255),
189-
(int) (color.getGreen() * 255), (int) (color.getBlue() * 255));
190-
setStyle(" -fx-background-color: " + hexColor);
190+
191+
final double opacity = 0;
192+
String style = StyleUtils.changeStyleAttribute(getStyle(), "fx-background-color",
193+
"rgba(" + ColorHelper.colorToCssRgba(color) + ")");
194+
style = StyleUtils.changeStyleAttribute(style, "fx-border-color",
195+
"rgba(" + ColorHelper.colorToCssRgb(color) + ", " + opacity + ")");
196+
setStyle(style);
191197
setText(item.getName());
192198

193199
}
@@ -211,15 +217,20 @@ protected void updateItem(final Project item, final boolean empty) {
211217
setGraphic(null);
212218
} else {
213219
final Color color = item.getColor();
214-
final String hexColor = String.format("#%02X%02X%02X", (int) (color.getRed() * 255),
215-
(int) (color.getGreen() * 255), (int) (color.getBlue() * 255));
216-
setStyle(" -fx-background-color: " + hexColor);
220+
221+
final double opacity = 0;
222+
String style = StyleUtils.changeStyleAttribute(getStyle(), "fx-background-color",
223+
"rgba(" + ColorHelper.colorToCssRgba(color) + ")");
224+
style = StyleUtils.changeStyleAttribute(style, "fx-border-color",
225+
"rgba(" + ColorHelper.colorToCssRgb(color) + ", " + opacity + ")");
226+
setStyle(style);
227+
217228
setText(item.getName());
218229
}
219230

220231
// Set the background of the arrow also
221232
if (arrowButton != null) {
222-
arrowButton.setBackground(getBackground());
233+
arrowButton.setStyle(getStyle());
223234
}
224235
}
225236

@@ -245,9 +256,13 @@ public Project fromString(final String string) {
245256

246257
projectComboBox.getSelectionModel().select(work.getProject());
247258
final Color color = work.getProject().getColor();
248-
final String hexColor = String.format("#%02X%02X%02X", (int) (color.getRed() * 255),
249-
(int) (color.getGreen() * 255), (int) (color.getBlue() * 255));
250-
projectComboBox.setStyle(" -fx-background-color: " + hexColor);
259+
260+
final double opacity = 0;
261+
String style = StyleUtils.changeStyleAttribute(projectComboBox.getStyle(), "fx-background-color",
262+
"rgba(" + ColorHelper.colorToCssRgba(color) + ")");
263+
style = StyleUtils.changeStyleAttribute(style, "fx-border-color",
264+
"rgba(" + ColorHelper.colorToCssRgb(color) + ", " + opacity + ")");
265+
projectComboBox.setStyle(style);
251266

252267
}
253268

0 commit comments

Comments
 (0)