Changes between Version 44 and Version 45 of PRO_LIB_CORE_TUTORIAL


Ignore:
Timestamp:
07/14/09 15:55:28 (16 years ago)
Author:
peko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PRO_LIB_CORE_TUTORIAL

    v44 v45  
    785785}}} 
    786786 
     787 ==== Depending on a non-final property inside a "create()" method of a ResourceProperty ==== 
     788 * Using an non-final property inside a the create method will eventually work if that property is not null or is already initialized. Changing that property however will not affect the value of the resource property since its create method is invoked only once... 
     789{{{ 
     790        public RwProp<Icon> icon() { 
     791                return getBean().makeValueProp("icon", Icon.class); 
     792        } 
     793         
     794        public RwProp<String> toolTip() { 
     795                return getBean().makeValueProp("toolTip", String.class); 
     796        } 
     797         
     798        public Prop<JButton> button() { 
     799                class button extends ResourceProperty<JButton> { 
     800 
     801                        @Override 
     802                        protected JButton create() { 
     803                                JButton res = new JButton(); 
     804                                res.setIcon(icon().get()); 
     805                                return res; 
     806                        } 
     807 
     808                        @Override 
     809                        protected void destroy(JButton res) { 
     810                                //nothing. 
     811                        } 
     812 
     813                        @Override 
     814                        protected void setup(JButton res) { 
     815                                res.setToolTipText(toolTip().get()); 
     816                        } 
     817                } 
     818                return getBean().makeProp(button.class); 
     819        } 
     820}}} 
     821 
     822 * In this case the icon will be set (if initialized by the time the create method is invoked). Besides, the tool-tip will be set, no matter what because the setUp method will be invoked after the initialization of the toolTip()'s property. If we change the tool-tip the setUp method will be re-setUp-ed. '''However if we change the icon property, the icon of the button will not be set to the new one.''' Be careful about such scenarios, because it will probably remain silent. 
     823 
     824 
    787825== Debugging ProLib == 
    788826Some advice: 
     
    796834 * Keep the ProLib and with high quality, because everything else will depend on it. 
    797835 * Be careful not to create cyclic dependencies (like a = b + 1, b = a + 1). No library can solve them. 
     836 ==== More sophisticated scenarios ==== 
     837 * Suppose you have several non-ProObject, non-Immutable objects that you need to keep in sync. Imagine you have three  
    798838 
    799839== TODO ==