// Path: src/java/se/idega/idegaweb/commune/school/event/SchoolEventListener.java
// public class SchoolEventListener implements IWPageEventListener {
// 
// 	private int _schoolID = -1;
// 	private int _schoolSeasonID = -1;
// 	private int _schoolYearID = -1;
// 	private int _schoolClassID = -1;
// 	private int _studentID = -1;
// 	
// 	/**
// 	 * @see com.idega.business.IWEventListener#actionPerformed(IWContext)
// 	 */
// 	public boolean actionPerformed(IWContext iwc) {
// 		try {
// 			SchoolCommuneSession session = getSchoolCommuneSession(iwc);
// 			this._schoolID = session.getSchoolID();	
// 	
// 			if (iwc.isParameterSet(session.getParameterSchoolID())) {
// 				this._schoolID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolSeasonID())) {
// 				this._schoolSeasonID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolSeasonID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolYearID())) {
// 				this._schoolYearID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolYearID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolClassID())) {
// 				this._schoolClassID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolClassID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterStudentID())) {
// 				this._studentID = Integer.parseInt(iwc.getParameter(session.getParameterStudentID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolGroupIDs())) {
// 				session.setSchoolGroupIDs(iwc.getParameterValues(session.getParameterSchoolGroupIDs()));
// 			}
// 			
// 			if ( this._schoolClassID != -1 && this._schoolYearID != -1 ) {
// 				validateSchoolClass(iwc);
// 			}
// 				
// 			session.setSchoolClassID(this._schoolClassID);
// 			session.setSchoolID(this._schoolID);
// 			session.setSchoolSeasonID(this._schoolSeasonID);
// 			session.setSchoolYearID(this._schoolYearID);
// 			session.setStudentID(this._studentID);
// 			return true;
// 		}
// 		catch (RemoteException re) {
// 			return false;
// 		}
// 	}
// 
// 	private void validateSchoolClass(IWContext iwc) throws RemoteException {
// 		SchoolClass schoolClass = getSchoolCommuneBusiness(iwc).getSchoolBusiness().findSchoolClass(new Integer(this._schoolClassID));
// 		SchoolYear schoolYear = getSchoolCommuneBusiness(iwc).getSchoolBusiness().getSchoolYear(new Integer(this._schoolYearID));
// 		if (!schoolClass.hasRelationToSchoolYear(schoolYear) ) {
// 			Collection schoolClasses = getSchoolCommuneBusiness(iwc).getSchoolBusiness().findSchoolClassesBySchoolAndSeasonAndYear(this._schoolID, this._schoolSeasonID, this._schoolYearID);
// 			if ( !schoolClasses.isEmpty() ) {
// 				Iterator iter = schoolClasses.iterator();
// 				while (iter.hasNext()) {
// 					this._schoolClassID = ((Integer)((SchoolClass) iter.next()).getPrimaryKey()).intValue();
// 					continue;
// 				}
// 			}
// 		}
// 	}
// 	
// 	private SchoolCommuneSession getSchoolCommuneSession(IWContext iwc) throws RemoteException {
// 		return (SchoolCommuneSession) IBOLookup.getSessionInstance(iwc, SchoolCommuneSession.class);	
// 	}
// 	
// 	private SchoolCommuneBusiness getSchoolCommuneBusiness(IWContext iwc) throws RemoteException {
// 		return (SchoolCommuneBusiness) IBOLookup.getServiceInstance(iwc, SchoolCommuneBusiness.class);	
// 	}
// 	
// }


