use of elemental2.dom.HTMLAnchorElement in project kie-wb-common by kiegroup.
the class DocumentPreviewViewImpl method setState.
@Override
public void setState(DocumentPreviewState previewState, Collection<DocumentPreviewStateAction> previewActions) {
state.className = resolveStateStyle(previewState);
if (previewState.equals(DocumentPreviewState.STORED)) {
document.classList.remove(DISABLED_ANCHOR_STYLE);
document.href = presenter.getDocumentLink();
document.download = presenter.getDocumentName();
} else {
document.classList.add(DISABLED_ANCHOR_STYLE);
document.removeAttribute("href");
document.removeAttribute("download");
}
clearActions();
previewActions.forEach(action -> {
if (actions.lastChild != null) {
HTMLElement separator = (HTMLElement) doc.createElement("span");
separator.textContent = "|";
separator.className = CONTENT;
actions.appendChild(separator);
}
HTMLAnchorElement anchor = (HTMLAnchorElement) doc.createElement("a");
anchor.textContent = action.getLabel();
anchor.onclick = event -> {
action.execute();
return null;
};
actions.appendChild(anchor);
});
}
use of elemental2.dom.HTMLAnchorElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetTest method testHandleBadgeCloseEvent.
@Test
public void testHandleBadgeCloseEvent() {
VariablesEditorWidgetView.Presenter presenter = mock(VariablesEditorWidgetView.Presenter.class);
widget.setParentWidget(presenter);
HTMLLabelElement tagLabel = mock(HTMLLabelElement.class);
HTMLAnchorElement tagCloseButton = mock(HTMLAnchorElement.class);
elemental2.dom.Event ex = mock(elemental2.dom.Event.class);
ex.type = "SomeType";
widget.setTagSet(new HashSet<>());
widget.handleBadgeCloseEvent("internal", tagLabel, tagCloseButton, ex);
verify(tagLabel, times(1)).remove();
verify(tagCloseButton, times(1)).remove();
// Updated Model
verify(widget, times(1)).notifyModelChanged();
ex.type = "DoNotUpdateModel";
widget.setTagSet(new HashSet<>());
widget.handleBadgeCloseEvent("internal", tagLabel, tagCloseButton, ex);
verify(tagLabel, times(2)).remove();
verify(tagCloseButton, times(2)).remove();
// No New Calls to Updated Model
verify(widget, times(1)).notifyModelChanged();
}
use of elemental2.dom.HTMLAnchorElement in project kie-wb-common by kiegroup.
the class HTMLDownloadHelper method download.
public void download(final String filename, final String html) {
final String sourceHTML = HEADER + html + FOOTER;
final String source = Global.encodeURIComponent(sourceHTML);
final HTMLAnchorElement fileDownload = (HTMLAnchorElement) document.createElement("a");
document.body.appendChild(fileDownload);
fileDownload.href = ENCODING + source;
fileDownload.download = filename + FILE_EXTENSION;
fileDownload.onclick = (e) -> null;
document.body.removeChild(fileDownload);
}
use of elemental2.dom.HTMLAnchorElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetViewImpl method getBadgeCloseButton.
protected HTMLAnchorElement getBadgeCloseButton() {
final HTMLAnchorElement badgeCloseButton = (HTMLAnchorElement) document.createElement("a");
badgeCloseButton.id = "closeButton";
badgeCloseButton.textContent = "x";
badgeCloseButton.className = "close tagCloseButton tagBadges";
return badgeCloseButton;
}
use of elemental2.dom.HTMLAnchorElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetViewImpl method renderTagElementsBadges.
protected void renderTagElementsBadges() {
for (final String tag : tagSet) {
final HTMLLabelElement tagLabel = getBadgeElement(tag);
final HTMLAnchorElement badgeCloseButton = getBadgeCloseButton();
badgeCloseButton.onclick = ex -> {
handleBadgeCloseEvent(tag, tagLabel, badgeCloseButton, ex);
return null;
};
tagLabel.appendChild(badgeCloseButton);
tagsContainer.appendChild(tagLabel);
updateTagCount();
removeButtons.put(tag, badgeCloseButton);
}
}
Aggregations