/** * <a href="http://www.openolat.org"> * OpenOLAT - Online Learning and Training</a><br> * <p> * Licensed under the Apache License, Version 2.0 (the "License"); <br> * you may not use this file except in compliance with the License.<br> * You may obtain a copy of the License at the * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> * <p> * Unless required by applicable law or agreed to in writing,<br> * software distributed under the License is distributed on an "AS IS" BASIS, <br> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> * See the License for the specific language governing permissions and <br> * limitations under the License. * <p> * Initial code contributed and copyrighted by<br> * frentix GmbH, http://www.frentix.com * <p> */ package org.olat.commons.calendar.ui; import java.util.Calendar; import java.util.Date; import org.olat.commons.calendar.CalendarManager; import org.olat.commons.calendar.CalendarUtils; import org.olat.commons.calendar.ui.events.CalendarGUIPrintEvent; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.elements.DateChooser; import org.olat.core.gui.components.form.flexible.elements.FormLink; import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.components.form.flexible.impl.FormEvent; import org.olat.core.gui.components.link.Link; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.core.util.Util; /** * * Initial date: 09.04.2013<br> * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ public class CalendarPrintController extends FormBasicController { private FormLink printButton; private DateChooser fromEl, toEl; public CalendarPrintController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl); setTranslator(Util.createPackageTranslator(CalendarManager.class, getLocale(), getTranslator())); initForm(ureq); } @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { //default today to in one month Date start = CalendarUtils.removeTime(new Date()); Calendar cal = Calendar.getInstance(); cal.setTime(start); cal.add(Calendar.MONTH, 1); Date end = cal.getTime(); setFormDescription("cal.print.desc"); formLayout.setElementCssClass("o_sel_calendar_print_chooser"); fromEl = uifactory.addDateChooser("cal.from", start, formLayout); toEl = uifactory.addDateChooser("cal.to", end, formLayout); printButton = uifactory.addFormLink("print", formLayout, Link.BUTTON); } @Override protected void doDispose() { // } @Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if(source == printButton) { Date from = fromEl.getDate(); Date to = toEl.getDate(); fireEvent(ureq, new CalendarGUIPrintEvent(from, to)); } super.formInnerEvent(ureq, source, event); } @Override protected void formOK(UserRequest ureq) { // } }