@Test public void testNullInitialization() { timeFrameEditor.init(UNDEFINED, changeCommand); assertEquals(timeFrameView, timeFrameEditor.view); verify(timeFrameView).init(timeFrameEditor); verify(timeFrameView).clearFirstMonthSelector(); verify(timeFrameView, times(Month.values().length)).addFirstMonthItem(any(Month.class)); verify(timeFrameView).setSelectedFirstMonthIndex(Month.JANUARY.getIndex() - 1); }
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(); }
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(); }
@Override public Widget asWidget() { return view.asWidget(); }
public void changeFirstMonth() { int selectedIdx = view.getSelectedFirstMonthIndex(); Month month = Month.getByIndex(selectedIdx + 1); setFirstMonthOfYear(month); fireChanges(); }
public void changeFirstMonth() { int selectedIdx = view.getSelectedFirstMonthIndex(); Month month = Month.getByIndex(selectedIdx + 1); setFirstMonthOfYear(month); fireChanges(); }
protected void changeFirstMonthAvailability() { view.hideFirstMonthSelector(); if (isFirstMonthAvailable()) { view.showFirstMonthSelector(); } }
@Test public void testViewInitialization() { timeFrameEditor.init(TEN_DAYS, changeCommand); assertEquals(timeFrameView, timeFrameEditor.view); verify(timeFrameView).init(timeFrameEditor); verify(timeFrameView).clearFirstMonthSelector(); verify(timeFrameView, times(Month.values().length)).addFirstMonthItem(any(Month.class)); verify(timeFrameView).setSelectedFirstMonthIndex(Month.MARCH.getIndex() - 1); }
@Override public Widget asWidget() { return view.asWidget(); }
protected void initFirstMonthSelector() { view.clearFirstMonthSelector(); Month current = getFirstMonthOfYear(); Month[] entries = Month.values(); for (int i = 0; i < entries.length; i++) { Month entry = entries[i]; view.addFirstMonthItem(entry); if (current != null && current.equals(entry)) { view.setSelectedFirstMonthIndex(i); } } }
@Test public void testNullInitialization() { timeFrameEditor.init(UNDEFINED, changeCommand); assertEquals(timeFrameView, timeFrameEditor.view); verify(timeFrameView).init(timeFrameEditor); verify(timeFrameView).clearFirstMonthSelector(); verify(timeFrameView, times(Month.values().length)).addFirstMonthItem(any(Month.class)); verify(timeFrameView).setSelectedFirstMonthIndex(Month.JANUARY.getIndex() - 1); }
@Test public void testViewInitialization() { timeFrameEditor.init(TEN_DAYS, changeCommand); assertEquals(timeFrameView, timeFrameEditor.view); verify(timeFrameView).init(timeFrameEditor); verify(timeFrameView).clearFirstMonthSelector(); verify(timeFrameView, times(Month.values().length)).addFirstMonthItem(any(Month.class)); verify(timeFrameView).setSelectedFirstMonthIndex(Month.MARCH.getIndex() - 1); }
protected void changeFirstMonthAvailability() { view.hideFirstMonthSelector(); if (isFirstMonthAvailable()) { view.showFirstMonthSelector(); } }
protected void initFirstMonthSelector() { view.clearFirstMonthSelector(); Month current = getFirstMonthOfYear(); Month[] entries = Month.values(); for (int i = 0; i < entries.length; i++) { Month entry = entries[i]; view.addFirstMonthItem(entry); if (current != null && current.equals(entry)) { view.setSelectedFirstMonthIndex(i); } } }