Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/schooltool/client/gui/forms/oldScreens/ActivitiesSetupPanel.java


1   /*
2    * ActivitiesSetupPanel.java
3    *
4    * Created on November 27, 2001, 2:25 PM
5    */
6   
7   package org.schooltool.client.gui.forms.oldScreens;
8   
9   import java.awt.*;
10  import java.awt.event.*;
11  import javax.swing.*;
12  import java.util.*;
13  import java.io.Serializable;
14  import org.schooltool.client.gui.forms.*;
15  import org.schooltool.client.gui.widgets.*;
16  import org.schooltool.client.gui.widgets.widgetevents.*;
17  import org.schooltool.client.gui.view.*;
18  import org.schooltool.ejb.session.client.access.*;
19  import org.schooltool.ejb.session.client.learner.*;
20  import org.schooltool.complextypes.learner.*;
21  /**
22   *
23   * @author  root
24   */
25  public class ActivitiesSetupPanel extends javax.swing.JPanel implements Serializable, FormInterface {
26  
27      private long activityPK = 0;
28      private accessModule access;
29      private learnerModule learner;
30      private ActivitiesPanel parent;
31      private Frame frame;
32      private JDialog dialog;
33      
34      /** Creates new form ActivitiesSetupPanel */
35      public ActivitiesSetupPanel() {
36          initComponents();
37      }
38      
39      public ActivitiesSetupPanel(Frame frame, ActivitiesPanel parent, accessModule access, long activityPK) {
40          this.access = access;
41          this.parent = parent;
42          this.frame = frame;
43          this.activityPK = activityPK;
44          
45          initComponents();
46          
47          load(activityPK);
48  
49          dialog = new JDialog(frame, "Activities Setup", true);
50              dialog.addWindowListener(new WindowAdapter() {
51                  public void windowClosing(WindowEvent we) {
52                      dialog.dispose();
53                  }
54              }); 
55              dialog.getContentPane().add(this);
56              dialog.pack();
57              dialog.setLocationRelativeTo(frame);
58              dialog.setVisible(true);
59      }
60  
61      /** This method is called from within the constructor to
62       * initialize the form.
63       * WARNING: Do NOT modify this code. The content of this method is
64       * always regenerated by the Form Editor.
65       */
66      private void initComponents() {//GEN-BEGIN:initComponents
67          pnlContent = new javax.swing.JPanel();
68          lblActivity = new javax.swing.JLabel();
69          txtActivity = new javax.swing.JTextField();
70          chkBillable = new javax.swing.JCheckBox();
71          pnlFees = new org.schooltool.client.gui.forms.standard.FeesPanel();
72          pnlSave = new javax.swing.JPanel();
73          btnSave = new javax.swing.JButton();
74          btnClose = new javax.swing.JButton();
75          
76          setLayout(new java.awt.GridBagLayout());
77          java.awt.GridBagConstraints gridBagConstraints1;
78          
79          setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
80          pnlContent.setLayout(new java.awt.GridBagLayout());
81          java.awt.GridBagConstraints gridBagConstraints2;
82          
83          pnlContent.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
84          lblActivity.setText("Description:");
85          gridBagConstraints2 = new java.awt.GridBagConstraints();
86          gridBagConstraints2.insets = new java.awt.Insets(6, 0, 6, 6);
87          gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
88          gridBagConstraints2.weightx = 0.5;
89          gridBagConstraints2.weighty = 0.1;
90          pnlContent.add(lblActivity, gridBagConstraints2);
91          
92          txtActivity.setColumns(20);
93          txtActivity.setMinimumSize(new java.awt.Dimension(200, 17));
94          gridBagConstraints2 = new java.awt.GridBagConstraints();
95          gridBagConstraints2.insets = new java.awt.Insets(6, 6, 6, 6);
96          gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
97          gridBagConstraints2.weightx = 0.5;
98          gridBagConstraints2.weighty = 0.1;
99          pnlContent.add(txtActivity, gridBagConstraints2);
100         
101         chkBillable.setText("Billable");
102         gridBagConstraints2 = new java.awt.GridBagConstraints();
103         gridBagConstraints2.gridx = 1;
104         gridBagConstraints2.gridy = 1;
105         gridBagConstraints2.insets = new java.awt.Insets(6, 6, 6, 6);
106         gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
107         gridBagConstraints2.weightx = 0.5;
108         gridBagConstraints2.weighty = 0.1;
109         pnlContent.add(chkBillable, gridBagConstraints2);
110         
111         pnlFees.setBorder(new javax.swing.border.TitledBorder("Fees"));
112         gridBagConstraints2 = new java.awt.GridBagConstraints();
113         gridBagConstraints2.gridx = 0;
114         gridBagConstraints2.gridy = 2;
115         gridBagConstraints2.gridwidth = 2;
116         gridBagConstraints2.weightx = 1.0;
117         gridBagConstraints2.weighty = 0.5;
118         pnlContent.add(pnlFees, gridBagConstraints2);
119         
120         pnlSave.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(10, 10, 10, 10)));
121         btnSave.setText("Save");
122         btnSave.addActionListener(new java.awt.event.ActionListener() {
123             public void actionPerformed(java.awt.event.ActionEvent evt) {
124                 btnSaveActionPerformed(evt);
125             }
126         });
127         
128         pnlSave.add(btnSave);
129         
130         btnClose.setText("Close");
131         btnClose.addActionListener(new java.awt.event.ActionListener() {
132             public void actionPerformed(java.awt.event.ActionEvent evt) {
133                 btnCloseActionPerformed(evt);
134             }
135         });
136         
137         pnlSave.add(btnClose);
138         
139         gridBagConstraints2 = new java.awt.GridBagConstraints();
140         gridBagConstraints2.gridx = 0;
141         gridBagConstraints2.gridy = 3;
142         gridBagConstraints2.gridwidth = 2;
143         gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
144         gridBagConstraints2.weightx = 1.0;
145         gridBagConstraints2.weighty = 0.1;
146         pnlContent.add(pnlSave, gridBagConstraints2);
147         
148         gridBagConstraints1 = new java.awt.GridBagConstraints();
149         gridBagConstraints1.weightx = 1.0;
150         gridBagConstraints1.weighty = 1.0;
151         add(pnlContent, gridBagConstraints1);
152         
153     }//GEN-END:initComponents
154 
155     private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
156         dialog.dispose();
157     }//GEN-LAST:event_btnCloseActionPerformed
158 
159     private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
160         try{
161             if (learner == null){
162                 learner = access.getLearnerModule();
163             }
164             Activities activity = new Activities();
165             activity.setDescription(txtActivity.getText());
166             
167             if (chkBillable.isSelected()){
168                 ComboBoxViewModel cbvm = pnlFees.getComboBoxViewModel();
169                 long feeFK =  cbvm.getPrimaryKey();
170                 activity.setFeeForeignKey(feeFK);
171             }
172             learner.saveActivities(activity);
173             parent.loadForm();
174             dialog.dispose();
175         }catch (Exception ex){
176             ex.printStackTrace();
177         }
178     }//GEN-LAST:event_btnSaveActionPerformed
179 
180     public Component getForm() {
181         return this;
182     }    
183 
184 
185     public void clear() {
186     }
187     
188     public void setLocalizationString(String value) {
189     }
190     
191     public String getSearchFormClassName() {
192         return "";
193     }
194     
195     public void setCallBack(ContentView view) {
196     }
197     
198     public void doInternationalization() {
199     }
200     
201     public void save() {
202     }
203     
204     public void delete() {
205     }
206     
207     public void setAccessMechanism(accessModule access) {
208     }
209     
210     
211     public void searchFormCallBack(long primaryKey) {
212     }
213     
214     public void load(long PK) {
215         try{
216             if (learner == null){
217                 learner = access.getLearnerModule();
218             }
219             
220             Activities activity = learner.findActivities(PK, 1);
221             String description = activity.getDescription();
222             txtActivity.setText(description);
223             long feeFK = activity.getFeeForeignKey();
224             pnlFees.setAccessMechanism(access);
225             pnlFees.load(feeFK);
226             
227         }catch(Exception ex){
228             ex.printStackTrace();
229         }
230     }
231     
232     public String getFormName() {
233     }
234     
235     // Variables declaration - do not modify//GEN-BEGIN:variables
236     private javax.swing.JPanel pnlContent;
237     private javax.swing.JLabel lblActivity;
238     private javax.swing.JTextField txtActivity;
239     private javax.swing.JCheckBox chkBillable;
240     private org.schooltool.client.gui.forms.standard.FeesPanel pnlFees;
241     private javax.swing.JPanel pnlSave;
242     private javax.swing.JButton btnSave;
243     private javax.swing.JButton btnClose;
244     // End of variables declaration//GEN-END:variables
245 
246 }