import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import se.idega.idegaweb.commune.school.event.SchoolEventListener;
import com.idega.block.school.business.SchoolYearComparator;
import com.idega.block.school.data.SchoolYear;
import com.idega.data.IDORelationshipException;
import com.idega.presentation.IWContext;
import com.idega.presentation.Table;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.Form;
import com.idega.presentation.ui.GenericButton;
import com.idega.presentation.ui.SubmitButton;
		catch (IDORelationshipException e1) {
			schoolYears = new ArrayList();
		}
		if (!schoolYears.isEmpty()) {
			Collections.sort(schoolYears, new SchoolYearComparator());
		}
		
		table.add(getSmallHeader(localize("school.school_season", "Season") + ":"), 1, row);
		table.add(Text.getNonBrakingSpace(), 1, row);
		table.add(getSchoolSeasons(false), 1, row++);
		table.setHeight(row++, 8);
		
		table.add(getSmallHeader(localize("school.school_years", "Years") + ":"), 1, row++);
		
		Iterator iter = schoolYears.iterator();
		while (iter.hasNext()) {
			SchoolYear year = (SchoolYear) iter.next();
			CheckBox box = getCheckBox(getSession().getParameterSchoolGroupIDs(), year.getPrimaryKey().toString());
			
			table.setCellpadding(1, row, 2);
			table.add(box, 1, row);
			table.add(Text.getNonBrakingSpace(), 1, row);
			table.add(getSmallText(year.getSchoolYearName()), 1, row++);
		}
		table.setHeight(row++, 15);
		
		SubmitButton button = (SubmitButton) getButton(new SubmitButton(localize("school.continue", "Continue")));
		button.setToEnableWhenChecked(getSession().getParameterSchoolGroupIDs());
		
		if (getBackPage() != null) {
// Path: src/java/se/idega/idegaweb/commune/school/event/SchoolEventListener.java
// public class SchoolEventListener implements IWPageEventListener {
// 
// 	private int _schoolID = -1;
// 	private int _schoolSeasonID = -1;
// 	private int _schoolYearID = -1;
// 	private int _schoolClassID = -1;
// 	private int _studentID = -1;
// 	
// 	/**
// 	 * @see com.idega.business.IWEventListener#actionPerformed(IWContext)
// 	 */
// 	public boolean actionPerformed(IWContext iwc) {
// 		try {
// 			SchoolCommuneSession session = getSchoolCommuneSession(iwc);
// 			this._schoolID = session.getSchoolID();	
// 	
// 			if (iwc.isParameterSet(session.getParameterSchoolID())) {
// 				this._schoolID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolSeasonID())) {
// 				this._schoolSeasonID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolSeasonID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolYearID())) {
// 				this._schoolYearID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolYearID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolClassID())) {
// 				this._schoolClassID = Integer.parseInt(iwc.getParameter(session.getParameterSchoolClassID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterStudentID())) {
// 				this._studentID = Integer.parseInt(iwc.getParameter(session.getParameterStudentID()));
// 			}
// 			
// 			if (iwc.isParameterSet(session.getParameterSchoolGroupIDs())) {
// 				session.setSchoolGroupIDs(iwc.getParameterValues(session.getParameterSchoolGroupIDs()));
// 			}
// 			
// 			if ( this._schoolClassID != -1 && this._schoolYearID != -1 ) {
// 				validateSchoolClass(iwc);
// 			}
// 				
// 			session.setSchoolClassID(this._schoolClassID);
// 			session.setSchoolID(this._schoolID);
// 			session.setSchoolSeasonID(this._schoolSeasonID);
// 			session.setSchoolYearID(this._schoolYearID);
// 			session.setStudentID(this._studentID);
// 			return true;
// 		}
// 		catch (RemoteException re) {
// 			return false;
// 		}
// 	}
// 
// 	private void validateSchoolClass(IWContext iwc) throws RemoteException {
// 		SchoolClass schoolClass = getSchoolCommuneBusiness(iwc).getSchoolBusiness().findSchoolClass(new Integer(this._schoolClassID));
// 		SchoolYear schoolYear = getSchoolCommuneBusiness(iwc).getSchoolBusiness().getSchoolYear(new Integer(this._schoolYearID));
// 		if (!schoolClass.hasRelationToSchoolYear(schoolYear) ) {
// 			Collection schoolClasses = getSchoolCommuneBusiness(iwc).getSchoolBusiness().findSchoolClassesBySchoolAndSeasonAndYear(this._schoolID, this._schoolSeasonID, this._schoolYearID);
// 			if ( !schoolClasses.isEmpty() ) {
// 				Iterator iter = schoolClasses.iterator();
// 				while (iter.hasNext()) {
// 					this._schoolClassID = ((Integer)((SchoolClass) iter.next()).getPrimaryKey()).intValue();
// 					continue;
// 				}
// 			}
// 		}
// 	}
// 	
// 	private SchoolCommuneSession getSchoolCommuneSession(IWContext iwc) throws RemoteException {
// 		return (SchoolCommuneSession) IBOLookup.getSessionInstance(iwc, SchoolCommuneSession.class);	
// 	}
// 	
// 	private SchoolCommuneBusiness getSchoolCommuneBusiness(IWContext iwc) throws RemoteException {
// 		return (SchoolCommuneBusiness) IBOLookup.getServiceInstance(iwc, SchoolCommuneBusiness.class);	
// 	}
// 	
// }


// Path: src/java/se/idega/idegaweb/commune/school/presentation/SchoolClassViewer.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import se.idega.idegaweb.commune.school.event.SchoolEventListener;
import com.idega.block.school.business.SchoolYearComparator;
import com.idega.block.school.data.SchoolYear;
import com.idega.data.IDORelationshipException;
import com.idega.presentation.IWContext;
import com.idega.presentation.Table;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.Form;
import com.idega.presentation.ui.GenericButton;
import com.idega.presentation.ui.SubmitButton;

		catch (IDORelationshipException e1) {
			schoolYears = new ArrayList();
		}
		if (!schoolYears.isEmpty()) {
			Collections.sort(schoolYears, new SchoolYearComparator());
		}
		
		table.add(getSmallHeader(localize("school.school_season", "Season") + ":"), 1, row);
		table.add(Text.getNonBrakingSpace(), 1, row);
		table.add(getSchoolSeasons(false), 1, row++);
		table.setHeight(row++, 8);
		
		table.add(getSmallHeader(localize("school.school_years", "Years") + ":"), 1, row++);
		
		Iterator iter = schoolYears.iterator();
		while (iter.hasNext()) {
			SchoolYear year = (SchoolYear) iter.next();
			CheckBox box = getCheckBox(getSession().getParameterSchoolGroupIDs(), year.getPrimaryKey().toString());
			
			table.setCellpadding(1, row, 2);
			table.add(box, 1, row);
			table.add(Text.getNonBrakingSpace(), 1, row);
			table.add(getSmallText(year.getSchoolYearName()), 1, row++);
		}
		table.setHeight(row++, 15);
		
		SubmitButton button = (SubmitButton) getButton(new SubmitButton(localize("school.continue", "Continue")));
		button.setToEnableWhenChecked(getSession().getParameterSchoolGroupIDs());
		
		if (getBackPage() != null) {
			GenericButton back = getButton(new GenericButton("back", localize("back", "Back")));