@Inject public TouchReservationHandler(@Assisted IsWidget widget, final EventsBus eventsBus) { handlerRegistration = widget.asWidget().addDomHandler(new TouchStartHandler() { @Override public void onTouchStart(TouchStartEvent event) { eventsBus.fireEvent(new PlayerEvent(PlayerEventTypes.TOUCH_EVENT_RESERVATION)); } }, TouchStartEvent.getType()); }
@Before public void before() { view = mock(IsWidget.class); Widget widget = cretateWidgetAndElementMock(); doReturn(widget).when(view).asWidget(); connectionStyleChecker = mock(ConnectionStyleChecker.class); instance = new ConnectionStyleCheckerHandler(view, connectionStyleChecker); }
@Test public void testSetValueUsingFileUrl() { final CSVDataSetDef dataSetDef = mock(CSVDataSetDef.class); when(dataSetDef.getUUID()).thenReturn("uuid1"); when(dataSetDef.getName()).thenReturn("name1"); when(dataSetDef.getProvider()).thenReturn(DataSetProviderType.CSV); when(dataSetDef.getFileURL()).thenReturn("fileUrl"); when(dataSetDef.getFilePath()).thenReturn(null); presenter.setValue(dataSetDef); assertEquals(false, presenter.isUsingFilePath()); verify(view, times(0)).init(presenter); verify(view, times(0)).initWidgets(any(ValueBoxEditor.View.class), any(IsWidget.class),any(ValueBoxEditor.View.class), any(ValueBoxEditor.View.class), any(ValueBoxEditor.View.class), any(ValueBoxEditor.View.class), any(ValueBoxEditor.View.class)); verify(view, times(1)).showFileURLInput(); verify(view, times(0)).showFilePathInput(); }
@Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); IsWidget attributesEditor = mock(IsWidget.class); presenter = new DataSetEditor<DataSetDef>(basicAttributesEditor, attributesEditor, columnsAndFilterEditor, previewTable, backendCacheAttributesEditor, clientCacheAttributesEditor, refreshEditor, clientServices, loadingBox, errorEvent, tabChangedEvent, view) { @Override public void init() { super.init(); } }; when(dataSetDef.getUUID()).thenReturn("uuid1"); when(dataSetDef.getName()).thenReturn("name1"); when(dataSetDef.getProvider()).thenReturn(DataSetProviderType.BEAN); when(columnsAndFilterEditor.dataSetFilter()).thenReturn(filterEditor); when(columnsAndFilterEditor.columnListEditor()).thenReturn(columnsEditor); when(columnsEditor.columns()).thenReturn(columnListEditor); }
@Test public void testShow() { final String name = "group1"; tested.show(name); verify(view, times(1)).setCancelButtonVisible(false); verify(view, times(1)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(1)).setSaveButtonText(anyString()); verify(view, times(1)).setWidget(any(IsWidget.class)); verify(view, times(1)).setSaveButtonVisible(false); verify(view, times(1)).setSaveButtonEnabled(false); verify(view, times(0)).showNotification(anyString()); verify(view, times(1)).clearNotifications(); verify(groupEditorDriver, times(1)).edit(group, groupEditor); verify(groupEditor, times(1)).clear(); }
@SuppressWarnings("unused") private void onChangeTitleWidgetEvent(@Observes ChangeTitleWidgetEvent event) { final PlaceRequest place = event.getPlaceRequest(); final IsWidget titleDecoration = event.getTitleDecoration(); final String title = event.getTitle(); for (Map.Entry<PanelDefinition, WorkbenchPanelPresenter> e : mapPanelDefinitionToPresenter.entrySet()) { final PanelDefinition panel = e.getKey(); final WorkbenchPanelPresenter presenter = e.getValue(); for (PartDefinition part : ensureIterable(panel.getParts())) { if (place.equals(part.getPlace())) { mapPartDefinitionToPresenter.get(part).setTitle(title); presenter.changeTitle(part, title, titleDecoration); break; } } } }
@Test public void testSetValueEnabled() { final DataSetDef dataSetDef = mock(DataSetDef.class); when(dataSetDef.getUUID()).thenReturn("uuid1"); when(dataSetDef.getName()).thenReturn("name1"); when(dataSetDef.getProvider()).thenReturn(DataSetProviderType.SQL); when(dataSetDef.getRefreshTime()).thenReturn("1 second"); presenter.setValue(dataSetDef); assertEquals(true, presenter.isRefreshEnabled()); verify(refreshTime, times(1)).setEnabled(true); verify(refreshAlways, times(1)).setEnabled(true); verify(view, times(1)).setEnabled(true); verify(view, times(0)).init(presenter); verify(view, times(0)).initWidgets(any(IsWidget.class), any(DataSetDefRefreshIntervalEditor.View.class)); verify(view, times(0)).addRefreshEnabledButtonHandler(any(Command.class)); }
/** {@inheritDoc} */ @Override public void selectTab(@NotNull PartPresenter partPresenter) { IsWidget view = partPresenter.getView(); int viewIndex = partStackContent.getWidgetIndex(view); boolean isWidgetExist = viewIndex != -1; if (!isWidgetExist) { partPresenter.go(partViewContainer); viewIndex = partStackContent.getWidgetIndex(view); } partStackContent.showWidget(viewIndex); setActiveTab(partPresenter); }
@Override public void split(IsWidget replicaWidget, Direction direction, double size) { this.direction = direction; splitLayoutPanel = new SplitLayoutPanel(SPLITTER_SIZE); specimenView = new SplitEditorPartViewImpl(specimenWidget, this); replicaView = new SplitEditorPartViewImpl(replicaWidget, this); if (direction == VERTICALLY) { splitVertically(size); } else if (direction == HORIZONTALLY) { splitHorizontally(size); } splitLayoutPanel.add(replicaView); rootPanel.remove(specimenWidget); rootPanel.add(splitLayoutPanel); tuneSplitter(splitLayoutPanel); }
@Test public void testSetDirtyFalse() { tested.setDirty(false); verify(view, times(0)).setCancelButtonVisible(anyBoolean()); verify(view, times(0)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(0)).setSaveButtonText(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); verify(view, times(0)).setSaveButtonVisible(anyBoolean()); verify(view, times(1)).setSaveButtonEnabled(false); verify(view, times(0)).showNotification(anyString()); verify(view, times(1)).clearNotifications(); verify(loadingBox, times(0)).show(); verify(loadingBox, times(0)).hide(); }
@Test public void testOnTabChangedEvent_ConfigurationTab() { when(editWorkflow.getEditor()).thenReturn(dataSetDefEditor); TabChangedEvent event = mock(TabChangedEvent.class); when(event.getContext()).thenReturn(dataSetDefEditor); when(event.getTabId()).thenReturn(DataSetEditor.TAB_CONFIGURATION); presenter.currentWorkflow = editWorkflow; presenter.onTabChangedEvent(event); verify(editWorkflow, times(1)).clearButtons(); verify(editWorkflow, times(1)).showTestButton(); verify(editWorkflow, times(0)).showNextButton(); verify(editWorkflow, times(0)).showBackButton(); verify(editWorkflow, times(0)).edit(any(SQLDataSetDef.class), any(List.class)); verify(errorPopupPresenter, times(0)).showMessage(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); }
private void generateComponents(LayoutTemplate layoutTemplate, final LayoutInstance layoutInstance, final LayoutColumn layoutColumn, final HTMLElement column) { for (final LayoutComponent layoutComponent : layoutColumn.getLayoutComponents()) { final LayoutDragComponent dragComponent = lookupLayoutDragComponent(layoutComponent); if (dragComponent != null) { Widget columnWidget = ElementWrapperWidget.getWidget(column); RenderingContext componentContext = new RenderingContext(layoutComponent, columnWidget); IsWidget componentWidget = dragComponent.getShowWidget(componentContext); if (layoutTemplate.isPageStyle() && layoutColumn.getHeight().isEmpty()) { componentWidget.asWidget().getElement().addClassName("uf-perspective-col"); } else if (!layoutColumn.getHeight().isEmpty()) { column.getClassList().add("uf-perspective-row-" + layoutColumn.getHeight()); } if (componentWidget != null) { DOMUtil.appendWidgetToElement(column, componentWidget); } } } }
@Test public void testClear() { tested.role = role; tested.clear(); assertNull(tested.role); verify(roleEditor).clear(); verify(roleEditor, never()).show(any(Role.class)); verify(view, atLeastOnce()).clearNotifications(); verify(view, never()).setCancelButtonVisible(true); verify(view, never()).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, never()).setSaveButtonText(anyString()); verify(view, never()).setWidget(any(IsWidget.class)); verify(view, never()).setSaveButtonVisible(anyBoolean()); verify(view, never()).setSaveButtonEnabled(anyBoolean()); verify(view, never()).showNotification(anyString()); }
@AssistedInject public MessageDialogPresenter( @NotNull MessageDialogView view, @NotNull @Assisted("title") String title, @NotNull @Assisted IsWidget content, @Nullable @Assisted ConfirmCallback confirmCallback, @Nullable @Assisted("confirmButtonText") String confirmButtonText) { this.view = view; this.view.setContent(content); this.view.setTitle(title); this.confirmCallback = confirmCallback; this.view.setDelegate(this); if (content.asWidget() != null) { content.asWidget().ensureDebugId("info-window-message"); } if (confirmButtonText != null) { view.setConfirmButtonText(confirmButtonText); } }
@AssistedInject public ChoiceDialogPresenter( final @NotNull ChoiceDialogView view, final @NotNull @Assisted String title, final @NotNull @Assisted IsWidget content, final @NotNull @Assisted("firstChoice") String firstChoiceLabel, final @NotNull @Assisted("secondChoice") String secondChoiceLabel, final @NotNull @Assisted("thirdChoice") String thirdChoiceLabel, final @Nullable @Assisted("firstCallback") ConfirmCallback firstChoiceCallback, final @Nullable @Assisted("secondCallback") ConfirmCallback secondChoiceCallback, final @Nullable @Assisted("thirdCallback") ConfirmCallback thirdChoiceCallback) { this.view = view; this.view.setContent(content); this.view.setTitle(title); this.view.setFirstChoiceLabel(firstChoiceLabel); this.view.setSecondChoiceLabel(secondChoiceLabel); this.view.setThirdChoiceLabel(thirdChoiceLabel); this.firstChoiceCallback = firstChoiceCallback; this.secondChoiceCallback = secondChoiceCallback; this.thirdChoiceCallback = thirdChoiceCallback; this.view.setDelegate(this); }
public IsWidget createSourceListContentWidget(SourcelistItemType type, String content, InlineBodyGeneratorSocket inlineBodyGeneratorSocket) { switch (type) { case IMAGE: return new Image(content); case TEXT: return new Label(content); case COMPLEX_TEXT: Node node = getNode(content); return inlineBodyGeneratorSocket.generateInlineBody(node); } return new Widget(); }
public void initView(SourcelistItemType sourcelistItemType, String itemContent, String styleName, InlineBodyGeneratorSocket inlineBodyGeneratorSocket) { setStyleName(styleName); IsWidget content = contentFactory.createSourceListContentWidget(sourcelistItemType, itemContent, inlineBodyGeneratorSocket); add(content); disableDefaultBehaviorOnSelect(content); }
@Override public <W extends IsWidget> void putItemsOnView(List<W> itemsInOrder) { mainPanel.clear(); for (IsWidget viewItem : itemsInOrder) { mainPanel.add(viewItem); } }
public List<IsWidget> getItemsInOrder(List<String> itemsOrder, final Map<String, ? extends IsWidget> items) { return Lists.transform(itemsOrder, new Function<String, IsWidget>() { @Override public IsWidget apply(String itemId) { return items.get(itemId); } }); }
public Optional<ConnectionItem> findConnectionItemForEventOnWidget(ConnectionMoveEvent event, IsWidget widget, ConnectionItems connectionItems) { NativeEvent nativeEvent = event.getNativeEvent(); Point clickPoint = positionHelper.getPoint(nativeEvent, widget); Optional<ConnectionItem> item = findItemOnPosition(clickPoint, connectionItems); if (item.isPresent()) { nativeEventWrapper.preventDefault(nativeEvent); } return item; }
@SuppressWarnings("PMD") private void checkNativeStylesForWidgetHierarchy(IsWidget widget) { if (widget != null) { List<Style> allStyles = collectAllStyles(widget); checkNativeStyles(allStyles); } }
private List<Style> collectAllStyles(IsWidget widget) { List<Style> allStyles = Lists.newArrayList(); com.google.gwt.user.client.Element widgetElement = widget.asWidget().getElement(); allStyles.add(cssHelper.getComputedStyle(widgetElement)); allStyles.addAll(collectAllChildrenStyles(widgetElement.getChildNodes())); return allStyles; }
public void showAnimation(SwiffyObject swiffy, Size size, EndHandler endHandler) { lastEndHandler = Optional.fromNullable(endHandler); IsWidget widget = swiffy.getWidget(); view.setAnimationWidget(widget, size); view.attachToRoot(); swiffy.start(); }
@Override public void setAnimationWidget(IsWidget widget, Size size) { content.clear(); WidgetSize widgetSize = new WidgetSize(size); widgetSize.setOnWidget(content); content.add(widget.asWidget()); }
@Test public void test_noChildren() throws SAXException, IOException { // given BodyGeneratorSocket bgs = mock(BodyGeneratorSocket.class); Element element = XMLParser.parse(XML_NO_CHILDREN).getDocumentElement(); // when LabellingView view = testObj.build(element, bgs); // then verify(view).setBackground(eq(IMAGE_BEAN)); verify(view, never()).addChild(any(IsWidget.class), anyInt(), anyInt()); }
@Test public void test_noChildrenNode() throws SAXException, IOException { // given BodyGeneratorSocket bgs = mock(BodyGeneratorSocket.class); Element element = XMLParser.parse(XML_NO_CHILDREN_NODE).getDocumentElement(); // when LabellingView view = testObj.build(element, bgs); // then verify(view).setBackground(eq(IMAGE_BEAN)); verify(view, never()).addChild(any(IsWidget.class), anyInt(), anyInt()); }
private void verifyChildrenPositioning(LabellingView view, List<ChildData> children) { ArgumentCaptor<Integer> leftCaptor = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<Integer> topCaptor = ArgumentCaptor.forClass(Integer.class); verify(view, times(children.size())).addChild(any(IsWidget.class), leftCaptor.capture(), topCaptor.capture()); assertThat(leftCaptor.getAllValues(), equalTo(CHILDREN_FULL_X)); assertThat(topCaptor.getAllValues(), equalTo(CHILDREN_FULL_Y)); }
@Test public void setChildrenOrder() throws Exception { final List<String> order = fillInstance(); instance.setChildrenOrder(order); verify(viewItems).getItemsInOrder(Matchers.eq(order)); verify(viewWidget).putItemsOnView(Matchers.anyListOf(IsWidget.class)); }
@Before public void before() { setUp(new GuiceModuleConfiguration(), new CustomGinModule()); viewItem = mock(OrderInteractionViewItem.class); when(moduleFactory.getOrderInteractionViewItem(Matchers.any(IsWidget.class), Matchers.anyString())).thenReturn(viewItem); instance = injector.getInstance(OrderInteractionViewItemsImpl.class); }
@Test public void addItem() throws Exception { // given IsWidget widget = mock(IsWidget.class); // when OrderInteractionViewItem item = instance.addItem("id", widget); // then verify(moduleFactory).getOrderInteractionViewItem(Matchers.eq(widget), Matchers.eq("id")); assertThat(item).isEqualTo(viewItem); }
@Test public void getItemsInOrder() throws Exception { IsWidget widget = mock(IsWidget.class); instance.addItem("id", widget); List<String> asList = Arrays.asList("a"); instance.getItemsInOrder(asList); verify(itemsSorter).getItemsInOrder(Matchers.eq(asList), Matchers.anyMapOf(String.class, IsWidget.class)); }
@Test @Parameters({"1,2,3", "2,1,3", "3,2,1", "2,2,1"}) public void getItemsInOrder(String id1, String id2, String id3) throws Exception { ViewItemsSorter sorter = new ViewItemsSorter(); ArrayList<String> itemsOrder = Lists.newArrayList(id1, id2, id3); List<IsWidget> itemsInOrder = sorter.getItemsInOrder(itemsOrder, itemsToSort); for (int x = 0; x < itemsOrder.size(); ++x) { Assertions.assertThat(itemsInOrder.get(x)).isEqualTo(itemsToSort.get(itemsOrder.get(x))); } }
@Test public void testOnAttachOrDetachCorrectStyles() { doNothing().when(connectionStyleChecker).areStylesCorrectThrowsExceptionWhenNot(Matchers.any(IsWidget.class)); instance.onAttachOrDetach(null); verifyZeroInteractions(view); }
@Test public void testOnAttachOrDetachNotCorrectStyles() { String message = "error"; doThrow(new CssStyleException(message)).when(connectionStyleChecker).areStylesCorrectThrowsExceptionWhenNot(Matchers.any(IsWidget.class)); instance.onAttachOrDetach(null); verify(element).setInnerText(Matchers.eq(message)); }
@Before public void before() { isWidget = mock(IsWidget.class); Widget widget = mock(Widget.class); doReturn(handlerRegistration).when(widget) .addDomHandler(Matchers.any(TouchStartHandler.class), Matchers.any(Type.class)); doReturn(widget).when(isWidget) .asWidget(); eventsBus = mock(EventsBus.class); }
public void setup(final String labelText, final IsWidget field, final int index) { label.setText(labelText); group.add(field); this.index = index; }
@Test public void testRemoveFromParent() { presenter.removeFromParent(); verify(view, times(0)).init(presenter); verify(view, times(0)).initWidgets(any(ValueBoxEditor.View.class), any(IsWidget.class)); verify(idWidget, times(1)).removeFromParent(); }
private DragArea buildTitleWidget(final String title, final IsWidget titleDecoration) { final SpanElement spanElement = buildTitleTextWidget(title, titleDecoration); final DragArea dragArea = new DragArea(); dragArea.add(spanElement); dragArea.ensureDebugId(DEBUG_TITLE_PREFIX + title); dragArea.addMouseDownHandler(new NoMouseDownHandler()); return dragArea; }
@Test public void testViewCallbackNullified() { final Double value = null; presenter.viewCallback.onValueChange(value); verify(pushMaxSize, times(1)).setValue(100); verify(pushEnabled, times(0)).setValue(anyBoolean()); verify(view, times(0)).setEnabled(anyBoolean()); verify(view, times(0)).setRange(anyDouble(), anyDouble()); verify(view, times(0)).init(anyString(), anyString(), any(IsWidget.class), any(ValueBoxEditor.View.class)); verify(view, times(0)).init(any(DataSetDefCacheAttributesEditorView.ViewCallback.class)); verify(view, times(0)).setValue(anyDouble()); }
/** * Makes a {@link MenuCustom} and associated {@link MenuItemHeaderView} that can be used * as a "header" in a menu. See http://getbootstrap.com/components/#dropdowns-headers * @param caption Caption to be shown for the menu header. * @param <T> {@link MenuItemHeaderView} * @return A {@link MenuItemViewHolder} with both a {@link MenuItem} and {@link MenuItemView} */ @SuppressWarnings("unchecked") public <T extends MenuItemHeaderView> MenuItemViewHolder<T> makeMenuItemHeader(final String caption) { final MenuItemView _view = menuItemViewProducer.select(new MenuItemHeader() { @Override public Class<? extends Annotation> annotationType() { return MenuItemHeader.class; } }).get(); final T view = (T) _view; final MenuItem item = MenuFactory.newTopLevelCustomMenu(new MenuFactory.CustomMenuBuilder() { @Override public void push(final MenuFactory.CustomMenuBuilder element) { } @Override public MenuItem build() { final BaseMenuCustom<IsWidget> cmdItem = new BaseMenuCustom<IsWidget>(null, caption) { @Override public IsWidget build() { return ElementWrapperWidget.getWidget(view.getElement()); } }; return cmdItem; } }).endMenu().build().getItems().get(0); view.setCaption(caption); return new MenuItemViewHolder<>(item, view); }