Search in sources :

Example 16 with Document

use of elemental2.dom.Document in project tapestry-5 by apache.

the class TestableResponseImplTest method http_headers.

@Test
public void http_headers() {
    Document document = tester.renderPage(TestPageForHttpHeaders.class.getSimpleName());
    assertTrue(document.toString().contains("Test page for HTTP headers"));
    TestableResponse response = tester.getService(TestableResponse.class);
    assertEquals(response.getHeader(TestPageForHttpHeaders.DATE_HEADER_NAME), 12345L);
    assertEquals(response.getHeader(TestPageForHttpHeaders.INT_HEADER_NAME), 6789);
    assertEquals(response.getHeader(TestPageForHttpHeaders.STRING_HEADER_NAME), "foo-bar-baz-barney");
}
Also used : TestPageForHttpHeaders(org.apache.tapestry5.integration.app2.pages.TestPageForHttpHeaders) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 17 with Document

use of elemental2.dom.Document in project console by hal.

the class StartAnalytics method call.

@Override
public Completable call(FlowContext context) {
    String pathname = window.location.getPathname();
    boolean testSuite = pathname.endsWith("ts.html");
    boolean collectUserData = settings.get(COLLECT_USER_DATA).asBoolean();
    if (!testSuite && collectUserData) {
        String id;
        if (environment.isDevMode()) {
            id = DEVELOPMENT_ID;
        } else if (environment.isProductionMode()) {
            id = PRODUCTION_ID;
        } else {
            id = UNKNOWN_ID;
        }
        HTMLScriptElement script = (HTMLScriptElement) document.createElement("script");
        script.text = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', " + stringify(config(id)) + ");";
        document.head.appendChild(script);
        GoogleAnalytics ga = new GoogleAnalytics();
        ga.customDimension(1, environment.getAccessControlProvider().name().toLowerCase());
        ga.customDimension(2, environment.getHalBuild().name().toLowerCase());
        ga.customDimension(3, environment.getHalVersion().toString());
        ga.customDimension(4, environment.getManagementVersion().toString());
        ga.customDimension(5, environment.getOperationMode().name().toLowerCase());
        ga.customDimension(6, environment.getInstanceInfo().productName());
        ga.customDimension(7, environment.getInstanceInfo().productVersion());
        ga.customDimension(8, environment.getInstanceInfo().releaseName());
        ga.customDimension(9, environment.getInstanceInfo().releaseVersion());
        ga.customDimension(10, endpoints.isSameOrigin());
        ga.customDimension(11, environment.isSingleSignOn());
        ga.customDimension(12, settings.get(LOCALE).value());
        Tracker tracker = new Tracker(ga);
        eventBus.addHandler(NavigationEvent.getType(), tracker);
        eventBus.addHandler(FinderContextEvent.getType(), tracker);
        eventBus.addHandler(ModelBrowserPathEvent.getType(), tracker);
        logger.info("Collect user data is on: {}", id);
    } else {
        logger.info("Collect user data is off.");
    }
    return Completable.complete();
}
Also used : GoogleAnalytics(org.jboss.hal.core.analytics.GoogleAnalytics) Tracker(org.jboss.hal.core.analytics.Tracker) HTMLScriptElement(elemental2.dom.HTMLScriptElement)

Example 18 with Document

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

the class DMNEditDRDToolboxActionTest method testOnMouseClick.

@Test
public void testOnMouseClick() throws NoSuchFieldException, IllegalAccessException {
    final HTMLElement htmlElement = new HTMLElement();
    htmlElement.style = new CSSStyleDeclaration();
    final HTMLDocument htmlDocument = new HTMLDocument();
    htmlDocument.body = new HTMLBodyElement();
    final Field field = DomGlobal.class.getDeclaredField("document");
    field.setAccessible(true);
    Field modifiersField = Field.class.getDeclaredField("modifiers");
    modifiersField.setAccessible(true);
    modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    field.set(DomGlobal.class, htmlDocument);
    when(drdContextMenu.getElement()).thenReturn(htmlElement);
    dmnEditDRDToolboxAction.onMouseClick(canvasHandler, UUID, mouseClickEvent);
    verify(drdContextMenu, times(1)).show(Mockito.<Collection>any());
}
Also used : Field(java.lang.reflect.Field) HTMLElement(elemental2.dom.HTMLElement) HTMLDocument(elemental2.dom.HTMLDocument) HTMLBodyElement(elemental2.dom.HTMLBodyElement) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 19 with Document

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

the class DocumentUpload method doUpload.

