source: main/trunk/gli/src/org/greenstone/gatherer/feedback/ReportDetails.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: 38.1 KB
Line 
1package org.greenstone.gatherer.feedback;
2
3import java.io.*;
4import java.awt.image.*;
5import javax.swing.*;
6import java.awt.*;
7import java.util.*;
8import javax.swing.event.MouseInputAdapter;
9import java.awt.event.*;
10import javax.swing.border.*;
11import java.util.Locale;
12import java.util.ResourceBundle;
13import java.text.MessageFormat;
14import javax.swing.tree.*;
15
16/**
17 * This class can give preview of all the history of actions user did or give preview of all the
18 * xml files that are ready to be send and it also can give preview of all the screen shot of
19 * all window taken when user did the actions.
20 * If user select Details button then they will view all xml files that are going to be send.
21 * If user select View History then they will see the history record that we took so far.
22 * @author Veronica Liesaputra
23 */
24public class ReportDetails extends WindowAdapter
25{
26 /**
27 * This is the tree that will be used to hold the feedback form,the history stored inside the vector
28 * at the moment, and hold the comment user did when they recreating the event.
29 * This tree's data partly will be supplied from whats inside vector.
30 */
31 private JTree tree;
32 /**
33 * This is the root node for tree.
34 */
35 private DefaultMutableTreeNode rootNode;
36 /**
37 * This hold the parent node of the current node that is currently just being added to tree.
38 */
39 private DefaultMutableTreeNode parentNode;
40 /**
41 * This hold the current node that is currently just being added to tree.
42 */
43 private DefaultMutableTreeNode currNode;
44 /**
45 * This is the tree model for tree.
46 */
47 private DefaultTreeModel treeModel;
48
49 /**
50 * This is the tree that will be used to hold the commands (actions) done by the user inside the vector
51 * at the moment.This tree builds from partial data of tree and which data entered to this tree
52 * is signed by the value of comm_bool and comm_start.
53 */
54 private JTree tree2;
55 /**
56 * This is the root node for tree2.
57 */
58 private DefaultMutableTreeNode rootNode2;
59 /**
60 * This is the parent node of the current node that is currently just being added to tree2.
61 */
62 private DefaultMutableTreeNode parentNode2;
63 /**
64 * This is the current node that is currently just being added to tree2.
65 */
66 private DefaultMutableTreeNode currNode2;
67 /**
68 * This is the tree model for tree2.
69 */
70 private DefaultTreeModel treeModel2;
71
72 /**
73 * This is the tree that will be used to hold the history of all the actions
74 * done by the user before they choose to do the Reporting Feedback sequence.
75 */
76 private JTree tree3;
77 /**
78 * This is the root node for tree3.
79 */
80 private DefaultMutableTreeNode rootNode3;
81 /**
82 * This is the parent node for the current node that is currently just being added to tree3.
83 */
84 private DefaultMutableTreeNode parentNode3;
85 /**
86 * This is the current node that is currently just being added to tree3.
87 */
88 private DefaultMutableTreeNode currNode3;
89 /**
90 * This is the tree model for tree3.
91 */
92 private DefaultTreeModel treeModel3;
93
94 /**
95 * This is the tree that will be used to hold the commands (actions) done by the user
96 * before they choose to do the Reporting Feedback sequence.This tree builds from partial data of tree3
97 * and which data entered to this tree2 is signed by the value of comm_bool and comm_start.
98 */
99 private JTree tree4;
100 /**
101 * This is the root node for tree4.
102 */
103 private DefaultMutableTreeNode rootNode4;
104 /**
105 * This is the parent node for the current node that is currently just being added to tree4.
106 */
107 private DefaultMutableTreeNode parentNode4;
108 /**
109 * This is the current node that is currently just being added to tree4.
110 */
111 private DefaultMutableTreeNode currNode4;
112 /**
113 * This is the tree model for tree4.
114 */
115 private DefaultTreeModel treeModel4;
116
117 /**
118 * This is the panel to display tree4.
119 */
120 private JPanel pane4;
121 /**
122 * This is the scroll pane for displaying tree3, so it is scrollable.
123 */
124 private JScrollPane scroll3;
125 /**
126 * This is the scroll pane for displaying tree4, so it is scrollable.
127 */
128 private JScrollPane scroll4;
129
130 /**
131 * This is the panel to display tree2.
132 */
133 private JPanel pane2;
134 /**
135 * This is the scroll pane for displaying tree2, so it is scrollable.
136 */
137 private JScrollPane scroll2;
138 /**
139 * This is the scroll pane for displaying tree, so it is scrollable.
140 */
141 private JScrollPane scroll;
142
143 /**
144 * This is all the information taken from the Feedback form and information that
145 * was taken from the system.
146 */
147 private String[] err_details;
148
149 /**
150 * This is the vector that hold all information about the history of all
151 * the actions user did.
152 * If rec = true, it means it hold the history of all the actions and information
153 * of all the windows were open when user did the actions during reporting feedback
154 * sequence.
155 * If rec = false, it means it hold the history of all the actions and information
156 * of all the windows were open when user did the actions before and after
157 * reporting feedback sequence.
158 */
159 private Vector vector;
160
161 /**
162 * This is a variable to know which tag xml data that wants to be added to the JTree.
163 */
164 private int count;
165
166 /**
167 * This is a flag variable to sign whether or not the next data is to be added to
168 * the command JTree.
169 */
170 private boolean comm_bool = false;
171 /**
172 * This is a flag variable to sign whether or not the next history is to be added to
173 * the command JTree.
174 */
175 private boolean comm_start = false;
176 /**
177 * This is a flag variable to sign whether or not at the moment we building a new tree
178 * or build from the existing tree.
179 */
180 private boolean new_tree = false;
181
182 /**
183 * This is a flag variable to sign which type of preview that user wants at the moment.
184 * If its true, then its means user will view all the 6 xml files that will be send.
185 * If its false, then its means user only wants to view the history and command user just did
186 * before and after the reporting feedback sequence.
187 */
188 private boolean rec = false;
189
190 /**
191 * This is array list of all the image icons that are inside all the command JTree.
192 */
193 private ArrayList movie;
194
195 /**
196 * This variable will hold the resource of the words that is stored in Messages.properties file.
197 * The calling using messages.getString(someString) will caused someString to be translated
198 * into some other string that is hold in that file.usually it will caused it to be translated
199 * to the language that the user use or choose to have as stated in Locale.
200 */
201 private static ResourceBundle messages;
202
203 private String[] img;
204
205 /**
206 * This constructor will be seeting up the data member to its appropriate value.
207 * (Precondition : (msg != null) && (bool != null))
208 * @param stack this is all vector to be supplied to tree.
209 * @param err_array holding all the information taken when user doing the FeedbackInterface form.
210 * @param imgFile holding all the information inside all the panels in the FeedbackInterface form.
211 * @param msg hold the resource of the words that is stored in Messages.properties file.
212 * @param bool hold the falg value of rec.
213 */
214 public ReportDetails(Vector stack,String[] err_array,String[] imgFile,ResourceBundle msg,boolean bool)
215 {
216 img = imgFile;
217 vector = stack;
218 err_details = err_array;
219 messages = msg;
220 rec = bool;
221 movie = new ArrayList();
222 makeNewWindow();
223 }
224
225 /**
226 * This method will make a modal-dialog window that will display all the preview.
227 */
228 public void makeNewWindow()
229 {
230 JDialog frame;
231 frame = new View (this);
232 frame.setModal(true);
233 frame.setVisible(true);
234 }
235
236 /**
237 * This class is the dialog window that will give the preview.
238 */
239 class View extends JDialog implements ActionListener
240 {
241 /**
242 * This variable is holding the current window that display the preview.
243 */
244 private JDialog frame;
245 /**
246 * This variable holding the owner of this window.
247 */
248 private ReportDetails framework = null;
249
250 /**
251 * This constructor will make the dialog window for previewing and setting up the
252 * content pane of this window.
253 * @param controller is the owner of this window.
254 */
255 public View (ReportDetails controller)
256 {
257 super();
258 framework = controller;
259 frame = this;
260
261 setTitle(messages.getString("ViewReport"));
262 setBackground(new Color(176,208,176));
263 setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
264 setDefaultLookAndFeelDecorated(true);
265
266 JPanel cont;
267 cont = new JPanel();
268 cont.setLayout(new BoxLayout(cont,BoxLayout.PAGE_AXIS));
269 cont.setBackground(new Color(176,208,176));
270
271 JTabbedPane tab;
272 tab = new JTabbedPane();
273 tab.setBackground(new Color(176,208,176));
274
275 new_tree = false;
276
277 if (err_details != null)
278 {
279 tab.addTab(messages.getString("ViewFeedbackForm"),
280 createFeedback_UI(err_details,img));
281 }
282
283 if (rec == true)
284 {
285 tab.addTab(messages.getString("ViewFeedbackHistoryState"),
286 createFeedbackHistory_UI(vector));
287 tab.addTab(messages.getString("ViewFeedbackCommandState"),pane2);
288 /*tab.addTab(messages.getString("ViewHistoryState"),
289 createHistory_UI());*/
290 createHistory_UI();
291 tab.addTab(messages.getString("ViewCommandState"),pane4);
292 }
293 else
294 {
295 /*tab.addTab(messages.getString("ViewHistoryState"),
296 createFeedbackHistory_UI(vector));*/
297 createFeedbackHistory_UI(vector);
298 tab.addTab(messages.getString("ViewCommandState"),pane2);
299 }
300
301 cont.add(tab);
302
303 JLabel lbl;
304 lbl = new JLabel(" ");
305 lbl.setBackground(new Color(176,208,176));
306
307 cont.add(lbl);
308
309 JPanel pane3;
310 pane3 = new JPanel();
311 pane3.setBackground(new Color(176,208,176));
312 JButton button;
313 button = new JButton(messages.getString("Close"));
314 button.setActionCommand(messages.getString("Close"));
315 button.addActionListener(this);
316 button.setDefaultCapable(true);
317 button.setToolTipText(messages.getString("ClosePreview"));
318 button.setBackground(new Color(176,208,176));
319
320 /*JButton button2;
321 button2 = new JButton(messages.getString("ViewMovie"));
322 button2.setActionCommand(messages.getString("ViewMovie"));
323 button2.addActionListener(new ActionListener()
324 {
325 public void actionPerformed (ActionEvent e)
326 {
327 JDialog.setDefaultLookAndFeelDecorated(true);
328 JDialog frame;
329 frame = new Movie(messages,movie);
330
331 frame.setContentPane(((Movie)frame).create_UI());
332 frame.pack();
333 frame.setVisible(true);
334 }
335 });
336 button2.setToolTipText(messages.getString("ViewMovieText"));
337 button2.setBackground(new Color(176,208,176));
338 pane3.add(button2);*/
339 pane3.add(button);
340 pane3.setBorder(new EmptyBorder(new Insets(0,10,10,10)));
341
342 cont.add(pane3);
343
344 cont.setBorder(new EmptyBorder(new Insets(5,5,5,5)));
345 getContentPane().add(cont);
346
347 tab.setAlignmentX(Component.LEFT_ALIGNMENT);
348 lbl.setAlignmentX(Component.LEFT_ALIGNMENT);
349 pane3.setAlignmentX(Component.LEFT_ALIGNMENT);
350
351 addWindowListener(framework);
352 Toolkit kit;
353 kit = Toolkit.getDefaultToolkit();
354 Dimension screenSize;
355 screenSize = kit.getScreenSize();
356 int screenHeight;
357 screenHeight = screenSize.height;
358 int screenWidth;
359 screenWidth = screenSize.width;
360 Dimension size;
361 size = this.getSize();
362 setLocation((screenWidth -size.width)/ 4,
363 (screenHeight - size.height)/ 4);
364
365 pack();
366 setResizable(false);
367 }
368
369 /**
370 * This method will get the vector that is stored inside temp_feedbackhist.log
371 * if rec is true, and will get the vector that is stored inside temp_history.log
372 * if rec is false. If file is not exist then it will return null.
373 * @return vector that is stored in the file.
374 */
375 public Vector getPrev_log()
376 {
377 Vector stack = null;
378 try
379 {
380 File f;
381 if (rec == true)
382 {
383 f = new File("temp_feedbackhist.log");
384 }
385 else
386 {
387 f = new File("temp_history.log");
388 }
389
390 if (f.exists() == true)
391 {
392 FileInputStream fis = new FileInputStream(f);
393 ObjectInputStream ois = new ObjectInputStream(fis);
394 stack = (Vector) ois.readObject();
395 ois.close();
396 return stack;
397 }
398 else
399 stack = null;
400 }
401 catch (IOException exp) {exp.printStackTrace();}
402 catch (ClassNotFoundException exp2)
403 {
404 System.out.println("class exp");}
405
406 return stack;
407 }
408
409 /**
410 * This method will update the graphics of this window and it will
411 * set variable finish in Conformation to true.
412 * @param g is the graphics for this window.
413 */
414 public void paint (Graphics g)
415 {
416 super.paint(g);
417 FeedbackInterface.setFinish(true);
418 }
419
420 /**
421 * This method will close the preview window if user select close button.
422 * @param e action event user did.
423 */
424 public void actionPerformed (ActionEvent e)
425 {
426 if(messages.getString("Close").equals(e.getActionCommand()))
427 {
428 dispose();
429 }
430 }
431
432 /**
433 * This method will add a record to history tree and the command tree.
434 * @param log is the record to be added.
435 */
436 public void getHist(History log)
437 {
438 comm_bool = true;
439 startContent(10);
440
441 startContent(7);
442 saveContent(log.getDate());
443 closeContent(7);
444
445 startContent(2);
446 saveContent(log.getTitle());
447 closeContent(2);
448
449 startContent(8);
450 saveContent(log.getCommand());
451 closeContent(8);
452
453 String image;
454 image = log.getImage();
455
456 if (image != null)
457 {
458 byte[] img;
459 img = Base64.decode(image);
460
461 String width,height;
462 width = log.getWidth();
463 height = log.getHeight();
464
465 int w,h;
466 w = Integer.parseInt(width);
467 h = Integer.parseInt(height);
468
469 ImageIcon icon,small_icon;
470 small_icon = new ImageIcon(img);
471 icon = new ImageIcon
472 (small_icon.getImage().getScaledInstance(w,h,Image.SCALE_SMOOTH));
473
474 movie.add(0,icon);
475
476 startContent(6);
477 saveImage(log.getImageName(),width,height);
478 closeContent(6);
479 }
480 comm_bool = false;
481
482 ArrayList component;
483 component = log.getArray();
484 int j;
485 for (j = 0 ; j < component.size() ; j++)
486 {
487 startContent(9);
488 CompGroup comp;
489 comp = (CompGroup) component.get(j);
490
491 startContent(8);
492 saveContent(comp.getStatus());
493 closeContent(8);
494
495 startContent(0);
496 UserComponent cmp;
497 cmp = comp.getComponent();
498 showReport(cmp);
499 closeContent(0);
500
501 closeContent(9);
502 }
503
504 comm_bool = true;
505 closeContent(10);
506 comm_bool = false;
507 }
508
509 /**
510 * This method will make the tree that contains the history and the commands of all the actions and window
511 * open when user did the action that stored in vector.
512 * @param vector the vector that contains the information need to be display in tree.
513 * @return the panel that display tree and tree2.
514 */
515 public JPanel createFeedbackHistory_UI(Vector vector)
516 {
517 scroll = null;
518 int k;
519
520 tree = null;
521 rootNode = null;
522 currNode = null;
523 parentNode = null;
524 treeModel = null;
525
526 tree2 = null;
527 rootNode2 = null;
528 currNode2 = null;
529 parentNode2 = null;
530 treeModel2 = null;
531
532 comm_bool = true;
533 comm_start = true;
534 new_tree = false;
535
536 startElement(messages.getString("HISTORY"));
537
538 for (k = 0 ; k < vector.size() ; k++)
539 {
540 History log;
541 log = (History) vector.get(k);
542 getHist(log);
543 }
544
545 Vector stack;
546 stack = getPrev_log();
547 if (stack != null)
548 {
549 for (k = 0 ; k < stack.size() ; k++)
550 {
551 History log;
552 log = (History) stack.get(k);
553 getHist(log);
554 }
555 stack.removeAllElements();
556 System.gc();
557 stack = null;
558 }
559
560 comm_bool = true;
561 endElement(messages.getString("HISTORY"));
562 comm_bool = false;
563
564 comm_start = false;
565
566 pane2 = new JPanel();
567 pane2.add(scroll2);
568 pane2.setBackground(new Color(176,208,176));
569 pane2.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
570
571 JPanel pane;
572 pane = new JPanel();
573 pane.add(scroll);
574 pane.setBackground(new Color(176,208,176));
575 pane.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
576
577 return pane;
578 }
579
580 /**
581 * This method will make the tree that contains the history and the commands of all the actions and window
582 * open when user did the action before user choose the reporting feedback sequence.
583 * @return the panel contains the preview of this history and commands before user choose to start
584 * the reporting feedback sequence.
585 */
586 public JPanel createHistory_UI()
587 {
588 scroll3 = null;
589 int k;
590
591 tree3 = null;
592 rootNode3 = null;
593 currNode3 = null;
594 parentNode3 = null;
595 treeModel3 = null;
596
597 tree4 = null;
598 rootNode4 = null;
599 currNode4 = null;
600 parentNode4 = null;
601 treeModel4 = null;
602
603 comm_bool = true;
604 comm_start = true;
605 new_tree = true;
606
607 startElement(messages.getString("HISTORY"));
608
609 try
610 {
611 File f = new File("history.log");
612 FileInputStream fis = new FileInputStream(f);
613 ObjectInputStream ois = new ObjectInputStream(fis);
614
615 Vector stack;
616 stack = (Vector) ois.readObject();
617
618 if (stack != null)
619 {
620 for (k = 0 ; k < stack.size() ; k++)
621 {
622 History log;
623 log = (History) stack.get(k);
624 getHist(log);
625 }
626 stack.removeAllElements();
627 System.gc();
628 stack = null;
629 }
630
631 stack = (Vector) ois.readObject();
632
633 if (stack != null)
634 {
635 for (k = 0 ; k < stack.size() ; k++)
636 {
637 History log;
638 log = (History) stack.get(k);
639 getHist(log);
640 }
641 stack.removeAllElements();
642 System.gc();
643 stack = null;
644 }
645
646 ois.close();
647 }
648 catch (IOException exp) {exp.printStackTrace();}
649 catch (ClassNotFoundException exp2)
650 {
651 System.out.println("class exp");}
652
653 comm_bool = true;
654 endElement(messages.getString("HISTORY"));
655 comm_bool = false;
656
657 comm_start = false;
658
659 pane4 = new JPanel();
660 pane4.add(scroll4);
661 pane4.setBackground(new Color(176,208,176));
662 pane4.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
663
664 JPanel pane;
665 pane = new JPanel();
666 pane.add(scroll3);
667 pane.setBackground(new Color(176,208,176));
668 pane.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
669
670 return pane;
671 }
672
673 /**
674 * This method display all the information taken when user did the Feedback form.
675 * @param err_details is the information taken when user did the Feedback form.
676 * @param img is the information from all the panels inside the Feedback form.
677 * @return panel displaying the information.
678 */
679 public JPanel createFeedback_UI(String[] err_details,String[] img)
680 {
681 scroll = null;
682
683 tree = null;
684 rootNode = null;
685 currNode = null;
686 parentNode = null;
687 treeModel = null;
688
689 tree2 = null;
690 rootNode2 = null;
691 currNode2 = null;
692 parentNode2 = null;
693 treeModel2 = null;
694
695 startElement(messages.getString("BUGS"));
696
697 startElement(messages.getString("IDCode"));
698 characters(err_details[0].toCharArray(),0,err_details[0].length());
699 endElement(messages.getString("IDCode"));
700
701 startElement(messages.getString("LastViewedWindow"));
702 characters(err_details[1].toCharArray(),0,err_details[1].length());
703 endElement(messages.getString("LastViewedWindow"));
704
705 startElement(messages.getString("Optionals"));
706
707 startElement(messages.getString("Type"));
708 characters(err_details[3].toCharArray(),0,err_details[3].length());
709 endElement(messages.getString("Type"));
710
711 startElement(messages.getString("Urgency"));
712 characters(err_details[4].toCharArray(),0,err_details[4].length());
713 endElement(messages.getString("Urgency"));
714
715 endElement(messages.getString("Optionals"));
716
717 startElement(messages.getString("User"));
718
719 startElement(messages.getString("Name"));
720 characters(err_details[5].toCharArray(),0,err_details[5].length());
721 endElement(messages.getString("Name"));
722
723 startElement(messages.getString("HomeDirectory"));
724 characters(err_details[6].toCharArray(),0,err_details[6].length());
725 endElement(messages.getString("HomeDirectory"));
726
727 startElement(messages.getString("WorkingDirectory"));
728 characters(err_details[7].toCharArray(),0,err_details[7].length());
729 endElement(messages.getString("WorkingDirectory"));
730
731 startElement(messages.getString("SMTP"));
732 characters(err_details[19].toCharArray(),0,err_details[19].length());
733 endElement(messages.getString("SMTP"));
734
735 startElement(messages.getString("Email"));
736 characters(err_details[20].toCharArray(),0,err_details[20].length());
737 endElement(messages.getString("Email"));
738
739 endElement(messages.getString("User"));
740
741 startElement(messages.getString("OpenFormTime"));
742 characters(err_details[8].toCharArray(),0,err_details[8].length());
743 endElement(messages.getString("OpenFormTime"));
744
745 startElement(messages.getString("SendFormTime"));
746 characters(err_details[9].toCharArray(),0,err_details[9].length());
747 endElement(messages.getString("SendFormTime"));
748
749 startElement(messages.getString("OperatingSystem"));
750 characters(err_details[10].toCharArray(),0,err_details[10].length());
751 endElement(messages.getString("OperatingSystem"));
752
753 startElement(messages.getString("Java"));
754
755 startElement(messages.getString("JavaInformation"));
756 characters(err_details[11].toCharArray(),0,err_details[11].length());
757 endElement(messages.getString("JavaInformation"));
758
759 startElement(messages.getString("TotalMemory"));
760 characters(err_details[21].toCharArray(),0,err_details[21].length());
761 endElement(messages.getString("TotalMemory"));
762
763 startElement(messages.getString("MaxMemory"));
764 characters(err_details[22].toCharArray(),0,err_details[22].length());
765 endElement(messages.getString("MaxMemory"));
766
767 startElement(messages.getString("FreeMemory"));
768 characters(err_details[23].toCharArray(),0,err_details[23].length());
769 endElement(messages.getString("FreeMemory"));
770
771 startElement(messages.getString("DefaultLocale"));
772 characters(err_details[12].toCharArray(),0,err_details[12].length());
773 endElement(messages.getString("DefaultLocale"));
774
775
776 endElement(messages.getString("Java"));
777
778 startElement(messages.getString("Browser"));
779 characters(err_details[13].toCharArray(),0,err_details[13].length());
780 endElement(messages.getString("Browser"));
781
782 startElement(messages.getString("LocalHostName"));
783 characters(err_details[14].toCharArray(),0,err_details[14].length());
784 endElement(messages.getString("LocalHostName"));
785
786 startElement(messages.getString("LocalHostAddress"));
787 characters(err_details[15].toCharArray(),0,err_details[15].length());
788 endElement(messages.getString("LocalHostAddress"));
789
790 startElement(messages.getString("ScreenResolution"));
791 characters(err_details[16].toCharArray(),0,err_details[16].length());
792 endElement(messages.getString("ScreenResolution"));
793
794 if (img!=null)
795 {
796 startElement("Sequences");
797 int i;
798 for ( i = 0 ; i < img.length ; i= i + 10)
799 {
800 startElement("Sequence");
801
802 startElement("Title");
803 characters(img[i].toCharArray(),0,img[i].length());
804 endElement("Title");
805
806 startElement("Details");
807 characters(img[i+9].toCharArray(),0,img[i+9].length());
808 endElement("Details");
809
810 startElement("ImageDescription");
811
812 startElement("ScreenShot");
813 startElement("Image");
814 saveImage(img[i+2],img[i+7],img[i+8]);
815 endElement("Image");
816 endElement("ScreenShot");
817
818 startElement("ErrorLineAndScreenShot");
819 startElement("Image");
820 saveImage(img[i+4],img[i+7],img[i+8]);
821 endElement("Image");
822 endElement("ErrorLineAndScreenShot");
823
824 startElement("ErrorLineForScreenShot");
825 startElement("Image");
826 saveImage(img[i+6],img[i+7],img[i+8]);
827 endElement("Image");
828 endElement("ErrorLineForScreenShot");
829
830 endElement("ImageDescription");
831
832 endElement("Sequence");
833 }
834 endElement("Sequences");
835 }
836
837 endElement(messages.getString("BUGS"));
838
839 JPanel pane;
840 pane = new JPanel();
841 pane.add(scroll);
842 pane.setBackground(new Color(176,208,176));
843 pane.setBorder(new EmptyBorder(new Insets(10,10,10,10)));
844
845 return pane;
846 }
847
848 /**
849 * This will add the UserComponent to the tree.
850 * @param sx is the UserComponent to be added.
851 */
852 public void showReport (UserComponent sx)
853 {
854 String type;
855 type = sx.getType();
856 String title;
857 title = sx.getTitle();
858 ArrayList content;
859 content = sx.getContent();
860 String selected;
861 selected = sx.getSelected();
862 String visible;
863 visible = sx.getVisible();
864 String image;
865 image = sx.getImage();
866 String img;
867 img = sx.getImageFileName();
868 String width;
869 width = sx.getWidth();
870 String height;
871 height = sx.getHeight();
872 String tooltip;
873 tooltip = sx.getToolTip();
874
875 if (type != null)
876 {
877 startContent(1);
878 saveContent(type);
879 closeContent(1);
880 }
881
882 if (title != null)
883 {
884 startContent(2);
885 saveContent(title);
886 closeContent(2);
887 }
888
889 if (content != null)
890 {
891 startContent(3);
892 int j;
893 for ( j = 0 ; j < content.size() ; j++)
894 {
895 if (content.get(j) instanceof String)
896 saveContent((String) content.get(j));
897 else if (content.get(j) instanceof UserComponent)
898 {
899 startContent(0);
900 UserComponent cmp;
901 cmp = (UserComponent) content.get(j);
902 showReport(cmp);
903 closeContent(0);
904 }
905 }
906 closeContent(3);
907 }
908
909 if (selected != null)
910 {
911 startContent(4);
912 saveContent(selected);
913 closeContent(4);
914 }
915
916 if (visible != null)
917 {
918 startContent(5);
919 saveContent(visible);
920 closeContent(5);
921 }
922
923 if (img != null)
924 {
925 startContent(6);
926 saveImage(img,width,height);
927 closeContent(6);
928 }
929 else
930 {
931 if (image != null)
932 {
933 startContent(11);
934 saveContent(image);
935 closeContent(11);
936 }
937 }
938
939 if (tooltip != null)
940 {
941 startContent(12);
942 saveContent(tooltip);
943 closeContent(12);
944 }
945 }
946
947 /**
948 * This method will give what type of information this node hold according the number
949 * @param num the number that describe what type of information it hold.
950 */
951 public void startContent (int num)
952 {
953 switch(num)
954 {
955 case 0: startElement(messages.getString("COMPONENT"));
956 break;
957 case 1: startElement(messages.getString("Type"));
958 break;
959 case 2: startElement(messages.getString("Title"));
960 break;
961 case 3: startElement(messages.getString("Content"));
962 break;
963 case 4: startElement(messages.getString("Selected"));
964 break;
965 case 5: startElement(messages.getString("Visible"));
966 break;
967 case 6: startElement(messages.getString("Image"));
968 break;
969 case 7: startElement(messages.getString("Date"));
970 break;
971 case 8: startElement(messages.getString("Command"));
972 break;
973 case 9: startElement(messages.getString("COMPONENTS"));
974 break;
975 case 10:startElement(messages.getString("LOG"));
976 break;
977 case 11:startElement(messages.getString("Icon"));
978 break;
979 case 12:startElement(messages.getString("ToolTipText"));
980 break;
981 case 13:startElement(messages.getString("Comment"));
982 break;
983 }
984 }
985
986 /**
987 * This will add the text content to the current node.
988 * @param text is the text content of the current node.
989 */
990 public void saveContent (String text)
991 {
992 if (text == null)
993 text = "\t";
994 characters(text.toCharArray(),0,text.length());
995 }
996
997 /**
998 * This will say that what type of information that has been finished added
999 * accroding its number.
1000 * @param num the number that describe what type of information it hold.
1001 */
1002 public void closeContent (int num)
1003 {
1004 switch(num)
1005 {
1006 case 0: endElement(messages.getString("COMPONENT"));
1007 break;
1008 case 1: endElement(messages.getString("Type"));
1009 break;
1010 case 2: endElement(messages.getString("Title"));
1011 break;
1012 case 3: endElement(messages.getString("Content"));
1013 break;
1014 case 4: endElement(messages.getString("Selected"));
1015 break;
1016 case 5: endElement(messages.getString("Visible"));
1017 break;
1018 case 6: endElement(messages.getString("Image"));
1019 break;
1020 case 7: endElement(messages.getString("Date"));
1021 break;
1022 case 8: endElement(messages.getString("Command"));
1023 break;
1024 case 9: endElement(messages.getString("COMPONENTS"));
1025 break;
1026 case 10:endElement(messages.getString("LOG"));
1027 break;
1028 case 11:endElement(messages.getString("Icon"));
1029 break;
1030 case 12:endElement(messages.getString("ToolTipText"));
1031 break;
1032 case 13:endElement(messages.getString("Comment"));
1033 break;
1034 }
1035 }
1036
1037 /**
1038 * This method will add the this string to the appropriate place in the tree.
1039 * @param type its the type to be added to the tree.
1040 */
1041 public void startElement (String type)
1042 {
1043
1044 if ((comm_bool == true)&&(comm_start == true))
1045 {
1046 if (new_tree == true)
1047 {
1048 if (type == messages.getString("HISTORY"))
1049 {
1050 rootNode4 = new DefaultMutableTreeNode(messages.getString("HISTORYCOMMANDS"));
1051 treeModel4 = new DefaultTreeModel(rootNode4);
1052
1053 parentNode4 = rootNode4;
1054 tree4 = new JTree(treeModel4);
1055 tree4.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
1056 tree4.setBackground(new Color(224,240,224));
1057 tree4.setEditable(false);
1058 tree4.setShowsRootHandles(true);
1059 }
1060 else
1061 {
1062 currNode4 = new DefaultMutableTreeNode(type + " : ");
1063 treeModel4.insertNodeInto(currNode4,parentNode4,parentNode4.getChildCount());
1064 parentNode4 = currNode4;
1065 }
1066 }
1067 else
1068 {
1069 if (type == messages.getString("HISTORY"))
1070 {
1071 rootNode2 = new DefaultMutableTreeNode(messages.getString("HISTORYCOMMANDS"));
1072 treeModel2 = new DefaultTreeModel(rootNode2);
1073
1074 parentNode2 = rootNode2;
1075 tree2 = new JTree(treeModel2);
1076 tree2.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
1077 tree2.setBackground(new Color(224,240,224));
1078 tree2.setEditable(false);
1079 tree2.setShowsRootHandles(true);
1080 }
1081 else
1082 {
1083 currNode2 = new DefaultMutableTreeNode(type + " : ");
1084 treeModel2.insertNodeInto(currNode2,parentNode2,parentNode2.getChildCount());
1085 parentNode2 = currNode2;
1086 }
1087 }
1088 }
1089
1090 if ((type == messages.getString("COMMENTS"))||(type == messages.getString("BUGS"))||
1091 (type == messages.getString("HISTORY")))
1092 {
1093 if (new_tree == true)
1094 {
1095 rootNode3 = new DefaultMutableTreeNode(type);
1096 treeModel3 = new DefaultTreeModel(rootNode3);
1097
1098 parentNode3 = rootNode3;
1099 tree3 = new JTree(treeModel3);
1100 tree3.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
1101
1102 tree3.setBackground(new Color(224,240,224));
1103 tree3.setEditable(false);
1104 tree3.setShowsRootHandles(true);
1105 }
1106 else
1107 {
1108 rootNode = new DefaultMutableTreeNode(type);
1109 treeModel = new DefaultTreeModel(rootNode);
1110
1111 parentNode = rootNode;
1112 tree = new JTree(treeModel);
1113 tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
1114
1115 tree.setBackground(new Color(224,240,224));
1116 tree.setEditable(false);
1117 tree.setShowsRootHandles(true);
1118 }
1119 }
1120 else
1121 {
1122 if (new_tree == true)
1123 {
1124 currNode3 = new DefaultMutableTreeNode(type + " : ");
1125 treeModel3.insertNodeInto(currNode3,parentNode3,parentNode3.getChildCount());
1126 parentNode3 = currNode3;
1127 }
1128 else
1129 {
1130 currNode = new DefaultMutableTreeNode(type + " : ");
1131 treeModel.insertNodeInto(currNode,parentNode,parentNode.getChildCount());
1132 parentNode = currNode;
1133 }
1134 }
1135 }
1136
1137 /**
1138 * This method is to mark that we finished adding the type to the tree.
1139 * @param type type that finished added to the tree.
1140 */
1141 public void endElement (String type)
1142 {
1143 if ((type == messages.getString("HISTORY"))||(type == messages.getString("BUGS"))||
1144 (type == messages.getString("COMMENTS")))
1145 {
1146 if (new_tree == true)
1147 {
1148 scroll3 = new JScrollPane(tree3);
1149 scroll3.setPreferredSize(new Dimension(600,600));
1150 if (comm_bool == true)
1151 {
1152 scroll4 = new JScrollPane(tree4);
1153 scroll4.setPreferredSize(new Dimension(600,600));
1154 }
1155 }
1156 else
1157 {
1158 scroll = new JScrollPane(tree);
1159 scroll.setPreferredSize(new Dimension(600,600));
1160 if (comm_bool == true)
1161 {
1162 scroll2 = new JScrollPane(tree2);
1163 scroll2.setPreferredSize(new Dimension(600,600));
1164 }
1165 }
1166 }
1167 else
1168 {
1169 if (new_tree == true)
1170 {
1171 parentNode3 = (DefaultMutableTreeNode) parentNode3.getParent();
1172
1173 if ((comm_bool == true)&&(comm_start == true))
1174 {
1175 if (parentNode4 == null) return;
1176 parentNode4 = (DefaultMutableTreeNode) parentNode4.getParent();
1177 }
1178 }
1179 else
1180 {
1181 parentNode = (DefaultMutableTreeNode) parentNode.getParent();
1182
1183 if ((comm_bool == true)&&(comm_start == true))
1184 {
1185 if (parentNode2 == null) return;
1186 parentNode2 = (DefaultMutableTreeNode) parentNode2.getParent();
1187 }
1188 }
1189 }
1190 }
1191
1192 /*public BufferedImage iconToImage(Icon icon, Component targetComponent)
1193 {
1194 int w = icon.getIconWidth();
1195 int h = icon.getIconHeight();
1196 GraphicsConfiguration gc = targetComponent.getGraphicsConfiguration();
1197 BufferedImage image = gc.createCompatibleImage(w, h);
1198 Graphics2D g = image.createGraphics();
1199 icon.paintIcon(targetComponent,g,0,0);
1200 g.dispose();
1201 return image;
1202 }
1203
1204 public BufferedImage savingImage (ImageIcon img)
1205 {
1206 JFrame f = new JFrame();
1207 f.setVisible(false);
1208 BufferedImage image = iconToImage(img,f);
1209 f.dispose();
1210 return image;
1211 }*/
1212
1213 /**
1214 * This will add the image filename,width and height to the tree.
1215 * @param filename image's filename
1216 * @param width image's width
1217 * @param height image's height
1218 */
1219 public void saveImage (String filename,String width,String height)
1220 {
1221 startElement(messages.getString("Title"));
1222 characters(filename.toCharArray(),0,filename.length());
1223 endElement(messages.getString("Title"));
1224
1225 startElement(messages.getString("Size"));
1226
1227 startElement(messages.getString("Width"));
1228 characters(width.toCharArray(),0,width.length());
1229 endElement(messages.getString("Width"));
1230
1231 startElement(messages.getString("Height"));
1232 characters(height.toCharArray(),0,height.length());
1233 endElement(messages.getString("Height"));
1234
1235 endElement(messages.getString("Size"));
1236
1237 /*JFrame f = new JFrame();
1238 f.setVisible(false);
1239 BufferedImage image = savingImage(img);
1240 BufferedImage bi = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);
1241 Graphics2D big = bi.createGraphics();
1242 big.drawImage(image.getScaledInstance(400,400,Image.SCALE_SMOOTH),0,0,f);
1243 f.dispose();
1244
1245
1246 JLabel label = new JLabel(new ImageIcon(bi));
1247 label.setPreferredSize(new Dimension(400,400));
1248 currNode = new DefaultMutableTreeNode(label);
1249 treeModel.insertNodeInto(currNode,parentNode,parentNode.getChildCount());*/
1250 }
1251
1252 /**
1253 * This method will add the characters to the current node's type.
1254 * @param ch is the char[] that is need to be added to the current node's type.
1255 * @param start is where we should start taking from ch.
1256 * @param len is the length of charcacters we should take from ch
1257 */
1258 public void characters (char[] ch, int start, int len)
1259 {
1260 String text;
1261 text = new String(ch,start,len);
1262 String text1;
1263 text1 = text.trim();
1264 if (text1.length() > 0)
1265 {
1266 if ((comm_bool == true)&&(comm_start == true))
1267 {
1268 if (new_tree == true)
1269 {
1270 String txt2;
1271 txt2 = (String) currNode4.getUserObject();
1272 currNode4.setUserObject(txt2 + text1);
1273 }
1274 else
1275 {
1276 String txt2;
1277 txt2 = (String) currNode2.getUserObject();
1278 currNode2.setUserObject(txt2 + text1);
1279 }
1280 }
1281
1282 if (new_tree == true)
1283 {
1284 String txt;
1285 txt = (String) currNode3.getUserObject();
1286 currNode3.setUserObject(txt + text1);
1287 }
1288 else
1289 {
1290 String txt;
1291 txt = (String) currNode.getUserObject();
1292 currNode.setUserObject(txt + text1);
1293 }
1294 }
1295 }
1296 }
1297
1298}
1299
1300
1301
1302
1303
1304
Note: See TracBrowser for help on using the repository browser.