Changeset 5253

Show
Ignore:
Timestamp:
08/25/08 08:50:11 (3 months ago)
Author:
artur.signell@…
Message:

Fixed #677 for Form

Location:
trunk/src/com/itmill/toolkit
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/tests/tickets/Ticket677.java

    r5252 r5253  
    33import com.itmill.toolkit.Application; 
    44import com.itmill.toolkit.ui.Button; 
     5import com.itmill.toolkit.ui.DateField; 
     6import com.itmill.toolkit.ui.Form; 
    57import com.itmill.toolkit.ui.GridLayout; 
    68import com.itmill.toolkit.ui.Label; 
     
    1416public class Ticket677 extends Application { 
    1517 
     18    private static final Object P1 = new Object(); 
     19    private static final Object P2 = new Object(); 
     20    private static final Object P3 = new Object(); 
     21 
    1622    private Panel panel; 
     23    private Form form; 
    1724 
    1825    public void init() { 
     
    2633 
    2734    private void createUI(GridLayout layout) { 
    28         panel = new Panel("panel caption"); 
    29         layout.addComponent(panel); 
     35        createPanel(layout); 
     36        createForm(layout); 
     37 
    3038        layout.addComponent(new Button("Enable", new ClickListener() { 
    3139 
    3240            public void buttonClick(ClickEvent event) { 
    3341                panel.setEnabled(true); 
     42                form.setEnabled(true); 
    3443            } 
    3544 
     
    4049            public void buttonClick(ClickEvent event) { 
    4150                panel.setEnabled(false); 
     51                form.setEnabled(false); 
    4252            } 
    4353 
    4454        })); 
     55 
     56    } 
     57 
     58    private void createForm(GridLayout layout) { 
     59        form = new Form(); 
     60        form.addField(P1, new TextField()); 
     61        form.addField(P2, new DateField()); 
     62        form.addField(P3, new DateField()); 
     63 
     64        layout.addComponent(form); 
     65    } 
     66 
     67    private void createPanel(GridLayout layout) { 
     68        panel = new Panel("panel caption"); 
     69        layout.addComponent(panel); 
    4570 
    4671        panel.addComponent(new Label("Label 1")); 
  • trunk/src/com/itmill/toolkit/ui/Form.java

    r5107 r5253  
    235235     *  
    236236     * @param makeVisible 
    237      *            If true (default), validation is made visible when commit() is 
    238      *            called. If false, the visibility is left as it is. 
     237     *                If true (default), validation is made visible when 
     238     *                commit() is called. If false, the visibility is left as it 
     239     *                is. 
    239240     */ 
    240241    public void setValidationVisibleOnCommit(boolean makeVisible) { 
     
    245246     * Is validation made automatically visible on commit? 
    246247     *  
    247      *  See setValidationVisibleOnCommit(). 
     248     * See setValidationVisibleOnCommit(). 
    248249     *  
    249250     * @return true if validation is made automatically visible on commit. 
     
    252253        return validationVisibleOnCommit; 
    253254    } 
    254      
     255 
    255256    /* 
    256257     * Commit changes to the data source Don't add a JavaDoc comment here, we 
     
    10751076    } 
    10761077 
     1078    public void setEnabled(boolean enabled) { 
     1079        super.setEnabled(enabled); 
     1080 
     1081        updateComponentDisabledState(!enabled); 
     1082    } 
     1083 
     1084    public void setDisabledByContainer(boolean disabledByContainer) { 
     1085        super.setDisabledByContainer(disabledByContainer); 
     1086 
     1087        updateComponentDisabledState(disabledByContainer); 
     1088    } 
     1089 
     1090    private void updateComponentDisabledState(boolean disabled) { 
     1091        // Update the disabledByContainer state for all subcomponents 
     1092        for (Iterator i = fields.values().iterator(); i.hasNext();) { 
     1093            Component c = (Component) i.next(); 
     1094            if (c instanceof AbstractComponent) { 
     1095                ((AbstractComponent) c).setDisabledByContainer(disabled); 
     1096            } 
     1097        } 
     1098 
     1099    } 
     1100 
    10771101}