Search in sources :

Example 1 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2-examples by mvp4g.

the class DetailView method createView.

public void createView() {
    container = div().add(div().style("width: 100%;").add(div().css("headline").textContent("Details")).add(detailFirstName = new TextField("Firstname")).add(detailName = new TextField("Name")).add(detailStreet = new TextField("Street")).add(detailZip = new TextField("Zip")).add(detailCity = new TextField("City")).add(div().css("buttonBar").add(button().css("button").textContent("Save").on(click, event -> {
        updateDetailForm();
        getPresenter().doUpdate(person);
    })).add(button().css("button").textContent("Revert").on(click, event -> {
        getPresenter().doRevert();
    })))).asElement();
}
Also used : Element(elemental2.dom.Element) Elements.button(org.jboss.gwt.elemento.core.Elements.button) Elements.div(org.jboss.gwt.elemento.core.Elements.div) HTMLDivElement(elemental2.dom.HTMLDivElement) Person(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.dto.Person) HTMLButtonElement(elemental2.dom.HTMLButtonElement) TextField(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.widgets.TextField) EventType.click(org.jboss.gwt.elemento.core.EventType.click) LazyReverseView(com.github.mvp4g.mvp4g2.core.ui.LazyReverseView) TextField(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.widgets.TextField)

Example 2 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2-examples by mvp4g.

the class DetailView method createView.

public void createView() {
    container = div().add(div().style("width: 100%;").add(div().css("headline").textContent("Details")).add(detailFirstName = new TextField("Firstname")).add(detailName = new TextField("Name")).add(detailStreet = new TextField("Street")).add(detailZip = new TextField("Zip")).add(detailCity = new TextField("City")).add(div().css("buttonBar").add(button().css("button").textContent("Save").on(click, event -> {
        updateDetailForm();
        getPresenter().doUpdate(person);
    })).add(button().css("button").textContent("Revert").on(click, event -> {
        getPresenter().doRevert();
    })))).asElement();
}
Also used : Element(elemental2.dom.Element) Elements.button(org.jboss.gwt.elemento.core.Elements.button) Elements.div(org.jboss.gwt.elemento.core.Elements.div) TextField(de.gishmo.gwt.example.mvp4g2.springboot.client.widgets.TextField) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Person(de.gishmo.gwt.example.mvp4g2.springboot.client.data.model.dto.Person) EventType.click(org.jboss.gwt.elemento.core.EventType.click) LazyReverseView(com.github.mvp4g.mvp4g2.core.ui.LazyReverseView) TextField(de.gishmo.gwt.example.mvp4g2.springboot.client.widgets.TextField)

Example 3 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2 by mvp4g.

the class EventTest method testEventDoesNotReturnVoid.

@Test
public void testEventDoesNotReturnVoid() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventDoesNotReturnVoid/EventBusEventDoesNotReturnVoid.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventDoesNotReturnVoid/MockShellPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventDoesNotReturnVoid/IMockShellView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventDoesNotReturnVoid/MockShellView01.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("Mvp4g2Processor: EventElement: >>doSomething<< must return 'void'");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 4 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2 by mvp4g.

the class EventTest method testEventTestHandlerNotInBindAndHandlersAttribute.

@Test
public void testEventTestHandlerNotInBindAndHandlersAttribute() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/EventTestHandlerNotInBindAndHandlersAttribute.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/MockOneEventHandler.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/MockShellPresenter.java"));
        }
    });
    CompilationSubject.assertThat(compilation).succeeded();
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_EventTestHandlerNotInBindAndHandlersAttribute_event01.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_EventTestHandlerNotInBindAndHandlersAttribute_event01.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_EventTestHandlerNotInBindAndHandlersAttribute_event02.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_EventTestHandlerNotInBindAndHandlersAttribute_event02.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_EventTestHandlerNotInBindAndHandlersAttribute_event03.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_EventTestHandlerNotInBindAndHandlersAttribute_event03.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_MockOneEventHandlerMetaData.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_MockOneEventHandlerMetaData.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_MockShellPresenterMetaData.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/Com_github_mvp4g_mvp4g2_processor_event_eventTestHandlerNotInBindAndHandlersAttribute_MockShellPresenterMetaData.java"));
    JavaFileObjectSubject.assertThat(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/EventTestHandlerNotInBindAndHandlersAttributeImpl.java")).hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventTestHandlerNotInBindAndHandlersAttribute/EventTestHandlerNotInBindAndHandlersAttributeImpl.java"));
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 5 with Event

use of com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event in project mvp4g2 by mvp4g.

the class EventTest method testEventBusWithOneInitHistoryAnnotationAndNonZeroArgmentsSignature.

@Test
public void testEventBusWithOneInitHistoryAnnotationAndNonZeroArgmentsSignature() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(new ArrayList<JavaFileObject>() {

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventBusWithOneInitHistoryAnnotationAndNonZeroArgmentsSignature/EventBusWithOneInitHistoryAnnotationAndNonZeroArgmentsSignature.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/event/eventBusWithOneInitHistoryAnnotationAndNonZeroArgmentsSignature/MockShellPresenter.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("@InitHistory can only be used on a method with no arguments");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Aggregations

Mvp4g2Processor (com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor)25 Compilation (com.google.testing.compile.Compilation)25 JavaFileObject (javax.tools.JavaFileObject)25 Test (org.junit.Test)25 TypeElement (javax.lang.model.element.TypeElement)5 LazyReverseView (com.github.mvp4g.mvp4g2.core.ui.LazyReverseView)4 ProcessorException (com.github.mvp4g.mvp4g2.processor.ProcessorException)4 Element (elemental2.dom.Element)4 HTMLButtonElement (elemental2.dom.HTMLButtonElement)4 HTMLDivElement (elemental2.dom.HTMLDivElement)4 Elements.button (org.jboss.gwt.elemento.core.Elements.button)4 Elements.div (org.jboss.gwt.elemento.core.Elements.div)4 EventType.click (org.jboss.gwt.elemento.core.EventType.click)4 Element (javax.lang.model.element.Element)3 ExecutableElement (javax.lang.model.element.ExecutableElement)3 Event (com.github.mvp4g.mvp4g2.core.eventbus.annotation.Event)2 InitHistory (com.github.mvp4g.mvp4g2.core.history.annotation.InitHistory)2 NotFoundHistory (com.github.mvp4g.mvp4g2.core.history.annotation.NotFoundHistory)2 EventBusMetaModel (com.github.mvp4g.mvp4g2.processor.model.EventBusMetaModel)2 EventMetaModel (com.github.mvp4g.mvp4g2.processor.model.EventMetaModel)2