Search in sources :

Example 21 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testHideTooltips.

@Test
public void testHideTooltips() {
    final HTMLElement listItems = mock(HTMLElement.class);
    final NodeList<Element> tooltips = spy(new NodeList<>());
    final Element element0 = mock(Element.class);
    final Element element1 = mock(Element.class);
    doReturn(element0).when(tooltips).getAt(0);
    doReturn(element1).when(tooltips).getAt(1);
    tooltips.length = 2;
    element0.parentNode = listItems;
    element1.parentNode = listItems;
    doReturn(listItems).when(dataTypeList).getListItems();
    doReturn(tooltips).when(listItems).querySelectorAll(".tooltip");
    listItem.hideTooltips();
    verify(listItems).removeChild(element0);
    verify(listItems).removeChild(element1);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) Test(org.junit.Test)

Example 22 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DNDDataTypesHandlerContext method getFirstDataType.

private Optional<DataType> getFirstDataType(final DataType current) {
    final NodeList<Node> nodes = dndDataTypesHandler.getDndListComponent().getDragArea().childNodes;
    for (int i = 0; i < nodes.length; i++) {
        final Element element = (Element) nodes.getAt(i);
        final Integer elementY = DNDListDOMHelper.Position.getY(element);
        final Integer elementX = DNDListDOMHelper.Position.getX(element);
        if (elementY > HIDDEN_Y_POSITION && elementX == 0 && !element.classList.contains(DRAGGING)) {
            final DataType dataType = getDataType(element);
            if (dataType != null && !Objects.equals(current.getName(), dataType.getName())) {
                return Optional.of(dataType);
            }
        }
    }
    return Optional.empty();
}
Also used : Node(elemental2.dom.Node) Element(elemental2.dom.Element) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 23 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DataTypeListItem method hideTooltips.

void hideTooltips() {
    final String selector = ".tooltip";
    final NodeList<Element> tooltips = getDataTypeList().getListItems().querySelectorAll(selector);
    for (int i = 0; i < tooltips.length; i++) {
        ElementHelper.remove(tooltips.getAt(i));
    }
}
Also used : Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) DataTypeConstraint(org.kie.workbench.common.dmn.client.editors.types.listview.constraint.DataTypeConstraint)

Example 24 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DataTypeListView method getNestedElements.

private List<Element> getNestedElements(final String parentUUID) {
    final String selector = "[" + PARENT_UUID_ATTR + "=\"" + parentUUID + "\"]";
    final NodeList<Element> nestedElements = listItems.querySelectorAll(selector);
    final List<Element> list = new ArrayList<>();
    for (int i = 0; i < nestedElements.length; i++) {
        final Element element = nestedElements.getAt(i);
        final boolean isVisible = getDndListComponent().getPositionY(element) > -1;
        if (isVisible) {
            list.add(element);
        }
    }
    return list;
}
Also used : Element(elemental2.dom.Element) HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) ArrayList(java.util.ArrayList)

Example 25 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class FlashMessagesViewTest method testDisableWarningHighlight.

@Test
public void testDisableWarningHighlight() {
    final String warningElementSelector = "." + WARNING_CSS_CLASS;
    final HTMLElement element = mock(HTMLElement.class);
    final HTMLElement parentElement = mock(HTMLElement.class);
    final NodeList<Element> warningElements = spy(new NodeList<>());
    final Element warningElement1 = mock(Element.class);
    final Element warningElement2 = mock(Element.class);
    doReturn(warningElement1).when(warningElements).getAt(0);
    doReturn(warningElement2).when(warningElements).getAt(1);
    doReturn(element).when(view).getElement();
    when(parentElement.querySelectorAll(warningElementSelector)).thenReturn(warningElements);
    element.parentNode = parentElement;
    warningElements.length = 2;
    warningElement1.classList = mock(DOMTokenList.class);
    warningElement2.classList = mock(DOMTokenList.class);
    view.disableWarningHighlight();
    verify(warningElement1.classList).remove(WARNING_CSS_CLASS);
    verify(warningElement2.classList).remove(WARNING_CSS_CLASS);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Test(org.junit.Test)

Aggregations

Element (elemental2.dom.Element)36 HTMLElement (elemental2.dom.HTMLElement)33 Test (org.junit.Test)24 HTMLDivElement (elemental2.dom.HTMLDivElement)18 HTMLButtonElement (elemental2.dom.HTMLButtonElement)16 DOMTokenList (elemental2.dom.DOMTokenList)15 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)9 HTMLInputElement (elemental2.dom.HTMLInputElement)8 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)7 NodeList (elemental2.dom.NodeList)4 Factory.createGripElement (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.Factory.createGripElement)4 DNDListDOMHelper.isDraggingElement (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.isDraggingElement)4 HTMLDocument (elemental2.dom.HTMLDocument)3 HTMLBodyElement (elemental2.dom.HTMLBodyElement)2 Node (elemental2.dom.Node)2 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)1 Window (elemental2.dom.Window)1 ArrayList (java.util.ArrayList)1 DataTypeConstraint (org.kie.workbench.common.dmn.client.editors.types.listview.constraint.DataTypeConstraint)1