/*
* 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.forms;
import static de.aidger.utils.Translation._;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JLabel;
import javax.swing.JPanel;
import de.aidger.model.models.FinancialCategory;
import de.aidger.view.models.UICostUnit;
/**
* A form used for viewing financial categories.
*
* @author aidGer Team
*/
@SuppressWarnings("serial")
public class FinancialCategoryViewerForm extends JPanel {
/**
* Constructs a financial category viewer form.
*
* @param fc
* the financial category that will be displayed
*/
public FinancialCategoryViewerForm(FinancialCategory fc) {
initComponents();
name.setText(fc.getName());
year.setText(String.valueOf(fc.getYear()));
for (int i = 0; i < fc.getCostUnits().length; ++i) {
addNewCostUnit(UICostUnit.valueOf(fc.getCostUnits()[i]), String
.valueOf(fc.getBudgetCosts()[i]));
}
}
/**
* Adds a new cost unit line to the form.
*/
private void addNewCostUnit(String costUnitStr, String budgetCostsStr) {
GridBagConstraints gridBagConstraints;
JLabel lblCostUnit = new JLabel(_("Cost unit"));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(lblCostUnit, gridBagConstraints);
JLabel costUnit = new JLabel(costUnitStr);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(costUnit, gridBagConstraints);
JLabel lblBudgetCosts = new JLabel(_("Budget Costs"));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(lblBudgetCosts, gridBagConstraints);
JLabel budgetCosts = new JLabel(budgetCostsStr + "\u20ac");
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = GridBagConstraints.RELATIVE;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(budgetCosts, gridBagConstraints);
}
/**
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
GridBagConstraints gridBagConstraints;
lblName = new JLabel();
name = new JLabel();
lblYear = new JLabel();
year = new JLabel();
setLayout(new GridBagLayout());
lblName.setText(_("Name"));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(lblName, gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(name, gridBagConstraints);
lblYear.setText(_("Year"));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(lblYear, gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(year, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private JLabel lblName;
private JLabel lblYear;
private JLabel name;
private JLabel year;
// End of variables declaration//GEN-END:variables
}