Permalink
Browse files

Small fix

  • Loading branch information...
1 parent 234f23a commit 40a010aad1719c534cab4f5a851c78a68a439cd0 @galdolber committed Apr 10, 2012
Showing with 6 additions and 75 deletions.
  1. +6 −75 src/main/java/guitplugin/GuitPresenterProcessor.java
@@ -157,18 +157,16 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
try {
fieldsMap = GuitViewHelper.findUiFields(filer, d);
} catch (SAXParseException ex) {
+ printMessage(Kind.NOTE, String.format("Error parsing XML (line "
+ + ex.getLineNumber() + "): " + ex.getMessage()), d);
printMessage(Kind.ERROR, String.format("Error parsing XML (line "
+ ex.getLineNumber() + "): " + ex.getMessage()), d);
continue;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
- if (!isWidget(d)) {
- generatePresenterSuper(d, fieldsMap);
- } else {
- generateWidgetSuper(d, fieldsMap);
- }
+ generatePresenterSuper(d, fieldsMap);
processController(d);
for (Entry<String, HashMap<String, String>> entry : fieldsMap.entrySet()) {
processPresenterWithOneXml(d, entry.getKey(), entry.getValue());
@@ -190,7 +188,8 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
}
}
} catch (Exception ex) {
- printMessage(Kind.ERROR, d.getQualifiedName() + ": " + ex.toString(), d);
+ // printMessage(Kind.ERROR, d.getQualifiedName() + ": " +
+ // ex.toString(), d);
}
}
}
@@ -200,7 +199,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
private void printMessage(Kind kind, String msg, Element e) {
if (isEclipse()) {
- env.getMessager().printMessage(Kind.NOTE, msg, e);
+ env.getMessager().printMessage(Kind.NOTE, msg, e);
}
env.getMessager().printMessage(kind, msg, e);
}
@@ -214,27 +213,6 @@ private boolean isEclipse() {
}
}
- private boolean isWidget(TypeElement d) {
- Collection<? extends AnnotationMirror> annotations = d.getAnnotationMirrors();
- for (AnnotationMirror a : annotations) {
- Element decl = a.getAnnotationType().asElement();
- if (decl == null) {
- continue;
- }
-
- String qualifiedName = ((TypeElement) decl).getQualifiedName().toString();
- if (qualifiedName.equals("com.guit.client.apt.GwtPresenter")) {
- for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : a.getElementValues()
- .entrySet()) {
- if (e.getKey().getSimpleName().toString().equals("isWidget")) {
- return (Boolean) e.getValue().getValue();
- }
- }
- }
- }
- return false;
- }
-
private void generateBinder(TypeElement classDeclaration) {
String packageName = elementsUtil.getPackageOf(classDeclaration).getQualifiedName().toString();
String simpleName = classDeclaration.getSimpleName().toString();
@@ -440,53 +418,6 @@ private void printDriver(TypeElement classDeclaration, PrintWriter writer) {
}
}
- private void generateWidgetSuper(TypeElement classDeclaration,
- HashMap<String, HashMap<String, String>> fieldsMap) {
- String packageName = elementsUtil.getPackageOf(classDeclaration).getQualifiedName().toString();
- String simpleName = classDeclaration.getSimpleName().toString();
- String name = simpleName + "Widget";
- String qualifiedName = packageName + "." + name;
- PrintWriter writer = getPrintWriter(qualifiedName);
- writer.println("package " + packageName + ";");
- writer.println();
- writer.println("import com.google.gwt.core.client.GWT;");
- writer.println();
- writer.println("import com.guit.client.GuitWidget;");
- Generated.printGeneratedImport(writer);
- writer.println();
-
- String extendsPresenter = getExtendsPresenter(classDeclaration);
- Set<String> allFields = null;
- if (extendsPresenter.equals("com.guit.client.GuitPresenter")) {
- TypeElement extendsPresenterElement = elementsUtil.getTypeElement(extendsPresenter);
- allFields = getAllField(extendsPresenterElement);
- }
-
- String binderName = simpleName + "Binder";
- Generated.printGenerated(writer, simpleName);
- writer.println("public abstract class " + name + " extends GuitWidget<" + binderName + "> {");
-
- writer.println(" public " + name + "() {");
- writer.println(" super((" + binderName + ") GWT.create(" + binderName + ".class));");
- writer.println(" }");
-
- for (Entry<String, String> entry : fieldsMap.entrySet().iterator().next().getValue().entrySet()) {
- if (entry.getValue().startsWith("com.guit.client.dom")) {
- if (allFields == null || !allFields.contains(entry.getKey())) {
- writer.println();
- writer.println(" @com.guit.client.apt.Generated");
- writer.println(" @com.guit.client.binder.ViewField");
- writer.println(" " + entry.getValue() + " " + entry.getKey() + ";");
- }
- }
- }
-
- printDependencies(classDeclaration, writer);
-
- writer.println("}");
- writer.close();
- }
-
private void generateControllerSuper(TypeElement classDeclaration) {
String packageName = elementsUtil.getPackageOf(classDeclaration).getQualifiedName().toString();
String simpleName = classDeclaration.getSimpleName().toString();

0 comments on commit 40a010a

Please sign in to comment.