Skip to content

Commit

Permalink
Refactor: Tag/Model.createProperty -> createNewProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
fducroquet committed Jul 27, 2016
1 parent 8303a60 commit 3fa8c54
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void main(String[] mainArgs) {

public CarColorApp(Root engine, ServerWebSocket webSocket) {
super(webSocket);
createProperty(ReactorStatics.SELECTION);
createNewProperty(ReactorStatics.SELECTION);
addStyle("background-color", "#3393ff");

new GenericH1Section(this, "Generic System Reactor Live Demo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public AppHtml(Root engine, ServerWebSocket webSocket) {
new GenericH1Section(this, "Generic System Reactor Live Demo").addStyle("background-color", "#ffa500");

select(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> gs[0]);
createProperty(ReactorStatics.SELECTION);
createNewProperty(ReactorStatics.SELECTION);
new GSTable(this).select(StringExtractor.MANAGEMENT, Car.class);
new GSTable(this, FlexDirection.ROW).select(StringExtractor.MANAGEMENT, Car.class);
new GSEditor(this, FlexDirection.ROW) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean containsProperty(Tag<?> tag, String propertyName) {
return propertiesMap.containsKey(tag) ? propertiesMap.get(tag).containsKey(propertyName) : false;
}

public void createProperty(Tag<?> tag, String propertyName) {
public void createNewProperty(Tag<?> tag, String propertyName) {
assert viewContextsMap.keySet().contains(tag);
if (propertiesMap.get(tag).containsKey(propertyName))
throw new IllegalStateException("Unable to create an already used property : " + propertyName);
Expand Down
4 changes: 2 additions & 2 deletions gs-reactor/src/main/java/org/genericsystem/reactor/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ public <T extends Serializable> void bindActionToValueChangeListener(String prop
});
}

public void createProperty(String propertyName) {
public void createNewProperty(String propertyName) {
addPrefixBinding(modelContext -> {
modelContext.createProperty(this, propertyName);
modelContext.createNewProperty(this, propertyName);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static class ColorCompositeRadio extends GSComposite {

public ColorCompositeRadio(GSTag parent, FlexDirection flexDirection) {
super(parent, flexDirection);
createProperty(ReactorStatics.SELECTION);
createNewProperty(ReactorStatics.SELECTION);
storeProperty(ReactorStatics.SELECTION_INDEX, model -> model.getSelectionIndex(this));
bindBiDirectionalSelection(flexSubElement);
storeProperty(ReactorStatics.SELECTION_STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public GSInputTextWithConversion(GSTag parent) {
addStyle("width", "100%");
addStyle("height", "100%");

createProperty(ReactorStatics.CONVERTER);
createNewProperty(ReactorStatics.CONVERTER);
initProperty(ReactorStatics.CONVERTER, model -> getConverter(model));
createProperty(ReactorStatics.VALUE);
createNewProperty(ReactorStatics.VALUE);

storeProperty(ReactorStatics.INVALID, model -> Bindings.createBooleanBinding(() -> {
boolean required = model.getGeneric().isRequiredConstraintEnabled(ApiStatics.BASE_POSITION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void initInputText(GSTag tag) {
@Deprecated
public void initCheckBox(GSTag tag) {
tag.select(gs -> Boolean.class.equals(gs[0].getMeta().getInstanceValueClassConstraint()) ? gs[0] : null);
tag.createProperty(ReactorStatics.CHECKED);
tag.createNewProperty(ReactorStatics.CHECKED);
tag.initProperty(ReactorStatics.CHECKED, model -> (Boolean) model.getGeneric().getValue());
tag.bindActionToValueChangeListener(ReactorStatics.CHECKED, (model, nva) -> model.getGeneric().updateValue(nva));
}
Expand Down Expand Up @@ -348,7 +348,7 @@ public void initInputSection(GSTag tag) {

@Override
public void initCheckBox(GSTag tag) {
tag.createProperty(ReactorStatics.VALUE);
tag.createNewProperty(ReactorStatics.VALUE);
tag.select(gs -> Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
tag.bindOptionalBiDirectionalAttribute(ReactorStatics.VALUE, ReactorStatics.CHECKED, ReactorStatics.CHECKED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private GSSelect(GSTag parent) {
super(parent, "select");
options();
init();
createProperty(ReactorStatics.SELECTION);
createNewProperty(ReactorStatics.SELECTION);
storeProperty(ReactorStatics.SELECTION_INDEX, model -> model.getSelectionIndex(this));
bindBiDirectionalSelection(optionElement);
storeProperty(ReactorStatics.SELECTION_STRING,
Expand Down Expand Up @@ -55,7 +55,7 @@ protected void options() {

@Override
protected void init() {
createProperty(ReactorStatics.SELECTION_SHIFT);
createNewProperty(ReactorStatics.SELECTION_SHIFT);
initProperty(ReactorStatics.SELECTION_SHIFT, 1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected void header() {
addStyle("margin-bottom", "1px");
new GSInputTextWithConversion(this) {
{
createProperty(ReactorStatics.ACTION);
createNewProperty(ReactorStatics.ACTION);
this.<TriFunction<Generic[], Serializable, Generic, Generic>> initProperty(ReactorStatics.ACTION, (gs, value, g) -> gs[0].setInstance(value));
}

Expand Down Expand Up @@ -176,7 +176,7 @@ protected void sections() {
new GSInputTextWithConversion(this) {
{
select(gs -> !Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
createProperty(ReactorStatics.ACTION);
createNewProperty(ReactorStatics.ACTION);
this.<TriFunction<Generic[], Serializable, Generic, Generic>> initProperty(ReactorStatics.ACTION, (gs, value, g) -> g.setHolder(gs[1], value));
}

Expand All @@ -191,9 +191,9 @@ public StringConverter<?> getConverter(GenericModel model) {
new GSCheckBox(this) {
{
select(gs -> Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
createProperty(ReactorStatics.VALUE);
createNewProperty(ReactorStatics.VALUE);
bindOptionalBiDirectionalAttribute(ReactorStatics.VALUE, ReactorStatics.CHECKED, ReactorStatics.CHECKED);
createProperty(ReactorStatics.ACTION);
createNewProperty(ReactorStatics.ACTION);
this.<TriFunction<Generic[], Serializable, Generic, Generic>> initProperty(ReactorStatics.ACTION, (gs, value, g) -> g.setHolder(gs[1], value));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GSCheckBox extends GSTag {

public GSCheckBox(GSTag parent) {
super(parent, "input");
createProperty(ReactorStatics.CHECKED);
createNewProperty(ReactorStatics.CHECKED);
}

@Override
Expand Down

0 comments on commit 3fa8c54

Please sign in to comment.