/* * iDART: The Intelligent Dispensing of Antiretroviral Treatment * Copyright (C) 2006 Cell-Life * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program 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 version * 2 for more details. * * You should have received a copy of the GNU General Public License version 2 * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ package org.celllife.idart.gui.reportParameters; import java.util.Calendar; import java.util.Date; import model.manager.reports.TransactionLoggingReport; import org.apache.log4j.Logger; import org.celllife.idart.gui.platform.GenericReportGui; import org.celllife.idart.gui.utils.ResourceUtils; import org.celllife.idart.gui.utils.iDartFont; import org.celllife.idart.gui.utils.iDartImage; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.vafada.swtcalendar.SWTCalendar; import org.vafada.swtcalendar.SWTCalendarListener; /** */ public class TransactionLog extends GenericReportGui { private Group grpDateRange; private Label lblStartDate; private Label lblEndDate; private SWTCalendar calendarStart; private SWTCalendar calendarEnd; /** * Constructor * * @param parent * Shell * @param activate * boolean */ public TransactionLog(Shell parent, boolean activate) { super(parent, REPORTTYPE_MONITORINGANDEVALUATION, activate); } /** * This method initializes newDate_DrugOrClinic */ @Override protected void createShell() { Rectangle bounds = new Rectangle(70, 50, 700, 380); buildShell(REPORT_TRANSACTION_LOG, bounds); // create the composites createMyGroups(); } private void createMyGroups() { createGrpDateRange(); } /** * This method initializes compHeader * */ @Override protected void createCompHeader() { iDartImage icoImage = iDartImage.REPORT_OUTGOINGPACKAGES; buildCompdHeader(REPORT_TRANSACTION_LOG, icoImage); } /** * This method initializes grpDateRange * */ private void createGrpDateRange() { grpDateRange = new Group(getShell(), SWT.NONE); grpDateRange.setText("Date Range:"); grpDateRange.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); grpDateRange.setBounds(new Rectangle(79, 80, 520, 201)); grpDateRange.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lblStartDate = new Label(grpDateRange, SWT.CENTER | SWT.BORDER); lblStartDate.setBounds(new org.eclipse.swt.graphics.Rectangle(40, 30, 180, 20)); lblStartDate.setText("Select a START date:"); lblStartDate.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lblEndDate = new Label(grpDateRange, SWT.CENTER | SWT.BORDER); lblEndDate.setBounds(new org.eclipse.swt.graphics.Rectangle(300, 30, 180, 20)); lblEndDate.setText("Select an END date:"); lblEndDate.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); calendarStart = new SWTCalendar(grpDateRange); calendarStart.setBounds(20, 55, 220, 140); calendarEnd = new SWTCalendar(grpDateRange); calendarEnd.setBounds(280, 55, 220, 140); } /** * Method getCalendarStart. * @return Calendar */ public Calendar getCalendarStart() { return calendarStart.getCalendar(); } /** * Method getCalendarEnd. * @return Calendar */ public Calendar getCalendarEnd() { return calendarEnd.getCalendar(); } /** * Method setStartDate. * @param date Date */ public void setStartDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendarStart.setCalendar(calendar); } /** * Method setEndDate. * @param date Date */ public void setEndDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendarEnd.setCalendar(calendar); } /** * Method addStartDateChangedListener. * @param listener SWTCalendarListener */ public void addStartDateChangedListener(SWTCalendarListener listener) { calendarStart.addSWTCalendarListener(listener); } /** * Method addEndDateChangedListener. * @param listener SWTCalendarListener */ public void addEndDateChangedListener(SWTCalendarListener listener) { calendarEnd.addSWTCalendarListener(listener); } /** * This method initializes compButtons * */ @Override protected void createCompButtons() { } @Override protected void cmdViewReportWidgetSelected() { if (calendarStart.getCalendar().getTime().after( calendarEnd.getCalendar() .getTime())) { MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR); mb.setText("Invalid End Date"); mb.setMessage("Please select an end date after the start date"); mb.open(); } else { TransactionLoggingReport report = new TransactionLoggingReport( getShell(), calendarStart.getCalendar() .getTime(), calendarEnd.getCalendar().getTime()); viewReport(report); } } /** * This method is called when the user presses "Close" button * */ @Override protected void cmdCloseWidgetSelected() { cmdCloseSelected(); } @Override protected void setLogger() { setLog(Logger.getLogger(this.getClass())); } }