/*
* This file is part of the aidGer project.
*
* Copyright (C) 2010-2013 The aidGer Team
*
* This program 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.
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.aidger.view.reports;
import static de.aidger.utils.Translation._;
import java.util.ArrayList;
import javax.swing.JPanel;
import de.aidger.model.reports.BalanceReportGroupCreator;
import de.aidger.model.reports.BalanceReportSemesterCreator;
/**
* A JPanel which holds all the groups of a semester.
*
* @author aidGer Team
*/
@SuppressWarnings("serial")
public class BalanceReportSemesterPanel extends javax.swing.JPanel {
/**
* The name of the semester.
*/
private final String name;
/**
* The semester creator, which adds groups to this semester panel.
*/
private BalanceReportSemesterCreator semesterCreator = null;
/**
* Initializes a new BalanceReportSemesterViewer.
*
* @param semester
* The name of the semester.
*/
public BalanceReportSemesterPanel(String semester,
BalanceReportSemesterCreator semesterCreator) {
this.semesterCreator = semesterCreator;
this.name = semester;
initComponents();
addGroups();
}
/**
* Adds all the groups of this semester to the panel.
*/
public void addGroups() {
ArrayList<ArrayList<Object>> groupCreators = semesterCreator
.getGroupCreators();
for (Object groupCreator : groupCreators) {
createGroup(new BalanceReportGroupPanel(
((String) ((ArrayList<Object>) groupCreator).get(1)),
(BalanceReportGroupCreator) ((ArrayList<Object>) groupCreator)
.get(0)));
}
}
/**
* Adds a new group panel to the semester panel.
*
* @param panel
* The panel to be added
*/
public void createGroup(JPanel panel) {
this.add(panel);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setBorder(javax.swing.BorderFactory.createTitledBorder(_("Semester")
+ (" ") + name));
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}