<s> from pyjamas . ui . Composite import Composite <EOL> from pyjamas . ui . CheckBox import CheckBox <EOL> from pyjamas . ui . HorizontalPanel import HorizontalPanel <EOL> from pyjamas . ui . VerticalPanel import VerticalPanel <EOL> from pyjamas . ui . Button import Button <EOL> from pyjamas . ui import HasAlignment <EOL> class DayCheckBox ( CheckBox ) : <EOL> def __init__ ( self , owner , caption , day ) : <EOL> CheckBox . __init__ ( self , caption ) <EOL> self . day = day <EOL> self . addClickListener ( owner . dayCheckBoxListener ) <EOL> self . setChecked ( owner . calendar . getDayIncluded ( day ) ) <EOL> class DayCheckBoxListener : <EOL> def __init__ ( self , calendar ) : <EOL> self . calendar = calendar <EOL> def onClick ( self , sender ) : <EOL> self . calendar . setDayIncluded ( sender . day , sender . isChecked ( ) ) <EOL> class DayFilterWidget ( Composite ) : <EOL> def __init__ ( self , calendar ) : <EOL> Composite . __init__ ( self ) <EOL> self . calendar = calendar <EOL> self . dayCheckBoxListener = DayCheckBoxListener ( calendar ) <EOL> self . outer = VerticalPanel ( ) <EOL> self . initWidget ( self . outer ) <EOL> self . setStyleName ( "<STR_LIT>" ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:0> ) ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:1> ) ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:2> ) ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:3> ) ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:4> ) ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:5> ) ) <EOL> self . outer . add ( DayCheckBox ( self , "<STR_LIT>" , <NUM_LIT:6> ) ) <EOL> self . buttonAll = Button ( "<STR_LIT>" , self ) <EOL> self . buttonNone = Button ( "<STR_LIT:None>" , self ) <EOL> hp = HorizontalPanel ( ) <EOL> hp . setHorizontalAlignment ( HasAlignment . ALIGN_CENTER ) <EOL> hp . add ( self . buttonAll ) <EOL> hp . add ( self . buttonNone ) <EOL> self . outer . add ( hp ) <EOL> self . outer . setCellVerticalAlignment ( hp , HasAlignment . ALIGN_BOTTOM ) <EOL> self . outer . setCellHorizontalAlignment ( hp , HasAlignment . ALIGN_CENTER ) <EOL> def setAllCheckBoxes ( self , checked ) : <EOL> for widget in self . outer : <EOL> if hasattr ( widget , "<STR_LIT>" ) : <EOL> widget . setChecked ( checked ) <EOL> self . dayCheckBoxListener . onClick ( widget ) <EOL> def onClick ( self , sender ) : <EOL> if self . buttonAll == sender : <EOL> self . setAllCheckBoxes ( True ) <EOL> elif self . buttonNone == sender : <EOL> self . setAllCheckBoxes ( False ) </s>
