source: main/trunk/gli/src/org/greenstone/gatherer/feedback/ComponentInformation.java@ 33998

Last change on this file since 33998 was 33998, checked in by davidb, 4 years ago

Removed import statement that is no longer used, and was stopping compilation using JDK11

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 56.3 KB
Line 
1package org.greenstone.gatherer.feedback;
2
3import java.awt.*;
4import java.io.*;
5import java.util.*;
6import javax.swing.*;
7import javax.swing.tree.*;
8import javax.swing.table.*;
9import javax.swing.text.*;
10import java.awt.image.*;
11import javax.imageio.ImageIO;
12import javax.swing.plaf.*;
13import javax.swing.plaf.basic.*;
14import javax.swing.colorchooser.*;
15import java.awt.event.*;
16import javax.swing.event.*;
17import java.util.Locale;
18import java.util.ResourceBundle;
19import java.text.MessageFormat;
20import javax.swing.plaf.metal.MetalIconFactory.*;
21import javax.swing.plaf.metal.MetalIconFactory;
22import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
23import javax.swing.plaf.metal.MetalInternalFrameTitlePane;
24
25/**
26 * In general, this class will get all information and add special listener
27 * to a Container and of all the components inside it.
28 * <p>This class will get the information about the Container and all the components inside it.
29 * The information we get is like whether or not the component is visible and the contents of it.
30 * This class will also add special listener to the Container and each of the components inside
31 * the Container. So, it will allows special listener to record and listen each of the actions
32 * the user do to the Container or any of the components inside it. The special listener
33 * is an instance of ActionRecorderDialog.</p>
34 * <p>This class will only recognized all the components that is belongs to the javax.swing package
35 * which are all the implementing classes of RootPaneContainer interface and all the direct known
36 * subclasses of JComponent. All the other components will be stated simply as Container
37 * and user cannot really get much information out of it.</p>
38 * <p>The added special listener to this component is as what its allowed in API, if the component
39 * have some modified listener added to it then that action will not be known and recorded by
40 * the special listener.</p>
41 *
42 * @author Veronica Liesaputra
43 */
44public class ComponentInformation
45{
46 /**
47 * This variable will hold the special listener that will listen and record any of the
48 * actions user do to the Container and any of the components inside it.
49 */
50 private ActionRecorderDialog m;
51
52 /**
53 * This variable will hold the resource of the words that is stored in Messages.properties file.
54 * The calling using messages.getString(someString) will caused someString to be translated
55 * into some other string that is hold in that file.usually it will caused it to be translated
56 * to the language that the user use or choose to have as stated in Locale.
57 */
58 private static ResourceBundle messages;
59
60 /**
61 * This variable will hold the pair of the component and the model of the component.
62 * With this variable allows ActionRecorderDialog listener to know which component the model that fires an action
63 * belongs to. In this HashMap the model is the key and the component where the model belongs to is
64 * the value.
65 */
66 private HashMap hash;
67
68 /**
69 * This constructor will set the special listener, the locale and the hashmap to be used in
70 * this Container.
71 * (Precondition: dialog != null)
72 * @param dialog its the special listener that will listen and record all the action
73 * user do to any of the component inside the Container.
74 * @param currentLocale its the locale that the user choose all the information to be displayed as.
75 * @param h its the HashMap that will hold the pair of model with the component it belongs.
76 */
77 public ComponentInformation
78 (ActionRecorderDialog dialog,Locale currentLocale,HashMap h)
79 {
80 m = dialog;
81 hash = h;
82 messages = ResourceBundle.getBundle("feedback", currentLocale);
83 }
84
85 /**
86 * This method will get all information about the JTextComponent.
87 * If the JTextComponent is a JTextField then it will add the special action listener to it.
88 * (Precondition: txt != null)
89 * @param txt its the JTextComponent we want to get all the information from.
90 * @return a UserComponent that hold the information about this
91 * JTextComponent.
92 */
93 public UserComponent getTextAreaInfo(JTextComponent txt)
94 {
95 UserComponent file;
96 file = new UserComponent();
97 String text;
98 text = txt.getText();
99
100 file.startContent(1);
101 if (txt instanceof JTextArea)
102 file.saveContent("JTextArea");
103 else if (txt instanceof JTextPane)
104 file.saveContent("JTextPane");
105 else if (txt instanceof JEditorPane)
106 file.saveContent("JEditorPane");
107 else if (txt instanceof JTextField)
108 {
109 ((JTextField)txt).removeActionListener(m);
110 ((JTextField)txt).addActionListener(m);
111
112 if (txt instanceof JFormattedTextField)
113 {
114 file.saveContent("JFormattedTextField");
115 }
116 else if (txt instanceof JPasswordField)
117 {
118 file.saveContent("JPasswordField");
119 }
120 else
121 {
122 file.saveContent("JTextField");
123 }
124 }
125
126 file.startContent(2);
127 file.saveContent(messages.getString("TextComponent"));
128
129 file.startContent(3);
130 if (text != null)
131 file.saveContent(text);
132 else
133 file.saveContent(" ");
134
135 file.startContent(4);
136 file.saveContent(txt.getSelectedText());
137
138 file.startContent(5);
139 file.saveContent(messages.getString("" + txt.isVisible()));
140
141 file.startContent(7);
142 file.saveContent(txt.getToolTipText());
143
144 return file;
145 }
146
147 /**
148 * This method will get all the information and add the special action listener to the JButton.
149 * (Precondition: button != null)
150 * @param button its the JButton we want to get the information from.
151 * @return a UserComponent that will hold the information about this JButton.
152 */
153 public UserComponent getButtonInfo (JButton button)
154 {
155 UserComponent file;
156 file = new UserComponent();
157 String text;
158 text = button.getText();
159
160 button.removeActionListener(m);
161 button.addActionListener(m);
162
163 file.startContent(1);
164 file.saveContent("JButton");
165
166 file.startContent(2);
167 file.saveContent(messages.getString("Button"));
168
169 file.startContent(3);
170 if (text != null)
171 file.saveContent(text);
172 else
173 file.saveContent(" ");
174
175 file.startContent(4);
176 file.saveContent(messages.getString("" + button.isSelected()));
177
178 file.startContent(5);
179 file.saveContent(messages.getString("" + button.isVisible()));
180
181 file.startContent(6);
182 Icon img = button.getIcon();
183 if (img != null)
184 {
185 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
186 }
187 else
188 {
189 file.saveContent(messages.getString("NoImage"));
190 }
191
192 file.startContent(7);
193 file.saveContent(button.getToolTipText());
194
195 return file;
196 }
197
198 /**
199 * This method will get all the information and add the special change listener to the JProgressBar.
200 * (Precondition: bar != null)
201 * @param bar its the JProgressBar we want to get information from.
202 * @return a UserComponent that will hold the information about this JProgressBar.
203 */
204 public UserComponent getProgressBarInfo (JProgressBar bar)
205 {
206 UserComponent file;
207 file = new UserComponent();
208 String text;
209 text = bar.getString();
210
211 bar.removeChangeListener(m);
212 bar.addChangeListener(m);
213
214 file.startContent(1);
215 file.saveContent("JProgressBar");
216
217 file.startContent(2);
218 file.saveContent(messages.getString("ProgressBar"));
219
220 file.startContent(3);
221 if (text != null)
222 file.saveContent(text);
223 else
224 file.saveContent(" ");
225
226 file.startContent(5);
227 file.saveContent(messages.getString("" + bar.isVisible()));
228
229 file.startContent(7);
230 file.saveContent(bar.getToolTipText());
231
232 return file;
233 }
234
235 /**
236 * This method will get all the information and add the special change listener to the JSlider.
237 * (Precondition: slider != null)
238 * @param slider its the JSlider we want to get information from.
239 * @return a UserComponent that will hold the information about this JSlider.
240 */
241 public UserComponent getSliderInfo (JSlider slider)
242 {
243 UserComponent file;
244 file = new UserComponent();
245 String text;
246 text = "" + slider.getValue();
247
248 slider.removeChangeListener(m);
249 slider.addChangeListener(m);
250
251 file.startContent(1);
252 file.saveContent("JSlider");
253
254 file.startContent(2);
255 file.saveContent(messages.getString("Slider"));
256
257 file.startContent(3);
258 if (text != null)
259 file.saveContent(text);
260 else
261 file.saveContent(" ");
262
263 file.startContent(5);
264 file.saveContent(messages.getString("" + slider.isVisible()));
265
266 file.startContent(7);
267 file.saveContent(slider.getToolTipText());
268
269 return file;
270 }
271
272 /**
273 * This method will get all the information and add the special change listener to the JSpinner.
274 * (Precondition: spinner != null)
275 * @param spinner its the JSpinner we want to the information from.
276 * @return a UserComponent that will hold the information about this JSpinner.
277 */
278 public UserComponent getSpinnerInfo (JSpinner spinner)
279 {
280 UserComponent file;
281 file = new UserComponent();
282 String text;
283 text = "" + spinner.getValue();
284
285 spinner.removeChangeListener(m);
286 spinner.addChangeListener(m);
287
288 file.startContent(1);
289 file.saveContent("JSpinner");
290
291 file.startContent(2);
292 file.saveContent(messages.getString("Spinner"));
293
294 file.startContent(3);
295 if (text != null)
296 file.saveContent(text);
297 else
298 file.saveContent(" ");
299
300 file.startContent(5);
301 file.saveContent(messages.getString("" + spinner.isVisible()));
302
303 file.startContent(7);
304 file.saveContent(spinner.getToolTipText());
305
306 return file;
307 }
308
309 /**
310 * This method will get all the information of the JLabel.
311 * (Precondition: lbl != null)
312 * @param lbl its the JLabel we want to get information from.
313 * @return a UserComponent that will hold the information about this JLabel.
314 */
315 public UserComponent getLabelInfo(JLabel lbl)
316 {
317 UserComponent file;
318 file = new UserComponent();
319 String text;
320 text = lbl.getText();
321
322 file.startContent(1);
323 file.saveContent("JLabel");
324
325 file.startContent(2);
326 file.saveContent(messages.getString("Label"));
327
328 file.startContent(3);
329 if (text != null)
330 file.saveContent(text);
331 else
332 file.saveContent(" ");
333
334 file.startContent(5);
335 file.saveContent(messages.getString("" + lbl.isVisible()));
336
337 file.startContent(6);
338 Icon img = lbl.getIcon();
339 if (img != null)
340 {
341 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
342 }
343 else
344 {
345 file.saveContent(messages.getString("NoImage"));
346 }
347
348 file.startContent(7);
349 file.saveContent(lbl.getToolTipText());
350
351 return file;
352 }
353
354 /**
355 * This method will get all the information and add the special action listener to the JComboBox.
356 * (Precondition: box != null)
357 * @param box its the JComboBox we want to get information from.
358 * @return a UserComponent that will hold the information about this JComboBox.
359 */
360 public UserComponent getComboBoxInfo(JComboBox box)
361 {
362 UserComponent file;
363 file = new UserComponent();
364 ComboBoxModel cm;
365 cm = box.getModel();
366
367 box.removeActionListener(m);
368 box.addActionListener(m);
369
370 file.startContent(1);
371 file.saveContent("JComboBox");
372
373 file.startContent(2);
374 file.saveContent(messages.getString("ComboBox"));
375
376 file.startContent(3);
377 int i;
378 for (i = 0; i < box.getItemCount() ; i++)
379 {
380 UserComponent file2;
381 file2 = new UserComponent();
382 //Assuming that they don't put any picture or images
383 String text;
384 Object objmsg;
385
386 objmsg = box.getItemAt(i);
387
388 if (objmsg instanceof String)
389 text = (String) objmsg + "\n";
390 else
391 text = objmsg.toString() + "\n" ;
392
393 file2.startContent(3);
394 if (text != null)
395 file2.saveContent(text);
396 else
397 file2.saveContent(" ");
398
399 file2.startContent(4);
400 if (i == box.getSelectedIndex())
401 file2.saveContent(messages.getString("Selected"));
402 else
403 file2.saveContent(messages.getString("NotSelected"));
404
405 file.saveContent(file2);
406 }
407
408 file.startContent(5);
409 file.saveContent(messages.getString("" + box.isVisible()));
410
411 file.startContent(7);
412 file.saveContent(box.getToolTipText());
413
414 return file;
415 }
416
417 /**
418 * This method will get all the information and add the special action listener to the JToggleButton.
419 * (Precondition: button != null)
420 * @param button its a JToggleButton inside the window
421 * @return a UserComponent that will hold the information about this JToggleButton.
422 */
423 public UserComponent getToggleButtonInfo (JToggleButton button)
424 {
425 UserComponent file;
426 file = new UserComponent();
427
428 button.removeActionListener(m);
429 button.addActionListener(m);
430
431 file.startContent(1);
432 if (button instanceof JCheckBox)
433 file.saveContent("JCheckBox");
434 else
435 file.saveContent("JRadioButton");
436
437 file.startContent(2);
438 file.saveContent(messages.getString("ToggleButton"));
439
440 file.startContent(3);
441 String text;
442 text = button.getText();
443 if (text != null)
444 file.saveContent(text);
445 else
446 file.saveContent(" ");
447
448 file.startContent(4);
449 if (button.isSelected() == true)
450 {
451 file.saveContent(messages.getString("Selected"));
452 }
453 else
454 file.saveContent(messages.getString("NotSelected"));
455
456 file.startContent(5);
457 file.saveContent(messages.getString("" + button.isVisible()));
458
459 file.startContent(6);
460 Icon img = button.getIcon();
461 if (img != null)
462 {
463 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
464 }
465 else
466 {
467 file.saveContent(messages.getString("NoImage"));
468 }
469
470 file.startContent(7);
471 file.saveContent(button.getToolTipText());
472
473 return file;
474 }
475
476 /**
477 * This method will get all the information and add the special action listener to the JMenuItem.
478 * (Precondition: menuitem != null)
479 * @param menuitem its the JMenuItem we want to get the information from.
480 * @return a UserComponent that will hold the information about this JMenuItem.
481 */
482 public UserComponent getMenuItemInfo (JMenuItem menuitem)
483 {
484 UserComponent file;
485 file = new UserComponent();
486
487 menuitem.removeActionListener(m);
488 menuitem.addActionListener(m);
489
490 file.startContent(1);
491 file.saveContent("JMenuItem");
492
493 file.startContent(2);
494 file.saveContent(messages.getString("MenuItem"));
495
496 file.startContent(3);
497 String text;
498 text = menuitem.getText();
499 if (text != null)
500 file.saveContent(text);
501 else
502 file.saveContent(" ");
503
504 file.startContent(4);
505 if (menuitem.isSelected() == true)
506 {
507 file.saveContent(messages.getString("Selected"));
508 }
509 else
510 file.saveContent(messages.getString("NotSelected"));
511
512 file.startContent(5);
513 file.saveContent(messages.getString("" + menuitem.isVisible()));
514
515 file.startContent(6);
516 Icon img = menuitem.getIcon();
517 if (img != null)
518 {
519 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
520 }
521 else
522 {
523 file.saveContent(messages.getString("NoImage"));
524 }
525
526 file.startContent(7);
527 file.saveContent(menuitem.getToolTipText());
528
529 return file;
530 }
531
532 /**
533 * This method will get all the information of the JMenuBar.
534 * (Precondition: menubar != null)
535 * @param menubar its the JMenuBar we want to get the information from.
536 * @return a UserComponent that will hold the information about this JMenuBar.
537 */
538 public UserComponent getMenuBarInfo (JMenuBar menubar)
539 {
540 UserComponent file;
541 file = new UserComponent();
542
543 file.startContent(1);
544 file.saveContent("JMenuBar");
545
546 file.startContent(2);
547 file.saveContent(messages.getString("MenuBar"));
548
549 file.startContent(3);
550 int i;
551 for (i= 0 ; i < menubar.getMenuCount() ; i++)
552 {
553 file.saveContent(getInside(menubar.getMenu(i)));
554 }
555
556 file.startContent(4);
557 if (menubar.isSelected() == true)
558 {
559 file.saveContent(messages.getString("Selected"));
560 }
561 else
562 file.saveContent(messages.getString("NotSelected"));
563
564 file.startContent(5);
565 file.saveContent(messages.getString("" + menubar.isVisible()));
566
567 file.startContent(7);
568 file.saveContent(menubar.getToolTipText());
569
570 return file;
571 }
572
573 /**
574 * This method will get all the information and add the special action and menu listener to the JMenu.
575 * (Precondition: menu != null)
576 * @param menu its the JMenu we want to the the information from.
577 * @return a UserComponent that will hold the information about this JMenu.
578 */
579 public UserComponent getMenuInfo (JMenu menu)
580 {
581 UserComponent file;
582 file = new UserComponent();
583
584 menu.removeActionListener(m);
585 menu.removeMenuListener(m);
586 menu.addActionListener(m);
587 menu.addMenuListener(m);
588
589 file.startContent(1);
590 file.saveContent("JMenu");
591
592 file.startContent(2);
593 String text;
594 text = menu.getText();
595 if (text != null)
596 file.saveContent(text);
597 else
598 file.saveContent(" ");
599
600 file.startContent(3);
601 int i;
602 for (i= 0 ; i < menu.getMenuComponentCount() ; i++)
603 {
604 file.saveContent(getInside((Container)menu.getMenuComponent(i)));
605 }
606
607 file.startContent(4);
608 if (menu.isSelected() == true)
609 {
610 file.saveContent(messages.getString("Selected"));
611 }
612 else
613 file.saveContent(messages.getString("NotSelected"));
614
615 file.startContent(5);
616 file.saveContent(messages.getString("" + menu.isVisible()));
617
618 file.startContent(6);
619 Icon img = menu.getIcon();
620 if (img != null)
621 {
622 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
623 }
624 else
625 {
626 file.saveContent(messages.getString("NoImage"));
627 }
628
629 file.startContent(7);
630 file.saveContent(menu.getToolTipText());
631
632 return file;
633 }
634
635 /**
636 * This method will get all the information of the JApplet.
637 * (Precondition: applet != null)
638 * @param applet its the JApplet we want to get the information from.
639 * @return a UserComponent that will hold the information about this JApplet.
640 */
641 public UserComponent getAppletInfo (JApplet applet)
642 {
643 UserComponent file;
644 file = new UserComponent();
645 Component[] group;
646 group = applet.getComponents();
647 int i;
648
649 file.startContent(1);
650 file.saveContent("JApplet");
651
652 file.startContent(2);
653 String text;
654 text = applet.getAppletInfo();
655 if (text != null)
656 file.saveContent(text);
657 else
658 file.saveContent(" ");
659
660 if (group != null)
661 {
662 file.startContent(3);
663 for (i = 0; i < group.length ; i++)
664 {
665 file.saveContent(getInside((Container)applet.getComponent(i)));
666 }
667 }
668
669 file.startContent(4);
670 file.saveContent(messages.getString("" + applet.isActive()));
671
672 file.startContent(5);
673 file.saveContent(messages.getString("" + applet.isVisible()));
674
675 return file;
676 }
677
678 /**
679 * This method will get all the information of the JWindow.
680 * (Precondition: window != null)
681 * @param window its the JWindow we want to get the information from.
682 * @return a UserComponent that will hold the information about this JWindow.
683 */
684 public UserComponent getWindowInfo (JWindow window)
685 {
686 UserComponent file;
687 file = new UserComponent();
688 Component[] group;
689 group = window.getComponents();
690 int i;
691
692 file.startContent(1);
693 file.saveContent("JWindow");
694
695 file.startContent(2);
696 file.saveContent(messages.getString("Window"));
697
698 if (group != null)
699 {
700 file.startContent(3);
701 for (i = 0; i < group.length ; i++)
702 {
703 file.saveContent(getInside((Container)window.getComponent(i)));
704 }
705 }
706
707 file.startContent(4);
708 file.saveContent(messages.getString("" + window.isActive()));
709
710 file.startContent(5);
711 file.saveContent(messages.getString("" + window.isVisible()));
712
713 return file;
714 }
715
716 /**
717 * This method will get all the information of the JDialog.
718 * (Precondition: dialog != null)
719 * @param dialog its the JDialog we want to get the information from.
720 * @return a UserComponent that will hold the information about this JDialog.
721 */
722 public UserComponent getDialogInfo (JDialog dialog)
723 {
724 UserComponent file;
725 file = new UserComponent();
726 Component[] group;
727 group = dialog.getComponents();
728 int i;
729
730 file.startContent(1);
731 file.saveContent("JDialog");
732
733 file.startContent(2);
734 String text = dialog.getTitle();
735 if (text != null)
736 file.saveContent(text);
737 else
738 file.saveContent(" ");
739
740 if (group != null)
741 {
742 file.startContent(3);
743 for (i = 0; i < group.length ; i++)
744 {
745 file.saveContent(getInside((Container)dialog.getComponent(i)));
746 }
747 }
748
749 file.startContent(4);
750 file.saveContent(messages.getString("" + dialog.isActive()));
751
752 file.startContent(5);
753 file.saveContent(messages.getString("" + dialog.isVisible()));
754
755 return file;
756 }
757
758 /**
759 * This method will get all the information of the JInternalFrame.
760 * (Precondition: frame != null)
761 * @param frame its the JInternalFrame we want to get the information from.
762 * @return a UserComponent that will hold the information about this JInternalFrame.
763 */
764 public UserComponent getInternalFrameInfo (JInternalFrame frame)
765 {
766 UserComponent file;
767 file = new UserComponent();
768 Component[] group;
769 group = frame.getComponents();
770 int i;
771
772 file.startContent(1);
773 file.saveContent("JInternalFrame");
774
775 file.startContent(2);
776 String text;
777 text = frame.getTitle();
778 if (text != null)
779 file.saveContent(text);
780 else
781 file.saveContent(" ");
782
783 if (group != null)
784 {
785 file.startContent(3);
786 for (i = 0; i < group.length ; i++)
787 {
788 file.saveContent(getInside((Container)frame.getComponent(i)));
789 }
790 }
791
792 file.startContent(4);
793 file.saveContent(messages.getString("" + frame.isSelected()));
794
795 file.startContent(5);
796 file.saveContent(messages.getString("" + frame.isVisible()));
797
798 file.startContent(6);
799 Icon img = frame.getFrameIcon();
800 if (img != null)
801 {
802 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
803 }
804 else
805 {
806 file.saveContent(messages.getString("NoImage"));
807 }
808
809 file.startContent(7);
810 file.saveContent(frame.getToolTipText());
811
812 return file;
813 }
814
815 /**
816 * This method will get all the information of the JFrame.
817 * (Precondition: frame != null)
818 * @param frame its the JFrame we want to get the information from.
819 * @return a UserComponent that will hold the information about this JFrame.
820 */
821 public UserComponent getFrameInfo (JFrame frame)
822 {
823 UserComponent file;
824 file = new UserComponent();
825 Component[] group;
826 group = frame.getComponents();
827 int i;
828
829 file.startContent(1);
830 file.saveContent("JFrame");
831
832 file.startContent(2);
833 String text;
834 text = frame.getTitle();
835 if (text != null)
836 file.saveContent(text);
837 else
838 file.saveContent(" ");
839
840 if (group != null)
841 {
842 file.startContent(3);
843 for (i = 0; i < group.length ; i++)
844 {
845 file.saveContent(getInside((Container)frame.getComponent(i)));
846 }
847 }
848
849 file.startContent(4);
850 file.saveContent(messages.getString("" + frame.isActive()));
851
852 file.startContent(5);
853 file.saveContent(messages.getString("" + frame.isVisible()));
854
855 file.startContent(6);
856 Image image;
857 image = frame.getIconImage();
858 if (image != null)
859 {
860 ImageIcon img;
861 img = new ImageIcon(image);
862 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
863 }
864 else
865 {
866 file.saveContent(messages.getString("NoImage"));
867 }
868
869 return file;
870 }
871
872 /**
873 * This method will get all the information of the JPanel.
874 * (Precondition: pane != null)
875 * @param pane its the JPanel we want to get the information from.
876 * @return a UserComponent that will hold the information about this JPanel.
877 */
878 public UserComponent getPanelInfo (JPanel pane)
879 {
880 UserComponent file;
881 file = new UserComponent();
882 Component[] group;
883 group = pane.getComponents();
884 int i;
885
886 file.startContent(1);
887 file.saveContent("JPanel");
888
889 file.startContent(2);
890 file.saveContent(messages.getString("Panel"));
891
892 if (group != null)
893 {
894 file.startContent(3);
895 for (i = 0; i < group.length ; i++)
896 {
897 file.saveContent(getInside((Container)pane.getComponent(i)));
898 }
899 }
900
901 file.startContent(5);
902 file.saveContent(messages.getString("" + pane.isVisible()));
903
904 file.startContent(7);
905 file.saveContent(pane.getToolTipText());
906
907 return file;
908 }
909
910 /**
911 * This method will get all the information of the JScrollPane.
912 * (Precondition: scroll != null)
913 * @param scroll its the JScrollPane we want to get the information from.
914 * @return a UserComponent that will hold the information about this JScrollPane.
915 */
916 public UserComponent getScrollInfo (JScrollPane scroll)
917 {
918 UserComponent file;
919 file = new UserComponent();
920 Component[] group;
921 group = scroll.getComponents();
922 int i;
923
924 file.startContent(1);
925 file.saveContent("JScrollPane");
926
927 file.startContent(2);
928 file.saveContent(messages.getString("Scroller"));
929
930 if (group != null)
931 {
932 file.startContent(3);
933 for (i = 0; i < group.length ; i++)
934 {
935 file.saveContent(getInside((Container)group[i]));
936 }
937 }
938
939 file.startContent(5);
940 file.saveContent(messages.getString("" + scroll.isVisible()));
941
942 file.startContent(7);
943 file.saveContent(scroll.getToolTipText());
944
945 return file;
946 }
947
948 /**
949 * This method will get all the information and add special change listener to the JTabbedPane.
950 * (Precondition: tab != null)
951 * @param tab its the JTabbedPane we want to get the information from.
952 * @return a UserComponent that will hold the information about this JTabbedPane.
953 */
954 public UserComponent getTabbedPaneInfo (JTabbedPane tab)
955 {
956 UserComponent file;
957 file = new UserComponent();
958 int j;
959
960 tab.removeChangeListener(m);
961 tab.addChangeListener(m);
962
963 file.startContent(1);
964 file.saveContent("JTabbedPane");
965
966 file.startContent(3);
967 for (j = 0 ; j < tab.getTabCount(); j++)
968 {
969 UserComponent file2;
970 file2 = new UserComponent();
971
972 file2.startContent(2);
973 String title;
974 title = tab.getTitleAt(j);
975 if (title != null)
976 file2.saveContent(title);
977 else
978 file2.saveContent(" ");
979
980 file2.startContent(6);
981 Icon img;
982 img = tab.getIconAt(j);
983 if (img != null)
984 {
985 file2.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
986 }
987 else
988 {
989 file2.saveContent(messages.getString("NoImage"));
990 }
991
992 file2.startContent(3);
993 Component group = tab.getComponentAt(j);
994 file2.saveContent(getInside((Container)group));
995
996 file2.startContent(4);
997 if (j == tab.getSelectedIndex())
998 file2.saveContent(messages.getString("Selected"));
999 else
1000 file2.saveContent(messages.getString("NotSelected"));
1001
1002 file.saveContent(file2);
1003 }
1004
1005 file.startContent(5);
1006 file.saveContent(messages.getString("" + tab.isVisible()));
1007
1008 file.startContent(7);
1009 file.saveContent(tab.getToolTipText());
1010
1011 return file;
1012 }
1013
1014 /**
1015 * This method will get all the information of the JOptionPane.
1016 * (Precondition: op != null)
1017 * @param op its the JOptionPane we want to get the information from.
1018 * @return a UserComponent that will hold the information about this JOptionPane.
1019 */
1020 public UserComponent getOptionPaneInfo (JOptionPane op)
1021 {
1022 UserComponent file;
1023 file = new UserComponent();
1024
1025 file.startContent(1);
1026 file.saveContent("JOptionPane");
1027
1028 file.startContent(2);
1029 file.saveContent(messages.getString("OptionPane"));
1030
1031 file.startContent(3);
1032 Object objmsg;
1033 objmsg = op.getMessage();
1034
1035 if (objmsg != null)
1036 {
1037 String text;
1038 if (objmsg instanceof String)
1039 text = (String) objmsg + "\n";
1040 else
1041 text = objmsg.toString() + "\n" ;
1042 file.saveContent(text);
1043 }
1044 else
1045 file.saveContent(" ");
1046
1047 Object[] obj;
1048 int i;
1049 obj = op.getOptions();
1050 if (obj != null)
1051 {
1052 for (i = 0; i < obj.length ; i++)
1053 {
1054 if (obj[i] instanceof String)
1055 file.saveContent((String) obj[i]);
1056 else
1057 file.saveContent(obj[i].toString());
1058 }
1059 }
1060
1061 file.startContent(5);
1062 file.saveContent(messages.getString("" + op.isVisible()));
1063
1064 file.startContent(6);
1065 Icon img = op.getIcon();
1066 if (img != null)
1067 {
1068 file.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
1069 }
1070 else
1071 {
1072 file.saveContent(messages.getString("NoImage"));
1073 }
1074
1075 file.startContent(7);
1076 file.saveContent(op.getToolTipText());
1077
1078 return file;
1079
1080 }
1081
1082 /**
1083 * This method will get all the information of the JViewPort.
1084 * (Precondition: vp != null)
1085 * @param vp its the JViewPort we want to get the information from.
1086 * @return a UserComponent that will hold the information about this JViewPort.
1087 */
1088 public UserComponent getViewPortInfo (JViewport vp)
1089 {
1090 UserComponent file;
1091 file = new UserComponent();
1092 Component[] group;
1093 group = vp.getComponents();
1094 int i;
1095
1096 file.startContent(1);
1097 file.saveContent("JViewPort");
1098
1099 file.startContent(2);
1100 file.saveContent(messages.getString("ViewPort"));
1101
1102 if (group != null)
1103 {
1104 file.startContent(3);
1105 for (i = 0; i < group.length ; i++)
1106 {
1107 file.saveContent(getInside((Container)group[i]));
1108 }
1109 }
1110
1111 file.startContent(5);
1112 file.saveContent(messages.getString("" + vp.isVisible()));
1113
1114 file.startContent(7);
1115 file.saveContent(vp.getToolTipText());
1116
1117 return file;
1118 }
1119
1120 /**
1121 * This method will get all the information of the Box.
1122 * (Precondition: box != null)
1123 * @param box its the Box we want to get the information from.
1124 * @return a UserComponent that will hold the information about this Box.
1125 */
1126 public UserComponent getBoxInfo (Box box)
1127 {
1128 UserComponent file;
1129 file = new UserComponent();
1130 Component[] group;
1131 group = box.getComponents();
1132 int i;
1133
1134 file.startContent(1);
1135 file.saveContent("Box");
1136
1137 file.startContent(2);
1138 file.saveContent(messages.getString("Box"));
1139
1140 if (group != null)
1141 {
1142 file.startContent(3);
1143 for (i = 0; i < group.length ; i++)
1144 {
1145 file.saveContent(getInside((Container)group[i]));
1146 }
1147 }
1148
1149 file.startContent(5);
1150 file.saveContent(messages.getString("" + box.isVisible()));
1151
1152 file.startContent(7);
1153 file.saveContent(box.getToolTipText());
1154
1155 return file;
1156 }
1157
1158 /**
1159 * This method will get all the information of the JSplitPane.
1160 * (Precondition: split != null)
1161 * @param split its the JSplitPane we want to get the information from.
1162 * @return a UserComponent that will hold the information about this JSplitPane.
1163 */
1164 public UserComponent getSplitPaneInfo (JSplitPane split)
1165 {
1166 UserComponent file;
1167 file = new UserComponent();
1168 Component[] group;
1169 group = split.getComponents();
1170 int i;
1171
1172 file.startContent(1);
1173 file.saveContent("JSplitPane");
1174
1175 file.startContent(2);
1176 file.saveContent(messages.getString("Splitters"));
1177
1178 if (group != null)
1179 {
1180 file.startContent(3);
1181 for (i = 0; i < group.length ; i++)
1182 {
1183 file.saveContent(getInside((Container)group[i]));
1184 }
1185 }
1186
1187 file.startContent(5);
1188 file.saveContent(messages.getString("" + split.isVisible()));
1189
1190 file.startContent(7);
1191 file.saveContent(split.getToolTipText());
1192
1193 return file;
1194 }
1195
1196 /**
1197 * This method will get all the information and add special list selection listener to the JList.
1198 * (Precondition: list != null)
1199 * @param list its the JList we want to get the information from.
1200 * @return a UserComponent that will hold the information about this JList.
1201 */
1202 public UserComponent getListInfo (JList list)
1203 {
1204 UserComponent file;
1205 file = new UserComponent();
1206 ListModel ls;
1207 ls = list.getModel();
1208 int i;
1209
1210 list.removeListSelectionListener(m);
1211 list.addListSelectionListener(m);
1212
1213 if (ls != null)
1214 {
1215 if (hash.containsKey(ls) == false)
1216 hash.put(ls,list);
1217 ls.removeListDataListener(m);
1218 ls.addListDataListener(m);
1219 }
1220
1221 file.startContent(1);
1222 file.saveContent("JList");
1223
1224 file.startContent(2);
1225 file.saveContent(messages.getString("List"));
1226
1227 if (ls != null)
1228 {
1229 file.startContent(3);
1230 for ( i = 0 ; i < ls.getSize() ; i++)
1231 {
1232 UserComponent file2;
1233 file2 = new UserComponent();
1234 //Assume that its all a text
1235 file2.startContent(3);
1236 String text;
1237 Object obj;
1238 obj = ls.getElementAt(i);
1239
1240 if (obj instanceof String)
1241 text = (String) obj;
1242 else
1243 text = obj.toString();
1244
1245 if (text != null)
1246 file2.saveContent(text);
1247 else
1248 file2.saveContent(" ");
1249
1250 file2.startContent(4);
1251 if ( i == list.getSelectedIndex())
1252 {
1253 file2.saveContent(messages.getString("Selected"));
1254 }
1255 else
1256 file2.saveContent(messages.getString("NotSelected"));
1257
1258 file.saveContent(file2);
1259 }
1260 }
1261
1262 file.startContent(5);
1263 file.saveContent(messages.getString("" + list.isVisible()));
1264
1265 file.startContent(7);
1266 file.saveContent(list.getToolTipText());
1267
1268 return file;
1269 }
1270
1271 /**
1272 * This method will get all the information and add special change listener to the JColorChooser.
1273 * (Precondition: color != null)
1274 * @param color its the JColorChooser we want to get the information from.
1275 * @return a UserComponent that will hold the information about this JColorChooser.
1276 */
1277 public UserComponent getColorInfo (JColorChooser color)
1278 {
1279 UserComponent file;
1280 file = new UserComponent();
1281 ColorSelectionModel cm;
1282 cm = color.getSelectionModel();
1283 int i;
1284
1285 if (cm != null)
1286 {
1287 if (hash.containsKey(cm) == false)
1288 hash.put(cm,color);
1289 cm.removeChangeListener(m);
1290 cm.addChangeListener(m);
1291 }
1292
1293 file.startContent(1);
1294 file.saveContent("JColorChooser");
1295
1296 file.startContent(2);
1297 file.saveContent(messages.getString("ColorChooser"));
1298
1299 file.startContent(3);
1300 UserComponent file2;
1301 file2 = new UserComponent();
1302 file2.startContent(2);
1303 file2.saveContent(messages.getString("PreviewPanel"));
1304
1305 file2.startContent(3);
1306 file2.saveContent(getInside((Container) color.getPreviewPanel()));
1307
1308 file.saveContent(file2);
1309
1310 file2 = new UserComponent();
1311 file2.startContent(2);
1312 file2.saveContent(messages.getString("ChooserPanels"));
1313
1314 AbstractColorChooserPanel[] cp;
1315 cp = color.getChooserPanels();
1316 if ((cp != null) && (cp.length != 0))
1317 {
1318 file2.startContent(3);
1319 for (i = 0 ; i < cp.length ; i++)
1320 {
1321 UserComponent file3;
1322 file3 = new UserComponent();
1323 file3.startContent(2);
1324 file3.saveContent(cp[i].getDisplayName());
1325
1326 ColorSelectionModel cpsm;
1327 cpsm = cp[i].getColorSelectionModel();
1328
1329 if (cpsm != null)
1330 {
1331 file3.startContent(3);
1332 file3.saveContent("" +
1333 cpsm.getSelectedColor());
1334 }
1335
1336 file3.startContent(6);
1337 Icon img = cp[i].getSmallDisplayIcon();
1338 if (img != null)
1339 {
1340 file3.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
1341 }
1342 else
1343 {
1344 file3.saveContent(messages.getString("NoImage"));
1345 }
1346
1347 file3.startContent(6);
1348 img = cp[i].getLargeDisplayIcon();
1349 if (img != null)
1350 {
1351 file3.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
1352 }
1353 else
1354 {
1355 file3.saveContent(messages.getString("NoImage"));
1356 }
1357 file2.saveContent(file3);
1358 }
1359 }
1360
1361 file.saveContent(file2);
1362
1363 file.startContent(4);
1364 file.saveContent("" + cm.getSelectedColor().toString());
1365
1366 file.startContent(5);
1367 file.saveContent(messages.getString("" + color.isVisible()));
1368
1369 file.startContent(7);
1370 file.saveContent(color.getToolTipText());
1371
1372 return file;
1373 }
1374
1375 /**
1376 * This method will get all the information and add special action listener to the JFileChooser.
1377 * (Precondition: fc != null)
1378 * @param fc its the JFileChooser we want to get the information from.
1379 * @return a UserComponent that will hold the information about this JFileChooser.
1380 */
1381 public UserComponent getFileChooserInfo (JFileChooser fc)
1382 {
1383 UserComponent file;
1384 file = new UserComponent();
1385 int i;
1386
1387 fc.removeActionListener(m);
1388 fc.addActionListener(m);
1389
1390 file.startContent(1);
1391 file.saveContent("JFileChooser");
1392
1393 file.startContent(2);
1394 file.saveContent(fc.getDialogTitle());
1395
1396 File[] f;
1397 f = fc.getSelectedFiles();
1398
1399 if (f != null)
1400 {
1401 file.startContent(3);
1402
1403 for ( i = 0 ; i < f.length ; i++)
1404 {
1405 UserComponent file2;
1406 file2 = new UserComponent();
1407 file2.startContent(1);
1408 file2.saveContent(fc.getTypeDescription(f[i]));
1409
1410 file2.startContent(2);
1411 file2.saveContent(fc.getName(f[i]));
1412
1413 file2.startContent(6);
1414 Icon img = fc.getIcon(f[i]);
1415 if (img != null)
1416 {
1417 file2.saveImage(img,messages.getString("icon")+img.hashCode()+".jpg");
1418 }
1419 else
1420 {
1421 file2.saveContent(messages.getString("NoImage"));
1422 }
1423 file.saveContent(file2);
1424 }
1425 }
1426
1427 file.startContent(5);
1428 file.saveContent(messages.getString("" + fc.isVisible()));
1429
1430 file.startContent(7);
1431 file.saveContent(fc.getToolTipText());
1432
1433 return file;
1434 }
1435
1436 /**
1437 * This method will get all the information and add special list selection and column model listener
1438 * to the JTable.
1439 * (Precondition: table != null)
1440 * @param table its the JTable we want to get the information from.
1441 * @return a UserComponent that will hold the information about this JTable.
1442 */
1443 public UserComponent getTableInfo (JTable table)
1444 {
1445 UserComponent file;
1446 file = new UserComponent();
1447 TableModel tm;
1448 tm = table.getModel();
1449 int i,j;
1450 String text;
1451
1452 TableColumnModel tcm;
1453 tcm = table.getColumnModel();
1454 ListSelectionModel lm;
1455 lm = table.getSelectionModel();
1456
1457 if (lm != null)
1458 {
1459 if (hash.containsKey(lm) == false)
1460 hash.put(lm,table);
1461 lm.removeListSelectionListener(m);
1462 lm.addListSelectionListener(m);
1463 }
1464
1465 if (tcm != null)
1466 {
1467 if (hash.containsKey(tcm) == false)
1468 hash.put(tcm,table);
1469 tcm.removeColumnModelListener(m);
1470 tcm.addColumnModelListener(m);
1471 }
1472
1473 file.startContent(1);
1474 file.saveContent("JTable");
1475
1476 file.startContent(2);
1477 file.saveContent(messages.getString("Table"));
1478
1479 if (tm != null)
1480 {
1481 file.startContent(3);
1482 for ( i = 0 ; i < tm.getRowCount() ; i++)
1483 {
1484 UserComponent file2;
1485 file2 = new UserComponent();
1486
1487 file2.startContent(2);
1488 text = messages.getString("row") +" " + (i + 1);
1489 file2.saveContent(text);
1490
1491 file2.startContent(3);
1492 for ( j = 0 ; j < tm.getColumnCount() ; j++)
1493 {
1494 UserComponent file3;
1495 file3 = new UserComponent();
1496
1497 file3.startContent(2);
1498 file3.saveContent(tm.getColumnName(j));
1499
1500 file3.startContent(3);
1501
1502 Object obj;
1503 obj = tm.getValueAt(i,j);
1504
1505 if (obj instanceof String)
1506 file3.saveContent((String)obj);
1507 else
1508 file3.saveContent(obj.toString());
1509
1510 file3.startContent(4);
1511 if (table.isCellSelected(i,j) == true)
1512 {
1513 file3.saveContent(messages.getString("Selected"));
1514 }
1515 else
1516 file3.saveContent(messages.getString("NotSelected"));
1517
1518 file2.saveContent(file3);
1519 }
1520
1521 file.saveContent(file2);
1522 }
1523 }
1524
1525 file.startContent(5);
1526 file.saveContent(messages.getString("" + table.isVisible()));
1527
1528 file.startContent(7);
1529 file.saveContent(table.getToolTipText());
1530
1531 return file;
1532 }
1533
1534 /**
1535 * This method will get all the information of the JScrollBar.
1536 * (Precondition: scroll != null)
1537 * @param scroll its the JScrollBar we want to get the information from.
1538 * @return a UserComponent that will hold the information about this JScrollBar.
1539 */
1540 public UserComponent getScrollBarInfo (JScrollBar scroll)
1541 {
1542 UserComponent file;
1543 file = new UserComponent();
1544
1545 file.startContent(1);
1546 file.saveContent("JScrollBar");
1547
1548 file.startContent(2);
1549 file.saveContent(messages.getString("ScrollerBar"));
1550
1551 file.startContent(3);
1552 file.saveContent(""+ scroll.getOrientation()+ " :"+ scroll.getValue());
1553
1554 file.startContent(5);
1555 file.saveContent(messages.getString("" + scroll.isVisible()));
1556
1557 file.startContent(7);
1558 file.saveContent(scroll.getToolTipText());
1559
1560 return file;
1561 }
1562
1563 /**
1564 * This method will get all the information and add special tree selection listener to the JTree.
1565 * (Precondition: tree != null)
1566 * @param tree its the JTree we want to get the information from.
1567 * @return a UserComponent that will hold the information about this JTree.
1568 */
1569 public UserComponent getTreeInfo (JTree tree)
1570 {
1571 UserComponent file;
1572 file = new UserComponent();
1573 TreeModel tm;
1574 tm = tree.getModel();
1575 int i;
1576
1577 tree.removeTreeSelectionListener(m);
1578 tree.addTreeSelectionListener(m);
1579
1580 if (tm != null)
1581 {
1582 if (hash.containsKey(tm) == false)
1583 hash.put(tm,tree);
1584 tm.removeTreeModelListener(m);
1585 tm.addTreeModelListener(m);
1586 }
1587
1588 file.startContent(1);
1589 file.saveContent("JTree");
1590
1591 file.startContent(2);
1592 file.saveContent(messages.getString("Tree"));
1593
1594 file.startContent(3);
1595 Object root;
1596 root = tm.getRoot();
1597 file.saveContent(getChildInfo(tm,root,tree));
1598
1599 file.startContent(5);
1600 file.saveContent(messages.getString("" + tree.isVisible()));
1601
1602 file.startContent(7);
1603 file.saveContent(tree.getToolTipText());
1604
1605 return file;
1606 }
1607
1608 /**
1609 * This method will get all the information about the parent node and all the childs of it inside the JTree.
1610 * (Precondition: (tree != null) && (tm != null) && (parent != null))
1611 * @param tm its the tree model of the JTree.
1612 * @param parent its the parent node that we want to get all the child information from.
1613 * @param tree its the JTree where the parent node belongs to.
1614 * @return a UserComponent that will hold the information about this parent node.
1615 */
1616 private UserComponent getChildInfo (TreeModel tm,Object parent,JTree tree)
1617 {
1618 UserComponent file;
1619 file = new UserComponent();
1620 if (tm.isLeaf(parent) == false)
1621 {
1622 file.startContent(2);
1623 String text;
1624 text = parent.toString();
1625 if (text != null)
1626 file.saveContent(text);
1627 else
1628 file.saveContent(" ");
1629
1630 int j;
1631 for (j = 0 ; j < tm.getChildCount(parent) ; j++)
1632 {
1633 file.startContent(3);
1634 Object child;
1635 child = tm.getChild(parent,j);
1636 file.saveContent(getChildInfo(tm,child,tree));
1637 }
1638 }
1639 else
1640 {
1641 file.startContent(2);
1642 String text;
1643 text = parent.toString();
1644 if (text != null)
1645 file.saveContent(text);
1646 else
1647 file.saveContent(" ");
1648 }
1649 return file;
1650 }
1651
1652 /**
1653 * This method will get all the information of a Container that is not belongs to any of the more specified
1654 * method stated in this class.
1655 * (Precondition: pane != null)
1656 * @param pane its the Container component we want to get the information from.
1657 * @return a UserComponent that will hold the information about this Container.
1658 */
1659 public UserComponent getCompInfo (Container pane)
1660 {
1661 UserComponent file;
1662 file = new UserComponent();
1663 Component[] group;
1664 group = pane.getComponents();
1665 int i;
1666
1667 file.startContent(1);
1668 file.saveContent("Container");
1669
1670 file.startContent(2);
1671 file.saveContent(messages.getString("Container"));
1672
1673 if (group != null)
1674 {
1675 file.startContent(3);
1676 file.saveContent(messages.getString("TitlePane"));
1677 file.saveContent(getInside(null));
1678 /*for (i = 0; i < group.length ; i++)
1679 {
1680 file.saveContent(getInside((Container)pane.getComponent(i)));
1681 }*/
1682 }
1683
1684 file.startContent(5);
1685 file.saveContent(messages.getString("" + pane.isVisible()));
1686
1687 return file;
1688 }
1689
1690 /**
1691 * This method will get all the information of the JPopupMenu.
1692 * (Precondition: popup != null)
1693 * @param popup its the JPopUpMenu we want to get the information from.
1694 * @return a UserComponent that will hold the information about this JPopupMenu.
1695 */
1696 public UserComponent getPopUpMenuInfo (JPopupMenu popup)
1697 {
1698 UserComponent file;
1699 file = new UserComponent();
1700 Component[] group;
1701 group = popup.getComponents();
1702 SingleSelectionModel sm;
1703 sm = popup.getSelectionModel();
1704 int i;
1705
1706 file.startContent(1);
1707 file.saveContent("JPopUpMenu");
1708
1709 file.startContent(2);
1710 String text;
1711 text = popup.getLabel();
1712 if (text != null)
1713 file.saveContent(popup.getLabel());
1714 else
1715 file.saveContent(" ");
1716
1717 if (group != null)
1718 {
1719 file.startContent(3);
1720 for (i = 0; i < group.length ; i++)
1721 {
1722 file.saveContent(getInside((Container)popup.getComponent(i)));
1723 }
1724 }
1725
1726 if (sm != null)
1727 {
1728 file.startContent(4);
1729 file.saveContent("" + sm.getSelectedIndex());
1730 }
1731
1732 file.startContent(5);
1733 file.saveContent(messages.getString("" + popup.isVisible()));
1734
1735 file.startContent(7);
1736 file.saveContent(popup.getToolTipText());
1737
1738 return file;
1739 }
1740
1741 /**
1742 * This method will get all the information of the JRootPane.
1743 * (Precondition: pane != null)
1744 * @param pane its the JRootPane we want to get the information from.
1745 * @return a UserComponent that will hold the information about this JRootPane.
1746 */
1747 public UserComponent getRootPaneInfo (JRootPane pane)
1748 {
1749 UserComponent file;
1750 file = new UserComponent();
1751 Component[] group;
1752 group = pane.getComponents();
1753 int i;
1754
1755 file.startContent(1);
1756 file.saveContent("JRootPane");
1757
1758 file.startContent(2);
1759 file.saveContent(messages.getString("RootPane"));
1760
1761 if (group != null)
1762 {
1763 file.startContent(3);
1764 for (i = 0; i < group.length ; i++)
1765 {
1766
1767 file.saveContent(getInside((Container)pane.getComponent(i)));
1768 }
1769 }
1770
1771 file.startContent(5);
1772 file.saveContent(messages.getString("" + pane.isVisible()));
1773
1774 file.startContent(7);
1775 file.saveContent(pane.getToolTipText());
1776
1777 return file;
1778 }
1779
1780 /**
1781 * This method will get all the information of the JLayeredPane.
1782 * (Precondition: pane != null)
1783 * @param pane its the JLayeredPane we want to get the information from.
1784 * @return a UserComponent that will hold the information about this JLayeredPane.
1785 */
1786 public UserComponent getLayeredPaneInfo (JLayeredPane pane)
1787 {
1788 UserComponent file;
1789 file = new UserComponent();
1790 Component[] group;
1791 group = pane.getComponents();
1792 int i;
1793
1794 file.startContent(1);
1795 file.saveContent("JLayeredPane");
1796
1797 file.startContent(2);
1798 file.saveContent(messages.getString("LayeredPane"));
1799
1800 if (group != null)
1801 {
1802 file.startContent(3);
1803 for (i = 0; i < group.length ; i++)
1804 {
1805 file.saveContent(getInside((Container)pane.getComponent(i)));
1806 }
1807 }
1808
1809 file.startContent(5);
1810 file.saveContent(messages.getString("" + pane.isVisible()));
1811
1812 file.startContent(7);
1813 file.saveContent(pane.getToolTipText());
1814
1815 return file;
1816 }
1817
1818 /**
1819 * This method will get all the information of the BasicInternalFrameTitlePane.
1820 * (Precondition: pane != null)
1821 * @param pane its the BasicInternalFrameTitlePane we want to get the information from.
1822 * @return a UserComponent that will hold the information about this BasicInternalFrameTitlePane.
1823 */
1824 public UserComponent getInternalFrameTitleInfo (BasicInternalFrameTitlePane pane)
1825 {
1826 UserComponent file;
1827 file = new UserComponent();
1828 Component[] group;
1829 group = pane.getComponents();
1830 int i;
1831
1832 file.startContent(1);
1833 file.saveContent("BasicInternalFrameTitlePane");
1834
1835 file.startContent(2);
1836 file.saveContent(messages.getString("InternalFrameTitlePane"));
1837
1838 /*if (group != null)
1839 {
1840 file.startContent(3);
1841 for (i = 0; i < group.length ; i++)
1842 {
1843 Component c;
1844 c = pane.getComponent(i);
1845
1846 else
1847 file.saveContent(getInside((Container)pane.getComponent(i)));
1848 }
1849 }*/
1850
1851 file.startContent(5);
1852 file.saveContent(messages.getString("" + pane.isVisible()));
1853
1854 file.startContent(7);
1855 file.saveContent(pane.getToolTipText());
1856
1857 return file;
1858 }
1859
1860 /**
1861 * This method will get all the information and add special column model and list selection
1862 * listener to JTableHeader.
1863 * (Precondition: header != null)
1864 * @param header its the JTableHeader we want to get the information from.
1865 * @return a UserComponent that will hold the information about this JTableHeader.
1866 */
1867 public UserComponent getTableHeaderInfo (JTableHeader header)
1868 {
1869 UserComponent file;
1870 file = new UserComponent();
1871 TableColumnModel tcm;
1872 tcm = header.getColumnModel();
1873 ListSelectionModel lm;
1874 lm = tcm.getSelectionModel();
1875
1876 if (tcm != null)
1877 {
1878 if (hash.containsKey(tcm) == false)
1879 hash.put(tcm,header);
1880 tcm.removeColumnModelListener(m);
1881 tcm.addColumnModelListener(m);
1882 }
1883
1884 if (lm != null)
1885 {
1886 if (hash.containsKey(lm) == false)
1887 hash.put(lm,header);
1888 lm.removeListSelectionListener(m);
1889 lm.addListSelectionListener(m);
1890 }
1891
1892 file.startContent(1);
1893 file.saveContent("JTableHeader");
1894
1895 file.startContent(2);
1896 file.saveContent(messages.getString("TableHeader"));
1897
1898 if (tcm != null)
1899 {
1900 int[] select = tcm.getSelectedColumns();
1901
1902 if (select != null)
1903 {
1904 file.startContent(3);
1905 for (int i = 0 ; i < select.length ; i++)
1906 {
1907 UserComponent file2;
1908 file2 = new UserComponent();
1909 file2.startContent(4);
1910 file2.saveContent("" + select[i]);
1911
1912 file.saveContent(file2);
1913 }
1914 }
1915 }
1916
1917 file.startContent(5);
1918 file.saveContent(messages.getString("" + header.isVisible()));
1919
1920 file.startContent(7);
1921 file.saveContent(header.getToolTipText());
1922
1923 return file;
1924 }
1925
1926 /**
1927 * This method will get all the information of the JToolBar.
1928 * (Precondition: tool != null)
1929 * @param tool its the JToolBar we want to get the information from.
1930 * @return a UserComponent that will hold the information about this JToolBar.
1931 */
1932 public UserComponent getToolBarInfo (JToolBar tool)
1933 {
1934 UserComponent file;
1935 file = new UserComponent();
1936 Component[] group;
1937 group = tool.getComponents();
1938 int i;
1939
1940 file.startContent(1);
1941 file.saveContent("JToolBar");
1942
1943 file.startContent(2);
1944 file.saveContent(messages.getString("ToolBar"));
1945
1946 if (group != null)
1947 {
1948 file.startContent(3);
1949 for (i = 0; i < group.length ; i++)
1950 {
1951 file.saveContent(getInside((Container)tool.getComponent(i)));
1952 }
1953 }
1954
1955 file.startContent(5);
1956 file.saveContent(messages.getString("" + tool.isVisible()));
1957
1958 file.startContent(7);
1959 file.saveContent(tool.getToolTipText());
1960
1961 return file;
1962 }
1963
1964 /**
1965 * This method will get all the information of the JToolTip.
1966 * (Precondition: tip != null)
1967 * @param tip its the JToolTip we want to get the information from.
1968 * @return a UserComponent that will hold the information about this JToolTip.
1969 */
1970 public UserComponent getToolTipInfo (JToolTip tip)
1971 {
1972 UserComponent file;
1973 file = new UserComponent();
1974 Component group;
1975 group = tip.getComponent();
1976 int i;
1977
1978 file.startContent(1);
1979 file.saveContent("JToolTip");
1980
1981 file.startContent(2);
1982 String text;
1983 text = tip.getTipText();
1984 if (text != null)
1985 file.saveContent(tip.getTipText());
1986 else
1987 file.saveContent(" ");
1988
1989 if (group != null)
1990 {
1991 file.startContent(3);
1992 file.saveContent(getInside((Container) group));
1993 }
1994
1995 file.startContent(5);
1996 file.saveContent(messages.getString("" + tip.isVisible()));
1997
1998 return file;
1999 }
2000
2001 /**
2002 * This method will get all the information of the JSeparator.
2003 * (Precondition: sept != null)
2004 * @param sept its the JSeparator we want to get the information from.
2005 * @return a UserComponent that will hold the information about this JSeparator.
2006 */
2007 public UserComponent getSeparatorInfo (JSeparator sept)
2008 {
2009 UserComponent file;
2010 file = new UserComponent();
2011
2012 file.startContent(1);
2013 file.saveContent("JSeparator");
2014
2015 file.startContent(2);
2016 file.saveContent(messages.getString("Separator"));
2017
2018 file.startContent(5);
2019 file.saveContent(messages.getString("" + sept.isVisible()));
2020
2021 file.startContent(7);
2022 file.saveContent(sept.getToolTipText());
2023
2024 return file;
2025 }
2026
2027 /**
2028 * This method will get all the information of the JDesktopPane.
2029 * (Precondition: pane != null)
2030 * @param pane its the JDesktopPane we want to get the information from.
2031 * @return a UserComponent that will hold the information about this JDesktopPane.
2032 */
2033 public UserComponent getDesktopPaneInfo (JDesktopPane pane)
2034 {
2035 UserComponent file;
2036 file = new UserComponent();
2037 JInternalFrame[] group;
2038 group = pane.getAllFrames();
2039
2040 file.startContent(1);
2041 file.saveContent("JDesktopPane");
2042
2043 file.startContent(2);
2044 file.saveContent(messages.getString("DesktopPane"));
2045
2046 if (group != null)
2047 {
2048 int i;
2049 file.startContent(3);
2050 for ( i = 0 ; i < group.length ; i++ )
2051 {
2052 file.saveContent (getInside((Container) group[i]));
2053 }
2054 }
2055
2056 file.startContent(5);
2057 file.saveContent(messages.getString("" + pane.isVisible()));
2058
2059 file.startContent(7);
2060 file.saveContent(pane.getToolTipText());
2061
2062 return file;
2063 }
2064
2065 /**
2066 * This method will give you a UserComponent that hold the information saying
2067 * the component is null (no component).
2068 * @return a UserComponent that will hold the information saying its a null component.
2069 */
2070 public UserComponent getNullInfo ()
2071 {
2072 UserComponent file;
2073 file = new UserComponent();
2074
2075 file.startContent(1);
2076 file.saveContent(messages.getString("NoComponent"));
2077
2078 return file;
2079 }
2080
2081 /**
2082 * This method will get all information about any kind of Container.
2083 * This method is the gateway to all other methods in this class and will give you all
2084 * information about the Container and whats inside it.If you dont know what the specific class
2085 * of your container then you go here and it will sort which appropriate method
2086 * this container should go to in this class.
2087 * @param comp its the Container we want to get the information from.
2088 * @return a UserComponent that hold the information about this Container.
2089 */
2090 public UserComponent getInside(Container comp)
2091 {
2092 if (comp == null)
2093 {
2094 return getNullInfo();
2095 }
2096 else if (comp instanceof JApplet)
2097 {
2098 return getAppletInfo ((JApplet) comp);
2099 }
2100 else if (comp instanceof JSeparator)
2101 {
2102 return getSeparatorInfo ((JSeparator) comp);
2103 }
2104 else if (comp instanceof JWindow)
2105 {
2106 return getWindowInfo((JWindow) comp);
2107 }
2108 else if (comp instanceof JDialog)
2109 {
2110 return getDialogInfo((JDialog) comp);
2111 }
2112 else if (comp instanceof JComboBox)
2113 {
2114 return getComboBoxInfo((JComboBox) comp);
2115 }
2116 else if (comp instanceof JLabel)
2117 {
2118 return getLabelInfo((JLabel) comp);
2119 }
2120 else if (comp instanceof JTextComponent)
2121 {
2122 return getTextAreaInfo((JTextComponent) comp);
2123 }
2124 else if (comp instanceof JFrame)
2125 {
2126 return getFrameInfo((JFrame) comp);
2127 }
2128 else if (comp instanceof JPanel)
2129 {
2130 return getPanelInfo((JPanel) comp);
2131 }
2132 else if (comp instanceof JScrollPane)
2133 {
2134 return getScrollInfo((JScrollPane) comp);
2135 }
2136 else if (comp instanceof JScrollBar)
2137 {
2138 return getScrollBarInfo ((JScrollBar) comp);
2139 }
2140 else if (comp instanceof JViewport)
2141 {
2142 return getViewPortInfo((JViewport) comp);
2143 }
2144 else if (comp instanceof JTabbedPane)
2145 {
2146 return getTabbedPaneInfo((JTabbedPane) comp);
2147 }
2148 else if (comp instanceof Box)
2149 {
2150 return getBoxInfo((Box) comp);
2151 }
2152 else if (comp instanceof JToggleButton)
2153 {
2154 return getToggleButtonInfo((JToggleButton) comp);
2155 }
2156 else if (comp instanceof JSplitPane)
2157 {
2158 return getSplitPaneInfo ((JSplitPane) comp);
2159 }
2160 else if (comp instanceof JList)
2161 {
2162 return getListInfo ((JList) comp);
2163 }
2164 else if (comp instanceof JTree)
2165 {
2166 return getTreeInfo ((JTree) comp);
2167 }
2168 else if (comp instanceof JTable)
2169 {
2170 return getTableInfo ((JTable) comp);
2171 }
2172 else if (comp instanceof JSlider)
2173 {
2174 return getSliderInfo ((JSlider) comp);
2175 }
2176 else if (comp instanceof JSpinner)
2177 {
2178 return getSpinnerInfo ((JSpinner) comp);
2179 }
2180 else if (comp instanceof JProgressBar)
2181 {
2182 return getProgressBarInfo ((JProgressBar) comp);
2183 }
2184 else if (comp instanceof JButton)
2185 {
2186 return getButtonInfo ((JButton) comp);
2187 }
2188 else if (comp instanceof JMenu)
2189 {
2190 return getMenuInfo ((JMenu) comp);
2191 }
2192 else if (comp instanceof JMenuBar)
2193 {
2194 return getMenuBarInfo ((JMenuBar) comp);
2195 }
2196 else if (comp instanceof JMenuItem)
2197 {
2198 return getMenuItemInfo ((JMenuItem) comp);
2199 }
2200 else if (comp instanceof JOptionPane)
2201 {
2202 return getOptionPaneInfo ((JOptionPane) comp);
2203 }
2204 else if (comp instanceof BasicInternalFrameTitlePane)
2205 {
2206 return getInternalFrameTitleInfo ((BasicInternalFrameTitlePane) comp);
2207 }
2208 else if (comp instanceof JColorChooser)
2209 {
2210 return getColorInfo ((JColorChooser) comp);
2211 }
2212 else if (comp instanceof JFileChooser)
2213 {
2214 return getFileChooserInfo ((JFileChooser) comp);
2215 }
2216 else if (comp instanceof JDesktopPane)
2217 {
2218 return getDesktopPaneInfo ((JDesktopPane) comp);
2219 }
2220 else if (comp instanceof JInternalFrame)
2221 {
2222 return getInternalFrameInfo ((JInternalFrame) comp);
2223 }
2224 else if (comp instanceof JLayeredPane)
2225 {
2226 return getLayeredPaneInfo ((JLayeredPane) comp);
2227 }
2228 else if (comp instanceof JPopupMenu)
2229 {
2230 return getPopUpMenuInfo ((JPopupMenu) comp);
2231 }
2232 else if (comp instanceof JRootPane)
2233 {
2234 return getRootPaneInfo ((JRootPane) comp);
2235 }
2236 else if (comp instanceof JTableHeader)
2237 {
2238 return getTableHeaderInfo ((JTableHeader) comp);
2239 }
2240 else if (comp instanceof JToolBar)
2241 {
2242 return getToolBarInfo ((JToolBar) comp);
2243 }
2244 else if (comp instanceof JToolTip)
2245 {
2246 return getToolTipInfo ((JToolTip) comp);
2247 }
2248 else
2249 {
2250 return getCompInfo (comp);
2251 }
2252 }
2253}
2254
2255
2256
2257
2258
2259
2260
Note: See TracBrowser for help on using the repository browser.