source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/org/greenstone/gatherer/feedback/ComponentInformation.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

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