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);
}
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);
}
};
}
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);
}
}
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;
}
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));
}
Aggregations