Skip to content

Commit

Permalink
gs-reactor Cache display improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
plagarrigue committed Sep 2, 2016
1 parent df78d7a commit 9ab93c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
Expand Up @@ -54,7 +54,7 @@ public GSUserGuide(Tag parent) {
HtmlLi li1 = new HtmlLi(this);
HtmlLi li2 = new HtmlLi(this);
HtmlLi li3 = new HtmlLi(this);
li1.setText("Add new color");
li1.setText("Add new color of any CSS color style (ex : Black, rgb(0,0,0), #000000, ...)");
li2.setText("Select car in the ComboBox");
li3.setText("Use \"add Button\" to update data");
}
Expand Down
Expand Up @@ -71,6 +71,7 @@ public final void stop() {
protected final ObjectProperty<IDifferential<Generic>> transactionProperty;
protected final ObjectProperty<Differential> differentialProperty = new SimpleObjectProperty<>();;
private ObservableIntegerValue cacheLevel;
private ObservableLongValue ts;
private final ContextEventListener<Generic> listener;
private Map<Generic, ObservableList<Generic>> dependenciesAsOservableListCacheMap = new HashMap<>();

Expand Down Expand Up @@ -100,7 +101,7 @@ public AbstractCache(Root root, ContextEventListener<Generic> listener) {
this.listener = listener;
transactionProperty = new SimpleObjectProperty<>(buildTransaction());
cacheLevel = Bindings.createIntegerBinding(() -> differentialProperty.get().getCacheLevel(), differentialProperty);

ts = Bindings.createLongBinding(() -> transactionProperty.get().getTs(), transactionProperty);
initialize();
}

Expand All @@ -124,6 +125,11 @@ public long getTs() {
return getTransaction().getTs();
}

@Override
public ObservableLongValue getTsObservableValue() {
return ts;
}

@Override
public Snapshot<Generic> getDependencies(Generic generic) {
return getDifferential().getDependencies(generic);
Expand Down
Expand Up @@ -6,6 +6,7 @@
import org.genericsystem.api.core.exceptions.ConcurrencyControlException;

import javafx.beans.value.ObservableIntegerValue;
import javafx.beans.value.ObservableLongValue;

/**
* @author Nicolas Feybesse
Expand Down Expand Up @@ -42,5 +43,7 @@ public interface DefaultCache<T extends DefaultGeneric<T>> extends DefaultContex

ObservableIntegerValue getCacheLevelObservableValue();

ObservableLongValue getTsObservableValue();

boolean contains(T generic);
}
Expand Up @@ -14,6 +14,7 @@
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableIntegerValue;
import javafx.beans.value.ObservableLongValue;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;

Expand Down Expand Up @@ -163,6 +164,11 @@ public ObservableIntegerValue getCacheLevelObservableValue() {
return getGeneric().getCurrentCache().getCacheLevelObservableValue();
}

public ObservableLongValue getTsObservableValue() {

return getGeneric().getCurrentCache().getTsObservableValue();
}

public void mount() {
getGeneric().getCurrentCache().mount();
}
Expand Down
@@ -1,8 +1,18 @@
package org.genericsystem.reactor.gs;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;

import org.genericsystem.common.Statics;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gstag.HtmlButton;
import org.genericsystem.reactor.gstag.HtmlLabel;

import javafx.beans.binding.Bindings;

public class GSMonitor extends GSDiv {

Expand All @@ -26,12 +36,17 @@ public GSMonitor(Tag parent, FlexDirection direction) {
bindAction(Context::cancel);
}
};
// new HtmlButton(this) {
// {
// setText("traverse");
// bindAction(Context::traverse);
// }
// };
new HtmlLabel(this) {
{
bindText(context -> Bindings.createStringBinding(() -> {
Long tsMs = (Long) context.getTsObservableValue().getValue() / Statics.MILLI_TO_NANOSECONDS;
Date dateMs = new Date(tsMs);
Instant instant = Instant.ofEpochMilli(dateMs.getTime());
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.systemDefault());
return "Last update : " + ldt.format(DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss"));
}, context.getTsObservableValue()));
}
};
// new GSButton(this) {
// {
// setText("Collect");
Expand Down

0 comments on commit 9ab93c2

Please sign in to comment.