source: main/trunk/gli/src/org/greenstone/gatherer/feedback/History.java@ 24915

Last change on this file since 24915 was 7315, checked in by kjdon, 20 years ago

Veronika's feedback code - still needs some work, but its disabled by default

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1package org.greenstone.gatherer.feedback;
2
3import java.util.*;
4import java.awt.image.*;
5import java.io.*;
6import javax.imageio.*;
7import javax.swing.*;
8import java.awt.*;
9
10/**
11 * This class is one record of the action user did to any of the component
12 * inside the window that the application open that is recorded by the
13 * special listener class.
14 * An instance of this class will hold all the information about the action
15 * user did at that moment,all information about all the components inside the
16 * window where the action occured and all information about all the components
17 * inside all the windows that were opened when the action occured.
18 * @author Veronica Liesaputra
19 */
20public class History implements Serializable
21{
22 /**
23 * This is the date of when the action is done by the user.
24 */
25 private String date;
26
27 /**
28 * This is the command that user did.
29 */
30 private String command;
31
32 /**
33 * This is the title of the window where the action occured.
34 */
35 private String title;
36
37 /**
38 * This hold all information about all the components inside the
39 * window where the action occured and all information about all the components
40 * inside all the windows that were open when the action occured.
41 */
42 private ArrayList component;
43
44 /**
45 * This hold the image of the window where the action occured.
46 */
47 private String image = null;
48
49 /**
50 * This is the image file name, if then user decide to save the image to a jpeg file.
51 */
52 private String imageName = "";
53
54 /**
55 * This is the height of image of the window where the action occured.
56 */
57 private String height;
58
59 /**
60 * This is the width of image of the window where the action occured.
61 */
62 private String width;
63
64 /**
65 * This constructor will be initializing the date,command and component value.
66 * (Precondition: (curr_date != null))
67 * @param curr_date is the date when the action occured.
68 * @param curr_command is the command the user did.
69 */
70 public History (Date curr_date,String curr_command)
71 {
72 date = curr_date.toString();
73 command = curr_command;
74 component = new ArrayList();
75 }
76
77 /**
78 * This method will be setting up the image attributes to the passed values.
79 * It will setting the image of the window where the action occured and its height
80 * and width.It will also generate the supposed file name for this image.
81 * (Precondition: (imag != null) && (h != null) && (w != null))
82 * @param img the image of the window where the action occured.
83 * @param h image's height.
84 * @param w image's width.
85 */
86 public void setImage(String img,String h,String w)
87 {
88 image = img;
89 height = h;
90 width = w;
91 StringTokenizer st;
92 st = new StringTokenizer(date,": ");
93 while (st.hasMoreTokens())
94 {
95 imageName += st.nextToken();
96 }
97 imageName += ".jpg";
98 }
99
100 /**
101 * This method will add a new CompGroup instance that hold information and
102 * the status of a window that were open when the action occured.
103 * @param comp UserComponent instance that hold information about all
104 * components inside the window.
105 * @param curr_status The current status of the window.
106 */
107 public void addComponent (UserComponent comp,String curr_status)
108 {
109 component.add(new CompGroup(comp,curr_status));
110 }
111
112 /**
113 * This method will get the image's height of the window where the action
114 * occured.
115 * @return image's height.
116 */
117 public String getHeight ()
118 {
119 return height;
120 }
121
122 /**
123 * This method will get the image's width of the window where the action
124 * occured.
125 * @return image's width.
126 */
127 public String getWidth ()
128 {
129 return width;
130 }
131
132 /**
133 * This method will set the title of the window where the action occured.
134 * @param name window's title.
135 */
136 public void setTitle (String name)
137 {
138 title = name;
139 }
140
141 /**
142 * This method will get the title of the window where the action occured.
143 * @return the window's title.
144 */
145 public String getTitle ()
146 {
147 return title;
148 }
149
150 /**
151 * This method will get the date when the action occured.
152 * @return the date when the action occured.
153 */
154 public String getDate()
155 {
156 return date;
157 }
158
159 /**
160 * This method will get the command that user did.
161 * @return the command user did.
162 */
163 public String getCommand()
164 {
165 return command;
166 }
167
168 /**
169 * This method will get the array of CompGroup instances that hold
170 * all the information and status of all the window that were open when
171 * the action occured.
172 * @return the array list of the CompGroup instances.
173 */
174 public ArrayList getArray()
175 {
176 return component;
177 }
178
179 /**
180 * This method will get the image of the window where the action occured.
181 * @return image the window's image.
182 */
183 public String getImage()
184 {
185 return image;
186 }
187
188 /**
189 * This method will get the supposed image's file name.
190 * @return image's file name.
191 */
192 public String getImageName()
193 {
194 return imageName;
195 }
196
197 /**
198 * This method will stored this instance to an xml file.
199 * It will only store the date,title,command,image and all
200 * image attributes of this instance to the xml file.
201 * @param sx is the xml file where we want to store.
202 */
203 public void sendXMLComm (SaveToXML sx)
204 {
205 sx.startContent(10);
206
207 sx.startContent(7);
208 sx.saveContent(date);
209 sx.closeContent(7);
210
211 sx.startContent(2);
212 sx.saveContent(title);
213 sx.closeContent(2);
214
215 sx.startContent(8);
216 sx.saveContent(command);
217 sx.closeContent(8);
218
219 if (image != null)
220 {
221 sx.startContent(6);
222 sx.saveImage(image,imageName,width,height);
223 sx.closeContent(6);
224 }
225
226 sx.closeContent(10);
227 }
228
229 /**
230 * This method will stored this instance to an xml file.
231 * It will store all the data members of this instance to
232 * the xml file.
233 * @param sx is the xml file where we want to store.
234 */
235 public void sendXML (SaveToXML sx)
236 {
237 sx.startContent(10);
238
239 sx.startContent(7);
240 sx.saveContent(date);
241 sx.closeContent(7);
242
243 sx.startContent(2);
244 sx.saveContent(title);
245 sx.closeContent(2);
246
247 sx.startContent(8);
248 sx.saveContent(command);
249 sx.closeContent(8);
250
251 if (image != null)
252 {
253 sx.startContent(6);
254 sx.saveImage(image,imageName,width,height);
255 sx.closeContent(6);
256 }
257
258 int j;
259 for (j = 0 ; j < component.size() ; j++)
260 {
261 sx.startContent(9);
262 CompGroup comp;
263 comp = (CompGroup) component.get(j);
264
265 sx.startContent(8);
266 sx.saveContent(comp.getStatus());
267 sx.closeContent(8);
268
269 sx.startContent(0);
270 comp.getComponent().sendingXML(sx);
271 sx.closeContent(0);
272
273 sx.closeContent(9);
274 }
275 sx.closeContent(10);
276 }
277}
278
279
280
281
282
283
284
Note: See TracBrowser for help on using the repository browser.