- Hlavní stránka
- Balíky
- Třídy
- Soubory

# src/cz/neubauer/tomas/hazardanalysis/viewcontroller/administration/AdminDangerTypeFrame.java

Zobrazit dokumentaci tohoto souboru.

    00001
    00004 package cz.neubauer.tomas.hazardanalysis.viewcontroller.administration;
    00005
    00006 import java.awt.BorderLayout;
    00007 import java.awt.FlowLayout;
    00008 import java.awt.GridLayout;
    00009 import java.awt.event.ActionEvent;
    00010 import java.awt.event.ActionListener;
    00011 import java.util.ArrayList;
    00012 import java.util.Vector;
    00013
    00014 import javax.swing.JButton;
    00015 import javax.swing.JComboBox;
    00016 import javax.swing.JFrame;
    00017 import javax.swing.JLabel;
    00018 import javax.swing.JPanel;
    00019 import javax.swing.JScrollPane;
    00020 import javax.swing.JTextArea;
    00021 import javax.swing.JTextField;
    00022
    00023 import cz.neubauer.tomas.hazardanalysis.model.dangers.DangerGroup;
    00024 import cz.neubauer.tomas.hazardanalysis.model.dangers.DangerType;
    00025 import cz.neubauer.tomas.hazardanalysis.viewcontroller.windowmanipulator.WindowManipulator;
    00026
    00030 public class AdminDangerTypeFrame extends JFrame {
    00031
    00035         private static final long serialVersionUID = 4007969535519734066L;
    00036
    00037         private AdminFrame owner;
    00038
    00039         private ArrayList<DangerGroup> groups;
    00040
    00041         private DangerType dangerType;
    00042
    00043         private JComboBox cmbGroups;
    00044
    00045         private JPanel pnlTextFields;
    00046
    00047         private JTextField txtCode;
    00048
    00049         private JTextField txtDescription;
    00050
    00051         private JTextArea txaSituationDescription;
    00052
    00053         private JTextField txtColumn1;
    00054
    00055         private JTextField txtColumn2;
    00056
    00057         private JTextField txtColumn3;
    00058
    00059         private JTextField txtColumn4;
    00060
    00061         private JTextField txtColumn5;
    00062
    00063         private JTextField txtColumn6;
    00064
    00065         private JTextField txtColumn7;
    00066
    00067         private JButton btnOK;
    00068
    00069         private JButton btnCancel;
    00070
    00071         private JPanel pnlButtons;
    00072
    00073         public AdminDangerTypeFrame(AdminFrame owner, DangerType dangerType,
    00074                         ArrayList<DangerGroup> groups) {
    00075                 this.owner = owner;
    00076                 this.dangerType = dangerType;
    00077                 this.groups = groups;
    00078                 initGUI();
    00079                 setVisible(true);
    00080         }
    00081
    00085         private void initGUI() {
    00086                 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    00087                 setTitle("Typ nebezpečí");
    00088
    00089                 pnlTextFields = new JPanel(new GridLayout(22, 1));
    00090
    00091                 pnlTextFields.add(new JLabel(" Číslo nebezpečí dle ČSN EN 1050:2001"));
    00092                 txtCode = new JTextField(dangerType.getCode(), 50);
    00093                 pnlTextFields.add(txtCode);
    00094
    00095                 pnlTextFields.add(new JLabel(" Popis typu"));
    00096                 txtDescription = new JTextField(dangerType.getDescription(), 50);
    00097                 pnlTextFields.add(txtDescription);
    00098
    00099                 pnlTextFields.add(new JLabel(" Popis nebezpečné situace"));
    00100                 txaSituationDescription = new JTextArea(dangerType
    00101                                 .getSituationDescription());
    00102                 txaSituationDescription.setColumns(40);
    00103                 txaSituationDescription.setRows(1);
    00104                 JScrollPane scroll = new JScrollPane(txaSituationDescription);
    00105                 scroll.setViewportView(txaSituationDescription);
    00106                 pnlTextFields.add(scroll);
    00107
    00108                 pnlTextFields.add(new JLabel(" Část 2 - A1:1995"));
    00109                 txtColumn1 = new JTextField(dangerType.getColumn_cast2_a1_1995(), 50);
    00110                 pnlTextFields.add(txtColumn1);
    00111
    00112                 pnlTextFields.add(new JLabel(" Část 1 r. 1991"));
    00113                 txtColumn2 = new JTextField(dangerType.getColumn_cast1_r1991(), 50);
    00114                 pnlTextFields.add(txtColumn2);
    00115
    00116                 pnlTextFields.add(new JLabel(" Část 2 r. 1991"));
    00117                 txtColumn3 = new JTextField(dangerType.getColumn_cast2_r1991(), 50);
    00118                 pnlTextFields.add(txtColumn3);
    00119
    00120                 pnlTextFields.add(new JLabel(" ČSN EN ISO 12100-1:2003"));
    00121                 txtColumn4 = new JTextField(dangerType
    00122                                 .getColumn_csn_en_iso_12100_1_2003(), 50);
    00123                 pnlTextFields.add(txtColumn4);
    00124
    00125                 pnlTextFields.add(new JLabel(" ČSN EN ISO 12100-2:2003"));
    00126                 txtColumn5 = new JTextField(dangerType
    00127                                 .getColumn_csn_en_iso_12100_2_2003(), 50);
    00128                 pnlTextFields.add(txtColumn5);
    00129
    00130                 pnlTextFields.add(new JLabel(" Odpovídající normy typu B"));
    00131                 txtColumn6 = new JTextField(dangerType.getColumn_normy_typu_b(), 50);
    00132                 pnlTextFields.add(txtColumn6);
    00133
    00134                 pnlTextFields.add(new JLabel(" Přílušné články ČSN EN 12415:2001"));
    00135                 txtColumn7 = new JTextField(dangerType
    00136                                 .getColumn_clanky_csn_en_12415_2001(), 50);
    00137                 pnlTextFields.add(txtColumn7);
    00138
    00139                 pnlTextFields.add(new JLabel(" Skupina nebezpečí"));
    00140                 cmbGroups = new JComboBox(new Vector<DangerGroup>(groups));
    00141                 cmbGroups.setSelectedItem(dangerType.getDangerGroup());
    00142                 pnlTextFields.add(cmbGroups);
    00143
    00144                 this.add(pnlTextFields, BorderLayout.CENTER);
    00145
    00146                 pnlButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
    00147
    00148                 btnOK = new JButton("OK");
    00149                 btnOK.addActionListener(new ActionListener() {
    00150                         @Override
    00151                         public void actionPerformed(ActionEvent e) {
    00152                                 AdminDangerTypeFrame.this.btnOKPerformed();
    00153                         }
    00154                 });
    00155                 pnlButtons.add(btnOK);
    00156
    00157                 btnCancel = new JButton("Zrušit");
    00158                 btnCancel.addActionListener(new ActionListener() {
    00159                         @Override
    00160                         public void actionPerformed(ActionEvent e) {
    00161                                 AdminDangerTypeFrame.this.btnCancelPerformed();
    00162                         }
    00163                 });
    00164                 pnlButtons.add(btnCancel);
    00165
    00166                 this.add(pnlButtons, BorderLayout.SOUTH);
    00167                 pack();
    00168                 WindowManipulator.centerWindow(this);
    00169         }
    00170
    00174         protected void btnOKPerformed() {
    00175                 DangerGroup dg = (DangerGroup) cmbGroups.getSelectedItem();
    00176                 dangerType.setCode(txtCode.getText());
    00177                 dangerType.setDescription(txtDescription.getText());
    00178                 dangerType.setColumn_cast2_a1_1995(txtColumn1.getText());
    00179                 dangerType.setColumn_cast1_r1991(txtColumn2.getText());
    00180                 dangerType.setColumn_cast2_r1991(txtColumn3.getText());
    00181                 dangerType.setColumn_csn_en_iso_12100_1_2003(txtColumn4.getText());
    00182                 dangerType.setColumn_csn_en_iso_12100_2_2003(txtColumn5.getText());
    00183                 dangerType.setColumn_normy_typu_b(txtColumn6.getText());
    00184                 dangerType.setColumn_clanky_csn_en_12415_2001(txtColumn7.getText());
    00185                 dangerType.setSituationDescription(txaSituationDescription.getText());
    00186                 dangerType.setDangerGroup(dg);
    00187                 dangerType.saveToDB(owner.getConnection());
    00188                 owner.refreshTree();
    00189                 dispose();
    00190         }
    00191
    00195         protected void btnCancelPerformed() {
    00196                 dispose();
    00197         }
    00198 }