@Override
public void doUpload(final Document document, File file) {
    if (!enabled) {
        return;
    }
    DocumentData documentData = new DocumentData(document.getId(), document.getName(), document.getSize(), document.getUrl(), (long) document.getLastModified());
    DocumentPreview preview = render(documentData);
    DocumentPreviewStateActionsHandlerImpl handler = new DocumentPreviewStateActionsHandlerImpl(DocumentPreviewState.PENDING);
    DocumentPreviewStateAction abortAction = new DocumentPreviewStateAction(translationService.getTranslation(Constants.DocumentUploadViewImplAbort), () -> uploader.remove(document.getId(), () -> doRemove(preview)));
    handler.addStateActions(DocumentPreviewState.UPLOADING, Collections.singletonList(abortAction));
    DocumentPreviewStateAction removeAction = new DocumentPreviewStateAction(translationService.getTranslation(Constants.DocumentUploadViewImplRemove), () -> uploader.remove(document.getId(), () -> doRemove(preview)));
    handler.addStateActions(DocumentPreviewState.PENDING, Collections.singletonList(removeAction));
    handler.addStateActions(DocumentPreviewState.UPLOADED, Collections.singletonList(removeAction));
    final Command startUploadCallback = () -> handler.notifyStateChange(DocumentPreviewState.UPLOADING);
    final ParameterizedCommand<Boolean> onFinishUpload = success -> {
        if (success) {
            handler.notifyStateChange(DocumentPreviewState.UPLOADED);
        } else {
            handler.notifyStateChange(DocumentPreviewState.ERROR);
        }
    };
    DocumentPreviewStateAction retryAction = new DocumentPreviewStateAction(translationService.getTranslation(Constants.DocumentUploadViewImplRetry), () -> {
        uploader.remove(document.getId(), () -> uploader.upload(document.getId(), file, startUploadCallback, onFinishUpload));
    });
    handler.addStateActions(DocumentPreviewState.ERROR, Arrays.asList(removeAction, retryAction));
    preview.setStateHandler(handler);
    uploader.upload(document.getId(), file, startUploadCallback, onFinishUpload);
    ValueChangeEvent.fire(DocumentUpload.this, getValue());
}
Also used : ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) Arrays(java.util.Arrays) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) Document(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.js.Document) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) PreDestroy(javax.annotation.PreDestroy) DocumentData(org.kie.workbench.common.forms.jbpm.model.document.DocumentData) GwtEvent(com.google.gwt.event.shared.GwtEvent) IsWidget(com.google.gwt.user.client.ui.IsWidget) DocumentPreview(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.DocumentPreview) Command(org.uberfire.mvp.Command) DocumentUploadManager(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.upload.DocumentUploadManager) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) DocumentPreviewStateActionsHandlerImpl(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.handlers.DocumentPreviewStateActionsHandlerImpl) Collection(java.util.Collection) File(elemental2.dom.File) DocumentPreviewStateAction(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.DocumentPreviewStateAction) Collectors(java.util.stream.Collectors) Constants(org.kie.workbench.common.forms.jbpm.client.resources.i18n.Constants) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) Dependent(javax.enterprise.context.Dependent) PostConstruct(javax.annotation.PostConstruct) DocumentPreviewState(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.DocumentPreviewState) Collections(java.util.Collections) DocumentData(org.kie.workbench.common.forms.jbpm.model.document.DocumentData) DocumentPreview(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.DocumentPreview) DocumentPreviewStateAction(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.DocumentPreviewStateAction) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) DocumentPreviewStateActionsHandlerImpl(org.kie.workbench.common.forms.jbpm.client.rendering.documents.control.preview.handlers.DocumentPreviewStateActionsHandlerImpl)

Example 20 with Document

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

the class PrintHelperTest method testChangeMediaAttributesToAll.

@Test
public void testChangeMediaAttributesToAll() {
    final HTMLDocument document = mock(HTMLDocument.class);
    final Element element = mock(Element.class);
    final NodeList<Element> links = spy(new NodeList<>());
    final String media = "media";
    links.length = 1;
    doReturn(element).when(links).item(0);
    doReturn(element).when(helper).asElement(element);
    when(document.querySelectorAll("link")).thenReturn(links);
    when(element.getAttribute(media)).thenReturn("print");
    helper.changeMediaAttributesToAll(document);
    verify(element).setAttribute(media, "all");
}
Also used : HTMLDocument(elemental2.dom.HTMLDocument) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) HTMLBodyElement(elemental2.dom.HTMLBodyElement) Test(org.junit.Test)

Aggregations

Document (org.apache.tapestry5.dom.Document)20 Test (org.testng.annotations.Test)17 PageTester (org.apache.tapestry5.test.PageTester)11 Test (org.junit.Test)10 HTMLDocument (elemental2.dom.HTMLDocument)9 HTMLElement (elemental2.dom.HTMLElement)9 HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)9 HTMLBodyElement (elemental2.dom.HTMLBodyElement)5 Element (elemental2.dom.Element)4 Element (org.apache.tapestry5.dom.Element)4 DOMTokenList (elemental2.dom.DOMTokenList)3 JsPropertyMap (jsinterop.base.JsPropertyMap)3 Document (org.gwtproject.dom.client.Document)3 Element (org.gwtproject.dom.client.Element)3 InputElement (org.gwtproject.dom.client.InputElement)3 Document (elemental2.dom.Document)2 File (elemental2.dom.File)2 Window (elemental2.dom.Window)2 Field (java.lang.reflect.Field)2 List (java.util.List)2