@UiHandler(value = "intervalTypeList") public void onIntervalTypeSelected(ChangeEvent changeEvent) { presenter.changeIntervalType(); } }
@UiHandler(value = "timeModeList") public void onTimeModeSelected(ChangeEvent changeEvent) { presenter.changeTimeMode(); }
public void execute() { fromEditor.getTimeInstant().setFirstMonthOfYear(getFirstMonthOfYear()); timeFrame.setFrom(fromEditor.getTimeInstant()); changeFirstMonthAvailability(); fireChanges(); } });
public void init(final TimeInstant ti, final Command onChangeCommand) { this.timeInstant = ti != null ? ti : new TimeInstant(); this.onChangeCommand = onChangeCommand; this.timeAmountEditor.init(timeInstant.getTimeAmount(), new Command() { public void execute() { timeInstant.setTimeAmount(timeAmountEditor.getTimeAmount()); onChangeCommand.execute(); } }); initTimeModeSelector(); initIntervalTypeSelector(); }
@Test public void testChangeTimeMode() { when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.BEGIN.getIndex()); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.BEGIN); verify(changeCommand).execute(); }
@Test public void testChangeIntervalType() { when(timeInstantView.getSelectedIntervalTypeIndex()).thenReturn(0); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); timeInstantEditor.changeIntervalType(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getIntervalType(), DateIntervalType.MINUTE); verify(changeCommand).execute(); }
@Test public void testNullInitialization() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); assertEquals(timeInstantView, timeInstantEditor.view); verify(timeInstantView).init(timeInstantEditor); verify(timeInstantView).clearTimeModeSelector(); verify(timeInstantView, times(TimeInstant.TimeMode.values().length)).addTimeModeItem(any(TimeInstant.TimeMode.class)); verify(timeInstantView).setSelectedTimeModeIndex(TimeInstant.TimeMode.NOW.getIndex()); verify(timeInstantView).disableIntervalTypeSelector(); verify(timeInstantView, never()).clearIntervalTypeSelector(); verify(timeInstantView, never()).enableIntervalTypeSelector(); verify(timeInstantView, never()).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeInstantView, never()).setSelectedIntervalTypeIndex(any(Integer.class)); }
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(); }
void changeIntervalType() { int selectedIdx = view.getSelectedIntervalTypeIndex(); DateIntervalType intervalType = INTERVAL_TYPES.get(selectedIdx); timeInstant.setIntervalType(intervalType); onChangeCommand.execute(); initIntervalTypeSelector(); } }
@Override public void init(TimeInstantEditor presenter) { this.presenter = presenter; this.timeAmountEditor = presenter.getTimeAmountEditor(); initWidget(uiBinder.createAndBindUi(this)); }
@Before public void init() { fromAmountEditor = new TimeAmountEditor(timeAmountView); toAmountEditor = new TimeAmountEditor(timeAmountView); fromInstantEditor = new TimeInstantEditor(timeInstantView, fromAmountEditor); toInstantEditor = new TimeInstantEditor(timeInstantView, toAmountEditor); timeFrameEditor = new TimeFrameEditor(timeFrameView, beanManager); SyncBeanDef tieBeanDef = mock(SyncBeanDef.class); when(beanManager.lookupBean(TimeInstantEditor.class)).thenReturn(tieBeanDef); when(tieBeanDef.newInstance()).thenReturn(fromInstantEditor, toInstantEditor); }
@Test public void testChangeTimeMode() { when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.BEGIN.getIndex()); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.BEGIN); verify(changeCommand).execute(); }
@Test public void testChangeIntervalType() { when(timeInstantView.getSelectedIntervalTypeIndex()).thenReturn(0); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); timeInstantEditor.changeIntervalType(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getIntervalType(), DateIntervalType.MINUTE); verify(changeCommand).execute(); }
@Test public void testNullInitialization() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); assertEquals(timeInstantView, timeInstantEditor.view); verify(timeInstantView).init(timeInstantEditor); verify(timeInstantView).clearTimeModeSelector(); verify(timeInstantView, times(TimeInstant.TimeMode.values().length)).addTimeModeItem(any(TimeInstant.TimeMode.class)); verify(timeInstantView).setSelectedTimeModeIndex(TimeInstant.TimeMode.NOW.getIndex()); verify(timeInstantView).disableIntervalTypeSelector(); verify(timeInstantView, never()).clearIntervalTypeSelector(); verify(timeInstantView, never()).enableIntervalTypeSelector(); verify(timeInstantView, never()).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeInstantView, never()).setSelectedIntervalTypeIndex(any(Integer.class)); }
public void init(final TimeInstant ti, final Command onChangeCommand) { this.timeInstant = ti != null ? ti : new TimeInstant(); this.onChangeCommand = onChangeCommand; this.timeAmountEditor.init(timeInstant.getTimeAmount(), new Command() { public void execute() { timeInstant.setTimeAmount(timeAmountEditor.getTimeAmount()); onChangeCommand.execute(); } }); initTimeModeSelector(); initIntervalTypeSelector(); }
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(); }
void changeIntervalType() { int selectedIdx = view.getSelectedIntervalTypeIndex(); DateIntervalType intervalType = INTERVAL_TYPES.get(selectedIdx); timeInstant.setIntervalType(intervalType); onChangeCommand.execute(); initIntervalTypeSelector(); } }
@Override public void init(TimeInstantEditor presenter) { this.presenter = presenter; this.timeAmountEditor = presenter.getTimeAmountEditor(); initWidget(uiBinder.createAndBindUi(this)); }
@Before public void init() { fromAmountEditor = new TimeAmountEditor(timeAmountView); toAmountEditor = new TimeAmountEditor(timeAmountView); fromInstantEditor = new TimeInstantEditor(timeInstantView, fromAmountEditor); toInstantEditor = new TimeInstantEditor(timeInstantView, toAmountEditor); timeFrameEditor = new TimeFrameEditor(timeFrameView, beanManager); SyncBeanDef tieBeanDef = mock(SyncBeanDef.class); when(beanManager.lookupBean(TimeInstantEditor.class)).thenReturn(tieBeanDef); when(tieBeanDef.newInstance()).thenReturn(fromInstantEditor, toInstantEditor); }
@Test public void testSwitchFromNow() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); reset(timeInstantView); when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.END.getIndex()); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.END); verify(timeInstantView).enableIntervalTypeSelector(); verify(changeCommand).execute(); } }