2009年4月13日 星期一

U19 第三個元件(3)──基本Data Model編輯器的存取

畫面呈現的作法確定之後,就只剩下建立Data Model與編輯器的對應關係。在使用上的設計有幾個簡單的方向:整個Data Model對應一個頁面或多個頁面的存取、對於欄位內容值的存取與屬性變更等。

  public boolean setDataModelValue(ModelParserModelInterface model);
  public boolean getDataModelValue(ModelParserModelInterface model);

  public Object getValue(String fieldId) throws IDNotFoundException;
  public boolean setValue(String fieldId, Object Value) throws IDNotFoundException;
  public Object getProperty(String fieldId, String propName) throws IDNotFoundException;
  public boolean setProperty(String fieldId, String propName, Object Value) throws IDNotFoundException;

  public Object getValue(String pageId, String fieldId) throws IDNotFoundException;
  public boolean setValue(String pageId, String fieldId, Object Value) throws IDNotFoundException;
  public Object getProperty(String pageId, String fieldId, String propName) throws IDNotFoundException;
  public boolean setProperty(String pageId, String fieldId, String propName, Object Value) throws IDNotFoundException;

以上是大致需要的介面方法定義。UI的佈置會以一個Data Model對應一個頁面為主,在多個bean file的場合下會有JTree的對應佈置,在頁面的存取規則定義pageId來指定取得實際使用的那個;資料放入UI時會以bean id來命名,方法內傳入fieldId即可定位實際存取的欄位。

說真的,基本Data Model編輯器若是不做也沒什麼影響,因為對IT人員來說直接開啟檔案編輯內容是又快又簡單的事,但是對一般使用者來說卻相對地很困難,尤其在尋找想要修改的內容或是輸入XML的標籤有錯誤時根本無法達成。要能快速地清楚所有可以修改的設定與其代表的意義,同時限定與檢核輸入值的正確性,這些好處就只有基本Data Model編輯器可以快速提供。

註:這裡的內容並未實作在workspace裡,但是在之前的專案裡已驗證過可行。

沒有留言:

張貼留言