javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java
changeset 435 fb4ed6cc0d4b
parent 140 590958fcb7d7
child 467 c50c541368f8
child 489 4b59fa013d49
     1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java	Fri Nov 09 11:47:00 2012 +0100
     1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java	Sat Jan 12 20:24:30 2013 +0100
     1.3 @@ -43,7 +43,7 @@
     1.4  import javax.tools.Diagnostic;
     1.5  import javax.tools.FileObject;
     1.6  import javax.tools.StandardLocation;
     1.7 -import org.apidesign.bck2brwsr.htmlpage.api.OnClick;
     1.8 +import org.apidesign.bck2brwsr.htmlpage.api.On;
     1.9  import org.apidesign.bck2brwsr.htmlpage.api.Page;
    1.10  import org.openide.util.lookup.ServiceProvider;
    1.11  
    1.12 @@ -55,7 +55,7 @@
    1.13  @ServiceProvider(service=Processor.class)
    1.14  @SupportedAnnotationTypes({
    1.15      "org.apidesign.bck2brwsr.htmlpage.api.Page",
    1.16 -    "org.apidesign.bck2brwsr.htmlpage.api.OnClick"
    1.17 +    "org.apidesign.bck2brwsr.htmlpage.api.On"
    1.18  })
    1.19  public final class PageProcessor extends AbstractProcessor {
    1.20      @Override
    1.21 @@ -146,11 +146,11 @@
    1.22              }
    1.23              TypeElement type = (TypeElement)clazz;
    1.24              for (Element method : clazz.getEnclosedElements()) {
    1.25 -                OnClick oc = method.getAnnotation(OnClick.class);
    1.26 +                On oc = method.getAnnotation(On.class);
    1.27                  if (oc != null) {
    1.28                      for (String id : oc.id()) {
    1.29                          if (pp.tagNameForId(id) == null) {
    1.30 -                            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "id = " + oc.id() + " does not exist in the HTML page. Found only " + pp.ids(), method);
    1.31 +                            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "id = " + id + " does not exist in the HTML page. Found only " + pp.ids(), method);
    1.32                              return false;
    1.33                          }
    1.34                          ExecutableElement ee = (ExecutableElement)method;
    1.35 @@ -159,21 +159,21 @@
    1.36                              hasParam = false;
    1.37                          } else {
    1.38                              if (ee.getParameters().size() != 1 || ee.getParameters().get(0).asType() != stringType) {
    1.39 -                                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@OnClick method should either have no arguments or one String argument", ee);
    1.40 +                                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@On method should either have no arguments or one String argument", ee);
    1.41                                  return false;
    1.42                              }
    1.43                              hasParam = true;
    1.44                          }
    1.45                          if (!ee.getModifiers().contains(Modifier.STATIC)) {
    1.46 -                            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@OnClick method has to be static", ee);
    1.47 +                            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@On method has to be static", ee);
    1.48                              return false;
    1.49                          }
    1.50                          if (ee.getModifiers().contains(Modifier.PRIVATE)) {
    1.51 -                            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@OnClick method can't be private", ee);
    1.52 +                            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@On method can't be private", ee);
    1.53                              return false;
    1.54                          }
    1.55 -                        w.append("  ").append(cnstnt(id)).
    1.56 -                            append(".addOnClick(new Runnable() { public void run() {\n");
    1.57 +                        w.append("  OnEvent." + oc.event()).append(".of(").append(cnstnt(id)).
    1.58 +                            append(").perform(new Runnable() { public void run() {\n");
    1.59                          w.append("    ").append(type.getSimpleName().toString()).
    1.60                              append('.').append(ee.getSimpleName()).append("(");
    1.61                          if (hasParam) {