use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DMNExternalLinksToExtensionElements method loadExternalLinksIntoExtensionElements.
static void loadExternalLinksIntoExtensionElements(final org.kie.workbench.common.dmn.api.definition.model.DRGElement source, final org.kie.dmn.model.api.DRGElement target) {
if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) {
return;
}
final DocumentationLinks links = source.getLinksHolder().getValue();
final DMNElement.ExtensionElements elements = getOrCreateExtensionElements(target);
removeAllExistingLinks(elements);
for (final DMNExternalLink link : links.getLinks()) {
final ExternalLink external = new ExternalLink();
external.setName(link.getDescription());
external.setUrl(link.getUrl());
elements.getAny().add(external);
}
target.setExtensionElements(elements);
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DMNExternalLinksToExtensionElements method loadExternalLinksFromExtensionElements.
static void loadExternalLinksFromExtensionElements(final JSITDRGElement source, final DRGElement target) {
if (!Objects.isNull(source.getExtensionElements())) {
final List<Object> extensions = source.getExtensionElements().getAny();
if (!Objects.isNull(extensions)) {
for (int i = 0; i < extensions.size(); i++) {
final Object extension = extensions.get(i);
if (JSITAttachment.instanceOf(extension)) {
final JSITAttachment jsiExtension = Js.uncheckedCast(extension);
final DMNExternalLink external = new DMNExternalLink();
external.setDescription(jsiExtension.getName());
external.setUrl(jsiExtension.getUrl());
target.getLinksHolder().getValue().addLink(external);
}
}
}
}
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class NameAndUrlPopoverViewImplTest method testOnClickOkButton.
@Test
public void testOnClickOkButton() {
final String description = "description";
final String url = "url";
final ArgumentCaptor<DMNExternalLink> captor = ArgumentCaptor.forClass(DMNExternalLink.class);
final Consumer onExternalLinkCreated = mock(Consumer.class);
attachmentNameInput.value = description;
urlInput.value = url;
popover.setOnExternalLinkCreated(onExternalLinkCreated);
popover.onClickOkButton(null);
verify(onExternalLinkCreated).accept(captor.capture());
final DMNExternalLink externalLink = captor.getValue();
assertEquals(description, externalLink.getDescription());
assertEquals(url, externalLink.getUrl());
verify(popover).hide();
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class DocumentationLinksWidgetTest method testOnExternalLinkDeleted.
@Test
public void testOnExternalLinkDeleted() {
final DocumentationLinks value = mock(DocumentationLinks.class);
final DMNExternalLink externalLink = mock(DMNExternalLink.class);
final List<DMNExternalLink> links = new ArrayList<>();
links.add(externalLink);
when(value.getLinks()).thenReturn(links);
widget.setValue(value);
widget.onExternalLinkDeleted(externalLink);
assertFalse(links.contains(externalLink));
verify(widget).refresh();
verify(locker).fire(any());
}
use of org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink in project kie-wb-common by kiegroup.
the class NameAndUrlPopoverViewImpl method onClickOkButton.
@EventHandler("okButton")
@SuppressWarnings("unused")
public void onClickOkButton(final ClickEvent clickEvent) {
final Consumer<DMNExternalLink> consumer = getOnExternalLinkCreated();
if (!Objects.isNull(consumer)) {
final String description = attachmentNameInput.value;
final String url = urlInput.value;
final DMNExternalLink externalLink = new DMNExternalLink(url, description);
consumer.accept(externalLink);
}
hide();
}
Aggregations