Issue raised by Tom Schindl regarding Labeled. Control and PopupControl have same issue with -fx-skin.
<quote>
while doing once more a warning fix pass I came across 3 styleable properties in Labeled:
* ObjectProperty<Node> graphicProperty
* DoubleProperty lineSpacingProperty
* DoubleProperty graphicTextGapProperty
The problem is that the CSS-Metadata is not appropriate for them
* StyleableProperties.GRAPHIC <Labeled,String>
* StyleableProperties.LINE_SPACING <Labeled,Number>
* StyleableProperties.GRAPHIC_TEXT_GAP <Labeled,Number>
According to the StyleableProperty this is not appropriate but have to be:
* StyleableProperties.GRAPHIC <Labeled,Node>
* StyleableProperties.LINE_SPACING <Labeled,Double>
* StyleableProperties.GRAPHIC_TEXT_GAP <Labeled,Double>
</quote>
After some discussion, my response was as follows and I think this is where the fix for this needs to go.
Just to recap the issue, looking at Labeled's GRAPHIC CssMetaData, we have
private static final CssMetaData<Labeled,String> GRAPHIC =
Where really we want
private static final CssMetaData<Labeled,Node> GRAPHIC =
The reason for it being String is that we want to be able to compare one url string to another to see if the new value is the same as the current value. This pattern is used elsewhere (skin, for instance).
As to your proposed solution, I prefer to keep StyleableProperty<T>. While StyleableProperty<T,R> is a possible way to solve this issue, I think it makes StyleableProperty less user-friendly.
The StyleConverter for the GRAPHIC CssMetaData is a StyleConverter<String, String>. If it were StyleConverter<String,Node>, then we'd be golden. I haven't tried this, but it would look something like this, I think...
private static final CssMetaData<Labeled,Node> GRAPHIC =
new CssMetaData<Labeled,Node>("-fx-graphic",
new StyleConverter<String,Node>() {
@Override
public Node convert(ParsedValue<String, Node> value, Font font) {
final String url = value.getValue();
final Image img = StyleManager.getInstance().getCachedImage(url);
return new ImageView(img);
}
})
<quote>
while doing once more a warning fix pass I came across 3 styleable properties in Labeled:
* ObjectProperty<Node> graphicProperty
* DoubleProperty lineSpacingProperty
* DoubleProperty graphicTextGapProperty
The problem is that the CSS-Metadata is not appropriate for them
* StyleableProperties.GRAPHIC <Labeled,String>
* StyleableProperties.LINE_SPACING <Labeled,Number>
* StyleableProperties.GRAPHIC_TEXT_GAP <Labeled,Number>
According to the StyleableProperty this is not appropriate but have to be:
* StyleableProperties.GRAPHIC <Labeled,Node>
* StyleableProperties.LINE_SPACING <Labeled,Double>
* StyleableProperties.GRAPHIC_TEXT_GAP <Labeled,Double>
</quote>
After some discussion, my response was as follows and I think this is where the fix for this needs to go.
Just to recap the issue, looking at Labeled's GRAPHIC CssMetaData, we have
private static final CssMetaData<Labeled,String> GRAPHIC =
Where really we want
private static final CssMetaData<Labeled,Node> GRAPHIC =
The reason for it being String is that we want to be able to compare one url string to another to see if the new value is the same as the current value. This pattern is used elsewhere (skin, for instance).
As to your proposed solution, I prefer to keep StyleableProperty<T>. While StyleableProperty<T,R> is a possible way to solve this issue, I think it makes StyleableProperty less user-friendly.
The StyleConverter for the GRAPHIC CssMetaData is a StyleConverter<String, String>. If it were StyleConverter<String,Node>, then we'd be golden. I haven't tried this, but it would look something like this, I think...
private static final CssMetaData<Labeled,Node> GRAPHIC =
new CssMetaData<Labeled,Node>("-fx-graphic",
new StyleConverter<String,Node>() {
@Override
public Node convert(ParsedValue<String, Node> value, Font font) {
final String url = value.getValue();
final Image img = StyleManager.getInstance().getCachedImage(url);
return new ImageView(img);
}
})