@Test public void testChangeTimeAmountQuantity() { TimeFrame timeFrame = TimeFrame.parse("now -1year till now"); timeFrameEditor.init(timeFrame, changeCommand); long qb = timeFrame.getFrom().getTimeAmount().getQuantity(); fromAmountEditor.decreaseQuantity(); long qa = timeFrame.getFrom().getTimeAmount().getQuantity(); verify(changeCommand).execute(); assertEquals(qb - 1, qa); }
public void init(TimeFrame tf, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeFrame = tf != null ? tf : TimeFrame.parse("begin[year] till end[year]"); this.fromEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.fromEditor.init(timeFrame.getFrom(), new Command() { public void execute() { fromEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setFrom(fromEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); this.toEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.toEditor.init(timeFrame.getTo(), new Command() { public void execute() { toEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setTo(toEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); view.init(this); initFirstMonthSelector(); changeFirstMonthAvailability(); }
TimeFrameEditor implements FunctionParameterEditor { public void init(TimeFrame tf, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeFrame = tf != null ? tf : TimeFrame.parse("begin[year] till end[year]"); this.fromEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.fromEditor.init(timeFrame.getFrom(), new Command() { public void execute() { fromEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setFrom(fromEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); this.toEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.toEditor.init(timeFrame.getTo(), new Command() { public void execute() { toEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setTo(toEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); view.init(this); initFirstMonthSelector(); changeFirstMonthAvailability(); } }
TimeFrameEditor implements FunctionParameterEditor { public void init(TimeFrame tf, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeFrame = tf != null ? tf : TimeFrame.parse("begin[year] till end[year]"); this.fromEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.fromEditor.init(timeFrame.getFrom(), new Command() { public void execute() { fromEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setFrom(fromEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); this.toEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.toEditor.init(timeFrame.getTo(), new Command() { public void execute() { toEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setTo(toEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); view.init(this); initFirstMonthSelector(); changeFirstMonthAvailability(); } @Inject  TimeFrameEditor(View view, SyncBeanManager beanManager); }
TimeFrameEditor implements FunctionParameterEditor { public void init(TimeFrame tf, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeFrame = tf != null ? tf : TimeFrame.parse("begin[year] till end[year]"); this.fromEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.fromEditor.init(timeFrame.getFrom(), new Command() { public void execute() { fromEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setFrom(fromEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); this.toEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.toEditor.init(timeFrame.getTo(), new Command() { public void execute() { toEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setTo(toEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); view.init(this); initFirstMonthSelector(); changeFirstMonthAvailability(); } @Inject  TimeFrameEditor(View view, SyncBeanManager beanManager); @Override Widget asWidget(); TimeFrame getTimeFrame(); TimeInstantEditor getFromEditor(); TimeInstantEditor getToEditor(); void init(TimeFrame tf, Command onChangeCommand); boolean isFirstMonthAvailable(); Month getFirstMonthOfYear(); void setFirstMonthOfYear(Month month); @Override void setFocus(boolean focus); void changeFirstMonth(); }
TimeFrameEditor implements FunctionParameterEditor { public void init(TimeFrame tf, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeFrame = tf != null ? tf : TimeFrame.parse("begin[year] till end[year]"); this.fromEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.fromEditor.init(timeFrame.getFrom(), new Command() { public void execute() { fromEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setFrom(fromEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); this.toEditor = beanManager.lookupBean(TimeInstantEditor.class).newInstance(); this.toEditor.init(timeFrame.getTo(), new Command() { public void execute() { toEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setTo(toEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } }); view.init(this); initFirstMonthSelector(); changeFirstMonthAvailability(); } @Inject  TimeFrameEditor(View view, SyncBeanManager beanManager); @Override Widget asWidget(); TimeFrame getTimeFrame(); TimeInstantEditor getFromEditor(); TimeInstantEditor getToEditor(); void init(TimeFrame tf, Command onChangeCommand); boolean isFirstMonthAvailable(); Month getFirstMonthOfYear(); void setFirstMonthOfYear(Month month); @Override void setFocus(boolean focus); void changeFirstMonth();  }