[8u40] Review Request (second iteration): (RT-36510) [CSS] Reduce CssMetaData boilerplate code

David Grieve david.grieve at oracle.com
Tue Jun 24 23:22:32 UTC 2014


I am seeking feedback on 
http://cr.openjdk.java.net/~dgrieve/RT-36510/webrev.00 which addresses 
https://javafx-jira.kenai.com/browse/RT-36510.

This iteration reduces the boiler-plate to one line to create the 
StyleableProperty and one method to return the CssMetaData list.

Example use:

public class MyButton extends Button {

     public MyButton(String text) {
         super(text);
         getStyleClass().add("my-button");
     }

     public ObservableValue<String> fooProperty() { return 
(ObservableValue<String>)foo; }
     public String getFoo() { return foo.getValue(); }
     public void setFoo(String value) { foo.setValue(value); }
     private final StyleableProperty<String> foo = 
StyleablePropertyFactory.getInstance().createStyleableStringProperty(this, 
"foo", "-my-foo", s -> ((MyButton)s).foo);

     public ObservableValue<Double> offsetProperty() { return 
(ObservableValue<Double>)offset; }
     public Double getOffset() { return offset.getValue().doubleValue(); }
     public void setOffset(Double value) { offset.setValue(value); }
     private final StyleableProperty<Number> offset = 
StyleablePropertyFactory.getInstance().createStyleableNumberProperty(this, 
"offset", "-my-offset", s -> ((MyButton)s).offset);

     public ObservableValue<Integer> countProperty() { return 
(ObservableValue<Integer>)count; }
     public Integer getCount() { return count.getValue().intValue(); }
     public void setCount(Integer value) { count.setValue(value); }
     private final StyleableProperty<Number> count = 
StyleablePropertyFactory.getInstance().createStyleableNumberProperty(this, 
"count", "-my-count", s -> ((MyButton)s).count);

     @Override
     public List<CssMetaData<? extends Styleable, ?>> 
getControlCssMetaData() {
         return StyleablePropertyFactory.getInstance().getCssMetaData(this);
     }

}



More information about the openjfx-dev mailing list