Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
plagarrigue committed Sep 2, 2016
2 parents 7bce3c5 + a3cc497 commit df78d7a
Show file tree
Hide file tree
Showing 37 changed files with 585 additions and 382 deletions.
10 changes: 7 additions & 3 deletions gs-api/src/main/java/org/genericsystem/api/core/ISignature.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ public interface ISignature<T extends ISignature<T>> {
List<T> getComponents();

/**
* Returns the <code>JSonId</code> of this signature.
* Returns the unique id of this signature.
*
* @return the <code>JSonObject</code> representing this signature.
* @return the design date representing this signature.
*/

long getTs();

/**
* Returns the birth ts of this signature.
*
* @return the ts of the transaction that make alive this signature.
*/
long getBirthTs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gs.FlexDirection;
import org.genericsystem.reactor.gs.GSModalButton;
import org.genericsystem.reactor.gs.GSSection;
import org.genericsystem.reactor.gs.GSDiv;
import org.genericsystem.reactor.gstag.HtmlHyperLink;
import org.genericsystem.reactor.gstag.HtmlLi;
import org.genericsystem.reactor.gstag.HtmlUl;

public class GSUserGuide extends GSSection {
public class GSUserGuide extends GSDiv {

public GSUserGuide(Tag parent) {
super(parent, FlexDirection.COLUMN);
addStyle("flex-direction", "column");
addStyle("flex-wrap", "nowrap");
addStyle("justify-content", "center");

GSSection gSection = new GSSection(this, FlexDirection.COLUMN) {
GSDiv gSection = new GSDiv(this, FlexDirection.COLUMN) {
{
addStyleClass("modal");
createInitializedDisplayProperty("none");
bindStyle(DISPLAY, DISPLAY);
new GSSection(this, FlexDirection.COLUMN) {
new GSDiv(this, FlexDirection.COLUMN) {
{
addStyle("max-width", "40%");
addStyleClass("modal-content");
Expand All @@ -34,7 +34,7 @@ public GSUserGuide(Tag parent) {
});
}
};
new GSSection(this, FlexDirection.COLUMN) {
new GSDiv(this, FlexDirection.COLUMN) {
{
setText("How to use CarColor Demo");
new HtmlUl(this) {
Expand Down Expand Up @@ -73,7 +73,7 @@ public GSUserGuide(Tag parent) {

}
};
new GSSection(this, FlexDirection.COLUMN) {
new GSDiv(this, FlexDirection.COLUMN) {
{
addStyle("text-align", "center");
setText("To plenty enjoy the power of GS-REACTOR, go to Learning / Get Started");
Expand All @@ -85,7 +85,7 @@ public GSUserGuide(Tag parent) {
};
}
};
new GSSection(this, FlexDirection.ROW) {
new GSDiv(this, FlexDirection.ROW) {
{
addStyle("justify-content", "center");
new GSModalButton(this, gSection) {
Expand Down
3 changes: 3 additions & 0 deletions gs-carcolor/src/main/resources/carcolorapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ function onMessageReceived(evt) {
case "section":
elt.classList.add("adding");
break;
case "div":
elt.classList.add("adding");
break;
case "header":
elt.classList.add("adding");
break;
Expand Down
15 changes: 5 additions & 10 deletions gs-reactor/src/main/java/org/genericsystem/reactor/Context.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.genericsystem.reactor;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -29,6 +28,7 @@ public class Context {
private Map<Tag, ObservableList<Context>> subContextsMap = new HashMap<>();
private Map<Tag, Map<String, ObservableValue<?>>> propertiesMap = new HashMap<>();
private final Generic[] generics;
private boolean destroyed = false;

public Context(Context parent, Generic[] generics) {
this.parent = parent;
Expand Down Expand Up @@ -103,8 +103,6 @@ public void destroy() {
internalDestroy();
}

public boolean destroyed = false;

public void internalDestroy() {
// System.out.println("InternalDestroy : " + this);
assert !destroyed;
Expand Down Expand Up @@ -182,15 +180,12 @@ public long shiftTs() throws RollbackException {
}

public void traverse() {
// System.out.println("traverse " + Arrays.toString(getGenerics()) + " "
// + isOpaque());
if (isOpaque()) {
// Tag tag = new ArrayList<>(htmlDomNodesMap.keySet()).get(0);
System.out.println("removeStyleClasse Opaque" + Arrays.toString(getGenerics()));
if (isOpaque())
htmlDomNodesMap.keySet().stream().forEach(tag -> tag.removeStyleClass(this, "opaque"));
}
subContextsMap.values().stream().flatMap(c -> c.stream()).forEach(Context::traverse);

}

public boolean isDestroyed() {
return destroyed;
}
}
22 changes: 12 additions & 10 deletions gs-reactor/src/main/java/org/genericsystem/reactor/HtmlDomNode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.genericsystem.reactor;

import java.util.Arrays;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
Expand Down Expand Up @@ -74,7 +73,10 @@ public HtmlDomNode(HtmlDomNode parent, Context modelContext, Tag tag) {
// for (Tag childTag : change.getAddedSubList()) {
// MetaBinding<BETWEEN> metaBinding = childTag.<BETWEEN> getMetaBinding();
// if (metaBinding != null) {
// modelContext.setSubContexts(childTag, new TransformationObservableList<BETWEEN, Context>(metaBinding.buildBetweenChildren(modelContext), (i, between) -> {
// modelContext.setSubContexts(childTag, new
// TransformationObservableList<BETWEEN,
// Context>(metaBinding.buildBetweenChildren(modelContext), (i, between) ->
// {
// Context childModel = metaBinding.buildModel(modelContext, between);
// createChildDomNode(i, childModel, childTag);
// return childModel;
Expand Down Expand Up @@ -110,12 +112,8 @@ protected <BETWEEN> void init(int index) {
}

public void createChildDomNode(int index, Context childContext, Tag childTag) {

if (childContext.isOpaque()) {
System.out.println("addStyle Opaque " + Arrays.toString(childContext.getGenerics()));
if (childContext.isOpaque())
childTag.addStyleClass("opaque");
}

childTag.createNode(this, childContext).init(computeIndex(index, childTag));
}

Expand Down Expand Up @@ -205,7 +203,9 @@ else if (change.wasAdded())
private final ChangeListener<String> textListener = (o, old, newValue) -> sendMessage(new JsonObject().put(MSG_TYPE, UPDATE_TEXT).put(ID, getId()).put(TEXT_CONTENT, newValue != null ? newValue : ""));

private final ChangeListener<Number> indexListener = (o, old, newValue) -> {
// System.out.println(new JsonObject().put(MSG_TYPE, UPDATE_SELECTION).put(ID, getId()).put(SELECTED_INDEX, newValue != null ? newValue : 0)
// System.out.println(new JsonObject().put(MSG_TYPE,
// UPDATE_SELECTION).put(ID, getId()).put(SELECTED_INDEX, newValue !=
// null ? newValue : 0)
// .encodePrettily());
sendMessage(new JsonObject().put(MSG_TYPE, UPDATE_SELECTION).put(ID, getId()).put(SELECTED_INDEX, newValue != null ? newValue : 0));
};
Expand Down Expand Up @@ -247,12 +247,14 @@ public JsonObject fillJson(JsonObject jsonObj) {

public void sendRemove() {
sendMessage(new JsonObject().put(MSG_TYPE, REMOVE).put(ID, id));
// System.out.println(new JsonObject().put(MSG_TYPE, REMOVE).put(ID, id).encodePrettily());
// System.out.println(new JsonObject().put(MSG_TYPE, REMOVE).put(ID,
// id).encodePrettily());
}

public void sendMessage(JsonObject jsonObj) {
jsonObj.put("count", count++);
// if (jsonObj.getString(MSG_TYPE).equals(ADD) || jsonObj.getString(MSG_TYPE).equals(REMOVE))
// if (jsonObj.getString(MSG_TYPE).equals(ADD) ||
// jsonObj.getString(MSG_TYPE).equals(REMOVE))
// System.out.println(jsonObj.encodePrettily());
getWebSocket().writeFinalTextFrame(jsonObj.encode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.genericsystem.reactor.HtmlDomNode.RootHtmlDomNode;
import org.genericsystem.reactor.Tag.RootTag;

public class GSApp extends GSSection implements RootTag {
public class GSApp extends GSDiv implements RootTag {

public GSApp() {
super(null, FlexDirection.COLUMN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

public class GSAttributeOfInstanceEditor extends GSSection {
public class GSAttributeOfInstanceEditor extends GSDiv {

public GSAttributeOfInstanceEditor(Tag parent) {
super(parent, FlexDirection.COLUMN);
addStyle("flex", "1");
addStyle("overflow", "hidden");
new GSMultiCheckBox(this, ((GSSection) parent).getReverseDirection()) {
new GSMultiCheckBox(this, ((GSDiv) parent).getReverseDirection()) {
{
addStyle("flex", "1");
select(gs -> gs[0].getComponents().size() == 2 && !gs[0].isSingularConstraintEnabled(ApiStatics.BASE_POSITION) ? gs[0] : null);
select(gs -> gs[0].getComponents().size() == 2 && !gs[0].isSingularConstraintEnabled(gs[0].getComponents().indexOf(gs[2])) ? gs[0] : null);
}
};
new GenericColumn(this) {
{
addStyle("flex", "1");
select(gs -> (gs[0].getComponents().size() != 2 || gs[0].isSingularConstraintEnabled(ApiStatics.BASE_POSITION)) ? gs[0] : null);
addStyle("flex-wrap", "wrap");
select(gs -> gs[0].getComponents().size() != 2 || gs[0].isSingularConstraintEnabled(gs[0].getComponents().indexOf(gs[2])) ? gs[0] : null);
new GSSubcellEditor(this) {
{
addStyle("flex", "1");
addStyle("flex", "1 0 auto");
forEach2(model -> BindingsTools.transmitSuccessiveInvalidations(new ListBinding<Generic>() {
ObservableList<Generic> holders = ObservableListExtractor.HOLDERS.apply(model.getGenerics());
{
Expand All @@ -48,7 +48,7 @@ protected ObservableList<Generic> computeValue() {
};
new GSSubcellEditorWithRemoval(this) {
{
addStyle("flex", "1");
addStyle("flex", "1 0 auto");
forEach2(model -> BindingsTools.transmitSuccessiveInvalidations(new ListBinding<Generic>() {
ObservableList<Generic> holders = ObservableListExtractor.HOLDERS.apply(model.getGenerics());
{
Expand All @@ -64,11 +64,15 @@ protected ObservableList<Generic> computeValue() {
};
new GSSubcellAdder(this) {
{
select__(model -> Bindings.createObjectBinding(() -> {
addStyle("flex", "1 0 auto");
select__(model -> {
ObservableList<Generic> holders = ObservableListExtractor.HOLDERS.apply(model.getGenerics());
return holders.isEmpty() || (model.getGeneric().getComponents().size() < 2 && !model.getGeneric().isPropertyConstraintEnabled())
|| (model.getGeneric().getComponents().size() >= 2 && !model.getGeneric().isSingularConstraintEnabled(ApiStatics.BASE_POSITION)) ? model : null;
}, ObservableListExtractor.HOLDERS.apply(model.getGenerics())));
return Bindings
.createObjectBinding(
() -> holders.isEmpty() || (model.getGeneric().getComponents().size() < 2 && !model.getGeneric().isPropertyConstraintEnabled())
|| (model.getGeneric().getComponents().size() >= 2 && !model.getGeneric().isSingularConstraintEnabled(ApiStatics.BASE_POSITION)) ? model : null,
ObservableListExtractor.HOLDERS.apply(model.getGenerics()));
});
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package org.genericsystem.reactor.gs;

import java.io.Serializable;

import javafx.beans.property.Property;

import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gs.GSCheckBoxWithValue.GSCheckBoxEditor;
import org.genericsystem.reactor.gstag.HtmlHyperLink;
import org.genericsystem.reactor.modelproperties.GSBuilderDefaults;

public class GSBooleanHolderEditor extends GSSection {
public class GSBooleanHolderEditor extends GSDiv {

protected GSCheckBoxWithValue checkbox;

Expand All @@ -21,7 +15,7 @@ public GSBooleanHolderEditor(Tag parent) {
public GSBooleanHolderEditor(Tag parent, GSCheckBoxConstructor constructor) {
super(parent, FlexDirection.ROW);
addStyle("flex", "1");
new GSSection(this, FlexDirection.ROW) {
new GSDiv(this, FlexDirection.ROW) {
{
addStyle("flex", "1");
addStyle("justify-content", "center");
Expand All @@ -36,45 +30,6 @@ public interface GSCheckBoxConstructor {
GSCheckBoxWithValue build(Tag parent);
}

public static class GSBooleanHolderEditorWithRemoval extends GSBooleanHolderEditor {

public GSBooleanHolderEditorWithRemoval(Tag parent) {
super(parent);
new HtmlHyperLink(this) {
{
addStyle("justify-content", "center");
addStyle("text-decoration", "none");
setText("×");
bindAction(Context::remove);
}
};
}
}

public static class GSBooleanHolderAdder extends GSBooleanHolderEditor {

public GSBooleanHolderAdder(Tag parent) {
super(parent, GSCheckBoxWithValue::new);
checkbox.addConvertedValueChangeListener((model, nva) -> {
if (nva != null)
model.getGenerics()[1].addHolder(model.getGeneric(), nva);
});
new HtmlHyperLink(this) {
{
addStyle("justify-content", "center");
addStyle("text-decoration", "none");
setText("+");
bindAction(model -> {
Property<Serializable> observable = checkbox.getConvertedValueProperty(model);
Boolean newValue = (Boolean) observable.getValue();
observable.setValue(null);
model.getGenerics()[1].addHolder(model.getGeneric(), newValue);
});
}
};
}
}

public static class GSBooleanHolderBuilder extends GSBooleanHolderEditor implements GSBuilderDefaults {

public GSBooleanHolderBuilder(Tag parent) {
Expand Down

0 comments on commit df78d7a

Please sign in to comment.