001 /** =====================================================================
002 *
003 * File Name : $Id: FaultAddition.java,v 1.6 2008/01/15 11:08:16 cb Exp $
004 *
005 * Description
006 * -----------
007 *
008 * See javadoc comment
009 *
010 * =====================================================================
011 *
012 * @Author : Craige Bevil
013 * Control Software Group
014 * Isaac Newton Group of Telescopes
015 *
016 * =====================================================================
017 *
018 * Modification Log
019 *
020 * Vers Date Author Reason
021 * ---- ---- ------ ------
022 * 1 C.Bevil First Release
023 *
024 * Commissioning Notes
025 * -------------------
026 *
027 * None
028 *
029 * =====================================================================
030 *
031 * @Version : $Id: FaultAddition.java,v 1.6 2008/01/15 11:08:16 cb Exp $
032 *
033 * @Author : $Author: cb $
034 *
035 * Header : $Header: /opt/INGsrc/src/CVS/softproj/FaultDatabase/src/FaultDatabase/FaultDatabase/src/GWTApplication/client/FaultAddition.java,v 1.6 2008/01/15 11:08:16 cb Exp $
036 *
037 * Log : $Log: FaultAddition.java,v $
038 * Log : Revision 1.6 2008/01/15 11:08:16 cb
039 * Log : Ran through PMD and sorted out the javadoc so that we could export the
040 * Log : javadoc to the javadoc repository.
041 * Log :
042 * Log : Revision 1.5 2007/08/17 14:23:34 cb
043 * Log : Removed the submit & reset buttons
044 * Log :
045 * Log : Revision 1.4 2007/08/17 07:25:20 cb
046 * Log : Updated after PMD session
047 * Log :
048 * Log : Revision 1.3 2007/08/01 13:00:08 cb
049 * Log : First prototype after import
050 * Log :
051 * Log : Revision 1.2 2007/07/13 10:54:09 cb
052 * Log : Complete interface prototype
053 * Log :
054 * Log : Revision 1.1.1.1 2007/06/01 08:33:26 cb
055 * Log : Imported using TkCVS
056 * Log :
057 *
058 * =====================================================================*/
059
060
061 package GWTApplication.client;
062
063 import com.google.gwt.user.client.*;
064 import com.google.gwt.user.client.rpc.*;
065 import com.google.gwt.user.client.ui.*;
066 import com.google.gwt.user.client.ui.FlexTable.*;
067
068 import java.util.*;
069
070 // Import the rich text widget
071
072 import com.jpavel.gwt.wysiwyg.client.*;
073
074
075 /**
076 * This is a base class will be used to generate a tab at the bottom
077 * of the fault modification form to allow them to create additions to
078 * a fault. This is essentially a base class for the classes which can
079 * be used to create workarounds, solutions and comments which can
080 * be added to a fault.
081 * <P>
082 * The class makes extensive use of the google web toolkit.
083 * @author Craige Bevil
084 * @version $Id: FaultAddition.java,v 1.6 2008/01/15 11:08:16 cb Exp $
085 */
086
087 abstract class FaultAddition extends FaultDBForm {
088
089 /**
090 * This is a listener which is called when we save the fault
091 */
092
093 protected FaultUpdatedListener faultUpdateListener;
094
095 /**
096 * This is the fault number which is associated with this fault
097 * addition
098 */
099
100 protected int FaultNumber;
101
102 /**
103 * This is the table into which we will pack all of these widgets
104 * which will be used to enter the data
105 */
106
107 protected FlexTable FaultAdditionTable = new FlexTable();
108
109 /**
110 * This is the text area into which the user will enter the
111 * details of the text addition
112 */
113
114 protected Editor FaultAdditionText = new Editor();
115
116 /**
117 * The user will enter the name of the person which made the
118 * fault addition into this field
119 */
120
121 protected LabelListBox EnteredBy = new LabelListBox(LabelListBox.HORIZONTAL_ALIGNMENT);
122
123 /**
124 * The user will enter the amount of time spent on this addition
125 * to the fault
126 */
127
128 protected LabelTextBox TimeSpent = new LabelTextBox(LabelTextBox.HORIZONTAL);
129
130 /**
131 * The details of the user authentication
132 */
133
134 protected AuthenticationDetails userAuthentication;
135
136 /**
137 * Constructor for the fault addition tab in the modify fault form
138 * @param FaultNumber This is the number of the defect report
139 * which this fault addition is associated with.
140 * @param svc A conduit to the servlet container
141 * @param internationalizationConstants This is used for
142 * internationalization so we can display the interface in English
143 * and Spanish
144 * @param userAuthentication The details of the user
145 * authentication.
146 * @param faultUpdateListener This is a listener object which is
147 * to be informed when the fault changes.
148 */
149
150 FaultAddition (final int FaultNumber,
151 final FaultServiceAsync svc,
152 final InternationalizationConstants internationalizationConstants,
153 final AuthenticationDetails userAuthentication,
154 final FaultUpdatedListener faultUpdateListener) {
155
156 this.svc = svc;
157 this.internationalizationConstants = internationalizationConstants;
158 this.FaultNumber = FaultNumber;
159 this.userAuthentication = userAuthentication;
160 this.faultUpdateListener = faultUpdateListener;
161
162 initWidget(FaultAdditionTable);
163
164 FlexCellFormatter formatter = (FlexCellFormatter)FaultAdditionTable.getCellFormatter();
165
166 FaultAdditionTable.setWidget(0,0,FaultAdditionText);
167 formatter.setColSpan(0,0,2);
168
169 FaultAdditionText.setWidth("100%");
170 FaultAdditionText.setHeight("200px");
171
172 EnteredBy.label.setText(internationalizationConstants.enteredBy());
173 EnteredBy.setWidth("4cm","5cm");
174 EnteredBy.listBox.setVisibleItemCount(1);
175
176 fillListBoxWithStaffMembers(EnteredBy.listBox,userAuthentication.UserEmailAddress,false);
177
178 TimeSpent.label.setText(internationalizationConstants.timeSpent());
179 TimeSpent.setWidth("4cm","5cm");
180 TimeSpent.textBox.setText("00:00");
181
182 FaultAdditionTable.setWidget(1,0,EnteredBy);
183 FaultAdditionTable.setWidget(1,1,TimeSpent);
184
185 }
186
187 /**
188 * An abstract method which should be provided by the subclass
189 * which will allow for the fields in the form to be initialised
190 * to their default values.
191 */
192
193 abstract void setFormDefaultValues();
194
195 /**
196 * Save the contents of the fault addition form to the database.
197 */
198
199 abstract void saveFormContentsToDatabase ();
200
201 /**
202 * Reset the contents of the fault addition form to what is
203 * current stored in the database for this fault addition.
204 */
205
206 abstract void resetFormToDefaultValues ();
207 }
208