001    /*
002     * Copyright (C) 2008 Adam Cornett This program is free software; you can
003     * redistribute it and/or modify it under the terms of the GNU General Public
004     * License as published by the Free Software Foundation; either version 3 of the
005     * License, or (at your option) any later version. This program is distributed
006     * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
007     * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
008     * See the GNU General Public License for more details. You should have received
009     * a copy of the GNU General Public License along with this program; if not, see
010     * <http://www.gnu.org/licenses>.
011     */
012    
013    package net.codescore.ui.admin.ppl;
014    
015    import org.zkoss.zul.Button;
016    import org.zkoss.zul.Grid;
017    import org.zkoss.zul.Hbox;
018    import org.zkoss.zul.Rows;
019    
020    import net.codescore.controllers.SchoolController;
021    import net.codescore.ui.components.list.sel.PersonPicker;
022    import net.codescore.ui.components.windows.ChildControlledWin;
023    import net.codescore.ui.components.windows.ControlledWin;
024    import net.codescore.ui.i18n.T;
025    
026    public class AddCoach extends ChildControlledWin<SchoolController> {
027            private static final long serialVersionUID = -6391329899554034412L;
028            private Grid grid;
029            private Rows rows;
030    
031            public AddCoach(ControlledWin<SchoolController> swin) {
032                    super(swin);
033                    setTitle(T._("admin.ppl.addcoach.wintitle"));
034                    initWindow();
035            }
036    
037            public void onCancel() {
038                    this.setParent(null);
039            }
040    
041            public void onOk() {
042                    getController().addCoach();
043                    this.setParent(null);
044            }
045    
046            private void initButtonBox() {
047                    Hbox buttonBox = new Hbox();
048                    Button ok, cancel;
049                    ok = new Button(T._("general.ok"));
050                    cancel = new Button(T._("general.cancel"));
051                    ok.addForward(null, this, "onOk");
052                    cancel.addForward(null, this, "onCancel");
053                    ok.setParent(buttonBox);
054                    cancel.setParent(buttonBox);
055                    buttonBox.setParent(this);
056            }
057    
058            private void initWindow() {
059                    grid = new Grid();
060                    grid.setParent(this);
061                    rows = new Rows();
062                    rows.setParent(grid);
063                    PersonPicker p =
064                            new PersonPicker(getController(), getController().getSchool());
065                    p.doRows(rows);
066                    initButtonBox();
067            }
068    }