2424import org .slf4j .Logger ;
2525import org .slf4j .LoggerFactory ;
2626
27+ import de .doubleslash .keeptime .common .ColorHelper ;
28+ import de .doubleslash .keeptime .common .StyleUtils ;
2729import de .doubleslash .keeptime .model .Model ;
2830import de .doubleslash .keeptime .model .Project ;
2931import 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