<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 36, comments - 30, trackbacks - 0, articles - 3

    這一節(jié)主要介紹如何給編輯器增加屬性頁,屬性頁主要用來顯示編輯器中選中對象的屬性的,比如在編輯器選中活動,可以在屬性頁上顯示活動的大小和位置等信息,要實現(xiàn)這一功能,首先要讓模型實現(xiàn)IPropertySource接口,我們讓模型的基類ModelElement實現(xiàn)這個接口,基類要實現(xiàn)這接口中六個方法,這六個方法如下:


    /** An empty property descriptor. */
           
    private static final IPropertyDescriptor[] EMPTY_ARRAY = new IPropertyDescriptor[0];
    /**
            * Returns a value for this property source that can be edited in a property sheet.   

          
            * 
    @return this instance
            
    */

           
    public Object getEditableValue() {         
                  
    return this;
           }

           
    /**
            * Children should override this. The default implementation returns an empty array.
            
    */

           
    public IPropertyDescriptor[] getPropertyDescriptors() {           
                  
    return EMPTY_ARRAY;
           }

           
           
    /**
            * Children should override this. The default implementation returns null.
            
    */

           
    public Object getPropertyValue(Object id) {
                  
    // TODO Auto-generated method stub
                  return null;
           }

           
           
    /**
            * Children should override this. The default implementation returns false.
            
    */

           
    public boolean isPropertySet(Object id) {
                  
    // TODO Auto-generated method stub
                  return false;
           }

           
    /**
            * Children should override this. The default implementation does nothing.
            
    */

           
    public void resetPropertyValue(Object id) {
                  
    // TODO Auto-generated method stub
                  
           }

           
    /**
            * Children should override this. The default implementation does nothing.
            
    */

           
    public void setPropertyValue(Object id, Object value) {
                  
    // TODO Auto-generated method stub
                  
           }

    這六個方法的含義在JavaDoc中已經(jīng)說的很清楚了,在這個類中我們還定義了IPropertyDescriptor類型的數(shù)組,這個數(shù)組的作用是存放要顯示屬性的名稱,由于根模型沒有什么可顯示的屬性,所以為空。當我們在編輯器中選中活動時,在屬性頁上要顯示它的屬性,因此我們應(yīng)該在AbstractActivity類中覆蓋父類中相應(yīng)的方法,代碼如下:

    /** 
            * 活動要顯示屬性的名稱
            * There is one IPropertyDescriptor entry per editable property.
            * 
    @see #getPropertyDescriptors()
            * 
    @see #getPropertyValue(Object)
            * 
    @see #setPropertyValue(Object, Object)
            
    */

           
    private static IPropertyDescriptor[] descriptors;
           
    /*
            * Initializes the property descriptors array.
            * @see #getPropertyDescriptors()
            * @see #getPropertyValue(Object)
            * @see #setPropertyValue(Object, Object)
            
    */

           
    static {
                  descriptors 
    = new IPropertyDescriptor[] 
                                
    new TextPropertyDescriptor(XPOS_PROP, "X"), // id and 

    description pair
                                
    new TextPropertyDescriptor(YPOS_PROP, "Y"),
                                
    new TextPropertyDescriptor(WIDTH_PROP, "Width"),
                                
    new TextPropertyDescriptor(HEIGHT_PROP, "Height")
                                
                  }
    ;
                  
    // use a custom cell editor validator for all four array entries
                  for (int i = 0; i < descriptors.length; i++{
                         
                                ((PropertyDescriptor) descriptors[i]).setValidator(
    new 

    ICellEditorValidator() 
    {
                                       
    public String isValid(Object value) {
                                              
    int intValue = -1;
                                              
    try {
                                                     intValue 
    = Integer.parseInt((String) 

    value);
                                              }
     catch (NumberFormatException exc) {
                                                     
    return "Not a number";
                                              }

                                              
    return (intValue >= 0? null : "Value must be >= 

    0";
                                       }

                                }
    );
                         }
                       
                                       
           }
     // static
           /**
            * Returns an array of IPropertyDescriptors for this AbstractActivity.
            * <p>The returned array is used to fill the property view, when the edit-part 

    corresponding
            * to this model element is selected.</p>
            * 
    @see #descriptors
            * 
    @see #getPropertyValue(Object)
            * 
    @see #setPropertyValue(Object, Object)
            
    */

           
    public IPropertyDescriptor[] getPropertyDescriptors() {
                  
    return descriptors;
           }

     
           
    /**
            * Return the property value for the given propertyId, or null.
            * <p>The property view uses the IDs from the IPropertyDescriptors array 
            * to obtain the value of the corresponding properties.</p>
            * 
    @see #descriptors
            * 
    @see #getPropertyDescriptors()
            
    */

           
    public Object getPropertyValue(Object propertyId) {
                  
    if (XPOS_PROP.equals(propertyId)) {
                         
    return Integer.toString(location.x);
                  }

                  
    if (YPOS_PROP.equals(propertyId)) {
                         
    return Integer.toString(location.y);
                  }

                  
    if (HEIGHT_PROP.equals(propertyId)) {
                         
    return Integer.toString(size.height);
                  }

                  
    if (WIDTH_PROP.equals(propertyId)) {
                         
    return Integer.toString(size.width);
                  }

                  
    return super.getPropertyValue(propertyId);
           }

           
           
    /**
            * Set the property value for the given property id.
            * If no matching id is found, the call is forwarded to the superclass.
            * <p>The property view uses the IDs from the IPropertyDescriptors array to set the 

    values
            * of the corresponding properties.</p>      
            
    */

           
    public void setPropertyValue(Object propertyId, Object value) {
                  
    if (XPOS_PROP.equals(propertyId)) {
                         
    int x = Integer.parseInt((String) value);
                         setLocation(
    new Point(x, location.y));
                  }
     else if (YPOS_PROP.equals(propertyId)) {
                         
    int y = Integer.parseInt((String) value);
                         setLocation(
    new Point(location.x, y));
                  }
     else if (HEIGHT_PROP.equals(propertyId)) {
                         
    int height = Integer.parseInt((String) value);
                         setSize(
    new Dimension(size.width, height));
                  }
     else if (WIDTH_PROP.equals(propertyId)) {
                         
    int width = Integer.parseInt((String) value);
                         setSize(
    new Dimension(width, size.height));
                  }
     else {
                         
    super.setPropertyValue(propertyId, value);
                  }

           }


    我們首先定義一個IPropertyDescriptor類型的數(shù)組,然后初始化這個數(shù)組,該數(shù)組存放要顯示活動的屬性,這里我們顯示活動圖形的坐標,大小屬性,由于屬性頁既能顯示屬性,還能編輯屬性,而坐標和大小屬性只能輸入數(shù)字,所以我們加入了校驗,如果給這些屬性輸入字符,就拋異常。getPropertyValue方法就是得到IPropertyDescriptor數(shù)組中對應(yīng)屬性名的屬性值,setPropertyValue方法就是對屬性值進行修改時,要同時修改模型的屬性,讓模型通知控制器來刷新視圖,例如我們修改坐標x的值,編輯器中活動

    的位置就要發(fā)生改變,

    Feedback

    # re: 流程設(shè)計器開發(fā)九(屬性頁部分)  回復(fù)  更多評論   

    2008-01-14 15:50 by anone
    LZ辛苦了。。。研究中,向你學(xué)習(xí)。。。
    我看了 三中提供的代碼,不知如何運行才看到界面呢?
    現(xiàn)在有新的代碼提供下載嗎?

    # re: 流程設(shè)計器開發(fā)九(屬性頁部分)  回復(fù)  更多評論   

    2008-01-14 16:03 by anone
    現(xiàn)在正在研究中,要命啊。LZ能多給點資料嗎?謝謝了。我留郵箱吧:
    a_none@163.com

    # re: 流程設(shè)計器開發(fā)九(屬性頁部分)  回復(fù)  更多評論   

    2008-01-14 16:24 by 玩轉(zhuǎn)Java
    三中下載的代碼已經(jīng)包含現(xiàn)在的內(nèi)容了,要看到界面,只要把插件項目,運行為工作臺,載新建一個擴展名為workflow的文件,打開這個文件就可以看到效果了。在下一節(jié),我將介紹如何通過向?qū)硇陆üぷ髁魑募?/div>

    # re: 流程設(shè)計器開發(fā)九(屬性頁部分)  回復(fù)  更多評論   

    2008-01-15 17:21 by anone
    好的,謝謝LZ 了。。。

    # re: 流程設(shè)計器開發(fā)九(屬性頁部分)[未登錄]  回復(fù)  更多評論   

    2010-06-29 16:00 by 啊啊
    代碼一樣,屬性頁怎么就顯示不出來呢?
    主站蜘蛛池模板: 四虎免费在线观看| 一级特黄aaa大片免费看| 国产做国产爱免费视频| 久久久久亚洲精品天堂| a级毛片免费观看在线| 亚洲人成网站18禁止| 青草草色A免费观看在线| 亚洲视频免费一区| 亚洲一区中文字幕在线电影网| 国产拍拍拍无码视频免费| 亚洲春色在线视频| 午夜视频在线免费观看| 亚洲精品视频免费在线观看| 57pao国产成视频免费播放| 亚洲黄色网站视频| a毛片基地免费全部视频| 亚洲精品午夜国产va久久| 日本免费一区二区三区最新| 春暖花开亚洲性无区一区二区| 亚洲国产一区二区三区| 国产99久久久国产精免费| 亚洲A∨无码一区二区三区| 国产又大又粗又长免费视频| 亚洲av永久无码一区二区三区| www国产亚洲精品久久久| a毛片成人免费全部播放| 亚洲国产精品成人久久蜜臀 | 久久免费观看国产精品88av| 亚洲综合小说久久另类区| 久久WWW免费人成人片| 亚洲AV电影天堂男人的天堂| 伊人久久大香线蕉亚洲| 91免费国产自产地址入| 色偷偷亚洲第一综合网| 亚洲av无码精品网站| 91在线视频免费播放| 亚洲阿v天堂在线2017免费| 老司机亚洲精品影院| 国产又大又粗又硬又长免费 | 美女视频黄频a免费| 亚洲激情视频在线观看|