Package org.gwt.mosaic.ui.client.table.RowValue

Examples of org.gwt.mosaic.ui.client.table.RowValue.ColumnDefinition


    SourceWriter srcWriter = composerFactory.createSourceWriter(context,
        printWriter);
    JMethod[] methods = rowValue.getMethods();
    List<JMethod> annotatedMethods = new ArrayList<JMethod>();
    for (JMethod method : methods) {
      ColumnDefinition annotation = method.getAnnotation(RowValue.ColumnDefinition.class);
      if (annotation != null) {
        annotatedMethods.add(method);
      }
    }
    Collections.sort(annotatedMethods, new Comparator<JMethod>() {
      public int compare(JMethod method1, JMethod method2) {
        return Integer.valueOf(
            method1.getAnnotation(RowValue.ColumnDefinition.class).column()).compareTo(
            Integer.valueOf(method1.getAnnotation(
                RowValue.ColumnDefinition.class).column()));
      }
    });
    // Create constructor
    srcWriter.println("public " + simpleName + "() {");
    srcWriter.indent();
    srcWriter.println("super();");
    for (JMethod method : annotatedMethods) {
      ColumnDefinition annotation = method.getAnnotation(RowValue.ColumnDefinition.class);
      String methodName = method.getName();
      String returnType = method.getReturnType().getSimpleSourceName();
      if (returnType.equals(String.class.getSimpleName())) {
        srcWriter.println("addColumnDefinition(new TextColumnDefinition<"
            + rowValue.getSimpleSourceName() + ">(\"" + annotation.header()
            + "\"," + annotation.sortable() + "," + annotation.filterable()
            + "," + annotation.editable() + ") {");
        srcWriter.indent();
        srcWriter.println("public String getCellValue("
            + rowValue.getSimpleSourceName() + " value) {");
        srcWriter.indentln("return value." + methodName + "();");
        srcWriter.println("}");
        srcWriter.outdent();
        srcWriter.println("});");
      } else if (returnType.equals(Date.class.getSimpleName())) {
        String dateTimeFormat = getDateTimeFormat(annotation.dateTimeFormat(),
            annotation.dateTimePattern());
        srcWriter.println("addColumnDefinition(new DateColumnDefinition<"
            + rowValue.getSimpleSourceName() + ">(\"" + annotation.header()
            + "\"," + dateTimeFormat + ", " + annotation.sortable() + ", "
            + annotation.filterable() + "," + annotation.editable() + ") {");
        srcWriter.indent();
        srcWriter.println("public Date getCellValue("
            + rowValue.getSimpleSourceName() + " value) {");
        srcWriter.indentln("return value." + methodName + "();");
        srcWriter.println("}");
        srcWriter.outdent();
        srcWriter.println("});");
      } else if (returnType.equals(Double.class.getSimpleName())
          || returnType.equals("double")) {
        String numberFormat = getNumberFormat(annotation.numberFormat(),
            annotation.numberPattern());
        srcWriter.println("addColumnDefinition(new NumberColumnDefinition<"
            + rowValue.getSimpleSourceName() + ">(\"" + annotation.header()
            + "\"," + numberFormat + "," + annotation.filterable() + ","
            + annotation.editable() + ") {");
        srcWriter.indent();
        srcWriter.println("public Double getCellValue("
            + rowValue.getSimpleSourceName() + " value) {");
        srcWriter.indentln("return value." + methodName + "();");
        srcWriter.println("}");
View Full Code Here

TOP

Related Classes of org.gwt.mosaic.ui.client.table.RowValue.ColumnDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.