Search in sources :

Example 1 with IsElement

use of org.jboss.errai.common.client.api.IsElement in project kie-wb-common by kiegroup.

the class PipelinePresenterTest method testAddStage.

@Test
public void testAddStage() {
    IsElement stage = mock(IsElement.class);
    presenter.addStage(stage);
    verify(view, times(1)).addStage(stage);
}
Also used : IsElement(org.jboss.errai.common.client.api.IsElement) Test(org.junit.Test)

Example 2 with IsElement

use of org.jboss.errai.common.client.api.IsElement in project kie-wb-common by kiegroup.

the class TreeExplorerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getDiagram().getGraph()).thenReturn(graph);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getShapeSetId()).thenReturn(SHAPE_SET_ID);
    when(textPropertyProviderFactory.getProvider(any(Element.class))).thenReturn(textPropertyProvider);
    when(definitionUtils.getDefinitionManager()).thenReturn(definitionManager);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(definitionAdapter.getId(anyObject())).thenReturn("defId");
    when(shapeManager.getShapeSet(eq(SHAPE_SET_ID))).thenReturn(shapeSet);
    when(shapeSet.getShapeFactory()).thenReturn(shapeFactory);
    when(shapeFactory.getGlyph(eq("defId"))).thenReturn(glyph);
    when(domGlyphRenderers.render(eq(glyph), anyDouble(), anyDouble())).thenReturn(isElement);
    this.childrenTraverseProcessor = spy(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()));
    this.testedTree = new TreeExplorer(childrenTraverseProcessor, textPropertyProviderFactory, elementSelectedEvent, definitionUtils, shapeManager, domGlyphRenderers, view) {

        @Override
        ElementWrapperWidget<?> wrapIconElement(final IsElement icon) {
            return mock(ElementWrapperWidget.class);
        }
    };
}
Also used : ElementWrapperWidget(org.jboss.errai.common.client.ui.ElementWrapperWidget) IsElement(org.jboss.errai.common.client.api.IsElement) IsElement(org.jboss.errai.common.client.api.IsElement) Element(org.kie.workbench.common.stunner.core.graph.Element) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Before(org.junit.Before)

Example 3 with IsElement

use of org.jboss.errai.common.client.api.IsElement in project kie-wb-common by kiegroup.

the class TreeExplorer method addItem.

@SuppressWarnings("unchecked")
private void addItem(final Element parent, final Node element, final boolean expand, final boolean checkParent) {
    final boolean isContainer = isContainer().test(element);
    final Glyph glyph = getGlyph(getShapeSetId(), element);
    final String name = getItemName(element);
    final IsElement icon = domGlyphRenderers.render(glyph, icoWidth, icoHeight);
    // Check the parent, in case a TreeItem mutates from/to ITEM type to CONTAINER type.
    final boolean isValidParentItem = null != parent && isValidTreeItem().test(parent);
    if (checkParent && isValidParentItem) {
        final boolean isParentContainer = isContainer().test((Node) parent);
        final boolean wasParentContainer = view.isContainer(parent.getUUID());
        if (isParentContainer != wasParentContainer) {
            view.removeItem(parent.getUUID());
            addItem(GraphUtils.getParent((Node<?, ? extends Edge>) parent), (Node) parent, expand, false);
        }
    }
    final ElementWrapperWidget<?> widget = wrapIconElement(icon);
    // Create and add the tree item.
    if (isValidParentItem) {
        view.addItem(element.getUUID(), parent.getUUID(), name, widget, isContainer, expand);
    } else {
        view.addItem(element.getUUID(), name, widget, isContainer, expand);
    }
}
Also used : IsElement(org.jboss.errai.common.client.api.IsElement) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) Node(org.kie.workbench.common.stunner.core.graph.Node) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 4 with IsElement

use of org.jboss.errai.common.client.api.IsElement in project kie-wb-common by kiegroup.

the class ListSelectorViewImpl method makeListSelectorItemView.

private Optional<IsElement> makeListSelectorItemView(final ListSelectorItem item) {
    Optional<IsElement> listSelectorItemView = Optional.empty();
    if (item instanceof ListSelectorTextItem) {
        final ListSelectorTextItem ti = (ListSelectorTextItem) item;
        final ListSelectorTextItemView selector = listSelectorTextItemViews.get();
        selector.setText(ti.getText());
        selector.setEnabled(ti.isEnabled());
        selector.addClickHandler(() -> {
            if (ti.isEnabled()) {
                presenter.onItemSelected(item);
            }
        });
        listSelectorItemView = Optional.of(selector);
    } else if (item instanceof ListSelectorDividerItem) {
        listSelectorItemView = Optional.of(listSelectorDividerItemViews.get());
    }
    return listSelectorItemView;
}
Also used : ListSelectorDividerItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorDividerItem) IsElement(org.jboss.errai.common.client.api.IsElement) ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem)

Example 5 with IsElement

use of org.jboss.errai.common.client.api.IsElement in project kie-wb-common by kiegroup.

the class PipelineParamsPagePresenterTest method testSetPipelineParamsForm.

@Test
public void testSetPipelineParamsForm() {
    IsElement formView = mock(IsElement.class);
    when(paramsForm.getView()).thenReturn(formView);
    presenter.setPipelineParamsForm(paramsForm);
    verify(view, times(1)).setForm(formView);
    verify(paramsForm, times(1)).addContentChangeHandler(any(ContentChangeHandler.class));
}
Also used : IsElement(org.jboss.errai.common.client.api.IsElement) ContentChangeHandler(org.guvnor.ala.ui.client.util.ContentChangeHandler) Test(org.junit.Test)

Aggregations

IsElement (org.jboss.errai.common.client.api.IsElement)5 Test (org.junit.Test)2 ContentChangeHandler (org.guvnor.ala.ui.client.util.ContentChangeHandler)1 ElementWrapperWidget (org.jboss.errai.common.client.ui.ElementWrapperWidget)1 Before (org.junit.Before)1 ListSelectorDividerItem (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorDividerItem)1 ListSelectorTextItem (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem)1 Glyph (org.kie.workbench.common.stunner.core.definition.shape.Glyph)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Element (org.kie.workbench.common.stunner.core.graph.Element)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 ChildrenTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl)1 TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)1