/**
* Copyright 2010 the original author or authors.
*
* This file is part of openTruuls™. http://www.opentruuls.org/ and
* have the permission to be integrated in the zksample2 demo application.
*
* Zksample2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zksample2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Zksample2. If not, see <http://www.gnu.org/licenses/gpl.html>.
*/
package de.forsthaus.webui.dashboard.module;
import java.io.Serializable;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Calendar;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Center;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Panelchildren;
import org.zkoss.zul.Toolbar;
import org.zkoss.zul.Window;
/**
* EN: <b>Calendar</b> controller for the dashboard.<br>
* Sample skeleton.
* <hr>
* DE: <b>Kalender</b> Controller fuer die SystemUebersicht.<br>
* Beispiel Struktur.
*
* <pre>
* call: Div div = DashboardCalendarCtrl.show(200);
* </pre>
*
* @author Stephan Gerth
*/
public class DashboardCalendarCtrl extends Div implements Serializable {
private static final long serialVersionUID = 1L;
// the height of this dashboard module
private int modulHeight;
// the title of the dashboard module
private String title = Labels.getLabel("common.Calendar");
// The icon path for the groupbox
private String iconPath = "/images/icons/calendar1_16x16.gif";
/**
* The static call method.
*
* @param modulHeight
* The height of this dashboard module
* @return the module as DIV.
*/
public static Div show(int modulHeight) {
return new DashboardCalendarCtrl(modulHeight);
}
/**
* Private Constructor. So it can only be created with the static show()
* method.<br>
*
* @param modulHeight
* The height of this dashboard module
*/
private DashboardCalendarCtrl(int modulHeight) {
super();
setModulHeight(modulHeight);
createComponents();
}
/**
* Creates the components.<br>
*/
private void createComponents() {
/**
* !! Windows as NameSpaceContainer to prevent not unique id's error
* from other dashboard module buttons or other used components.
*/
Window win = new Window();
win.setBorder("none");
win.setSclass("OT-DashboardWindow");
win.setParent(this);
Panel pl = new Panel();
pl.setBorder("normal");
pl.setClosable(false);
pl.setParent(win);
Caption cap = new Caption();
cap.setImage(iconPath);
cap.setLabel(title);
cap.setStyle("padding: 0px;");
cap.setParent(pl);
Panelchildren plc = new Panelchildren();
plc.setParent(pl);
// Buttons Toolbar/Timer
Div div = new Div();
div.setStyle("padding: 0px");
div.setParent(cap);
Hbox hbox = new Hbox();
hbox.setPack("stretch");
hbox.setWidth("100%");
hbox.setParent(div);
Toolbar toolbarRight = new Toolbar();
toolbarRight.setStyle("float:right; border-style: none;");
toolbarRight.setParent(hbox);
// body
Borderlayout bl = new Borderlayout();
bl.setHeight(getModulHeight() + "px");
bl.setParent(plc);
Center ct = new Center();
ct.setSclass("FDCenterNoBorder");
ct.setStyle("background-color: white");
ct.setParent(bl);
// Module dependend
Calendar calendar = new Calendar();
calendar.setId("cal");
calendar.setStyle("border: none;");
calendar.setWidth("98%");
calendar.setParent(ct);
doReadData();
}
/**
* Reads the data.
*/
public void doReadData() {
}
/**
* Inner onBtnClick Listener class.<br>
*
* @author sGerth
*/
private final class BtnClickListener implements EventListener {
@Override
public void onEvent(Event event) throws Exception {
// check which button is pressed
if (event.getTarget().getId().equalsIgnoreCase("btnRefresh")) {
doReadData();
}
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++ //
// ++++++++++++++++ Setter/Getter ++++++++++++++++++ //
// +++++++++++++++++++++++++++++++++++++++++++++++++ //
public void setModulHeight(int modulHeight) {
this.modulHeight = modulHeight;
}
public int getModulHeight() {
return modulHeight;
}
}