Tuesday, October 8, 2013

Dart's annotation

I refined the look and feel of sample app using Dart's annotation.

This feature is very useful for customizing a lot of thing without touching the code itself.
So there are quite a lot of area to use annotations.

The annotation mechanism of Dart is quit easy to use, it is also part of dart:mirrors. So in order to use this on browser, we still need to use my portable_mirror library(I extended the API for this).

The things I have done is:
  1. Table
    • remove id and rev column from table
    • change expenseType to type
       
  2. Form
    • disable id, rev text input
These are specified by annotation for the getter  in Expense class.
Also I fixed table so that it has max height and can use scroll.
So this GUI is now looks beter. but it will be useful to support more annotations to adjust look and feel such as ordering specification. location to put text etc.

class Expense  {
  ....
  
  @GUI_Table(invisible: true)
  @GUI_Form(disabled: true)
  String get id => _id;
  void set id(String i) { _id = i; }
  
  @GUI_Table(invisible: true)
  @GUI_Form(disabled: true)
  String get rev => _rev;
  void set rev(String value) { _rev = value; }
  
  @GUI_Table(label: "type")
  ExpenseType get expenseType => _type;
  void set expenseType(ExpenseType i) { _type = i; }
  
  ...
}

No comments:

Post a Comment