protected void checkLoader(ComplexPanel panel) { assertTrue(panel.getWidget(0) instanceof MaterialWidget); MaterialWidget loaderWrapper = (MaterialWidget) panel.getWidget(0); assertTrue(loaderWrapper.getElement().hasClassName(CssName.LOADER_WRAPPER)); assertTrue(loaderWrapper.getElement().hasClassName(CssName.VALIGN_WRAPPER)); assertTrue(loaderWrapper.getWidget(0) instanceof MaterialPreLoader); MaterialPreLoader preLoader = (MaterialPreLoader) loaderWrapper.getWidget(0); checkPreLoader(preLoader); assertEquals(4, preLoader.getChildren().size()); for (Widget w : preLoader.getChildren()) { assertTrue(w instanceof MaterialSpinner); MaterialSpinner spinner = (MaterialSpinner) w; checkSpinner(spinner); } MaterialLoader.loading(false); assertEquals(panel.getWidgetCount(), 0); }
@Override public void addContextGroupMenuItem(final String menuItemId, final String id, final String label, final MenuPosition position) { final ListDropDown listDropDown = GWT.create(ListDropDown.class); listDropDown.setStyleName("dropdown-submenu"); final Anchor anchor = GWT.create(Anchor.class); anchor.addStyleName(Styles.DROPDOWN_TOGGLE); anchor.setDataToggle(Toggle.DROPDOWN); anchor.setText(label); final DropDownMenu dropDownMenu = GWT.create(DropDownMenu.class); listDropDown.add(anchor); listDropDown.add(dropDownMenu); positionMenuItem(listDropDown, position); ComplexPanel contextContainer = getMenuItemContextWidgetMap().get(menuItemId); if (contextContainer == null) { contextContainer = getContextContainer(menuItemId); } contextContainer.add(listDropDown); getMenuItemContextWidgetMap().put(id, dropDownMenu); }
@Override public void selectMenuItem(final String id) { ComplexPanel menuItemWidget = getMenuItemWidgetMap().get(id); if (menuItemWidget == null) { menuItemWidget = GWT.create(ListItem.class); menuItemWidget.addStyleName(UF_PERSPECTIVE_CONTEXT_MENU_EMPTY); getMenuItemWidgetMap().put(id, menuItemWidget); navbarNav.add(menuItemWidget); } super.selectMenuItem(id); addContextMenusToContainer(id, menuItemWidget); for (Map.Entry<String, ComplexPanel> context : getContextContainerWidgetMap().entrySet()) { if (context.getKey().equals(id)) { context.getValue().setVisible(true); context.getValue().getParent().addStyleName(UF_PERSPECTIVE_CONTEXT_MENU_CONTAINER); } else { context.getValue().setVisible(false); } } }
@Override public void doTest(final ComplexPanel sandbox) { testAdd(); testClear(); testContains(); testEquals(); testGet(); testIndexOf(); testIsEmpty(); testIterator(); testLastIndexOf(); testRemove(); testSet(); testSize(); // FIXME testListIterator(); testRetain(); testToArray(); testToString(); testSublist(); }
@Override public void doTest(ComplexPanel sandbox) { test(D3.time().year(), "January 11, 1979 09:05:18", "January 1, 1979 00:00:00", "January 1, 1980 00:00:00", "January 1, 1979 00:00:00", "January 11, 1982 09:05:18"); test(D3.time().month(), "January 11, 1979 09:05:18", "January 1, 1979 00:00:00", "February 1, 1979 00:00:00", "January 1, 1979 00:00:00", "April 11, 1979 09:05:18"); test(D3.time().hour(), "January 11, 1979 09:05:18", "January 11, 1979 09:00:00", "January 11, 1979 10:00:00", "January 11, 1979 09:00:00", "January 11, 1979 12:05:18"); test(D3.time().minute(), "January 11, 1979 09:05:18", "January 11, 1979 09:05:00", "January 11, 1979 09:06:00", "January 11, 1979 09:05:00", "January 11, 1979 09:08:18"); test(D3.time().second(), "January 11, 1979 09:05:18", "January 11, 1979 09:05:18", "January 11, 1979 09:05:18", "January 11, 1979 09:05:18", "January 11, 1979 09:05:21"); test(D3.time().day(), "January 11, 1979 09:05:18", "January 11, 1979 00:00:00", "January 12, 1979 00:00:00", "January 11, 1979 00:00:00", "January 14, 1979 09:05:18"); test(D3.time().week(), "January 11, 1979 09:05:18", "January 7, 1979 00:00:00", "January 14, 1979 00:00:00", "January 14, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().sunday(), "January 11, 1979 09:05:18", "January 7, 1979 00:00:00", "January 14, 1979 00:00:00", "January 14, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().monday(), "January 11, 1979 09:05:18", "January 8, 1979 00:00:00", "January 15, 1979 00:00:00", "January 8, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().tuesday(), "January 11, 1979 09:05:18", "January 9, 1979 00:00:00", "January 16, 1979 00:00:00", "January 9, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().wednesday(), "January 11, 1979 09:05:18", "January 10, 1979 00:00:00", "January 17, 1979 00:00:00", "January 10, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().thursday(), "January 11, 1979 09:05:18", "January 11, 1979 00:00:00", "January 18, 1979 00:00:00", "January 11, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().friday(), "January 11, 1979 09:05:18", "January 5, 1979 00:00:00", "January 12, 1979 00:00:00", "January 12, 1979 00:00:00", "February 1, 1979 09:05:18"); test(D3.time().saturday(), "January 11, 1979 09:05:18", "January 6, 1979 00:00:00", "January 13, 1979 00:00:00", "January 13, 1979 00:00:00", "February 1, 1979 09:05:18"); }
@Override public void doTest(final ComplexPanel sandbox) { // built in testEasingFunction(Easing.back(4), Easing.back(Mode.IN_OUT, 4)); testEasingFunction(Easing.bounce(), Easing.bounce(Mode.IN_OUT)); testEasingFunction(Easing.circle(), Easing.circle(Mode.OUT)); testEasingFunction(Easing.cubic(), Easing.cubic(Mode.IN_OUT)); testEasingFunction(Easing.exp(), Easing.exp(Mode.OUT_IN)); testEasingFunction(Easing.linear(), Easing.linear(Mode.IN_OUT)); testEasingFunction(Easing.quad(), Easing.quad(Mode.IN_OUT)); testEasingFunction(Easing.sin(), Easing.sin(Mode.IN_OUT)); testEasingFunction(Easing.elastic(10, 0.5), Easing.elastic(Mode.IN_OUT, 10, 0.5)); testEasingFunction(Easing.poly(3), Easing.poly(Mode.IN_OUT, 3)); // custom EasingFunction f = new EasingFunction() { @Override public double ease(final double t) { return t; } }; testEasingFunction(f, f); // pass it }
@Test public void testPanels() throws Exception { invokeAllAccessibleMethods(new AbsolutePanel() {}); invokeAllAccessibleMethods(new CellPanel() {}); invokeAllAccessibleMethods(new ComplexPanel() {}); invokeAllAccessibleMethods(new DeckLayoutPanel() {}); invokeAllAccessibleMethods(new DeckPanel() {}); invokeAllAccessibleMethods(new DecoratorPanel() {}); invokeAllAccessibleMethods(new DockLayoutPanel(Unit.PX) {}); invokeAllAccessibleMethods(new DockPanel() {}); invokeAllAccessibleMethods(new FlowPanel() {}); invokeAllAccessibleMethods(new FocusPanel() {}); invokeAllAccessibleMethods(new HorizontalPanel() {}); invokeAllAccessibleMethods(new HTMLPanel("") {}); invokeAllAccessibleMethods(new LayoutPanel() {}); invokeAllAccessibleMethods(new PopupPanel() {}); invokeAllAccessibleMethods(new RenderablePanel("") {}); invokeAllAccessibleMethods(new ResizeLayoutPanel() {}); invokeAllAccessibleMethods(new SimpleLayoutPanel() {}); invokeAllAccessibleMethods(new SimplePanel() {}); invokeAllAccessibleMethods(new SplitLayoutPanel() {}); invokeAllAccessibleMethods(new StackPanel() {}); invokeAllAccessibleMethods(new VerticalPanel() {}); }
public void testProgressBasic() { MaterialLoader.progress(true); ComplexPanel panel = RootPanel.get(); // when / then checkProgress(panel); }
protected void checkProgress(ComplexPanel panel) { assertNotNull(panel.getWidget(0)); assertTrue(panel.getWidget(0) instanceof MaterialWidget); MaterialWidget loaderWrapper = (MaterialWidget) panel.getWidget(0); assertTrue(loaderWrapper.getElement().hasClassName(CssName.PROGRESS_WRAPPER)); assertTrue(loaderWrapper.getElement().hasClassName(CssName.VALIGN_WRAPPER)); assertTrue(loaderWrapper.getWidget(0) instanceof MaterialProgress); MaterialProgress progress = (MaterialProgress) loaderWrapper.getWidget(0); checkProgressBar(progress); checkProgressValue(progress); MaterialLoader.loading(false); assertEquals(0, panel.getWidgetCount()); }
public void testLoaderBasic() { MaterialLoader.loading(true); ComplexPanel panel = RootPanel.get(); // when / then checkLoader(panel); }
private static int findIndex(Widget cell) { int retval = ((ComplexPanel) cell.getParent()).getWidgetIndex(cell); Widget w; for (int i = 0; i < ((ComplexPanel) cell.getParent()).getWidgetIndex(cell); i++) { w = ((ComplexPanel) cell.getParent()).getWidget(i); if (w instanceof HTML) retval--; } return retval; }
protected <T extends ComplexPanel> boolean handleDefaultAction(final T panel) { for (int i = 0; i < panel.getWidgetCount(); i++) { final Widget w = panel.getWidget(i); if (w instanceof ModalFooter) { return handleModalFooter((ModalFooter) w); } else if (w instanceof ModalDialog) { return handleDefaultAction((ModalDialog) w); } else if (w instanceof ModalContent) { return handleDefaultAction((ModalContent) w); } } return false; }
private void removeChildWidgets(final ComplexPanel panel) { final Iterator<Widget> iterator = panel.iterator(); while (iterator.hasNext()) { iterator.next(); iterator.remove(); } }
@Override public void addMenuItem(final String id, final String label, final String parentId, final Command command, final MenuPosition position) { final AnchorListItem menuItem = GWT.create(AnchorListItem.class); menuItem.setText(label); if (command != null) { menuItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { command.execute(); } }); } getMenuItemWidgetMap().put(id, menuItem); if (parentId == null) { positionMenuItem(menuItem, position); navbarNav.add(menuItem); } else { final ComplexPanel parent = getMenuItemWidgetMap().get(parentId); if (parent != null) { parent.add(menuItem); } } }
@Override public void addContextMenuItem( final String menuItemId, final String id, final String label, final String parentId, final Command command, final MenuPosition position) { final AnchorListItem menuItem = GWT.create(AnchorListItem.class); menuItem.setText(label); if (command != null) { menuItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { command.execute(); } }); } positionMenuItem(menuItem, position); ComplexPanel contextContainer = getMenuItemContextWidgetMap().get(parentId); if (contextContainer == null) { contextContainer = getContextContainer(menuItemId); } contextContainer.add(menuItem); getMenuItemContextWidgetMap().put(id, menuItem); }
@Override public void clearContextMenu() { super.clearContextMenu(); for (final ComplexPanel contextContainer : getContextContainerWidgetMap().values()) { contextContainer.clear(); contextContainer.removeFromParent(); } getContextContainerWidgetMap().clear(); }
private ComplexPanel getContextContainer(final String menuItemId) { ComplexPanel contextContainer = getContextContainerWidgetMap().get(menuItemId); if (contextContainer == null) { contextContainer = GWT.create(UnorderedList.class); contextContainer.addStyleName("nav navbar-nav navbar-persistent"); contextContainer.addStyleName(UF_PERSPECTIVE_CONTEXT_MENU); contextContainer.setVisible(false); getContextContainerWidgetMap().put(menuItemId, contextContainer); } return contextContainer; }
private void addContextMenusToContainer(final String menuItemId, final ComplexPanel menuItemWidget) { final ComplexPanel contextContainer = getContextContainerWidgetMap().get(menuItemId); final ComplexPanel container = menuItemWidget.getParent().getParent() instanceof ListDropDown ? (ListDropDown) menuItemWidget.getParent().getParent() : menuItemWidget; if (contextContainer != null && container.getWidgetIndex(contextContainer) == -1) { container.add(contextContainer); } }
@Override protected void selectElement(final ComplexPanel item) { iterateWidgets(navbarNav); if (item == null) { return; } item.addStyleName(Styles.ACTIVE); if (item.getParent() != null && item.getParent().getParent() instanceof ListDropDown) { item.getParent().getParent().addStyleName(Styles.ACTIVE); } }
private void iterateWidgets(final ComplexPanel widget) { widget.removeStyleName(Styles.ACTIVE); widget.removeStyleName(UF_PERSPECTIVE_CONTEXT_MENU_CONTAINER); for (Widget next : widget) { if (next instanceof ComplexPanel) { iterateWidgets((ComplexPanel) next); } } }
@Override public void selectMenuItem(final String id) { final ComplexPanel menuItemWidget = getMenuItemWidgetMap().get(id); if (menuItemWidget != null) { selectElement(menuItemWidget); } }
@Override public void enableMenuItem(final String menuItemId, final boolean enabled) { final ComplexPanel cp = getMenuItemWidgetMap().get(menuItemId); if (cp == null) { return; } if (cp instanceof AnchorListItem) { ((AnchorListItem) cp).setEnabled(enabled); } }
@Override public void enableContextMenuItem(final String menuItemId, final boolean enabled) { final ComplexPanel cp = getMenuItemContextWidgetMap().get(menuItemId); if (cp == null) { return; } if (cp instanceof AnchorListItem) { ((AnchorListItem) cp).setEnabled(enabled); } }
@Override public void clearContextMenu() { for (final ComplexPanel contextContainer : getMenuItemContextWidgetMap().values()) { contextContainer.clear(); contextContainer.removeFromParent(); } getMenuItemContextWidgetMap().clear(); }
@Override public void addContextMenuItem( final String menuItemId, final String id, final String label, final String parentId, final Command command, final MenuPosition position) { final AnchorListItem menuItem = GWT.create(AnchorListItem.class); menuItem.setText(label); if (parentId == null) { menuItem.addStyleName(UF_PERSPECTIVE_CONTEXT_MENU); } if (command != null) { menuItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { command.execute(); } }); } final ComplexPanel contextContainer = getMenuItemContextWidgetMap().get(parentId); if (contextContainer != null) { contextContainer.add(menuItem); } else { menuItemContextMenus.get(menuItemId).add(menuItem); } getMenuItemContextWidgetMap().put(id, menuItem); }
@Override public void clearContextMenu() { super.clearContextMenu(); for (final ComplexPanel contextContainer : menuItemContextMenus.values()) { contextContainer.clear(); contextContainer.removeFromParent(); } menuItemContextMenus.clear(); }
@Override public void selectMenuItem(final String id) { super.selectMenuItem(id); final String menuLabel = menuLabelMap.get(id); text.setText(menuLabel == null ? "" : menuLabel); for (ComplexPanel context : menuItemContextMenus.get(id)) { navbarNav.add(context); } }
@Override protected void selectElement(final ComplexPanel item) { for (Widget widget : dropDownMenu) { widget.removeStyleName(Styles.ACTIVE); } if (item != null) { item.addStyleName(Styles.ACTIVE); } }
@Before public void setup() { workbenchMenuStandardNavBarView = spy(WorkbenchMenuStandardNavBarView.class); workbenchMenuStandardNavBarView.getMenuItemWidgetMap().put("menuItemId", spy(ComplexPanel.class)); }
@Test public void testSelectElement() { final ListDropDown parent1 = mock(ListDropDown.class); final Widget parent2 = mock(Widget.class); final ComplexPanel panel = mock(ComplexPanel.class); when(navbarNav.iterator()).thenReturn(Collections.<Widget>emptyList().iterator()); when(panel.getParent()).thenReturn(parent2); when(parent2.getParent()).thenReturn(parent1); workbenchMenuStandardNavBarView.selectElement(panel); verify(panel).addStyleName(Styles.ACTIVE); verify(parent1).addStyleName(Styles.ACTIVE); }
@Test public void testClear() { workbenchMenuStandardNavBarView.getContextContainerWidgetMap().put("key", mock(ComplexPanel.class)); workbenchMenuStandardNavBarView.getMenuItemContextWidgetMap().put("key", mock(ComplexPanel.class)); workbenchMenuStandardNavBarView.clear(); verify(navbarNav).clear(); assertTrue(workbenchMenuStandardNavBarView.getContextContainerWidgetMap().isEmpty()); assertTrue(workbenchMenuStandardNavBarView.getMenuItemContextWidgetMap().isEmpty()); }
@Test public void testSelectElement() { final ComplexPanel panel = mock(ComplexPanel.class); final ComplexPanel panelActive = mock(ComplexPanel.class); when(dropDownMenu.iterator()).thenReturn(Collections.<Widget>singletonList(panel).iterator()); workbenchMenuCompactNavBarView.selectElement(panelActive); verify(panelActive).addStyleName(Styles.ACTIVE); verify(panel).removeStyleName(Styles.ACTIVE); }
@Test public void testClear() { workbenchMenuCompactNavBarView.getMenuItemContextMenus().put("key", mock(ComplexPanel.class)); workbenchMenuCompactNavBarView.getMenuItemContextWidgetMap().put("key", mock(ComplexPanel.class)); workbenchMenuCompactNavBarView.clear(); verify(navbarNav).clear(); assertTrue(workbenchMenuCompactNavBarView.getMenuItemContextMenus().isEmpty()); assertTrue(workbenchMenuCompactNavBarView.getMenuItemContextWidgetMap().isEmpty()); }
private List<Widget> getItems() { List<Widget> items = new ArrayList<Widget>(); if (uiObject instanceof ComplexPanel) { ComplexPanel complexPanel = (ComplexPanel)uiObject; int numItems = complexPanel.getWidgetCount(); for (int i=0; i<numItems; i++) { Widget item = complexPanel.getWidget(i); items.add(item); } } return items; }
@Override public void doTest(final ComplexPanel sandbox) { testTsvParse(); testTsvParseWithAccessor(); testTsvParseRows(); testTsvParseRowsWithAccessor(); testTsvWithAccessorAndCallback(); testTsvWithCallback(); testTsvWithChainingAccessorAndCallback(); }
@Override public void doTest(final ComplexPanel sandbox) { testCreate(); testLength(); testGet(); testSet(); testIndexOf(); testLastIndexOf(); testPush(); testReverse(); testShift(); testSlice(); testSort(); testSplice(); testUnshift(); testJoin(); testPop(); testForEach(); testEvery(); testSome(); testMap(); testFilter(); }
@Override public void doTest(final ComplexPanel sandbox) { parse(); format(); utc(); iso(); }
@Override public void doTest(final ComplexPanel sandbox) { testD3InterpolateNumber(); testD3InterpolateRound(); testD3InterpolateString(); testD3InterpolateRgb(); testD3InterpolateHsl(); // testD3InterpolateHcl(); // testD3InterpolateLab(); testD3InterpolateObject(); testD3InterpolateArray(); testD3InterpolateTransform(); testD3InterpolateZoom(); testD3Interpolators(); }
@Override public void setUp(final ComplexPanel sandbox) { super.setUp(sandbox); // append an element in the sandbox cobaye = DOM.createDiv(); sandbox.getElement().appendChild(cobaye); }
@Override public void doTest(final ComplexPanel sandbox) { Array<?> domain = D3.time().scale().domain(); assertEquals(2, domain.length()); System.out.println(domain.getValue(0).asJsDate()); System.out.println(domain.getValue(1).asJsDate()); Array<?> range = D3.time().scale().range(Array.fromInts(0, 5)).range(); // nice and count }