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

Last change on this file since 24915 was 12297, checked in by kjdon, 18 years ago

changed = to ==

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 58.6 KB
Line 
1package org.greenstone.gatherer.feedback;
2
3import javax.swing.*;
4import java.awt.*;
5import java.awt.event.*;
6import java.util.*;
7import javax.swing.tree.*;
8import javax.swing.event.*;
9import javax.swing.text.*;
10import java.io.*;
11import java.awt.image.*;
12import java.util.Locale;
13import java.util.ResourceBundle;
14import java.text.MessageFormat;
15import javax.swing.border.*;
16import java.text.*;
17
18import org.greenstone.gatherer.util.JarTools;
19
20/**
21 * This is the special class listener.
22 * <p>This class will record all the action did to any of the
23 * component inside the window that were open by the application.
24 * <br> This listener will start listening since the beginning of the application
25 * until the user quits from the application. It will record :
26 * <br>1. All the information about the window and its components where the action occured.
27 * <br>2. All the information about all windows and its components that were open when the action occured.
28 * <br>Note : point 1 and 2 only start when user wants to send feedback.
29 * <br>3. The action's command the user did.
30 * <br>4. The date of when the action occured.
31 * <br><br>The history of the action will be stored in history.log file, which then will be compressed
32 * to a zip file called MyZipFile.zip.</p>
33 * <p>The listener this class implements are only the listener interface that a javax.swing.* component
34 * could have as stated in API.Some of the listener however is not implemented here as it is considered the event
35 * listened by those listener are not essential to be recorded as they not making any major changes
36 * to the application.</p>
37 * <p>This listener will only record maximum last 60 instructions user did to the application.</p>
38 * <p>In this class also we can add some stuff globally through out all the window open by
39 * the application.
40 * <br>This is the class will add a menu called Feedback through out all the window of type JFrame or JDialog
41 * open by the application.This menu will allow user to either sending feedback or viewing the history
42 * of all the action user did so far.
43 * @author Veronica Liesaputra
44 */
45public class ActionRecorderDialog
46 implements ActionListener,TreeModelListener,ItemListener,ListDataListener,ChangeListener,
47 ListSelectionListener,MenuListener,TableColumnModelListener,TreeSelectionListener
48{
49 /**
50 * This hold the title of the window where the action occured.
51 */
52 private String myframe;
53
54 /**
55 * This hold the title of the window where user called send feedback.
56 */
57 private String feedbackframe;
58
59 /**
60 * This hold the instance of ComponentInformation to get all the information inside a window.
61 */
62 private ComponentInformation compInfo;
63
64 /**
65 * This will hold a record of the action that user just did at the moment.
66 */
67 private History log;
68
69 /**
70 * This will reference to the window where the action occured.
71 */
72 private Window point;
73
74 /**
75 * This hold the vector of all the History instances of all the record of action user did
76 * so far.
77 * This vector will hold the history of all the 30 actions user just did.
78 * There are 2 situation for this vector :
79 * <br>1. Before user choose to send feedback.
80 * <br>Here, If we want to add another record to the vector when the vector size already 30 then,
81 * all the 30 records inside the vector will be saved in the temp_history.log file. The vector will
82 * be cleared and then added with the new record.
83 * <br>If the user quits the application, then whats in the vector will be saved to history.log file.
84 * <br>2. After user choose to send feedback.
85 * <br>When user choose to send feedback,then what happen is what ever inside the vector at the moment
86 * will be saved to history.log file and then vector will be cleared and it will add the new instruction.
87 * <br> If we want to add another record to the vector when the vector size already 30 then,
88 * all the 30 records inside the vector will be saved in the temp_feedbackhist.log file. The vector will
89 * be cleared and then added with the new record.
90 * <br> If the user finished with the feedback then it will cleared all the vector and load the vector
91 * inside the history.log to it and add the new record to the vector.
92 * <br> If the user quits the application, then whats in the vector will not be saved.
93 */
94 private static Vector vector;
95
96 /**
97 * This is the flag to tell whether or not the image for the window where the action occured is
98 * finished being added properly to the appropriate record.
99 * If savefinish = true then it means that the thread of adding image to the record stop, otherwise
100 * it means its not yet finished so don't stop the thread.
101 */
102 private static boolean savefinish = true;
103
104 /**
105 * This is the thread that contains all the code that the application should be when the user exiting
106 * the application.
107 */
108 private Thread writeThread;
109
110 /**
111 * This is the thread that contains all the code to add the image of the window where the action
112 * occured to the proper record.
113 * This thread will stop if savefinish = true.
114 */
115 private Thread saveThread;
116
117 /**
118 * This is the runtime of this application.
119 */
120 private Runtime run;
121
122 /**
123 * This variable will hold the resource of the words that is stored in feedback.properties file.
124 * The calling using messages.getString(someString) will caused someString to be translated
125 * into some other string that is hold in that file.usually it will caused it to be translated
126 * to the language that the user use or choose to have as stated in Locale.
127 */
128 private static ResourceBundle messages;
129
130 /**
131 * This is an instance of ScreenShot that will allow this application to take screen shot of the whole
132 * screen or just the screen shot of the window where the actions occured.
133 */
134 private ScreenShot sh;
135
136 /**
137 * This HashMap stored the pair of model and its component.
138 * This will allow this listener to know which component the model where the actions occured belongs to.
139 */
140 private HashMap modelHash;
141
142 /**
143 * This is the flag variable to sign that the user start the Reporting Feedback sequence.
144 * If start_rec = false means that the user did not start reporting feedback sequence.
145 * Otherwise, it means the user start reporting feedback sequence, here there will be changes in the
146 * content of the vector used to save all the records.This also will change the appearance of the
147 * window that are currently open by the application. it will make toolbar value = true, rec = true and
148 * stop_rec = false.
149 */
150 private boolean start_rec = false;
151
152 /**
153 * This is the flag variable to sign that the user are now recording the Reporting Feedback sequence.
154 * If rec = true, it means its recording, otherwise its false.It also will decide
155 * the GUI appearance of the window that are currently open by the application.
156 */
157 private boolean rec = false;
158
159 /**
160 * This is the flag variable to sign that user are finished the Reporting Feedback sequence.
161 * If stop_rec = false, then it means user stop the Reporting Feedback sequence.So here, there will
162 * be changes in the vector's content. If rec = true then it will also delete the added toolbar on the currently open
163 * window by the application and its also will delete all the history and file taken when user doing the
164 * Reporting Feedback sequence.
165 */
166 private boolean stop_rec = true;
167
168 /**
169 * This is the thread do task to take history of the actions.
170 */
171 private Thread saveallThread;
172
173 /**
174 * This is the flag to say whether or not the send feedback button been pushed by user.
175 */
176 private boolean start_fd = false;
177
178 /**
179 * This is a blocker to say that user cannot do anything while we taking history.
180 */
181 private MouseListener mouse_blocker_listener = new MouseAdapter() {};
182
183 /**
184 * This is the feedback interface window.
185 */
186 private FeedbackInterface frame;
187
188 /**
189 * This is an instance of CompListener that will add listener to all the components inside it.
190 */
191 private CompListener compList;
192
193 /**
194 * This is the accelerator key (shortcuts key) for taking screenshot.
195 */
196 private KeyStroke shKey;
197
198 /**
199 * This is the accelerator key (shortcuts key) for reporting feedback.
200 */
201 private KeyStroke fdKey;
202
203 /**
204 * This is the accelerator key (shortcuts key) for viewing history.
205 */
206 private KeyStroke histKey;
207
208 /**
209 * This is the accelerator key (shortcuts key) for sending feedback straight away.
210 */
211 private KeyStroke sndfdKey;
212
213 /**
214 * This is the window that is active at the moment.
215 */
216 private Window activeWindow;
217
218 /**
219 * This is the modal window where user wants to take the screeshot or sending feedback.
220 */
221 private Window modalWindow;
222
223 /**
224 * This constructor will seeting up the data member to its appropriate value.
225 * It will get the vector that are stored in the history.log file and also it will
226 * setup the writeThread.
227 * @param currentLocale is the locale user choose all the text to be displayed as.
228 */
229 public ActionRecorderDialog (Locale currentLocale)
230 {
231 messages = ResourceBundle.getBundle("feedback",currentLocale);
232 setup_UIManager();
233
234 fdKey = KeyStroke.getKeyStroke("F2");
235 histKey = KeyStroke.getKeyStroke("F3");
236 shKey = KeyStroke.getKeyStroke("F5");
237 sndfdKey = KeyStroke.getKeyStroke("F12");
238 /*shKey = KeyStroke.getKeyStroke(KeyEvent.VK_SLASH,InputEvent.CTRL_MASK|
239 InputEvent.SHIFT_MASK);*/
240
241 final ZipFile zip;
242 zip = new ZipFile();
243 zip.unZipFile();
244 vector = getPrev_log("history.log");
245 sh = new ScreenShot();
246 modelHash = new HashMap();
247 compInfo = new ComponentInformation(this,currentLocale,modelHash);
248 compList = new CompListener(this,modelHash);
249 EventQueue eq;
250 eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
251 eq.push(new MyEventQueue());
252 run = Runtime.getRuntime();
253 Runnable writeRun;
254 writeRun = new Runnable()
255 {
256 public void run()
257 {
258 try
259 {
260 if (stop_rec == true)
261 {
262 File f;
263 f = new File("history.log");
264 FileOutputStream fos;
265 fos = new FileOutputStream("history.log");
266 ObjectOutputStream oos;
267 oos = new ObjectOutputStream(fos);
268 oos.writeObject(vector);
269 vector.removeAllElements();
270 vector = getPrev_log("temp_history.log");
271 oos.writeObject(vector);
272 oos.close();
273 f = new File("temp_history.log");
274 f.delete();
275 }
276
277 File f2;
278 f2 = new File("feedbackhist.log");
279 f2.delete();
280 f2 = new File("temp_feedbackhist.log");
281 f2.delete();
282
283 zip.sendZipFile();
284 writeThread = null;
285 }
286 catch (IOException exp) {}
287 }
288 };
289
290 writeThread = new Thread(writeRun);
291 run.addShutdownHook(writeThread);
292 }
293
294 /** change the locale for the resource bundle*/
295 public void setLocale(Locale loc) {
296 messages = ResourceBundle.getBundle("feedback",loc);
297 }
298 /**
299 * This method will setup some of the GUI appearance that window should have when the user
300 * choose to start the Reporting Feedback sequence.
301 */
302 public void setup_UIManager ()
303 {
304 // why do you do all this???
305 //UIManager.put("TabbedPane.selected",(new Color(224,240,224)));
306 //UIManager.put("Button.select",(new Color(224,240,224)));
307 //UIManager.put("ScrollBar.background",(new Color(176,208,176)));
308 //UIManager.put("ScrollBar.highlight",(new Color(224,240,224)));
309 //UIManager.put("ScrollBar.thumb",(new Color(224,240,224)));
310 //UIManager.put("ScrollBar.track",(new Color(224,240,224)));
311 //UIManager.put("Tree.textBackground",new Color(224,240,224));
312 //UIManager.put("Label.font",new Font("Dialog",Font.PLAIN,12));
313 //UIManager.put("ComboBox.font",new Font("Dialog",Font.PLAIN,12));
314 //UIManager.put("TextArea.font",new Font("Dialog",Font.PLAIN,12));
315 }
316
317 /**
318 * This method will get the information about all the components inside the window that are
319 * open by the application when the action occured and save it to vector.
320 * @param comp its the component where the user did the action.
321 * @param command its the action's command the user did.
322 */
323 private void saving (final Component comp,final String command)
324 {
325 if ((command.equals(messages.getString("SendFeedback"))) ||
326 ((command.equals("FastSend")) && (stop_rec == false)))
327 {
328 start_fd = true;
329 }
330
331 Runnable saveall;
332 saveall = new Runnable ()
333 {
334 public void run ()
335 {
336 try
337 {
338 Runnable savework;
339 savework = new Runnable ()
340 {
341 public void run ()
342 {
343 Date curr_date;
344 curr_date = new Date();
345 log = new History(curr_date,command);
346
347 if ((start_fd == true)&&(command.equals(messages.getString("WindowOpened"))))
348 {
349 start_rec = true;
350 rec = true;
351 start_fd = false;
352 }
353
354 getFrame(comp,command);
355 saveState(command);
356 saveLog();
357
358 if ((point != null) && (rec == true))
359 {
360 if (command.equals(messages.getString("WindowClosed")))
361 {
362 if (point instanceof JDialog)
363 if (((JDialog)point).isModal() == true)
364 if (point == modalWindow)
365 frame.setComment(false);
366 }
367 }
368 }
369 };
370
371 SwingUtilities.invokeAndWait(savework);
372 }
373 catch (Exception ex) {ex.printStackTrace();}
374 }
375 };
376
377 saveallThread = new Thread(saveall);
378 saveallThread.start();
379 }
380
381 /**
382 * This method will get the screen shot of the window where the actions occured and
383 * add the image also its dimension to the passed record.
384 * It will caused the saveThread to start so it can allows other stuff to be run concurrently
385 * and this thread will be stopped when the screen shot of the window alreadyfinished taken.
386 * @param hst is the record where the image and its dimension should be stored to.
387 */
388 public void saveImage (final History hst)
389 {
390 Runnable saveRun;
391 saveRun = new Runnable()
392 {
393 History hist = hst;
394 public void run()
395 {
396 String img,width,height;
397 Rectangle rect;
398 int w, h,dimwidth,dimheight;
399
400 if (point != null)
401 {
402 dimwidth = sh.getWidth();
403 dimheight = sh.getHeight();
404
405 w = point.getWidth();
406 h = point.getHeight();
407
408 try
409 {
410 rect = new Rectangle(point.getLocationOnScreen(),
411 new Dimension(w,h));
412
413 if (w >= dimwidth)
414 w = dimwidth - 50;
415
416 width = "" + w;
417
418 if (h >= dimheight)
419 h = dimheight - 50;
420
421 height = "" + h;
422 }
423 catch (IllegalComponentStateException exp)
424 {
425 rect = null;
426 width = null;
427 height = null;
428 }
429 }
430 else
431 {
432 rect = null;
433 width = null;
434 height = null;
435 }
436
437 if (rect != null)
438 {
439 img = sh.getImage(rect);
440 if (savefinish == true)
441 {
442 hist.setImage(img,height,width);
443 }
444 }
445 }
446 };
447
448 Thread saveThread;
449 saveThread = new Thread(saveRun);
450 saveThread.start();
451 }
452
453 /**
454 * This method will setup the savefinish value.
455 * (Precondition: (save != null))
456 * @param save the value savefinish should have.
457 */
458 public static void setSavefinish (boolean save)
459 {
460 savefinish = save;
461 }
462
463
464 /**
465 * This method will make the JMenu that is should be added to all the
466 * window opened by the application.
467 * <br>If rec = false then the JMenu will give user option to start the Reporting Feedback sequence
468 * or Sending feedback or to view the history of actions they have done so far.
469 * <br>If rec = true then the JMenu will only give user option to view the history of actions
470 * they have done so far or sending feedback or taking screenshot.
471 * @return JMenu that should be added to all window open.
472 */
473 public JMenu makeMenu ()
474 {
475 JMenu menu;
476 JMenuItem item,item2,item3;
477 ImageIcon icon,icon2,icon3;
478
479 icon3 = JarTools.getImage("fastsend.gif");
480 item3 = new JMenuItem(messages.getString("SendFeedback"),
481 new ImageIcon(icon3.getImage().getScaledInstance
482 (20,20,Image.SCALE_SMOOTH)));
483 item3.setActionCommand("FastSend");
484 item3.addActionListener(this);
485 item3.setMnemonic(KeyEvent.VK_N);
486 item3.setAccelerator(sndfdKey);
487 item3.setToolTipText("Send feedback now");
488
489 item = null;
490
491 if (rec == false)
492 {
493 icon = JarTools.getImage("feedback.gif");
494 item = new JMenuItem("Report Feedback",
495 new ImageIcon(icon.getImage().getScaledInstance
496 (20,20,Image.SCALE_SMOOTH)));
497 item.setActionCommand(messages.getString("SendFeedback"));
498 item.addActionListener(this);
499 item.setMnemonic(KeyEvent.VK_F);
500 item.setAccelerator(fdKey);
501 item.setToolTipText("Report feedback");
502 }
503 else
504 {
505 icon = JarTools.getImage("camera.gif");
506 item = new JMenuItem(messages.getString("ScreenShot"),
507 new ImageIcon(icon.getImage().getScaledInstance
508 (20,20,Image.SCALE_SMOOTH)));
509 item.setActionCommand("ScreenShot");
510 item.setMnemonic(KeyEvent.VK_S);
511 item.addActionListener(this);
512 item.setAccelerator(shKey);
513 item.setToolTipText("Take screenshot of the whole screen.");
514 }
515
516 icon2 = JarTools.getImage("history.gif");
517 item2 = new JMenuItem(messages.getString("LookHistory"),
518 new ImageIcon(icon2.getImage().getScaledInstance
519 (20,20,Image.SCALE_SMOOTH)));
520 item2.setActionCommand(messages.getString("LookHistory"));
521 item2.addActionListener(this);
522 item2.setMnemonic(KeyEvent.VK_H);
523 item2.setAccelerator(histKey);
524 item2.setToolTipText(messages.getString("LookHistoryButton"));
525
526 menu = new JMenu (messages.getString("Feedback"));
527 menu.setMnemonic(KeyEvent.VK_D);
528
529
530 if (item != null)
531 menu.add(item);
532
533 menu.add(item3);
534
535 menu.add(item2);
536
537 if (rec == true)
538 menu.setBackground(new Color(176,209,217));
539 else
540 menu.setBackground(new Color(204,204,204));
541
542 return menu;
543 }
544
545 public void refreshLocationAndSize(Window window) {
546
547 window.setLocation(window.getX(),window.getY());
548
549 Toolkit kit;
550 kit = Toolkit.getDefaultToolkit();
551 Dimension screenSize;
552 screenSize = kit.getScreenSize();
553 int screenHeight;
554 screenHeight = screenSize.height;
555 int screenWidth;
556 screenWidth = screenSize.width;
557
558 if ((window.getSize().width > screenWidth) &&
559 (window.getSize().height > screenHeight)) {
560 window.setSize(window.getPreferredSize());
561 }
562 }
563
564
565 /**
566 * This method will setup the GUI that this window should have at the moment.
567 * If start_rec is true then JMenu don't have the option to start Reporting Feedback sequence in it.
568 * If stop_rec is true and rec is true then JMenu there should be an option to start Reporting Feedback sequence in it.
569 * The JMenu will only be affected window of type JDialog and JFrame only.
570 * (Precondition: (window != null))
571 * @param window its the window that we want to set the GUI
572 */
573 public void setUI (Window window)
574 {
575 if (start_rec == true) {
576 if (window instanceof JFrame) {
577 JFrame a;
578 a = (JFrame) window;
579
580 JMenuBar menuBar;
581 menuBar = a.getJMenuBar();
582
583 if (menuBar != null) {
584
585 JMenu temp_menu;
586 temp_menu = menuBar.getMenu(menuBar.getMenuCount() - 1);
587 temp_menu.setBackground(new Color(176,209,217));
588 temp_menu.remove(0);
589
590 JMenuItem item;
591 ImageIcon icon;
592 icon = JarTools.getImage("camera.gif");
593 item = new JMenuItem(messages.getString("ScreenShot"),
594 new ImageIcon(icon.getImage().getScaledInstance
595 (20,20,Image.SCALE_SMOOTH)));
596 item.setActionCommand("ScreenShot");
597 item.setMnemonic(KeyEvent.VK_S);
598 item.addActionListener(this);
599 item.setAccelerator(shKey);
600 item.setToolTipText("Take screenshot of this window");
601
602 temp_menu.insert(item,0);
603 }
604
605 refreshLocationAndSize(a);
606 a.validate();
607 a.repaint();
608 }
609 else if (window instanceof JDialog) {
610
611 JDialog a;
612 a = (JDialog) window;
613 JMenuBar menuBar;
614 menuBar = a.getJMenuBar();
615
616 if (menuBar != null) {
617
618 JMenu temp_menu;
619 temp_menu = menuBar.getMenu(menuBar.getMenuCount() - 1);
620 temp_menu.setBackground(new Color(176,209,217));
621 temp_menu.remove(0);
622
623 JMenuItem item;
624 ImageIcon icon;
625 icon = JarTools.getImage("camera.gif");
626 item = new JMenuItem(messages.getString("ScreenShot"),
627 new ImageIcon(icon.getImage().getScaledInstance
628 (20,20,Image.SCALE_SMOOTH)));
629 item.setActionCommand("ScreenShot");
630 item.setMnemonic(KeyEvent.VK_S);
631 item.addActionListener(this);
632 item.setAccelerator(shKey);
633 item.setToolTipText("Take screenshot of this window");
634
635 temp_menu.insert(item,0);
636 }
637 refreshLocationAndSize(a);
638 a.validate();
639 a.repaint();
640 }
641 else if (window instanceof JWindow) {
642 JWindow a;
643 a = (JWindow) window;
644
645 ((JComponent) a.getContentPane()).unregisterKeyboardAction(fdKey);
646
647 ((JComponent) a.getContentPane()).registerKeyboardAction(this, "ScreenShot", shKey,JComponent.WHEN_IN_FOCUSED_WINDOW);
648 }
649 else
650 return;
651 }
652 else {
653
654 if ((stop_rec == true) && (rec == true)) {
655
656 if (window instanceof JFrame) {
657 JFrame a;
658 a = (JFrame) window;
659
660 JMenuBar menuBar;
661 menuBar = a.getJMenuBar();
662
663 if (menuBar != null) {
664
665 JMenu temp_menu;
666 temp_menu = menuBar.getMenu(menuBar.getMenuCount() - 1);
667 temp_menu.setBackground(new Color(204,204,204));
668 temp_menu.remove(0);
669
670 ImageIcon icon;
671 JMenuItem item;
672
673 icon = JarTools.getImage("feedback.gif");
674 item = new JMenuItem("Report Feedback", new ImageIcon(icon.getImage().getScaledInstance(20,20,Image.SCALE_SMOOTH)));
675 item.setActionCommand(messages.getString("SendFeedback"));
676 item.addActionListener(this);
677 item.setMnemonic(KeyEvent.VK_F);
678 item.setAccelerator(fdKey);
679 item.setToolTipText(messages.getString("SendFeedbackButton"));
680
681 temp_menu.insert(item,0);
682 }
683 a.setSize(a.getPreferredSize());
684 a.validate();
685 a.repaint();
686 }
687 else if (window instanceof JDialog) {
688 JDialog a;
689 a = (JDialog) window;
690
691 JMenuBar menuBar;
692 menuBar = a.getJMenuBar();
693
694 if (menuBar != null) {
695
696 JMenu temp_menu;
697 temp_menu = menuBar.getMenu(menuBar.getMenuCount() - 1);
698 temp_menu.setBackground(new Color(204,204,204));
699 temp_menu.remove(0);
700
701 ImageIcon icon;
702 JMenuItem item;
703
704 icon = JarTools.getImage("feedback.gif");
705 item = new JMenuItem("Report Feedback", new ImageIcon(icon.getImage().getScaledInstance(20,20,Image.SCALE_SMOOTH)));
706 item.setActionCommand(messages.getString("SendFeedback"));
707 item.addActionListener(this);
708 item.setMnemonic(KeyEvent.VK_F);
709 item.setAccelerator(fdKey);
710 item.setToolTipText(messages.getString("SendFeedbackButton"));
711
712 temp_menu.insert(item,0);
713 }
714 a.setSize(a.getPreferredSize());
715 a.validate();
716 a.repaint();
717 }
718 else if (window instanceof JWindow) {
719 JWindow a;
720 a = (JWindow) window;
721
722 ((JComponent) a.getContentPane()).registerKeyboardAction(this, messages.getString("SendFeedback"), fdKey, JComponent.WHEN_IN_FOCUSED_WINDOW);
723
724 ((JComponent) a.getContentPane()).unregisterKeyboardAction(shKey);
725
726 }
727 else
728 return;
729 }
730 else
731 return;
732 }
733 }
734
735 /**
736 * This will make an Window[] convert to ArrayList that contain list of Window.
737 * (Precondition: (windows != null))
738 * @param windows the array that we want to convert to ArrayList
739 * @return the array list that contains all object in array windows.
740 */
741 public ArrayList addToArrayList (Window[] windows,ArrayList arr)
742 {
743 int i;
744
745 for (i = 0 ; i < windows.length ; i++)
746 {
747 arr.add(windows[i]);
748 }
749
750 return arr;
751 }
752
753 /**
754 * This method will get all the information of the window that are currently open when the action
755 * occured and these windows are not the window where the action occured.
756 * It will add these windows information to the current record and it will also setting up the
757 * GUI for each of these windows.
758 * @param command the action's command user did.
759 */
760 public void saveState(String command)
761 {
762 Window[] frame_windows;
763 ArrayList windows;
764 Frame[] frames;
765 int i,j;
766
767 if (log == null)
768 return;
769
770 windows = new ArrayList();
771
772 frames = Frame.getFrames();
773 for (i = 0 ; i<frames.length;i++)
774 {
775 frame_windows = frames[i].getOwnedWindows();
776 windows = addToArrayList(frame_windows,windows);
777
778 for (j = 0;j < frame_windows.length ; j++)
779 {
780 Window window;
781 window = frame_windows[j];
782
783 if (window == point)
784 {
785 Container cont;
786 cont = window.getParent();
787
788 if ((cont != null) && (cont instanceof Window) &&
789 (windows.contains(cont) == false)&&(cont != point))
790 {
791 if (cont instanceof ReportDetails.View) {}
792 else if (cont instanceof Movie) {}
793 else
794 {
795 setUI((Window) cont);
796
797 /*if (rec == true)
798 {
799 log.addComponent(compInfo.getInside((Window) cont),
800 messages.getString("CurrentlyOpenWindow"));
801 }
802 else*/
803 compList.getInside((Window) cont);
804
805 windows.add(cont);
806 }
807 }
808 else
809 {}
810 }
811 else
812 {
813 if (window instanceof ReportDetails.View) {}
814 else if (window instanceof Movie) {}
815 else
816 {
817 if ((window != null) && (window != point))
818 {
819 setUI(window);
820
821 if (rec == true)
822 {
823 log.addComponent(compInfo.getInside((Window) window),
824 messages.getString("CurrentlyOpenWindow"));
825 }
826 else
827 compList.getInside((Window) window);
828
829 Container cont;
830 cont = window.getParent();
831
832 if ((cont != null) && (cont instanceof Window) &&
833 (cont != point) && (windows.contains(cont) == false))
834 {
835 if (cont instanceof ReportDetails.View) {}
836 else if (cont instanceof Movie) {}
837 else
838 {
839 setUI((Window)cont);
840
841 /*if (rec == true)
842 {
843 log.addComponent(compInfo.getInside((Window) cont),
844 messages.getString("CurrentlyOpenWindow"));
845 }
846 else*/
847 compList.getInside((Window) cont);
848
849 windows.add(cont);
850 }
851 }
852 else {}
853 }
854 }
855 }
856 }
857 }
858 }
859
860 /**
861 * This method will get all the information about the window where the actions occured and it also will setting up
862 * how hthe GUI should look like in this window and it will also take the image of this window.
863 * @param comp is the component where the actions happened.
864 * @param command is the command of user's action
865 */
866 public void getFrame (Component comp,String command)
867 {
868 boolean cls;
869
870 cls = false;
871 point = null;
872
873 Container frame;
874 myframe = null;
875
876 if (comp == null)
877 return;
878 else if (comp instanceof Window)
879 frame = (Container) comp;
880 else
881 frame = SwingUtilities.getWindowAncestor(comp);
882
883 if (frame instanceof Window)
884 {
885 JMenu menu;
886 point = (Window) frame;
887
888 point.addMouseListener(mouse_blocker_listener);
889 point.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
890
891
892 if ((frame instanceof ReportDetails.View)||
893 (frame instanceof Movie))
894 {
895 log = null;
896 return;
897 }
898
899 if (command.equals(messages.getString("WindowClosed")))
900 {
901 cls = true;
902 if (frame instanceof FeedbackInterface)
903 {
904 stop_rec = true;
905 }
906 else
907 {}
908 }
909
910 if (command.equals(messages.getString("WindowOpened")))
911 {
912 menu = makeMenu();
913 }
914 else
915 {
916 menu = null;
917 }
918
919 if (frame instanceof JFrame)
920 {
921 JFrame a;
922 a = (JFrame) frame;
923
924 myframe = a.getTitle();
925
926 if (menu != null)
927 {
928 JMenuBar menuBar;
929 menuBar = a.getJMenuBar();
930
931 if (menuBar == null)
932 {
933 menuBar = new JMenuBar();
934 menuBar.add(menu);
935 a.setJMenuBar(menuBar);
936 }
937 else
938 menuBar.add(menu);
939 }
940
941 if ((menu != null))
942 {
943 refreshLocationAndSize(a);
944 a.validate();
945 a.repaint();
946 }
947 }
948 else if (frame instanceof JDialog)
949 {
950 JDialog a;
951 a = (JDialog) frame;
952
953 myframe = a.getTitle();
954
955 if (menu != null)
956 {
957 JMenuBar menuBar;
958 menuBar = a.getJMenuBar();
959
960 if (menuBar == null)
961 {
962 menuBar = new JMenuBar();
963 menuBar.add(menu);
964 a.setJMenuBar(menuBar);
965 }
966 else
967 menuBar.add(menu);
968 }
969
970 if ((menu != null))
971 {
972 refreshLocationAndSize(a);
973 a.validate();
974 a.repaint();
975 }
976 }
977 else if (frame instanceof JWindow)
978 {
979 JWindow a;
980 a = (JWindow) frame;
981
982 if (menu != null)
983 {
984 ((JComponent) a.getContentPane()).registerKeyboardAction(this,
985 messages.getString("LookHistory"),
986 histKey,
987 JComponent.WHEN_IN_FOCUSED_WINDOW);
988
989 if (rec == false)
990 {
991 ((JComponent) a.getContentPane()).registerKeyboardAction(this,
992 messages.getString("SendFeedback"),
993 fdKey,
994 JComponent.WHEN_IN_FOCUSED_WINDOW);
995
996 ((JComponent) a.getContentPane()).unregisterKeyboardAction(shKey);
997 }
998 else
999 {
1000 ((JComponent) a.getContentPane()).unregisterKeyboardAction(fdKey);
1001
1002 ((JComponent) a.getContentPane()).registerKeyboardAction(this,
1003 "ScreenShot",
1004 shKey,
1005 JComponent.WHEN_IN_FOCUSED_WINDOW);
1006 }
1007 }
1008
1009 if (cls == true)
1010 {
1011 ((JComponent) a.getContentPane()).unregisterKeyboardAction(fdKey);
1012
1013 ((JComponent) a.getContentPane()).unregisterKeyboardAction(shKey);
1014 }
1015 }
1016
1017 /*if ((command.equals(messages.getString("WindowClosed")))||
1018 (log == null))
1019 {}
1020 else
1021 saveImage(log);*/
1022
1023 /*if (rec == true)
1024 log.addComponent(compInfo.getInside(point),command);
1025 else*/
1026 compList.getInside(point);
1027
1028 if (myframe == null)
1029 myframe = " ";
1030
1031 log.setTitle(myframe);
1032
1033 return;
1034 }
1035 else
1036 return;
1037 }
1038
1039 /**
1040 * This method will add the current record to the vector.
1041 */
1042 public void saveLog()
1043 {
1044 if (start_rec == true)
1045 {
1046 save_HistLog("history.log");
1047 vector.removeAllElements();
1048 System.gc();
1049 start_rec = false;
1050 stop_rec = false;
1051 rec = true;
1052 }
1053
1054 if (log != null)
1055 vector.add(0,log);
1056
1057 if (vector.size() > 30)
1058 {
1059 if (rec == false)
1060 {
1061 save_tempHistLog("history.log");
1062 }
1063 else
1064 save_tempHistLog("feedbackhist.log");
1065 vector.removeAllElements();
1066 //vector.removeElementAt(vector.size() - 1);
1067 System.gc();
1068 }
1069
1070 if ((rec == true) && (stop_rec == true))
1071 {
1072 save_HistLog("feedbackhist.log");
1073 vector.removeAllElements();
1074 System.gc();
1075 vector = getPrev_log("history.log");
1076 File f2;
1077 f2 = new File("feedbackhist.log");
1078 f2.delete();
1079 f2 = new File("temp_feedbackhist.log");
1080 f2.delete();
1081 start_rec = false;
1082 stop_rec = true;
1083 rec = false;
1084 }
1085
1086 if (point != null)
1087 {
1088 point.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1089 point.removeMouseListener(mouse_blocker_listener);
1090 }
1091 }
1092
1093 /**
1094 * This method will save whatever in the vector at the moment to a file
1095 * with the specified filename.
1096 * Then it will also save the vector inside the file with the name "temp_"
1097 * concatenated with the specified filename into it.
1098 * (Precondition : (filename != null))
1099 * @param filename its the name of the file where the vector should be saved.
1100 */
1101 public void save_HistLog(String filename)
1102 {
1103 try
1104 {
1105 File f;
1106 f = new File(filename);
1107 FileOutputStream fos;
1108 fos = new FileOutputStream(f);
1109 ObjectOutputStream oos;
1110 oos = new ObjectOutputStream(fos);
1111 oos.writeObject(vector);
1112 vector.removeAllElements();
1113 System.gc();
1114 vector = getPrev_log("temp_"+ filename);
1115 oos.writeObject(vector);
1116 oos.close();
1117 f = new File("temp_" + filename);
1118 f.delete();
1119 writeThread = null;
1120 }
1121 catch (IOException exp) {}
1122 }
1123
1124 /**
1125 * This method will save whatever in the vector at the moment to a file with a
1126 * name "temp_" concatenated with the specified filename into it.
1127 * (Precondition : (filename != null))
1128 * @param filename its part of the name of the file where the vector should be saved.
1129 */
1130 public void save_tempHistLog(String filename)
1131 {
1132 try
1133 {
1134 File f;
1135 f = new File("temp_"+ filename);
1136 FileOutputStream fos;
1137 fos = new FileOutputStream(f);
1138 ObjectOutputStream oos;
1139 oos = new ObjectOutputStream(fos);
1140 oos.writeObject(vector);
1141 oos.close();
1142 }
1143 catch (IOException exp) {}
1144 }
1145
1146 /**
1147 * This method will get vector that is stored in a file with the specified filename and
1148 * it will also save the second vector in that file to a file with a name
1149 * temp_history.log.
1150 * If file with the specified filename does not exist then it will return a new vector.
1151 * (Precondition : (filename != null))
1152 * @param filename is the name of the file where we want to get the vector.
1153 * @return the first vector saved in the file with the specified filename.
1154 */
1155 public Vector getPrev_log(String filename)
1156 {
1157 Vector stack;
1158 ObjectInputStream ois;
1159 stack = null;
1160 try
1161 {
1162 File f;
1163 f = new File(filename);
1164 if (f.exists() == true)
1165 {
1166 FileInputStream fis;
1167 fis = new FileInputStream(f);
1168 ois = new ObjectInputStream(fis);
1169 stack = (Vector) ois.readObject();
1170
1171 Vector stack2;
1172 stack2 = null;
1173
1174 try
1175 {
1176 stack2 = (Vector) ois.readObject();
1177 }
1178 catch (EOFException e) {stack2 = null;}
1179
1180 if (stack2 != null)
1181 {
1182 File f2;
1183 f2 = new File("temp_history.log");
1184 FileOutputStream fos;
1185 fos = new FileOutputStream(f2);
1186 ObjectOutputStream oos;
1187 oos = new ObjectOutputStream(fos);
1188 oos.writeObject(stack2);
1189 oos.close();
1190 stack2.removeAllElements();
1191 stack2 = null;
1192 System.gc();
1193 }
1194
1195 ois.close();
1196 return stack;
1197 }
1198 else
1199 stack = new Vector();
1200 }
1201 catch (IOException exp) {exp.printStackTrace();}
1202 catch (ClassNotFoundException exp2) {System.out.println("class exp");}
1203
1204 return stack;
1205 }
1206
1207 /**
1208 * This method will make sure that there is something running at the moment.
1209 */
1210 private static void ensureEventThread()
1211 {
1212 if (SwingUtilities.isEventDispatchThread())
1213 {
1214 return;
1215 }
1216 throw new RuntimeException("something running");
1217 }
1218
1219 /**
1220 * This method will called the Conformation window to show up.
1221 * @param err_array this is the array containing all the information taken when user doing the Feedback form.
1222 * @param imgFile this is the array conataining the String representation of the images taken when user doing the
1223 * Feedback form.
1224 */
1225 /*public void getVector(String[] err_array,String[] imgFile)
1226 {
1227 Conformation rd;
1228 rd = new Conformation(vector,err_array,imgFile,messages);
1229 return;
1230 }*/
1231
1232 /**
1233 * This method will get the vector that hold the history.
1234 * @return the vector that hold the history stored so far.
1235 */
1236 public Vector getVector()
1237 {
1238 return vector;
1239 }
1240
1241 /**
1242 * This class will catch the window opened and window closed event.
1243 * If an application open or close a window it will be listened by this class so the information
1244 * about that window and all the other open window can be took.
1245 */
1246 class MyEventQueue extends EventQueue
1247 {
1248 /**
1249 * This method will catch the window opened and window closed event.
1250 * If an application open or close a window it will be listened by this class so the information
1251 * about that window and all the other open window can be took.
1252 * @param evt its the event.
1253 */
1254 protected void dispatchEvent(AWTEvent evt)
1255 {
1256 super.dispatchEvent(evt);
1257 int id;
1258 id = evt.getID();
1259
1260 if ((id == WindowEvent.WINDOW_OPENED)||(id == WindowEvent.WINDOW_CLOSED))
1261 {
1262 String command;
1263 command = " ";
1264
1265 if (id == WindowEvent.WINDOW_OPENED) command = messages.getString("WindowOpened");
1266 else if (id == WindowEvent.WINDOW_CLOSED) command = messages.getString("WindowClosed");
1267
1268 WindowEvent e;
1269 e = (WindowEvent) evt;
1270 Window comp;
1271 comp = e.getWindow();
1272
1273 if ((comp instanceof ReportDetails.View)||
1274 (comp instanceof Movie))
1275 return;
1276
1277 saving(comp,command);
1278 }
1279 }
1280 }
1281
1282 /**
1283 * This method will take the screenshot of the whole screen.
1284 * @param p the window where user select to take screenshot.
1285 * @return the screenshot image.
1286 */
1287 //public byte[] recreateEvent (final Window p)
1288 public BufferedImage recreateEvent (final Window p)
1289 {
1290 setup_UIManager();
1291 Rectangle rect;
1292 int w, h;
1293
1294 if (p != null)
1295 {
1296 w = p.getWidth();
1297 h = p.getHeight();
1298
1299 try
1300 {
1301 rect = new Rectangle(p.getLocationOnScreen(),
1302 new Dimension(w,h));
1303 }
1304 catch (IllegalComponentStateException exp)
1305 {
1306 rect = null;
1307 }
1308 }
1309 else
1310 {
1311 rect = null;
1312 }
1313
1314 if (rect != null)
1315 {
1316 //byte[] img;
1317 BufferedImage img;
1318 img = sh.captureScreen();
1319
1320 return img;
1321 }
1322 else
1323 return null;
1324 }
1325
1326 /**
1327 * This method will listen to any action event that occured.
1328 * It will allow this special listener class to record all the information inside all the
1329 * window open when the action occured.
1330 * @param e the ActionEvent.
1331 */
1332 public void actionPerformed(ActionEvent e)
1333 {
1334 String command;
1335 command = e.getActionCommand();
1336 Component comp;
1337 comp = (Component)e.getSource();
1338
1339 saving(comp,command);
1340
1341 if (myframe == null)
1342 myframe = " ";
1343
1344 if("FastSend".equals(e.getActionCommand()))
1345 {
1346 point.addMouseListener(mouse_blocker_listener);
1347 point.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1348
1349 BufferedImage img;
1350 boolean modal;
1351
1352 modal = false;
1353
1354 img = recreateEvent(point);
1355
1356 if (stop_rec == true)
1357 {
1358 feedbackframe = myframe;
1359
1360 JDialog.setDefaultLookAndFeelDecorated(true);
1361 stop_rec = false;
1362 frame = null;
1363 frame = new FeedbackInterface(sh,feedbackframe,messages,this);
1364 if ((img != null) && (savefinish == true))
1365 {
1366 int x,y,w,h,iw,ih;
1367 double wrat,hrat;
1368 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
1369
1370 iw = (int) (dim.getWidth() - 60);
1371 ih = (int) (dim.getHeight() * 0.75) - 50;
1372
1373 wrat = iw/((double)dim.getWidth());
1374 hrat = ih/((double)dim.getHeight());
1375
1376 w = (int) (point.getWidth() * wrat);
1377 h = (int) (point.getHeight() * hrat);
1378 x = (int) (point.getLocationOnScreen().x * wrat);
1379 y = (int) (point.getLocationOnScreen().y * hrat);
1380
1381 //frame.addScreenPanel(feedbackframe,sh.getBuffImage(),img);
1382 frame.addScreenPanel(feedbackframe,img,x,y,w,h);
1383 }
1384 frame.setVisible(false);
1385 }
1386 else
1387 {
1388 if ((img != null) &&(savefinish == true))
1389 {
1390 int x,y,w,h,iw,ih;
1391 double wrat,hrat;
1392 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
1393
1394 iw = (int) (dim.getWidth() - 60);
1395 ih = (int) (dim.getHeight() * 0.75) - 50;
1396
1397 wrat = iw/((double)dim.getWidth());
1398 hrat = ih/((double)dim.getHeight());
1399
1400 w = (int) (point.getWidth() * wrat);
1401 h = (int) (point.getHeight() * hrat);
1402 x = (int) (point.getLocationOnScreen().x * wrat);
1403 y = (int) (point.getLocationOnScreen().y * hrat);
1404
1405 //frame.addScreenPanel(feedbackframe,sh.getBuffImage(),img);
1406 if (point instanceof JDialog)
1407 modal = ((JDialog) point).isModal();
1408
1409 feedbackframe = myframe;
1410 frame.addScreenPanel(feedbackframe,img,x,y,w,h);
1411 }
1412 }
1413
1414 ActionEvent evt;
1415 evt = new ActionEvent(frame.send_button,ActionEvent.ACTION_PERFORMED,messages.getString("Send"));
1416
1417 frame.actionPerformed(evt);
1418
1419 point.removeMouseListener(mouse_blocker_listener);
1420 point.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1421 }
1422
1423 if(messages.getString("SendFeedback").equals(e.getActionCommand()))
1424 {
1425 setup_UIManager();
1426 //byte[] img;
1427 BufferedImage img;
1428 boolean modal;
1429
1430 point.addMouseListener(mouse_blocker_listener);
1431 point.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1432
1433 modal = false;
1434
1435 img = recreateEvent(point);
1436 feedbackframe = myframe;
1437 if (point instanceof JDialog)
1438 modal = ((JDialog)point).isModal();
1439
1440 JDialog.setDefaultLookAndFeelDecorated(true);
1441 stop_rec = false;
1442 frame = null;
1443 frame = new FeedbackInterface(sh,feedbackframe,messages,this);
1444 if ((img != null) && (savefinish == true))
1445 {
1446 int x,y,w,h,iw,ih;
1447 double wrat,hrat;
1448 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
1449
1450 iw = (int) (dim.getWidth() - 60);
1451 ih = (int) (dim.getHeight() * 0.75) - 50;
1452
1453 wrat = iw/((double)dim.getWidth());
1454 hrat = ih/((double)dim.getHeight());
1455
1456 w = (int) (point.getWidth() * wrat);
1457 h = (int) (point.getHeight() * hrat);
1458 x = (int) (point.getLocationOnScreen().x * wrat);
1459 y = (int) (point.getLocationOnScreen().y * hrat);
1460
1461 //frame.addScreenPanel(feedbackframe,sh.getBuffImage(),img);
1462 frame.addScreenPanel(feedbackframe,img,x,y,w,h);
1463 frame.setComment(modal);
1464
1465 if (modal == true)
1466 {
1467 modalWindow = point;
1468 }
1469 }
1470
1471 point.removeMouseListener(mouse_blocker_listener);
1472 point.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1473 }
1474
1475 if ("ScreenShot".equals(e.getActionCommand()))
1476 {
1477 point.addMouseListener(mouse_blocker_listener);
1478 point.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1479
1480 //byte[] img;
1481 BufferedImage img;
1482 boolean modal;
1483 modal = false;
1484 img = recreateEvent(point);
1485
1486 if ((img != null) &&(savefinish == true))
1487 {
1488 int x,y,w,h,iw,ih;
1489 double wrat,hrat;
1490 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
1491
1492 iw = (int) (dim.getWidth() - 60);
1493 ih = (int) (dim.getHeight() * 0.75) - 50;
1494
1495 wrat = iw/((double)dim.getWidth());
1496 hrat = ih/((double)dim.getHeight());
1497
1498 w = (int) (point.getWidth() * wrat);
1499 h = (int) (point.getHeight() * hrat);
1500 x = (int) (point.getLocationOnScreen().x * wrat);
1501 y = (int) (point.getLocationOnScreen().y * hrat);
1502
1503 //frame.addScreenPanel(feedbackframe,sh.getBuffImage(),img);
1504 if (point instanceof JDialog)
1505 modal = ((JDialog) point).isModal();
1506
1507 feedbackframe = myframe;
1508 frame.addScreenPanel(feedbackframe,img,x,y,w,h);
1509 frame.setComment(modal);
1510
1511 if (modal == true)
1512 modalWindow = point;
1513 }
1514
1515 point.removeMouseListener(mouse_blocker_listener);
1516 point.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1517 }
1518
1519 if (messages.getString("LookHistory").equals(e.getActionCommand()))
1520 {
1521 point.addMouseListener(mouse_blocker_listener);
1522 point.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1523
1524 setup_UIManager();
1525 ReportDetails rd;
1526 rd = new ReportDetails(vector,null,null,messages,rec);
1527
1528 point.removeMouseListener(mouse_blocker_listener);
1529 point.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1530 }
1531 }
1532
1533
1534 /**
1535 * This method will listen to any Change event that occured.
1536 * It will allow this special listener class to record all the information inside all the
1537 * window open when the action occured.
1538 * @param e the ChangeEvent.
1539 */
1540 public void stateChanged(ChangeEvent e)
1541 {
1542 String command;
1543 command = messages.getString("ChangeState");
1544 Object obj;
1545 obj = e.getSource();
1546
1547 Component comp;
1548
1549 if (obj instanceof Component)
1550 {
1551 comp = (Component)e.getSource();
1552 }
1553 else
1554 {
1555 if (modelHash.containsKey(obj) == true)
1556 {
1557 comp = (Component) modelHash.get(obj);
1558 }
1559 else
1560 {
1561 comp = null;
1562 System.out.println("weird" + obj.toString());
1563 }
1564 }
1565
1566 saving(comp,command);
1567 }
1568
1569 /**
1570 * This method will listen to any tree selection event that occured.
1571 * It will allow this special listener class to record all the information inside all the
1572 * window open when the action occured.
1573 * @param e the TreeSelectionEvent.
1574 */
1575 public void valueChanged(TreeSelectionEvent e)
1576 {
1577 MutableTreeNode node;
1578 node = (MutableTreeNode)
1579 (e.getPath().getLastPathComponent());
1580
1581 if (node == null) return;
1582
1583 Object obj;
1584 obj = e.getSource();
1585
1586 Component comp;
1587
1588 if (obj instanceof Component)
1589 {
1590 comp = (Component)e.getSource();
1591 }
1592 else
1593 {
1594 if (modelHash.containsKey(obj) == true)
1595 {
1596 comp = (Component) modelHash.get(obj);
1597 }
1598 else
1599 {
1600 comp = null;
1601 System.out.println("weird" + obj.toString());
1602 }
1603 }
1604
1605 String command;
1606 command = messages.getString("Node") + " ";
1607 if (node instanceof DefaultMutableTreeNode)
1608 command = command + ((DefaultMutableTreeNode)node).getUserObject() + " ";
1609 command = command + messages.getString("ValueChanged");
1610
1611 saving(comp,command);
1612 }
1613
1614 /**
1615 * This method will listen to any tree nodes change in the tree model event that occured.
1616 * It will allow this special listener class to record all the information inside all the
1617 * window open when the action occured.
1618 * @param e the TreeModelEvent.
1619 */
1620 public void treeNodesChanged(TreeModelEvent e)
1621 {
1622 MutableTreeNode node;
1623 node = (MutableTreeNode)
1624 (e.getTreePath().getLastPathComponent());
1625
1626 try {
1627 int index;
1628 index = e.getChildIndices()[0];
1629 node = (MutableTreeNode)(node.getChildAt(index));
1630 } catch (NullPointerException exc) {}
1631
1632 Object obj;
1633 obj = e.getSource();
1634
1635 Component comp;
1636
1637 if (obj instanceof Component)
1638 {
1639 comp = (Component)e.getSource();
1640 }
1641 else
1642 {
1643 if (modelHash.containsKey(obj) == true)
1644 {
1645 comp = (Component) modelHash.get(obj);
1646 }
1647 else
1648 {
1649 comp = null;
1650 System.out.println("weird" + obj.toString());
1651 }
1652 }
1653
1654 String command;
1655 command = messages.getString("Node");
1656
1657 if (node instanceof DefaultMutableTreeNode)
1658 command = command + " " + ((DefaultMutableTreeNode)node).getUserObject();
1659
1660 command = command + " " + messages.getString("Change");
1661
1662 saving(comp,command);
1663 }
1664
1665 /**
1666 * This method will listen to any tree nodes inserted in the tree model event that occured.
1667 * It will allow this special listener class to record all the information inside all the
1668 * window open when the action occured.
1669 * @param e the TreeModelEvent.
1670 */
1671 public void treeNodesInserted(TreeModelEvent e)
1672 {
1673 MutableTreeNode node;
1674 node = (MutableTreeNode)
1675 (e.getTreePath().getLastPathComponent());
1676
1677 try {
1678 int index;
1679 index = e.getChildIndices()[0];
1680 node = (MutableTreeNode)(node.getChildAt(index));
1681 } catch (NullPointerException exc) {}
1682
1683 Object obj;
1684 obj = e.getSource();
1685
1686 Component comp;
1687
1688 if (obj instanceof Component)
1689 {
1690 comp = (Component)e.getSource();
1691 }
1692 else
1693 {
1694 if (modelHash.containsKey(obj) == true)
1695 {
1696 comp = (Component) modelHash.get(obj);
1697 }
1698 else
1699 {
1700 comp = null;
1701 System.out.println("weird" + obj.toString());
1702 }
1703 }
1704
1705 String command;
1706 command = messages.getString("Node");
1707 if (node instanceof DefaultMutableTreeNode)
1708 command = command + " " + ((DefaultMutableTreeNode)node).getUserObject();
1709
1710 command = command + " " + messages.getString("Inserted");
1711
1712 saving(comp,command);
1713 }
1714
1715 /**
1716 * This method will listen to any tree nodes removed in the tree model event that occured.
1717 * It will allow this special listener class to record all the information inside all the
1718 * window open when the action occured.
1719 * @param e the TreeModelEvent.
1720 */
1721 public void treeNodesRemoved(TreeModelEvent e)
1722 {
1723 MutableTreeNode node;
1724 node = (MutableTreeNode)
1725 (e.getTreePath().getLastPathComponent());
1726
1727 try {
1728 int index;
1729 index = e.getChildIndices()[0];
1730 node = (MutableTreeNode)(node.getChildAt(index));
1731 } catch (NullPointerException exc) {}
1732
1733 Object obj;
1734 obj = e.getSource();
1735
1736 Component comp;
1737
1738 if (obj instanceof Component)
1739 {
1740 comp = (Component)e.getSource();
1741 }
1742 else
1743 {
1744 if (modelHash.containsKey(obj) == true)
1745 {
1746 comp = (Component) modelHash.get(obj);
1747 }
1748 else
1749 {
1750 comp = null;
1751 System.out.println("weird" + obj.toString());
1752 }
1753 }
1754
1755 String command;
1756 command = messages.getString("Node");
1757 if (node instanceof DefaultMutableTreeNode)
1758 command = command + " " + ((DefaultMutableTreeNode)node).getUserObject();
1759 command = command + " " + messages.getString("Removed");
1760
1761 saving(comp,command);
1762 }
1763
1764 /**
1765 * This method will listen to any tree structure change in the tree model event that occured.
1766 * It will allow this special listener class to record all the information inside all the
1767 * window open when the action occured.
1768 * @param e the TreeModelEvent.
1769 */
1770 public void treeStructureChanged(TreeModelEvent e)
1771 {
1772 Object obj;
1773 obj = e.getSource();
1774
1775 Component comp;
1776
1777 if (obj instanceof Component)
1778 {
1779 comp = (Component)e.getSource();
1780 }
1781 else
1782 {
1783 if (modelHash.containsKey(obj) == true)
1784 {
1785 comp = (Component) modelHash.get(obj);
1786 }
1787 else
1788 {
1789 comp = null;
1790 System.out.println("weird" + obj.toString());
1791 }
1792 }
1793
1794 String command;
1795 command = messages.getString("TreeStructuredChanged");
1796
1797 saving(comp,command);
1798 }
1799
1800 /**
1801 * This method will listen to any item state change in the item event that occured.
1802 * It will allow this special listener class to record all the information inside all the
1803 * window open when the action occured.
1804 * @param e the ItemEvent.
1805 */
1806 public void itemStateChanged(ItemEvent e)
1807 {
1808 Component comp;
1809 comp = (Component) e.getSource();
1810 String command;
1811 command = ((String) e.getItem()) + " " +
1812 messages.getString("ItemStateChanged");
1813
1814 saving(comp,command);
1815 }
1816
1817 /**
1818 * This method will listen to any contents change in the list data event that occured.
1819 * It will allow this special listener class to record all the information inside all the
1820 * window open when the action occured.
1821 * @param e the ListDataEvent.
1822 */
1823 public void contentsChanged (ListDataEvent e)
1824 {
1825 Object obj;
1826 obj = e.getSource();
1827
1828 Component comp;
1829
1830 if (obj instanceof Component)
1831 {
1832 comp = (Component)e.getSource();
1833 }
1834 else
1835 {
1836 if (modelHash.containsKey(obj) == true)
1837 {
1838 comp = (Component) modelHash.get(obj);
1839 }
1840 else
1841 {
1842 comp = null;
1843 System.out.println("weird" + obj.toString());
1844 }
1845 }
1846
1847 String command;
1848 command = messages.getString("ListChanged");
1849
1850 saving(comp,command);
1851 }
1852
1853 /**
1854 * This method will listen to any interval added in the list data event that occured.
1855 * It will allow this special listener class to record all the information inside all the
1856 * window open when the action occured.
1857 * @param e the ListDataEvent.
1858 */
1859 public void intervalAdded (ListDataEvent e)
1860 {
1861 Object obj;
1862 obj = e.getSource();
1863
1864 Component comp;
1865
1866 if (obj instanceof Component)
1867 {
1868 comp = (Component)e.getSource();
1869 }
1870 else
1871 {
1872 if (modelHash.containsKey(obj) == true)
1873 {
1874 comp = (Component) modelHash.get(obj);
1875 }
1876 else
1877 {
1878 comp = null;
1879 System.out.println("weird" + obj.toString());
1880 }
1881 }
1882
1883 String command;
1884 command = messages.getString("ListContentsAdded");
1885
1886 saving(comp,command);
1887 }
1888
1889 /**
1890 * This method will listen to any interval removed in the list data event that occured.
1891 * It will allow this special listener class to record all the information inside all the
1892 * window open when the action occured.
1893 * @param e the ListDataEvent.
1894 */
1895 public void intervalRemoved (ListDataEvent e)
1896 {
1897 Object obj;
1898 obj = e.getSource();
1899
1900 Component comp;
1901
1902 if (obj instanceof Component)
1903 {
1904 comp = (Component)e.getSource();
1905 }
1906 else
1907 {
1908 if (modelHash.containsKey(obj) == true)
1909 {
1910 comp = (Component) modelHash.get(obj);
1911 }
1912 else
1913 {
1914 comp = null;
1915 System.out.println("weird" + obj.toString());
1916 }
1917 }
1918
1919 String command;
1920 command = messages.getString("ListContentRemoved");
1921
1922 saving(comp,command);
1923 }
1924
1925 /**
1926 * This method will listen to any value changed in the list data event that occured.
1927 * It will allow this special listener class to record all the information inside all the
1928 * window open when the action occured.
1929 * @param e the ListDataEvent.
1930 */
1931 public void valueChanged (ListSelectionEvent e)
1932 {
1933 Object obj;
1934 obj = e.getSource();
1935
1936 Component comp;
1937
1938 if (obj instanceof Component)
1939 {
1940 comp = (Component)e.getSource();
1941 }
1942 else
1943 {
1944 if (modelHash.containsKey(obj) == true)
1945 {
1946 comp = (Component) modelHash.get(obj);
1947 }
1948 else
1949 {
1950 comp = null;
1951 System.out.println("weird" + obj.toString());
1952 }
1953 }
1954
1955 String command;
1956 command = messages.getString("ListValueChanged");
1957
1958 saving(comp,command);
1959 }
1960
1961 /**
1962 * This method will listen to any menu canceled in the menu event that occured.
1963 * It will allow this special listener class to record all the information inside all the
1964 * window open when the action occured.
1965 * @param e the MenuEvent.
1966 */
1967 public void menuCanceled (MenuEvent e)
1968 {
1969 Component comp;
1970 comp = (Component) e.getSource();
1971 String command;
1972 command = messages.getString("MenuCanceled");
1973
1974 saving(comp,command);
1975 }
1976
1977 /**
1978 * This method will listen to any menu deselected in the menu event that occured.
1979 * It will allow this special listener class to record all the information inside all the
1980 * window open when the action occured.
1981 * @param e the MenuEvent.
1982 */
1983 public void menuDeselected (MenuEvent e)
1984 {
1985 Component comp;
1986 comp = (Component) e.getSource();
1987 String command;
1988 command = messages.getString("MenuDeselected");
1989
1990 saving(comp,command);
1991 }
1992
1993 /**
1994 * This method will listen to any menu selected in the menu event that occured.
1995 * It will allow this special listener class to record all the information inside all the
1996 * window open when the action occured.
1997 * @param e the MenuEvent.
1998 */
1999 public void menuSelected(MenuEvent e)
2000 {
2001 Component comp;
2002 comp = (Component) e.getSource();
2003 String command;
2004 command = messages.getString("MenuSelected");
2005
2006 saving(comp,command);
2007 }
2008
2009 /**
2010 * This method will listen to any column added in the table column model event that occured.
2011 * It will allow this special listener class to record all the information inside all the
2012 * window open when the action occured.
2013 * @param e the TableColumnModelEvent.
2014 */
2015 public void columnAdded (TableColumnModelEvent e)
2016 {
2017 Object obj;
2018 obj = e.getSource();
2019
2020 Component comp;
2021
2022 if (obj instanceof Component)
2023 {
2024 comp = (Component)e.getSource();
2025 }
2026 else
2027 {
2028 if (modelHash.containsKey(obj) == true)
2029 {
2030 comp = (Component) modelHash.get(obj);
2031 }
2032 else
2033 {
2034 comp = null;
2035 System.out.println("weird" + obj.toString());
2036 }
2037 }
2038
2039 String command;
2040 command = messages.getString("ColumnIndex") + " " + e.getToIndex()
2041 + messages.getString("AddedToTable");
2042
2043 saving(comp,command);
2044 }
2045
2046 public void columnMarginChanged(ChangeEvent e) {}
2047
2048 /**
2049 * This method will listen to any column moved in the table column model event that occured.
2050 * It will allow this special listener class to record all the information inside all the
2051 * window open when the action occured.
2052 * @param e the TableColumnModelEvent.
2053 */
2054 public void columnMoved(TableColumnModelEvent e)
2055 {
2056 Object obj;
2057 obj = e.getSource();
2058
2059 Component comp;
2060
2061 if (obj instanceof Component)
2062 {
2063 comp = (Component)e.getSource();
2064 }
2065 else
2066 {
2067 if (modelHash.containsKey(obj) == true)
2068 {
2069 comp = (Component) modelHash.get(obj);
2070 }
2071 else
2072 {
2073 comp = null;
2074 System.out.println("weird" + obj.toString());
2075 }
2076 }
2077
2078 String command;
2079 command = messages.getString("ColumnIndexFrom") + " " +
2080 e.getFromIndex() + " " +
2081 messages.getString("MovedToColumnIndex") + " " + e.getToIndex() +
2082 " " + messages.getString("InTheTable");
2083
2084 saving(comp,command);
2085 }
2086
2087 /**
2088 * This method will listen to any column removed in the table column model event that occured.
2089 * It will allow this special listener class to record all the information inside all the
2090 * window open when the action occured.
2091 * @param e the TableColumnModelEvent.
2092 */
2093 public void columnRemoved(TableColumnModelEvent e)
2094 {
2095 Object obj;
2096 obj = e.getSource();
2097
2098 Component comp;
2099
2100 if (obj instanceof Component)
2101 {
2102 comp = (Component)e.getSource();
2103 }
2104 else
2105 {
2106 if (modelHash.containsKey(obj) == true)
2107 {
2108 comp = (Component) modelHash.get(obj);
2109 }
2110 else
2111 {
2112 comp = null;
2113 System.out.println("weird" + obj.toString());
2114 }
2115 }
2116
2117 String command;
2118 command = messages.getString("ColumnIndex") + " " + e.getFromIndex() +
2119 " " + messages.getString("RemovedFromTheTable");
2120
2121 saving(comp,command);
2122 }
2123
2124 public void columnSelectionChanged(ListSelectionEvent e) {}
2125}
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
Note: See TracBrowser for help on using the repository browser.