Search in sources :

Example 6 with HTMLAnchorElement

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

the class VariableListItemWidgetViewImpl method handleAcceptButton.

@EventHandler("acceptButton")
public void handleAcceptButton(final ClickEvent e) {
    final String tagAdded = tagNamesComboBox.getValue();
    if (!Strings.isNullOrEmpty(tagAdded) && !tagSet.contains(tagAdded)) {
        for (final HTMLAnchorElement closeAnchor : removeButtons.values()) {
            closeAnchor.onclick.onInvoke(new elemental2.dom.Event("DoNotUpdateModel"));
        }
        removeButtons.clear();
        tagSet.add(tagAdded);
        setCustomTags(setToList(tagSet));
        notifyModelChanged();
        if (!VariablesEditorFieldRenderer.getDefaultTagsSet().contains(tagAdded) && getPreviousCustomValue() != null && !tagAdded.equals(getPreviousCustomValue())) {
            // Is custom
            tagSet.remove(getPreviousCustomValue());
        }
        renderTagElementsBadges();
    }
}
Also used : HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) EventHandler(org.jboss.errai.ui.shared.api.annotations.EventHandler)

Example 7 with HTMLAnchorElement

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

the class VariableListItemWidgetTest method testSetTags.

@Test
public void testSetTags() {
    List<String> tags = Arrays.asList("internal", "input", "customTag");
    VariablesEditorWidgetView.Presenter presenter = mock(VariablesEditorWidgetView.Presenter.class);
    widget.setParentWidget(presenter);
    widget.setTagSet(new HashSet<>());
    HTMLLabelElement tagLabel = mock(HTMLLabelElement.class);
    HTMLAnchorElement tagCloseButton = mock(HTMLAnchorElement.class);
    when(widget.getBadgeElement(anyString())).thenReturn(tagLabel);
    when(widget.getBadgeCloseButton()).thenReturn(tagCloseButton);
    HTMLDivElement tagsContainer = mock(HTMLDivElement.class);
    widget.tagsContainer = tagsContainer;
    widget.removeButtons = new HashMap<>();
    widget.setTagTypes(tags);
    verify(tagNamesComboBox, times(1)).addCustomValueToListBoxValues("customTag", "");
}
Also used : HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Mockito.anyString(org.mockito.Mockito.anyString) HTMLLabelElement(elemental2.dom.HTMLLabelElement) Test(org.junit.Test)

Aggregations

HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)7 HTMLLabelElement (elemental2.dom.HTMLLabelElement)3 Test (org.junit.Test)2 HTMLDivElement (elemental2.dom.HTMLDivElement)1 HTMLElement (elemental2.dom.HTMLElement)1 EventHandler (org.jboss.errai.ui.shared.api.annotations.EventHandler)1 Mockito.anyString (org.mockito.Mockito.anyString)1