1 | package org.greenstone.gatherer.feedback;
|
---|
2 |
|
---|
3 | import java.io.*;
|
---|
4 | import java.awt.*;
|
---|
5 | import java.awt.image.*;
|
---|
6 | import java.awt.event.*;
|
---|
7 | import javax.swing.*;
|
---|
8 | import javax.swing.border.*;
|
---|
9 | import java.util.*;
|
---|
10 | import java.net.*;
|
---|
11 | import java.rmi.server.*;
|
---|
12 | import javax.imageio.*;
|
---|
13 | import java.util.Locale;
|
---|
14 | import java.util.ResourceBundle;
|
---|
15 | import java.text.MessageFormat;
|
---|
16 | import com.sun.image.codec.jpeg.*;
|
---|
17 | import javax.swing.Timer;
|
---|
18 | import org.greenstone.gatherer.Gatherer;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * This class will show the FeedbackInterface form.
|
---|
22 | * It will allow user to described about the problem better.Here we will also take some more information available
|
---|
23 | * in the system such as the size of the memory available and the screen size.User also could take more screenshot
|
---|
24 | * so they will be able to say the sequence of events that lead up to the problem.
|
---|
25 | * <br>If the user don't want to send this form, then all the information taken from this form will be deleted
|
---|
26 | * and user will be quitted from the Reporting Feedback sequence.
|
---|
27 | *
|
---|
28 | * @author Veronica Liesaputra
|
---|
29 | */
|
---|
30 | public class FeedbackInterface extends JDialog
|
---|
31 | implements ActionListener
|
---|
32 | {
|
---|
33 | /**
|
---|
34 | * This is the button user need to pressed if they want to view the files.
|
---|
35 | * This button will be disabled when the timer is running and finish = false.
|
---|
36 | */
|
---|
37 | private JButton view_button;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * This button means that the user finished give the information and
|
---|
41 | * want to send it.
|
---|
42 | */
|
---|
43 | public JButton send_button;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * This button means that the user don't want to send information and
|
---|
47 | * back to normal application.
|
---|
48 | * All the data taken start from user choose to start doing the Feedback sequence
|
---|
49 | * up to this point will be delete.
|
---|
50 | */
|
---|
51 | private JButton notsend_button;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * This is the text area where user can explain more about the problem.
|
---|
55 | */
|
---|
56 | private JTextArea problem_details;
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * This is the combo box that allow user to specify the poblem type.
|
---|
60 | */
|
---|
61 | private JComboBox problem_type;
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * This is the combo box that allow user to specify the urgency of the problem.
|
---|
65 | */
|
---|
66 | private JComboBox problem_urgency;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * This combo box will ask whether or not user want to send the screenshot.
|
---|
70 | */
|
---|
71 | private JComboBox problem_screenshot;
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * This text field allow user to type the smtp address of their email that
|
---|
75 | * they want this application to use to send all the data.
|
---|
76 | * If they don't fill this field then it will set to the same
|
---|
77 | * smtp adress of where the data will be send to.
|
---|
78 | */
|
---|
79 | private JTextField smtp_address;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * This text field allow user to type the email adress that they want this
|
---|
83 | * application to use to send all the data.
|
---|
84 | * If they don't fill this field then it will set to the same email
|
---|
85 | * adress of where the data will be send to.
|
---|
86 | */
|
---|
87 | private JTextField email_address;
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * This is the name of the window the user lastly used.
|
---|
91 | * This is the name of the window where the user called to start the Feedback
|
---|
92 | * sequence.
|
---|
93 | */
|
---|
94 | private String frameName;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * This is the unique code generated for each time user start doing the Feedback
|
---|
98 | * sequence.
|
---|
99 | * This code will be used as reference to which feedback that the user send.
|
---|
100 | */
|
---|
101 | private static String code;
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * This is the date when the user start open this FeedbackInterface form.
|
---|
105 | */
|
---|
106 | private Date curr_date;
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * This is the special listener class that record all the action user did in application.
|
---|
110 | */
|
---|
111 | private static ActionRecorderDialog dialog;
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * This variable will hold the resource of the words that is stored in Messages.properties file.
|
---|
115 | * The calling using messages.getString(someString) will caused someString to be translated
|
---|
116 | * into some other string that is hold in that file.usually it will caused it to be translated
|
---|
117 | * to the language that the user use or choose to have as stated in Locale.
|
---|
118 | */
|
---|
119 | private static ResourceBundle messages;
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * This is the screen shot instance that will allow the application to take screen shot of the whole
|
---|
123 | * screen or only the window that the user currently doing their action.
|
---|
124 | */
|
---|
125 | private ScreenShot screen;
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * This is the thread that allows the encoding of the image file to String and the saving of image to
|
---|
129 | * a jpeg file happens concurrently.
|
---|
130 | */
|
---|
131 | private Thread save;
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * This is the hashmap that hold the screen shot and the panel where the screenshot is held.
|
---|
135 | */
|
---|
136 | private HashMap picAndPane;
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * This is the panel that hold all the panels containing the screenshots taken.
|
---|
140 | */
|
---|
141 | private JPanel picture_scroll;
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * This is how many rows of screenshots panel displayed at the moment.
|
---|
145 | */
|
---|
146 | private int row;
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * This is the array list that hold all the screenshots panel displayed.
|
---|
150 | */
|
---|
151 | private ArrayList paneArray;
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * This button will remove the last screenshot panels.
|
---|
155 | */
|
---|
156 | private JButton remove;
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * This is a reference to feedback interface displayed at the moment.
|
---|
160 | */
|
---|
161 | private FeedbackInterface frame;
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * This is the thread to send all the xml files back to the developer.
|
---|
165 | */
|
---|
166 | private Thread sendThread;
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * This is the flag to tell whether or not the sending files finished or not.
|
---|
170 | * It is also flag to tell whether or not the viewing files finished or not.
|
---|
171 | */
|
---|
172 | private static boolean finish;
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * This is the timer to displayed the progress bar to tell user to wait while
|
---|
176 | * we sending the files or while we generate the xml files to be viewed.
|
---|
177 | * If finish = false then wait cursor,progress bar and wait label will be displayed.
|
---|
178 | * If finish = true then default cursor will be displayed.
|
---|
179 | */
|
---|
180 | private Timer timer;
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * Progress bar displayed when user sending or want to view details.
|
---|
184 | */
|
---|
185 | private JProgressBar progressBar;
|
---|
186 |
|
---|
187 | /**
|
---|
188 | * Label displayed to tell user to wait for a while.
|
---|
189 | */
|
---|
190 | private JLabel wait_lbl;
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * This is the background colour for the window.
|
---|
194 | */
|
---|
195 | private Color bckcolor;
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * This is the panel to displayed all descriptions panel.
|
---|
199 | */
|
---|
200 | private JPanel tempPane;
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * This is the thread that will be running when user pressed the preview button.
|
---|
204 | * This thread will show the 6 xml files that are going to be send. It will run concurrently
|
---|
205 | * with the timer, if value of finish = true, this thread will be null-ed.
|
---|
206 | */
|
---|
207 | private Thread prevThread;
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * This is the flag to say whether or not this window should be dispose when timer is stop
|
---|
211 | * and finish = true.
|
---|
212 | * If selected = true then this window should be dispose, otherwise don't dispose it.
|
---|
213 | */
|
---|
214 | private boolean selected = false;
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * This is a blocker to say that user cannot do anything while waiting.
|
---|
218 | */
|
---|
219 | private MouseListener mouse_blocker_listener = new MouseAdapter() {};
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Will make a dialog window that allows people to write more about the problem that want
|
---|
223 | * to send.
|
---|
224 | * This is the GUI for user to write on Feedback form. It is also setting the up the appropriate
|
---|
225 | * data member with the value passed on to this constructor.
|
---|
226 | * (Precondition: (sh != null) && (dlg != null) && (msg != null))
|
---|
227 | * @param sh an instance of ScreenShot that will allow application to take screenshot.
|
---|
228 | * @param frame_name name of the window where user called Feedback form from.
|
---|
229 | * @param msg holding the resource of the words that is stored in Messages.properties file.
|
---|
230 | * @param dlg holding the special listener.
|
---|
231 | */
|
---|
232 | public FeedbackInterface(ScreenShot sh,String frame_name,
|
---|
233 | ResourceBundle msg,ActionRecorderDialog dlg)
|
---|
234 | {
|
---|
235 | super();
|
---|
236 |
|
---|
237 | frame = this;
|
---|
238 |
|
---|
239 | bckcolor = new Color(176,209,217);
|
---|
240 |
|
---|
241 | picAndPane = new HashMap();
|
---|
242 |
|
---|
243 | messages = msg;
|
---|
244 | frameName = frame_name;
|
---|
245 | dialog = dlg;
|
---|
246 |
|
---|
247 | FeedbackInterface.setDefaultLookAndFeelDecorated(true);
|
---|
248 | setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
---|
249 | setTitle(messages.getString("SendFeedbackForm"));
|
---|
250 |
|
---|
251 | screen = sh;
|
---|
252 | Container container;
|
---|
253 | container = getContentPane();
|
---|
254 | createUI(container);
|
---|
255 | curr_date = new Date();
|
---|
256 |
|
---|
257 | Toolkit kit;
|
---|
258 | kit = Toolkit.getDefaultToolkit();
|
---|
259 | Dimension screenSize;
|
---|
260 | screenSize = kit.getScreenSize();
|
---|
261 | int screenHeight;
|
---|
262 | screenHeight = screenSize.height;
|
---|
263 | int screenWidth;
|
---|
264 | screenWidth = screenSize.width;
|
---|
265 | Dimension size;
|
---|
266 | size = this.getSize();
|
---|
267 | setLocation((screenWidth - size.width - 500) ,
|
---|
268 | (screenHeight - size.height - 700));
|
---|
269 |
|
---|
270 | setBackground(bckcolor);
|
---|
271 | pack();
|
---|
272 | setModal(false);
|
---|
273 | setVisible(true);
|
---|
274 | }
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * This method is setting up the content pane for the Feedback form window.
|
---|
278 | * (Precondition: (window != null))
|
---|
279 | * @param window the content pane of Feedback form window.
|
---|
280 | */
|
---|
281 | public void createUI(Container window)
|
---|
282 | {
|
---|
283 | JPanel container;
|
---|
284 | container = new JPanel();
|
---|
285 | container.setBackground(bckcolor);
|
---|
286 | container.setLayout(new BoxLayout(container,BoxLayout.PAGE_AXIS));
|
---|
287 |
|
---|
288 | String opening_text;
|
---|
289 | opening_text = messages.getString("FeedbackOpeningText");
|
---|
290 | JTextArea textArea;
|
---|
291 | textArea = new JTextArea(opening_text);
|
---|
292 | textArea.setMinimumSize(new Dimension(100,100));
|
---|
293 | textArea.setOpaque(false);
|
---|
294 | textArea.setEditable(false);
|
---|
295 | textArea.setLineWrap(true);
|
---|
296 | textArea.setWrapStyleWord(true);
|
---|
297 | textArea.setBorder(new EmptyBorder(10,10,0,10));
|
---|
298 | textArea.setBackground(bckcolor);
|
---|
299 | container.add(textArea);
|
---|
300 |
|
---|
301 | tempPane = new JPanel();
|
---|
302 | tempPane.setLayout(new BorderLayout());
|
---|
303 | tempPane.setBackground(new Color(176,208,176));
|
---|
304 |
|
---|
305 | paneArray = new ArrayList();
|
---|
306 | picture_scroll = new JPanel();
|
---|
307 | row = 1;
|
---|
308 | picture_scroll.setLayout(new GridLayout(0,1));
|
---|
309 | picture_scroll.setBackground(new Color(176,208,176));
|
---|
310 | tempPane.add(picture_scroll,BorderLayout.PAGE_START);
|
---|
311 |
|
---|
312 | JPanel btnPanel;
|
---|
313 | btnPanel = new JPanel();
|
---|
314 | btnPanel.setBackground(new Color(176,208,176));
|
---|
315 | remove = new JButton("Remove");
|
---|
316 | remove.setActionCommand("Remove");
|
---|
317 | remove.addActionListener(new ActionListener ()
|
---|
318 | {
|
---|
319 | public void actionPerformed(ActionEvent e)
|
---|
320 | {
|
---|
321 | Object obj;
|
---|
322 | JPanel pane;
|
---|
323 |
|
---|
324 | if (paneArray.size() == 0)
|
---|
325 | System.out.println("There is no panel here!");
|
---|
326 | else
|
---|
327 | {
|
---|
328 | pane = (JPanel) paneArray.get((row - 2));
|
---|
329 | obj = picAndPane.get(pane);
|
---|
330 | obj = null;
|
---|
331 | picAndPane.remove(pane);
|
---|
332 | paneArray.remove((row - 2));
|
---|
333 |
|
---|
334 | if (paneArray.size() == 0)
|
---|
335 | remove.setVisible(false);
|
---|
336 |
|
---|
337 | picture_scroll.remove(pane);
|
---|
338 |
|
---|
339 | row--;
|
---|
340 |
|
---|
341 | picture_scroll.setSize(picture_scroll.getPreferredSize());
|
---|
342 | picture_scroll.revalidate();
|
---|
343 | picture_scroll.repaint();
|
---|
344 | tempPane.setSize(tempPane.getPreferredSize());
|
---|
345 | tempPane.revalidate();
|
---|
346 | tempPane.repaint();
|
---|
347 | }
|
---|
348 | }
|
---|
349 | });
|
---|
350 | remove.setToolTipText("Remove last thumbnail");
|
---|
351 | remove.setBackground(new Color(176,208,176));
|
---|
352 | remove.setVisible(false);
|
---|
353 | btnPanel.add(remove);
|
---|
354 | tempPane.add(btnPanel,BorderLayout.PAGE_END);
|
---|
355 |
|
---|
356 | JScrollPane pict_scroll;
|
---|
357 | pict_scroll = new JScrollPane(tempPane);
|
---|
358 | pict_scroll.setBackground(bckcolor);
|
---|
359 | pict_scroll.setPreferredSize(new Dimension(300,300));
|
---|
360 | pict_scroll.setBorder(new EmptyBorder(0,10,10,10));
|
---|
361 | container.add(pict_scroll);
|
---|
362 |
|
---|
363 | JPanel pane;
|
---|
364 | pane = new JPanel();
|
---|
365 | pane.setBackground(bckcolor);
|
---|
366 | pane.setLayout(new GridLayout(0,2));
|
---|
367 | pane.setBorder(new EmptyBorder(10,10,10,10));
|
---|
368 |
|
---|
369 | JLabel txt_type;
|
---|
370 | txt_type = new JLabel(messages.getString("Whatkindofproblemisit") + "? ");
|
---|
371 | txt_type.setBackground(bckcolor);
|
---|
372 | pane.add(txt_type);
|
---|
373 |
|
---|
374 | String [] type = {" ",messages.getString("ContentError"),
|
---|
375 | messages.getString("ImageNotShow"),
|
---|
376 | messages.getString("StrangeBehaviour"),
|
---|
377 | messages.getString("SomethingUnexpectedHappen"),
|
---|
378 | messages.getString("HardToUse"),
|
---|
379 | messages.getString("Other")};
|
---|
380 | problem_type = new JComboBox(type);
|
---|
381 | problem_type.setOpaque(false);
|
---|
382 | problem_type.addActionListener(this);
|
---|
383 | problem_type.setBackground(bckcolor);
|
---|
384 | pane.add(problem_type);
|
---|
385 |
|
---|
386 | JLabel txt_urgent;
|
---|
387 | txt_urgent = new JLabel(messages.getString("Howbadistheproblem")+"? ");
|
---|
388 | txt_urgent.setBackground(bckcolor);
|
---|
389 | pane.add(txt_urgent);
|
---|
390 |
|
---|
391 | String[] urgent = {" ",messages.getString("Critical"),
|
---|
392 | messages.getString("Serious"),
|
---|
393 | messages.getString("Medium"),messages.getString("Minor"),
|
---|
394 | messages.getString("Trivial")};
|
---|
395 | problem_urgency = new JComboBox(urgent);
|
---|
396 | problem_urgency.setOpaque(false);
|
---|
397 | problem_urgency.addActionListener(this);
|
---|
398 | problem_urgency.setBackground(bckcolor);
|
---|
399 | pane.add(problem_urgency);
|
---|
400 |
|
---|
401 | /*JLabel txt_screenshot;
|
---|
402 | txt_screenshot= new JLabel(messages.getString("Doyouwanttosendthescreenshot") + "? ");
|
---|
403 | txt_screenshot.setBackground(new Color(108,168,108));
|
---|
404 | pane.add(txt_screenshot);
|
---|
405 |
|
---|
406 | String[] screenshot = {messages.getString("Yes"),
|
---|
407 | messages.getString("No")};
|
---|
408 | problem_screenshot = new JComboBox(screenshot);
|
---|
409 | problem_screenshot.addActionListener(this);
|
---|
410 | problem_screenshot.setBackground(new Color(108,168,108));
|
---|
411 | pane.add(problem_screenshot);*/
|
---|
412 |
|
---|
413 |
|
---|
414 | /*JLabel txt_smtp;
|
---|
415 | txt_smtp = new JLabel(messages.getString("SMTPaddress") + "? ");
|
---|
416 | txt_smtp.setBackground(new Color(176,208,176));
|
---|
417 | pane.add(txt_smtp);
|
---|
418 |
|
---|
419 | smtp_address = new JTextField();
|
---|
420 | smtp_address.setBackground(new Color(224,240,224));
|
---|
421 | pane.add(smtp_address);*/
|
---|
422 |
|
---|
423 |
|
---|
424 | /*JLabel txt_email;
|
---|
425 | txt_email = new JLabel(messages.getString("Emailaddress") + "? ");
|
---|
426 | txt_email.setBackground(new Color(176,208,176));
|
---|
427 | pane.add(txt_email);
|
---|
428 |
|
---|
429 | email_address = new JTextField();
|
---|
430 | email_address.setBackground(new Color(224,240,224));
|
---|
431 | pane.add(email_address);*/
|
---|
432 |
|
---|
433 | JLabel empty;
|
---|
434 | empty = new JLabel (" ");
|
---|
435 | empty.setBackground(bckcolor);
|
---|
436 | pane.add(empty);
|
---|
437 | JLabel empty2;
|
---|
438 | empty2 = new JLabel (" ");
|
---|
439 | empty2.setBackground(bckcolor);
|
---|
440 | pane.add(empty2);
|
---|
441 | container.add(pane);
|
---|
442 |
|
---|
443 | JPanel panely;
|
---|
444 | panely = new JPanel();
|
---|
445 | panely.setLayout(new GridLayout(0,3));
|
---|
446 | panely.setBackground(bckcolor);
|
---|
447 | panely.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
|
---|
448 |
|
---|
449 | view_button = new JButton("Details . . .");
|
---|
450 | view_button.setActionCommand(messages.getString("Preview"));
|
---|
451 | view_button.addActionListener(this);
|
---|
452 | view_button.setToolTipText(messages.getString("ConformationPreview"));
|
---|
453 | view_button.setBackground(bckcolor);
|
---|
454 | panely.add(view_button);
|
---|
455 |
|
---|
456 | send_button = new JButton(messages.getString("Send"));
|
---|
457 | send_button.setActionCommand(messages.getString("Send"));
|
---|
458 | send_button.addActionListener(this);
|
---|
459 | send_button.setDefaultCapable(true);
|
---|
460 | send_button.setToolTipText(messages.getString("FeedbackSendButton"));
|
---|
461 | send_button.setBackground(bckcolor);
|
---|
462 | panely.add(send_button);
|
---|
463 |
|
---|
464 | notsend_button = new JButton("Cancel");
|
---|
465 | notsend_button.setActionCommand(messages.getString("NotSend"));
|
---|
466 | notsend_button.addActionListener(this);
|
---|
467 | notsend_button.setToolTipText(messages.getString("FeedbackNotSendButton"));
|
---|
468 | notsend_button.setBackground(bckcolor);
|
---|
469 | panely.add(notsend_button);
|
---|
470 | container.add(panely);
|
---|
471 |
|
---|
472 | //Align the left edges of the components.
|
---|
473 | textArea.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
474 | pict_scroll.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
475 | pane.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
476 | panely.setAlignmentX(Component.LEFT_ALIGNMENT);
|
---|
477 |
|
---|
478 | String about;
|
---|
479 | about = messages.getString("FeedbackAboutText");
|
---|
480 | JTextArea about_txt;
|
---|
481 | about_txt = new JTextArea(about);
|
---|
482 | about_txt.setEditable(false);
|
---|
483 | about_txt.setLineWrap(true);
|
---|
484 | about_txt.setWrapStyleWord(true);
|
---|
485 | about_txt.setBackground(bckcolor);
|
---|
486 | about_txt.setBorder(new EmptyBorder(10,10,10,10));
|
---|
487 |
|
---|
488 | String privacy;
|
---|
489 | privacy = messages.getString("FeedbackPrivacyText");
|
---|
490 | JTextArea privacy_txt;
|
---|
491 | privacy_txt = new JTextArea(privacy);
|
---|
492 | privacy_txt.setEditable(false);
|
---|
493 | privacy_txt.setLineWrap(true);
|
---|
494 | privacy_txt.setWrapStyleWord(true);
|
---|
495 | privacy_txt.setBackground(bckcolor);
|
---|
496 | privacy_txt.setBorder(new EmptyBorder(10,10,10,10));
|
---|
497 |
|
---|
498 | JTabbedPane tab;
|
---|
499 | tab = new JTabbedPane();
|
---|
500 | tab.setBackground(bckcolor);
|
---|
501 | tab.addTab(messages.getString("Form"),container);
|
---|
502 | tab.addTab(messages.getString("About"),about_txt);
|
---|
503 | tab.addTab(messages.getString("Privacy"),privacy_txt);
|
---|
504 | tab.setBorder(new EmptyBorder(5,5,5,5));
|
---|
505 |
|
---|
506 | JPanel panelx;
|
---|
507 | panelx = new JPanel();
|
---|
508 | panelx.setLayout(new BoxLayout(panelx,BoxLayout.PAGE_AXIS));
|
---|
509 | panelx.setBackground(bckcolor);
|
---|
510 | panelx.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
|
---|
511 |
|
---|
512 | wait_lbl = new JLabel(messages.getString("Pleasewait"));
|
---|
513 | wait_lbl.setBackground(bckcolor);
|
---|
514 | wait_lbl.setVisible(false);
|
---|
515 | panelx.add(wait_lbl);
|
---|
516 |
|
---|
517 | progressBar = new JProgressBar ();
|
---|
518 | progressBar.setBackground(bckcolor);
|
---|
519 | progressBar.setVisible(false);
|
---|
520 | panelx.add(progressBar);
|
---|
521 |
|
---|
522 | JLabel emp2;
|
---|
523 | emp2 = new JLabel (" ");
|
---|
524 | emp2.setBackground(bckcolor);
|
---|
525 | panelx.add(emp2);
|
---|
526 |
|
---|
527 | wait_lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
|
---|
528 | progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
|
---|
529 | emp2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
---|
530 |
|
---|
531 | final String p1;
|
---|
532 | final String p2;
|
---|
533 | p1 = "Tab";
|
---|
534 | p2 = "ProgressBar";
|
---|
535 |
|
---|
536 | final JPanel cards;
|
---|
537 | cards = new JPanel(new CardLayout());
|
---|
538 | cards.setBackground(bckcolor);
|
---|
539 | cards.add(tab,p1);
|
---|
540 | cards.add(panelx,p2);
|
---|
541 |
|
---|
542 | window.add(cards);
|
---|
543 |
|
---|
544 |
|
---|
545 | timer = new Timer(1000, new ActionListener()
|
---|
546 | {
|
---|
547 | public void actionPerformed(ActionEvent evt)
|
---|
548 | {
|
---|
549 | if (finish == true)
|
---|
550 | {
|
---|
551 | if (sendThread != null)
|
---|
552 | {
|
---|
553 | sendThread.interrupt();
|
---|
554 | sendThread = null;
|
---|
555 | }
|
---|
556 |
|
---|
557 | if (prevThread != null)
|
---|
558 | {
|
---|
559 | prevThread.interrupt();
|
---|
560 | prevThread = null;
|
---|
561 | }
|
---|
562 |
|
---|
563 | Component glass_pane;
|
---|
564 | glass_pane = frame.getGlassPane();
|
---|
565 |
|
---|
566 | glass_pane.setVisible(false);
|
---|
567 | glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
---|
568 | glass_pane.removeMouseListener(mouse_blocker_listener);
|
---|
569 |
|
---|
570 | wait_lbl.setVisible(false);
|
---|
571 | progressBar.setIndeterminate(false);
|
---|
572 | progressBar.setVisible(false);
|
---|
573 |
|
---|
574 | frame.setTitle(messages.getString("SendFeedbackForm"));
|
---|
575 |
|
---|
576 | CardLayout cl = (CardLayout)(cards.getLayout());
|
---|
577 | cl.show(cards,p1);
|
---|
578 |
|
---|
579 | if (selected == true)
|
---|
580 | frame.dispose();
|
---|
581 |
|
---|
582 | timer.stop();
|
---|
583 | }
|
---|
584 | else
|
---|
585 | {
|
---|
586 | Component glass_pane;
|
---|
587 | glass_pane = frame.getGlassPane();
|
---|
588 |
|
---|
589 | glass_pane.addMouseListener(mouse_blocker_listener);
|
---|
590 | glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
591 | glass_pane.setVisible(true);
|
---|
592 |
|
---|
593 | frame.setTitle("Please wait...");
|
---|
594 |
|
---|
595 | CardLayout cl = (CardLayout)(cards.getLayout());
|
---|
596 | cl.show(cards,p2);
|
---|
597 |
|
---|
598 | wait_lbl.setVisible(true);
|
---|
599 | progressBar.setIndeterminate(true);
|
---|
600 | progressBar.setVisible(true);
|
---|
601 | }
|
---|
602 | }
|
---|
603 | });
|
---|
604 | }
|
---|
605 |
|
---|
606 | /**
|
---|
607 | * This method will set the finish variable values.
|
---|
608 | * When the sending files is finished, the sending application will set the finish value to true.
|
---|
609 | * @param fin whether or not the send files is finished.
|
---|
610 | */
|
---|
611 | public static void setFinish (boolean fin)
|
---|
612 | {
|
---|
613 | finish = fin;
|
---|
614 | }
|
---|
615 |
|
---|
616 | /**
|
---|
617 | * This is the class to represent the whole panel that hold the screenshot and the comments
|
---|
618 | * about the screenshot.
|
---|
619 | */
|
---|
620 | private class ThumbnailPic implements Serializable
|
---|
621 | {
|
---|
622 | /**
|
---|
623 | * This is the panel that hold a thumbnail for a screenshot and a comments text area.
|
---|
624 | */
|
---|
625 | private JPanel picpane;
|
---|
626 |
|
---|
627 | /**
|
---|
628 | * This hold the BufferedImages for the whole screen version of screenshot.
|
---|
629 | */
|
---|
630 | private BufferedImage[] screenimages;
|
---|
631 |
|
---|
632 | /**
|
---|
633 | * This hold the BufferedImages for the window version only.
|
---|
634 | */
|
---|
635 | private BufferedImage[] windowimages;
|
---|
636 |
|
---|
637 | /**
|
---|
638 | * This is the text area where user can enter their comments.
|
---|
639 | */
|
---|
640 | private JTextArea problem_details;
|
---|
641 |
|
---|
642 | /**
|
---|
643 | * This is a flag to tell us which image user wants to send.Its defaults value is false.
|
---|
644 | * If iswindow = true then it means user wants to send the window version only.
|
---|
645 | * If iswindow = false then it means user wants to send the whole screen version.
|
---|
646 | */
|
---|
647 | private boolean iswindow;
|
---|
648 |
|
---|
649 | /**
|
---|
650 | * This is the titles for the panel.
|
---|
651 | * Usually this is the title of the window where user wants to do the screenshot.
|
---|
652 | * If the title is more than 40 characters then we will trim it and add ... at the back of it.
|
---|
653 | */
|
---|
654 | private String titles;
|
---|
655 |
|
---|
656 | /**
|
---|
657 | * This is the width of the image user wants to send.
|
---|
658 | */
|
---|
659 | private String iw;
|
---|
660 |
|
---|
661 | /**
|
---|
662 | * This is the height of the image user wants to send.
|
---|
663 | */
|
---|
664 | private String ih;
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * This is the x-coordinate where the window located inside the whole screen image.
|
---|
668 | */
|
---|
669 | private int xcoord;
|
---|
670 |
|
---|
671 | /**
|
---|
672 | * This is the y-coordinate where the window located inside the whole screen image.
|
---|
673 | */
|
---|
674 | private int ycoord;
|
---|
675 |
|
---|
676 | /**
|
---|
677 | * This is the width of the window inside the whole screen image.
|
---|
678 | */
|
---|
679 | private int width;
|
---|
680 |
|
---|
681 | /**
|
---|
682 | * This is the height of the window inside the whole screen image.
|
---|
683 | */
|
---|
684 | private int height;
|
---|
685 |
|
---|
686 | /**
|
---|
687 | * This is the constructor that will setup the panel that contains
|
---|
688 | * a thumbnail screenshot and a comments text area.
|
---|
689 | * @param image the whole screen screenshot image.
|
---|
690 | * @param text the title for this pane.
|
---|
691 | * @param x the x-coordinate of the window inside the whole screen image.
|
---|
692 | * @param y the y-coordinate of the window inside the whole screen image.
|
---|
693 | * @param w the width of the window inside the whole screen image.
|
---|
694 | * @param h the height of the window inside the whole screen image.
|
---|
695 | */
|
---|
696 | //public ThumbnailPic (BufferedImage screen,byte[] image,String text)
|
---|
697 | public ThumbnailPic (BufferedImage image,String text,int x,int y,int w,int h)
|
---|
698 | {
|
---|
699 | xcoord = x;
|
---|
700 | ycoord = y;
|
---|
701 | width = w;
|
---|
702 | height = h;
|
---|
703 | iswindow = false;
|
---|
704 | titles = text;
|
---|
705 | screenimages = new BufferedImage[3];
|
---|
706 | windowimages = new BufferedImage[3];
|
---|
707 | //screenimages[0] = screen;
|
---|
708 | screenimages[0] = image;
|
---|
709 | screenimages[1] = null;
|
---|
710 | screenimages[2] = null;
|
---|
711 | windowimages[0] = null;
|
---|
712 | windowimages[1] = null;
|
---|
713 | windowimages[2] = null;
|
---|
714 | addPanel(image);
|
---|
715 | }
|
---|
716 |
|
---|
717 | /**
|
---|
718 | * This method will setup the components inside the panel properly.
|
---|
719 | * @param image the whole screen screenshot image.
|
---|
720 | */
|
---|
721 | //public void addPanel (byte[] image)
|
---|
722 | public void addPanel (BufferedImage image)
|
---|
723 | {
|
---|
724 | picpane = new JPanel();
|
---|
725 | picpane.setLayout(new BorderLayout());
|
---|
726 |
|
---|
727 | final JButton picture;
|
---|
728 | picture = new JButton();
|
---|
729 |
|
---|
730 | int w;
|
---|
731 | int h;
|
---|
732 |
|
---|
733 | w = (int) (150/2);
|
---|
734 | h = (int) (150/2);
|
---|
735 |
|
---|
736 | iw = "" + image.getWidth();
|
---|
737 | ih = "" + image.getHeight();
|
---|
738 |
|
---|
739 | ImageIcon thumbnail;
|
---|
740 | thumbnail = new ImageIcon(image.getScaledInstance(w,h,Image.SCALE_SMOOTH));
|
---|
741 |
|
---|
742 | picture.setIcon(thumbnail);
|
---|
743 | picture.setText("Draw . . .");
|
---|
744 | picture.setActionCommand("Scribble");
|
---|
745 | picture.addActionListener(new ActionListener()
|
---|
746 | {
|
---|
747 | public void actionPerformed (ActionEvent e)
|
---|
748 | {
|
---|
749 | frame.addMouseListener(mouse_blocker_listener);
|
---|
750 | frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
---|
751 | SelectPicture select;
|
---|
752 | select = new SelectPicture(screenimages,windowimages,iswindow,problem_details.getText(),messages);
|
---|
753 | frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
---|
754 | frame.removeMouseListener(mouse_blocker_listener);
|
---|
755 | select.setWindowBounds(xcoord,ycoord,width,height);
|
---|
756 |
|
---|
757 | iswindow = select.getIsWindow();
|
---|
758 |
|
---|
759 | screenimages[0] = select.getImage3();
|
---|
760 | screenimages[1] = select.getImage();
|
---|
761 | screenimages[2] = select.getImage2();
|
---|
762 |
|
---|
763 | if (iswindow == true)
|
---|
764 | {
|
---|
765 | windowimages[0] = select.getWindowImage3();
|
---|
766 | windowimages[1] = select.getWindowImage();
|
---|
767 | windowimages[2] = select.getWindowImage2();
|
---|
768 | }
|
---|
769 | else
|
---|
770 | {
|
---|
771 | windowimages[0] = null;
|
---|
772 | windowimages[1] = null;
|
---|
773 | windowimages[2] = null;
|
---|
774 | }
|
---|
775 |
|
---|
776 | problem_details.setText(select.getDetails());
|
---|
777 |
|
---|
778 | int w,h;
|
---|
779 | w = (int) (150/2);
|
---|
780 | h = (int) (150/2);
|
---|
781 |
|
---|
782 | ImageIcon thumbnail;
|
---|
783 |
|
---|
784 | if (iswindow == false)
|
---|
785 | thumbnail = new ImageIcon(screenimages[1].getScaledInstance(w,h,Image.SCALE_SMOOTH));
|
---|
786 | else
|
---|
787 | thumbnail = new ImageIcon(windowimages[1].getScaledInstance(w,h,Image.SCALE_SMOOTH));
|
---|
788 |
|
---|
789 | picture.setIcon(thumbnail);
|
---|
790 |
|
---|
791 | if (select.getSendNow() == true)
|
---|
792 | {
|
---|
793 | ActionEvent evt;
|
---|
794 | evt = new ActionEvent(send_button,ActionEvent.ACTION_PERFORMED,messages.getString("Send"));
|
---|
795 |
|
---|
796 | frame.actionPerformed(evt);
|
---|
797 | }
|
---|
798 | }
|
---|
799 | });
|
---|
800 | picture.setToolTipText("Click if you want to draw on it");
|
---|
801 | picture.setMargin(new Insets(5,5,5,5));
|
---|
802 | picture.setVerticalTextPosition(AbstractButton.BOTTOM);
|
---|
803 | picture.setHorizontalTextPosition(AbstractButton.CENTER);
|
---|
804 | picture.setBackground(new Color(176,208,176));
|
---|
805 | picpane.add(picture,BorderLayout.LINE_START);
|
---|
806 |
|
---|
807 | JPanel txtPane;
|
---|
808 | txtPane = new JPanel(new BorderLayout());
|
---|
809 | txtPane.setBackground(new Color(176,208,176));
|
---|
810 | txtPane.setBorder(new EmptyBorder(5,5,5,5));
|
---|
811 |
|
---|
812 | JLabel lbldesc = new JLabel("Comments :");
|
---|
813 | lbldesc.setBackground(new Color(176,208,176));
|
---|
814 | txtPane.add(lbldesc,BorderLayout.PAGE_START);
|
---|
815 |
|
---|
816 | problem_details = new JTextArea();
|
---|
817 | problem_details.setWrapStyleWord(true);
|
---|
818 | problem_details.setEditable(true);
|
---|
819 | problem_details.setBackground(new Color(224,240,224));
|
---|
820 |
|
---|
821 | JScrollPane scroll;
|
---|
822 | scroll = new JScrollPane(problem_details);
|
---|
823 | scroll.setBackground(new Color(176,208,176));
|
---|
824 | scroll.setPreferredSize(new Dimension(300,150));
|
---|
825 | txtPane.add(scroll,BorderLayout.LINE_START);
|
---|
826 |
|
---|
827 | picpane.setSize(new Dimension(150,150));
|
---|
828 | picpane.add(txtPane,BorderLayout.CENTER);
|
---|
829 | }
|
---|
830 |
|
---|
831 | /**
|
---|
832 | * This method will get the width of the image user wants to send.
|
---|
833 | * @return the width of the image.
|
---|
834 | */
|
---|
835 | public String getWidth()
|
---|
836 | {
|
---|
837 | if (iswindow == false)
|
---|
838 | return "" + screenimages[0].getWidth();
|
---|
839 | else
|
---|
840 | {
|
---|
841 | return "" + windowimages[0].getWidth();
|
---|
842 | }
|
---|
843 | }
|
---|
844 |
|
---|
845 | /**
|
---|
846 | * This method will get the height of the image user wants to send.
|
---|
847 | * @return the height of the image.
|
---|
848 | */
|
---|
849 | public String getHeight()
|
---|
850 | {
|
---|
851 | if (iswindow == false)
|
---|
852 | return "" + screenimages[0].getHeight();
|
---|
853 | else
|
---|
854 | {
|
---|
855 | return "" + windowimages[0].getHeight();
|
---|
856 | }
|
---|
857 | }
|
---|
858 |
|
---|
859 | /**
|
---|
860 | * This method will get the titles of this panel.
|
---|
861 | * @return the panel's title.
|
---|
862 | */
|
---|
863 | public String getTitles()
|
---|
864 | {
|
---|
865 | return titles;
|
---|
866 | }
|
---|
867 |
|
---|
868 | /**
|
---|
869 | * This method will get user comments inside the text area.
|
---|
870 | * @return the user's comments.
|
---|
871 | */
|
---|
872 | public String getProblemDetails ()
|
---|
873 | {
|
---|
874 | String txt;
|
---|
875 | txt = problem_details.getText();
|
---|
876 |
|
---|
877 | if (txt == null)
|
---|
878 | return " ";
|
---|
879 | else
|
---|
880 | return txt;
|
---|
881 | }
|
---|
882 |
|
---|
883 | /**
|
---|
884 | * This method will setting up the text inside the text area.
|
---|
885 | * @param comments the text set to the text area.
|
---|
886 | */
|
---|
887 | public void setComments (String comments)
|
---|
888 | {
|
---|
889 | problem_details.setText(comments);
|
---|
890 | }
|
---|
891 |
|
---|
892 | /**
|
---|
893 | * This method will get the image that user wants to send.
|
---|
894 | * @return image going to be send.
|
---|
895 | */
|
---|
896 | public BufferedImage[] getImages ()
|
---|
897 | {
|
---|
898 | if (iswindow == false)
|
---|
899 | return screenimages;
|
---|
900 | else
|
---|
901 | return windowimages;
|
---|
902 | }
|
---|
903 |
|
---|
904 | /**
|
---|
905 | * This method will get the non-scribble lines image that user wants to send.
|
---|
906 | * @return the string representation of the non-scribble lines image.
|
---|
907 | */
|
---|
908 | public String getScreenImage ()
|
---|
909 | {
|
---|
910 | if (iswindow == false)
|
---|
911 | return convert(screenimages[0]);
|
---|
912 | else
|
---|
913 | return convert(windowimages[1]);
|
---|
914 | }
|
---|
915 |
|
---|
916 | /**
|
---|
917 | * This method will get the scribble lines image that user wants to send.
|
---|
918 | * @return the string representation of the scribble lines image.
|
---|
919 | */
|
---|
920 | public String getScreenAndLineImage ()
|
---|
921 | {
|
---|
922 | if (iswindow == false)
|
---|
923 | {
|
---|
924 | if (screenimages[1]!= null)
|
---|
925 | return convert(screenimages[1]);
|
---|
926 | else
|
---|
927 | return convert(screenimages[0]);
|
---|
928 | }
|
---|
929 | else
|
---|
930 | {
|
---|
931 | if (windowimages[1]!= null)
|
---|
932 | return convert(windowimages[1]);
|
---|
933 | else
|
---|
934 | return convert(windowimages[0]);
|
---|
935 | }
|
---|
936 | }
|
---|
937 |
|
---|
938 | /**
|
---|
939 | * This method will get only scribble lines image that user wants to send.
|
---|
940 | * @return the string representation of the only scribble lines image.
|
---|
941 | */
|
---|
942 | public String getLineForScreenImage ()
|
---|
943 | {
|
---|
944 | if (iswindow == false)
|
---|
945 | {
|
---|
946 | if (screenimages[2] != null)
|
---|
947 | return convert(screenimages[2]);
|
---|
948 | else
|
---|
949 | return "";
|
---|
950 | }
|
---|
951 | else
|
---|
952 | {
|
---|
953 | if (windowimages[2] != null)
|
---|
954 | return convert(windowimages[2]);
|
---|
955 | else
|
---|
956 | return "";
|
---|
957 | }
|
---|
958 | }
|
---|
959 |
|
---|
960 | /**
|
---|
961 | * This method will get the panel that hold a thumbnail and a text area.
|
---|
962 | * @return panel that represent the thumbnail and the text area.
|
---|
963 | */
|
---|
964 | public JPanel getPanel()
|
---|
965 | {
|
---|
966 | return picpane;
|
---|
967 | }
|
---|
968 | }
|
---|
969 |
|
---|
970 | /**
|
---|
971 | * This method will setting up the comments to be displayed inside the latest added panel.
|
---|
972 | * So if the window where user wants to take the screenshot at the moment is a modal window
|
---|
973 | * then it will setting the comments to ask user to close the window before they can enter
|
---|
974 | * their comments there.
|
---|
975 | * @param modal the modality of the window where user wants to take the screenshot.
|
---|
976 | */
|
---|
977 | public void setComment (boolean modal)
|
---|
978 | {
|
---|
979 | if (paneArray.size() == 0)
|
---|
980 | System.out.println("There is no panel here!");
|
---|
981 | else
|
---|
982 | {
|
---|
983 | JPanel pane;
|
---|
984 | pane = (JPanel) paneArray.get((row - 2));
|
---|
985 | ThumbnailPic obj;
|
---|
986 | obj = (ThumbnailPic) picAndPane.get(pane);
|
---|
987 | String text;
|
---|
988 | if (modal == true)
|
---|
989 | text = "Please close '" + obj.getTitles() + "' window \nbefore you can enter comments here.";
|
---|
990 | else
|
---|
991 | text = " ";
|
---|
992 | obj.setComments(text);
|
---|
993 | }
|
---|
994 | }
|
---|
995 |
|
---|
996 | /**
|
---|
997 | * This method will add a panel that contains the thumbnail button and the text area.
|
---|
998 | * @param title the window's title.
|
---|
999 | * @param image the whole screen image.
|
---|
1000 | * @param x the window's x-coordinate in the image.
|
---|
1001 | * @param y the window's y-coordinate in the image.
|
---|
1002 | * @param width the window's width in the image.
|
---|
1003 | * @param height the window's height in the image.
|
---|
1004 | */
|
---|
1005 | //public void addScreenPanel (String title,BufferedImage screen,byte[] image)
|
---|
1006 | public void addScreenPanel (String title,BufferedImage image,int x,int y,int width,int height)
|
---|
1007 | {
|
---|
1008 | final JPanel pane;
|
---|
1009 | pane = new JPanel();
|
---|
1010 | pane.setLayout(new BorderLayout());
|
---|
1011 | pane.setBackground(new Color(176,208,176));
|
---|
1012 |
|
---|
1013 | Border loweredetched;
|
---|
1014 | loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
---|
1015 |
|
---|
1016 | String ttl;
|
---|
1017 | if (title.length() > 41)
|
---|
1018 | ttl = title.substring(0,40) + " . . . ";
|
---|
1019 | else
|
---|
1020 | ttl = title;
|
---|
1021 |
|
---|
1022 | TitledBorder border;
|
---|
1023 | border = BorderFactory.createTitledBorder(loweredetched, title);
|
---|
1024 | border.setTitleJustification(TitledBorder.LEFT);
|
---|
1025 |
|
---|
1026 | pane.setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(5,5,5,5),border));
|
---|
1027 |
|
---|
1028 | ThumbnailPic pic;
|
---|
1029 | //pic = new ThumbnailPic(screen,image,title);
|
---|
1030 | pic = new ThumbnailPic(image,title,x,y,width,height);
|
---|
1031 | picAndPane.put(pane,pic);
|
---|
1032 | pane.add(pic.getPanel(),BorderLayout.LINE_START);
|
---|
1033 |
|
---|
1034 | remove.setVisible(true);
|
---|
1035 | picture_scroll.add(pane);
|
---|
1036 | paneArray.add(pane);
|
---|
1037 | row++;
|
---|
1038 | picture_scroll.setSize(picture_scroll.getPreferredSize());
|
---|
1039 | picture_scroll.revalidate();
|
---|
1040 | picture_scroll.repaint();
|
---|
1041 | tempPane.setSize(tempPane.getPreferredSize());
|
---|
1042 | tempPane.revalidate();
|
---|
1043 | tempPane.repaint();
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | /**
|
---|
1047 | * This method will generate the unique code that will be used as the
|
---|
1048 | * reference number of the feedback that user are about to send.
|
---|
1049 | * @return the unique code.
|
---|
1050 | */
|
---|
1051 | public String getPrevData ()
|
---|
1052 | {
|
---|
1053 | try
|
---|
1054 | {
|
---|
1055 | UID id = new UID();
|
---|
1056 | code = "" + InetAddress.getLocalHost().hashCode() + id.hashCode();
|
---|
1057 | }
|
---|
1058 | catch (UnknownHostException exp) {}
|
---|
1059 | return code;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | /**
|
---|
1063 | * This method allows another class to get the unique code that can be used as
|
---|
1064 | * the reference number of the feedback that user are about to send.
|
---|
1065 | * This method should be called only if
|
---|
1066 | * getPrevData() method already been called before.Otherwise it will return null.
|
---|
1067 | * @return the unique code
|
---|
1068 | */
|
---|
1069 | public static String getCode()
|
---|
1070 | {
|
---|
1071 | return code;
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | /**
|
---|
1075 | * This method will encode BufferedImage into their String representation using
|
---|
1076 | * Base64 encoder.
|
---|
1077 | * (Precondition: (image != null))
|
---|
1078 | * @param image is the image that we want to encode to String.
|
---|
1079 | */
|
---|
1080 | public String convert (BufferedImage image)
|
---|
1081 | {
|
---|
1082 | String txt;
|
---|
1083 | txt = null;
|
---|
1084 |
|
---|
1085 | try
|
---|
1086 | {
|
---|
1087 | ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
---|
1088 | ImageIO.write(image,"jpeg",stream);
|
---|
1089 | byte[] bytes = stream.toByteArray();
|
---|
1090 |
|
---|
1091 | txt = Base64.encodeBytes(bytes);
|
---|
1092 |
|
---|
1093 | }
|
---|
1094 | catch(IOException ex) {}
|
---|
1095 |
|
---|
1096 | return txt;
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | /**
|
---|
1100 | * This method is to make sure that there is no thread running at the moment.
|
---|
1101 | */
|
---|
1102 | private void ensureEventThread()
|
---|
1103 | {
|
---|
1104 | if(SwingUtilities.isEventDispatchThread())
|
---|
1105 | {
|
---|
1106 | return;
|
---|
1107 | }
|
---|
1108 | throw new RuntimeException(messages.getString("file"));
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 | /**
|
---|
1112 | * This method will create all 6 xml files, jarred them into one file, deletes all xml files and
|
---|
1113 | * sending it.
|
---|
1114 | * The xml files for:
|
---|
1115 | * <br> 1.The history & information of all the actions done and windows opened by the application
|
---|
1116 | * after user choose to start the sequence of sending feedback.
|
---|
1117 | * <br> 2.The history of all the commands (actions) done by the user before choosing
|
---|
1118 | * after start the sequence of sending feedback.
|
---|
1119 | * <br> 3.The informations we get from the feedback interface form period.
|
---|
1120 | * <br> will be getting from vector and the temp_feedbackhist.log file.
|
---|
1121 | * (Precondition: (sx != null) && (vector != null) && (err_array != null))
|
---|
1122 | * @param sx the xml parser.
|
---|
1123 | * @param vector the vector that hold the history and information.
|
---|
1124 | * @param err_array the arrays of information we take from the feedback interface period.
|
---|
1125 | * @param imgFile the arrays of information we take from the panels inside feedback interface form.
|
---|
1126 | */
|
---|
1127 | private void sendState (SaveToXML sx,Vector vector,String[] err_array,String[] imgFile)
|
---|
1128 | {
|
---|
1129 | String dirname;
|
---|
1130 | dirname = "xmlfeedback/";
|
---|
1131 |
|
---|
1132 | File dir = new File("xmlfeedback");
|
---|
1133 | if (dir.isDirectory() == false)
|
---|
1134 | dir.mkdir();
|
---|
1135 |
|
---|
1136 | sx.saveFeedback(err_array,imgFile);
|
---|
1137 |
|
---|
1138 | sx.open(dirname + "feedbackcontent" + FeedbackInterface.getCode() + ".xml",
|
---|
1139 | "HISTORY");
|
---|
1140 | SaveToXML sx2;
|
---|
1141 | sx2 = new SaveToXML(messages);
|
---|
1142 | sx2.open(dirname + "feedbackcommand" + FeedbackInterface.getCode() + ".xml",
|
---|
1143 | "COMMANDS");
|
---|
1144 |
|
---|
1145 | for (int i = 0 ; i < vector.size() ; i++)
|
---|
1146 | {
|
---|
1147 | History log;
|
---|
1148 | log = (History) vector.get(i);
|
---|
1149 | log.sendXML(sx);
|
---|
1150 | log.sendXMLComm(sx2);
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | Vector stack;
|
---|
1154 | stack = getPrev_log();
|
---|
1155 | if (stack != null)
|
---|
1156 | {
|
---|
1157 | for (int i = 0 ; i < stack.size() ; i++)
|
---|
1158 | {
|
---|
1159 | History log;
|
---|
1160 | log = (History) stack.get(i);
|
---|
1161 | log.sendXML(sx);
|
---|
1162 | log.sendXMLComm(sx2);
|
---|
1163 | }
|
---|
1164 | stack.removeAllElements();
|
---|
1165 | System.gc();
|
---|
1166 | stack = null;
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | sx2.close("COMMANDS");
|
---|
1170 | sx.close("HISTORY");
|
---|
1171 |
|
---|
1172 | getHistPrev_log(sx,sx2);
|
---|
1173 |
|
---|
1174 | ZipFile zip;
|
---|
1175 | zip = new ZipFile();
|
---|
1176 | zip.sendZipXMLFile();
|
---|
1177 |
|
---|
1178 | File f;
|
---|
1179 | f = new File (dirname + "feedback" + FeedbackInterface.getCode() + ".xml");
|
---|
1180 | f.delete();
|
---|
1181 | f = new File (dirname + "feedbackcontent" + FeedbackInterface.getCode() + ".xml");
|
---|
1182 | f.delete();
|
---|
1183 | f = new File (dirname + "feedbackcommand" + FeedbackInterface.getCode() + ".xml");
|
---|
1184 | f.delete();
|
---|
1185 | /*f = new File (dirname + "content" + FeedbackInterface.getCode() + ".xml");
|
---|
1186 | f.delete();*/
|
---|
1187 | f = new File (dirname + "command" + FeedbackInterface.getCode() + ".xml");
|
---|
1188 | f.delete();
|
---|
1189 |
|
---|
1190 | String[] args = new String[5];
|
---|
1191 | args[0] = "[email protected]";
|
---|
1192 | args[1] = dirname + "Jar" + FeedbackInterface.getCode() + "File.jar";
|
---|
1193 | args[4] = "lib/parser.jar";
|
---|
1194 | args[2] = err_array[19];
|
---|
1195 | args[3] = err_array[20];
|
---|
1196 | SendHTTP sm = new SendHTTP();
|
---|
1197 | //SendMail sm = new SendMail();
|
---|
1198 | sm.sendMail(args,messages,FeedbackInterface.getCode());
|
---|
1199 | }
|
---|
1200 |
|
---|
1201 | /**
|
---|
1202 | * This method will create the 2 xml files.
|
---|
1203 | * The xml files are:
|
---|
1204 | * <br> 1.The history & information of all the actions done and windows opened by the application
|
---|
1205 | * before user choose to start the sequence of sending feedback.
|
---|
1206 | * <br> 2.The history of all the commands (actions) done by the user before choosing
|
---|
1207 | * to start the sequence of sending feedback.
|
---|
1208 | * <br> The information will be getting from history.log file and the temp_history.log file.
|
---|
1209 | * (Precondition: (sx != null) && (sx2 != null))
|
---|
1210 | * @param sx the xml parser for the history xml file.
|
---|
1211 | * @param sx2 the xml parser for the command xml file.
|
---|
1212 | */
|
---|
1213 | private void getHistPrev_log(SaveToXML sx,SaveToXML sx2)
|
---|
1214 | {
|
---|
1215 | Vector stack = null;
|
---|
1216 | try
|
---|
1217 | {
|
---|
1218 | File f = new File("history.log");
|
---|
1219 | if (f.exists() == true)
|
---|
1220 | {
|
---|
1221 | FileInputStream fis = new FileInputStream(f);
|
---|
1222 | ObjectInputStream ois = new ObjectInputStream(fis);
|
---|
1223 |
|
---|
1224 | stack = (Vector) ois.readObject();
|
---|
1225 |
|
---|
1226 | String dirname;
|
---|
1227 | dirname = "xmlfeedback/";
|
---|
1228 |
|
---|
1229 | /*sx.open(dirname + "content" + FeedbackInterface.getCode() + ".xml",
|
---|
1230 | "HISTORY");*/
|
---|
1231 | sx2.open(dirname + "command" + FeedbackInterface.getCode() + ".xml",
|
---|
1232 | "COMMANDS");
|
---|
1233 |
|
---|
1234 | if (stack != null)
|
---|
1235 | {
|
---|
1236 | for (int i = 0 ; i < stack.size() ; i++)
|
---|
1237 | {
|
---|
1238 | History log;
|
---|
1239 | log = (History) stack.get(i);
|
---|
1240 | //log.sendXML(sx);
|
---|
1241 | log.sendXMLComm(sx2);
|
---|
1242 | }
|
---|
1243 | stack.removeAllElements();
|
---|
1244 | System.gc();
|
---|
1245 | stack = null;
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | stack = (Vector) ois.readObject();
|
---|
1249 |
|
---|
1250 | if (stack != null)
|
---|
1251 | {
|
---|
1252 | for (int i = 0 ; i < stack.size() ; i++)
|
---|
1253 | {
|
---|
1254 | History log;
|
---|
1255 | log = (History) stack.get(i);
|
---|
1256 | //log.sendXML(sx);
|
---|
1257 | log.sendXMLComm(sx2);
|
---|
1258 | }
|
---|
1259 | stack.removeAllElements();
|
---|
1260 | System.gc();
|
---|
1261 | stack = null;
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | sx2.close("COMMANDS");
|
---|
1265 | //sx.close("HISTORY");
|
---|
1266 |
|
---|
1267 | ois.close();
|
---|
1268 | }
|
---|
1269 | }
|
---|
1270 | catch (IOException exp) {exp.printStackTrace();}
|
---|
1271 | catch (ClassNotFoundException exp2)
|
---|
1272 | {
|
---|
1273 | System.out.println("class exp");}
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | /**
|
---|
1277 | * This method will get the Vector stored in temp_feedbackhist.log file.
|
---|
1278 | * @return the vector stored in temp_feedbackhist.log file.
|
---|
1279 | */
|
---|
1280 | public Vector getPrev_log()
|
---|
1281 | {
|
---|
1282 | Vector stack = null;
|
---|
1283 | try
|
---|
1284 | {
|
---|
1285 | File f = new File("temp_feedbackhist.log");
|
---|
1286 | if (f.exists() == true)
|
---|
1287 | {
|
---|
1288 | FileInputStream fis = new FileInputStream(f);
|
---|
1289 | ObjectInputStream ois = new ObjectInputStream(fis);
|
---|
1290 | stack = (Vector) ois.readObject();
|
---|
1291 | ois.close();
|
---|
1292 | return stack;
|
---|
1293 | }
|
---|
1294 | else
|
---|
1295 | stack = null;
|
---|
1296 | }
|
---|
1297 | catch (IOException exp) {exp.printStackTrace();}
|
---|
1298 | catch (ClassNotFoundException exp2)
|
---|
1299 | {
|
---|
1300 | System.out.println("class exp");}
|
---|
1301 |
|
---|
1302 | return stack;
|
---|
1303 | }
|
---|
1304 |
|
---|
1305 | /**
|
---|
1306 | * This is the thread that will start when user click send button and it will
|
---|
1307 | * make 6 xml files,jarred them together into 1 jar file, deletes the 6 xml files and send it.
|
---|
1308 | * @param vector the vector stored the current actions history.
|
---|
1309 | * @param err_array the array that stored all the information took during feedback interface period.
|
---|
1310 | * @param imgFile the array of that stored all the information from all the panels inside feedback interface form.
|
---|
1311 | */
|
---|
1312 | public void sendMethod (final Vector vector,final String err_array[], final String imgFile[])
|
---|
1313 | {
|
---|
1314 | ensureEventThread();
|
---|
1315 | Runnable sendRun;
|
---|
1316 | sendRun = new Runnable()
|
---|
1317 | {
|
---|
1318 | public void run ()
|
---|
1319 | {
|
---|
1320 | finish = false;
|
---|
1321 | selected = true;
|
---|
1322 | SaveToXML sx;
|
---|
1323 | sx = new SaveToXML(messages);
|
---|
1324 | sendState(sx,vector,err_array,imgFile);
|
---|
1325 | finish = true;
|
---|
1326 | }
|
---|
1327 | };
|
---|
1328 | sendThread = new Thread(sendRun);
|
---|
1329 | sendThread.start();
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | /**
|
---|
1333 | * This method will called the window that will display the preview of all
|
---|
1334 | * the file going to be send.
|
---|
1335 | * @param vector the vector stored the current actions history.
|
---|
1336 | * @param err_array the array that stored all the information took during feedback interface period.
|
---|
1337 | * @param imgFile the array of that stored all the information from all the panels inside feedback interface form.
|
---|
1338 | */
|
---|
1339 | public void viewMethod (final Vector vector,final String err_array[], final String imgFile[])
|
---|
1340 | {
|
---|
1341 | ensureEventThread();
|
---|
1342 | Runnable prevRun;
|
---|
1343 | prevRun = new Runnable()
|
---|
1344 | {
|
---|
1345 | public void run ()
|
---|
1346 | {
|
---|
1347 | finish = false;
|
---|
1348 | selected = false;
|
---|
1349 | ReportDetails rd;
|
---|
1350 | rd = new ReportDetails(vector,err_array,imgFile,messages,true);
|
---|
1351 | finish = true;
|
---|
1352 | }
|
---|
1353 | };
|
---|
1354 |
|
---|
1355 | prevThread = new Thread(prevRun);
|
---|
1356 | prevThread.start();
|
---|
1357 | }
|
---|
1358 |
|
---|
1359 | /**
|
---|
1360 | * This method will save a BufferedImage to a jpeg file with the specified filename.
|
---|
1361 | * This method is a thread that will caused the thread save to be started and stop
|
---|
1362 | * if the saving process is finished.
|
---|
1363 | * (Precondition: (I != null))
|
---|
1364 | * @param I is the BufferedImage that we want to save.
|
---|
1365 | * @param picScreen name of the jpeg file where we want to store the BufferedImage
|
---|
1366 | */
|
---|
1367 | public void saveGraph(final BufferedImage I,final String picScreen)
|
---|
1368 | {
|
---|
1369 | ensureEventThread();
|
---|
1370 | Runnable saveRun;
|
---|
1371 | saveRun = new Runnable ()
|
---|
1372 | {
|
---|
1373 | public void run()
|
---|
1374 | {
|
---|
1375 | try
|
---|
1376 | {
|
---|
1377 | File file;
|
---|
1378 | file = new File(picScreen);
|
---|
1379 | FileOutputStream out;
|
---|
1380 | out = new FileOutputStream(file);
|
---|
1381 |
|
---|
1382 | JPEGImageEncoder encoder;
|
---|
1383 | encoder = JPEGCodec.createJPEGEncoder(out);
|
---|
1384 | JPEGEncodeParam param;
|
---|
1385 | param = encoder.getDefaultJPEGEncodeParam(I);
|
---|
1386 | param.setQuality(1.0f, false);
|
---|
1387 | encoder.setJPEGEncodeParam(param);
|
---|
1388 | encoder.encode(I);
|
---|
1389 | out.close();
|
---|
1390 | save = null;
|
---|
1391 | }
|
---|
1392 | catch (Exception ex) {}
|
---|
1393 | }
|
---|
1394 | };
|
---|
1395 |
|
---|
1396 | save = new Thread(saveRun);
|
---|
1397 | save.start();
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 | /**
|
---|
1401 | * This method will get all the informations from the all the panels inside the feedback interface form.
|
---|
1402 | * @return the arrays of information from all the panels.
|
---|
1403 | */
|
---|
1404 | public String[] getimgFile()
|
---|
1405 | {
|
---|
1406 | String[] imgFile;
|
---|
1407 | imgFile = null;
|
---|
1408 |
|
---|
1409 | /*String answer;
|
---|
1410 | answer = (String) problem_screenshot.getSelectedItem();
|
---|
1411 | if(answer == messages.getString("Yes"))
|
---|
1412 | {*/
|
---|
1413 |
|
---|
1414 | if (paneArray.size() > 0)
|
---|
1415 | {
|
---|
1416 | imgFile = new String[(paneArray.size() * 10)];
|
---|
1417 |
|
---|
1418 | int step;
|
---|
1419 | for (step = 0 ; step < (paneArray.size()*10) ; step=step+10)
|
---|
1420 | {
|
---|
1421 | JPanel pane;
|
---|
1422 | ThumbnailPic obj;
|
---|
1423 | pane = (JPanel) paneArray.get((step/10));
|
---|
1424 | obj = (ThumbnailPic) picAndPane.get(pane);
|
---|
1425 |
|
---|
1426 | //obj.setSize();
|
---|
1427 |
|
---|
1428 | String title;
|
---|
1429 | title = obj.getTitles();
|
---|
1430 |
|
---|
1431 | imgFile[step+0] = title;
|
---|
1432 | imgFile[step+1] = obj.getScreenImage();
|
---|
1433 | title = "Window" + pane.hashCode() + "File";
|
---|
1434 | imgFile[step+2] = messages.getString("screen")+title+step+".jpg";
|
---|
1435 | imgFile[step+3] = obj.getScreenAndLineImage();
|
---|
1436 | imgFile[step+4] = messages.getString("ErrorLineAnd")+imgFile[step+2];
|
---|
1437 | imgFile[step+5] = obj.getLineForScreenImage();
|
---|
1438 | imgFile[step+6] = messages.getString("ErrorLineFor")+imgFile[step+2];
|
---|
1439 | imgFile[step+7] = obj.getWidth();
|
---|
1440 | imgFile[step+8] = obj.getHeight();
|
---|
1441 | imgFile[step+9] = obj.getProblemDetails();
|
---|
1442 | }
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 | return imgFile;
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | /**
|
---|
1449 | * This method will get all the informations taken during feedback interface period, such as os version.
|
---|
1450 | * @return then arrays of informations.
|
---|
1451 | */
|
---|
1452 | public String[] geterr_array()
|
---|
1453 | {
|
---|
1454 | String[] err_array;
|
---|
1455 | err_array = null;
|
---|
1456 |
|
---|
1457 | String os_name;
|
---|
1458 | os_name = System.getProperty("os.name") + " " + System.getProperty("os.version")
|
---|
1459 | + " " + System.getProperty("os.arch");
|
---|
1460 |
|
---|
1461 | Date problem_date;
|
---|
1462 | String err_date,java_info,screen_res;
|
---|
1463 | problem_date = new Date();
|
---|
1464 | err_date = problem_date.toString();
|
---|
1465 | java_info = System.getProperty("java.vendor")+ " " + System.getProperty("java.class.version");
|
---|
1466 | Dimension dim;
|
---|
1467 | dim = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
1468 | screen_res = "" + dim.width + "x" + dim.height;
|
---|
1469 |
|
---|
1470 | try
|
---|
1471 | {
|
---|
1472 | err_array = new String[24];
|
---|
1473 |
|
---|
1474 | err_array[0] = code;
|
---|
1475 | err_array[1] = frameName;
|
---|
1476 | err_array[2] = "";
|
---|
1477 | err_array[3] = (String) problem_type.getSelectedItem();
|
---|
1478 | err_array[4] = (String) problem_urgency.getSelectedItem();
|
---|
1479 | err_array[5] = System.getProperty("user.name");
|
---|
1480 | err_array[6] = System.getProperty("user.home");
|
---|
1481 | err_array[7] = System.getProperty("user.dir");
|
---|
1482 | err_array[8] = curr_date.toString();
|
---|
1483 | err_array[9] = err_date;
|
---|
1484 | err_array[10] = os_name;
|
---|
1485 | err_array[11] = java_info;
|
---|
1486 | err_array[12] = "" + Locale.getDefault();
|
---|
1487 | err_array[13] = Gatherer.PROGRAM_NAME + " " + Gatherer.PROGRAM_VERSION;
|
---|
1488 | err_array[14] = InetAddress.getLocalHost().getHostName();
|
---|
1489 | err_array[15] = InetAddress.getLocalHost().getHostAddress();
|
---|
1490 | err_array[16] = screen_res;
|
---|
1491 | err_array[17] = "";
|
---|
1492 |
|
---|
1493 | /*String test_txt;
|
---|
1494 | test_txt = smtp_address.getText();
|
---|
1495 | if ((test_txt == null)||(test_txt.length() < 5))*/
|
---|
1496 | err_array[19] = "mail.waikato.ac.nz";
|
---|
1497 | /*else
|
---|
1498 | err_array[19] = test_txt;
|
---|
1499 |
|
---|
1500 | test_txt = email_address.getText();
|
---|
1501 | if ((test_txt == null)||(test_txt.length() < 5))*/
|
---|
1502 | err_array[20] = "[email protected]";
|
---|
1503 | //else
|
---|
1504 | //err_array[20] = test_txt;
|
---|
1505 |
|
---|
1506 | Runtime run;
|
---|
1507 | run = Runtime.getRuntime();
|
---|
1508 | err_array[21] = formatFileSize(run.totalMemory());
|
---|
1509 | err_array[22] = formatFileSize(run.maxMemory());
|
---|
1510 | err_array[23] = formatFileSize(run.freeMemory());
|
---|
1511 | }
|
---|
1512 | catch(UnknownHostException exp) {}
|
---|
1513 |
|
---|
1514 | return err_array;
|
---|
1515 | }
|
---|
1516 |
|
---|
1517 | /**
|
---|
1518 | * This method will format the file size given into more elegant form,e.g. 2KB
|
---|
1519 | * @param length the file size.
|
---|
1520 | * @return the more elegant string representations of the file size.
|
---|
1521 | */
|
---|
1522 | public String formatFileSize(long length)
|
---|
1523 | {
|
---|
1524 | String BYTE_SUFFIX;
|
---|
1525 | BYTE_SUFFIX = " B";
|
---|
1526 | long GIGABYTE;
|
---|
1527 | GIGABYTE = 1024000000l;
|
---|
1528 | String GIGABYTE_SUFFIX;
|
---|
1529 | GIGABYTE_SUFFIX = " GB";
|
---|
1530 | long KILOBYTE;
|
---|
1531 | KILOBYTE = 1024l;
|
---|
1532 | String KILOBYTE_SUFFIX;
|
---|
1533 | KILOBYTE_SUFFIX = " KB";
|
---|
1534 | long MEGABYTE;
|
---|
1535 | MEGABYTE = 1024000l;
|
---|
1536 | String MEGABYTE_SUFFIX;
|
---|
1537 | MEGABYTE_SUFFIX = " MB";
|
---|
1538 |
|
---|
1539 | StringBuffer result;
|
---|
1540 | result = new StringBuffer("");
|
---|
1541 | float number;
|
---|
1542 | number = 0f;
|
---|
1543 | String suffix;
|
---|
1544 | suffix = null;
|
---|
1545 |
|
---|
1546 | if(length >= GIGABYTE)
|
---|
1547 | {
|
---|
1548 | number = (float) length / (float) GIGABYTE;
|
---|
1549 | suffix = GIGABYTE_SUFFIX;
|
---|
1550 | }
|
---|
1551 | else if(length >= MEGABYTE)
|
---|
1552 | {
|
---|
1553 | number = (float) length / (float) MEGABYTE;
|
---|
1554 | suffix = MEGABYTE_SUFFIX;
|
---|
1555 | }
|
---|
1556 | else if(length >= KILOBYTE)
|
---|
1557 | {
|
---|
1558 | number = (float) length / (float) KILOBYTE;
|
---|
1559 | suffix = KILOBYTE_SUFFIX;
|
---|
1560 | }
|
---|
1561 | else
|
---|
1562 | {
|
---|
1563 | return length + BYTE_SUFFIX;
|
---|
1564 | }
|
---|
1565 |
|
---|
1566 | String number_str;
|
---|
1567 | number_str = Float.toString(number);
|
---|
1568 | char number_char[] = number_str.toCharArray();
|
---|
1569 | int pos,i;
|
---|
1570 | pos = 0;
|
---|
1571 |
|
---|
1572 | while(number_char != null && pos < number_char.length && number_char[pos] != '.')
|
---|
1573 | {
|
---|
1574 | result.append(number_char[pos]);
|
---|
1575 | pos++;
|
---|
1576 | }
|
---|
1577 |
|
---|
1578 | if(pos < number_char.length)
|
---|
1579 | {
|
---|
1580 | result.append(number_char[pos]);
|
---|
1581 | pos++;
|
---|
1582 |
|
---|
1583 | for(i = 0; i < 2 && pos < number_char.length; i++, pos++)
|
---|
1584 | result.append(number_char[pos]);
|
---|
1585 |
|
---|
1586 | while(pos < number_char.length && number_char[pos] != 'E')
|
---|
1587 | pos++;
|
---|
1588 |
|
---|
1589 | while(pos < number_char.length)
|
---|
1590 | {
|
---|
1591 | result.append(number_char[pos]);
|
---|
1592 | pos++;
|
---|
1593 | }
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | result.append(suffix);
|
---|
1597 |
|
---|
1598 | return result.toString();
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 | /**
|
---|
1602 | * This method will decide what action should be done if the user entered a button in
|
---|
1603 | * the Feedback form.
|
---|
1604 | * <br>If user click cancel button then all the information taken in this form will be deleted
|
---|
1605 | * and user will be quitted from the Reporting Feedback sequence.
|
---|
1606 | * <br>If user click the send button then all the information taken will be stored in array which
|
---|
1607 | * then will be saved into xml files and sent when user confirm to send all the files.
|
---|
1608 | * <br>If user click the details button then they can view all the xml files that are going to be send.
|
---|
1609 | * @param e the button that user clicked
|
---|
1610 | */
|
---|
1611 | public void actionPerformed (ActionEvent e)
|
---|
1612 | {
|
---|
1613 | getPrevData();
|
---|
1614 |
|
---|
1615 | if(messages.getString("Send").equals(e.getActionCommand()))
|
---|
1616 | {
|
---|
1617 | String[] imgFile;
|
---|
1618 | String[] err_array;
|
---|
1619 |
|
---|
1620 | imgFile = getimgFile();
|
---|
1621 | err_array = geterr_array();
|
---|
1622 |
|
---|
1623 | timer.start();
|
---|
1624 |
|
---|
1625 | sendMethod(dialog.getVector(),err_array,imgFile);
|
---|
1626 | }
|
---|
1627 |
|
---|
1628 | if(messages.getString("Preview").equals(e.getActionCommand()))
|
---|
1629 | {
|
---|
1630 | String[] imgFile;
|
---|
1631 | String[] err_array;
|
---|
1632 |
|
---|
1633 | imgFile = getimgFile();
|
---|
1634 | err_array = geterr_array();
|
---|
1635 |
|
---|
1636 | timer.start();
|
---|
1637 |
|
---|
1638 | viewMethod(dialog.getVector(),err_array,imgFile);
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | if(messages.getString("NotSend").equals(e.getActionCommand()))
|
---|
1642 | {
|
---|
1643 | dispose();
|
---|
1644 | }
|
---|
1645 | }
|
---|
1646 | }
|
---|
1647 |
|
---|
1648 |
|
---|
1649 |
|
---|
1650 |
|
---|
1651 |
|
---|
1652 |
|
---|
1653 |
|
---|
1654 |
|
---|
1655 |
|
---|
1656 |
|
---|