diff -r c8810910c311 -r d3cbe257c4e9 javaquery/demo-calculator-dynamic/src/main/java/org/apidesign/bck2brwsr/demo/calc/Calc.java --- a/javaquery/demo-calculator-dynamic/src/main/java/org/apidesign/bck2brwsr/demo/calc/Calc.java Mon Mar 25 16:47:17 2013 +0100 +++ b/javaquery/demo-calculator-dynamic/src/main/java/org/apidesign/bck2brwsr/demo/calc/Calc.java Mon Jun 09 09:39:59 2014 +0200 @@ -36,7 +36,7 @@ @Property(name = "display", type = double.class), @Property(name = "operation", type = String.class), @Property(name = "hover", type = boolean.class), - @Property(name = "history", type = double.class, array = true) + @Property(name = "history", type = HistoryImpl.class, array = true) }) public class Calc { static { @@ -74,19 +74,22 @@ c.getDisplay() ); c.setDisplay(newValue); - if (!c.getHistory().contains(newValue)) { - c.getHistory().add(newValue); + if (!containsValue(c.getHistory(), newValue)) { + History h = new History(); + h.setValue(newValue); + h.setOperation(c.getOperation()); + c.getHistory().add(h); } c.setMemory(0); } @OnFunction - static void recoverMemory(Calculator c, double data) { - c.setDisplay(data); + static void recoverMemory(Calculator c, History data) { + c.setDisplay(data.getValue()); } @OnFunction - static void removeMemory(Calculator c, double data) { + static void removeMemory(Calculator c, History data) { c.getHistory().remove(data); } @@ -131,4 +134,13 @@ static boolean emptyHistory(List history) { return history.isEmpty(); } + + private static boolean containsValue(List arr, final double newValue) { + for (History history : arr) { + if (history.getValue() == newValue) { + return true; + } + } + return false; + } }