Search in sources :

Example 1 with EventHandler

use of com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler in project mvp4g2-examples by mvp4g.

the class DetailPresenter method onGotoDetail.

@EventHandler
public void onGotoDetail(long id) {
    eventBus.setNavigationConfirmation(this);
    try {
        Person result = PersonService.get().get(id);
        view.setUpData(result);
        eventBus.setContent(view.asElement());
        eventBus.setStatus("Edit person data");
    } catch (PersonNotFoundException e) {
        DomGlobal.window.alert("Panic!");
    }
}
Also used : PersonNotFoundException(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.exception.PersonNotFoundException) Person(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.dto.Person) EventHandler(com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler)

Example 2 with EventHandler

use of com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler in project mvp4g2-examples by mvp4g.

the class ListPresenter method onGotoList.

@EventHandler
public void onGotoList(String searchName, String searchCity) {
    List<Person> result = PersonService.get().get(new PersonSearch(searchName, searchCity));
    view.resetTable();
    view.setData(result);
    eventBus.setContent(view.asElement());
    if (result.size() == 0) {
        eventBus.setStatus("No person found");
    } else if (result.size() == 1) {
        eventBus.setStatus("Found one person");
    } else {
        eventBus.setStatus("Found " + Integer.toString(result.size()) + " persons");
    }
}
Also used : PersonSearch(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.dto.PersonSearch) Person(de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.dto.Person) EventHandler(com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler)

Example 3 with EventHandler

use of com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler in project mvp4g2-examples by mvp4g.

the class ListPresenter method onGotoList.

@EventHandler
public void onGotoList(String searchName, String searchCity) {
    GWT.debugger();
    ClientContext.get().getPersonService().search(new PersonSearch(searchName, searchCity), new MethodCallback<List<Person>>() {

        @Override
        public void onFailure(Method method, Throwable throwable) {
            DomGlobal.alert("error: " + throwable.getMessage());
        }

        @Override
        public void onSuccess(Method method, List<Person> persons) {
            GWT.debugger();
            view.setData(persons);
            eventBus.setContent(view.asElement());
            if (persons.size() == 0) {
                eventBus.setStatus("No person found");
            } else if (persons.size() == 1) {
                eventBus.setStatus("Found one person");
            } else {
                eventBus.setStatus("Found " + Integer.toString(persons.size()) + " persons");
            }
        }
    });
}
Also used : PersonSearch(de.gishmo.gwt.example.mvp4g2.springboot.client.data.model.dto.PersonSearch) List(java.util.List) Method(org.fusesource.restygwt.client.Method) Person(de.gishmo.gwt.example.mvp4g2.springboot.client.data.model.dto.Person) EventHandler(com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler)

Example 4 with EventHandler

use of com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler in project mvp4g2 by mvp4g.

the class HandlerTest method testEventHandlerAnnotationAnnotatedOnAInterface.

@Test
public void testEventHandlerAnnotationAnnotatedOnAInterface() {
    Compilation compilation = javac().withProcessors(new Mvp4g2Processor()).compile(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/eventHandlerAnnotationAnnotatedOnAInterface/EventHandlerAnnotationAnnotatedOnAInterface.java"));
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("@Handler can only be used with a class");
}
Also used : Compilation(com.google.testing.compile.Compilation) Mvp4g2Processor(com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor) Test(org.junit.Test)

Example 5 with EventHandler

use of com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler in project mvp4g2 by mvp4g.

the class HandlerTest method testEventHandlingMethodDoesNotReturnVoid02.

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

        {
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/eventHandlingMethodDoesNotReturnVoid02/EventBusEventHandlingMethodDoesNotReturnVoid.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/eventHandlingMethodDoesNotReturnVoid02/MockOneEventHandler.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/eventHandlingMethodDoesNotReturnVoid02/MockShellPresenter01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/eventHandlingMethodDoesNotReturnVoid02/IMockShellView01.java"));
            add(JavaFileObjects.forResource("com/github/mvp4g/mvp4g2/processor/eventhandler/eventHandlingMethodDoesNotReturnVoid02/MockShellView01.java"));
        }
    });
    CompilationSubject.assertThat(compilation).failed();
    CompilationSubject.assertThat(compilation).hadErrorContaining("Mvp4g2Processor: >>com.github.mvp4g.mvp4g2.processor.eventhandler.eventHandlingMethodDoesNotReturnVoid02.MockOneEventHandler<< -> EventElement: >>onDoSomethingInHandler(java.lang.String)<< 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)

Aggregations

Mvp4g2Processor (com.github.mvp4g.mvp4g2.processor.Mvp4g2Processor)32 Compilation (com.google.testing.compile.Compilation)32 Test (org.junit.Test)32 JavaFileObject (javax.tools.JavaFileObject)29 EventHandler (com.github.mvp4g.mvp4g2.core.ui.annotation.EventHandler)3 Person (de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.dto.Person)2 HandlerMetaData (com.github.mvp4g.mvp4g2.core.internal.ui.HandlerMetaData)1 ProcessorException (com.github.mvp4g.mvp4g2.processor.ProcessorException)1 HandlerMetaModel (com.github.mvp4g.mvp4g2.processor.model.HandlerMetaModel)1 ClassNameModel (com.github.mvp4g.mvp4g2.processor.model.intern.ClassNameModel)1 ClassName (com.squareup.javapoet.ClassName)1 JavaFile (com.squareup.javapoet.JavaFile)1 MethodSpec (com.squareup.javapoet.MethodSpec)1 TypeSpec (com.squareup.javapoet.TypeSpec)1 PersonSearch (de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.dto.PersonSearch)1 PersonNotFoundException (de.gishmo.gwt.example.mvp4g2.simpleapplication.client.data.model.exception.PersonNotFoundException)1 Person (de.gishmo.gwt.example.mvp4g2.springboot.client.data.model.dto.Person)1 PersonSearch (de.gishmo.gwt.example.mvp4g2.springboot.client.data.model.dto.PersonSearch)1 IOException (java.io.IOException)1 List (java.util.List)1