1 | package org.greenstone.gatherer.feedback;
|
---|
2 |
|
---|
3 | import org.omg.IOP.ComponentIdHelper;
|
---|
4 | import java.awt.*;
|
---|
5 | import java.io.*;
|
---|
6 | import java.util.*;
|
---|
7 | import javax.swing.*;
|
---|
8 | import javax.swing.tree.*;
|
---|
9 | import javax.swing.table.*;
|
---|
10 | import javax.swing.text.*;
|
---|
11 | import java.awt.image.*;
|
---|
12 | import javax.imageio.ImageIO;
|
---|
13 | import javax.swing.plaf.*;
|
---|
14 | import javax.swing.plaf.basic.*;
|
---|
15 | import javax.swing.colorchooser.*;
|
---|
16 | import java.awt.event.*;
|
---|
17 | import javax.swing.event.*;
|
---|
18 | import java.text.MessageFormat;
|
---|
19 | import javax.swing.plaf.metal.MetalIconFactory.*;
|
---|
20 | import javax.swing.plaf.metal.MetalIconFactory;
|
---|
21 | import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
|
---|
22 | import javax.swing.plaf.metal.MetalInternalFrameTitlePane;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * In general, this class will get add special listener
|
---|
26 | * to a Container and of all the components inside it.
|
---|
27 | * <p>This class will also add special listener to the Container and each of the components inside
|
---|
28 | * the Container. So, it will allows special listener to record and listen each of the actions
|
---|
29 | * the user do to the Container or any of the components inside it. The special listener
|
---|
30 | * is an instance of ActionRecorderDialog.</p>
|
---|
31 | * <p>This class will only recognized all the components that is belongs to the javax.swing package
|
---|
32 | * which are all the implementing classes of RootPaneContainer interface and all the direct known
|
---|
33 | * subclasses of JComponent. All the other components will be stated simply as Container
|
---|
34 | * and user cannot really get much information out of it.</p>
|
---|
35 | * <p>The added special listener to this component is as what its allowed in API, if the component
|
---|
36 | * have some modified listener added to it then that action will not be known and recorded by
|
---|
37 | * the special listener.</p>
|
---|
38 | *
|
---|
39 | * @author Veronica Liesaputra
|
---|
40 | */
|
---|
41 | public class CompListener
|
---|
42 | {
|
---|
43 | /**
|
---|
44 | * This variable will hold the special listener that will listen and record any of the
|
---|
45 | * actions user do to the Container and any of the components inside it.
|
---|
46 | */
|
---|
47 | private ActionRecorderDialog m;
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * This variable will hold the pair of the component and the model of the component.
|
---|
51 | * With this variable allows ActionRecorderDialog listener to know which component the model that fires an action
|
---|
52 | * belongs to. In this HashMap the model is the key and the component where the model belongs to is
|
---|
53 | * the value.
|
---|
54 | */
|
---|
55 | private HashMap hash;
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * This constructor will set the special listener, the locale and the hashmap to be used in
|
---|
59 | * this Container.
|
---|
60 | * (Precondition: dialog != null)
|
---|
61 | * @param dialog its the special listener that will listen and record all the action
|
---|
62 | * user do to any of the component inside the Container.
|
---|
63 | * @param h its the HashMap that will hold the pair of model with the component it belongs.
|
---|
64 | */
|
---|
65 | public CompListener
|
---|
66 | (ActionRecorderDialog dialog,HashMap h)
|
---|
67 | {
|
---|
68 | m = dialog;
|
---|
69 | hash = h;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * If the JTextComponent is a JTextField then it will add the special action listener to it.
|
---|
74 | * (Precondition: txt != null)
|
---|
75 | * @param txt its the JTextComponent we want to get all the information from.
|
---|
76 | */
|
---|
77 | public void getTextAreaInfo(JTextComponent txt)
|
---|
78 | {
|
---|
79 | if (txt instanceof JTextField)
|
---|
80 | {
|
---|
81 | ((JTextField)txt).removeActionListener(m);
|
---|
82 | ((JTextField)txt).addActionListener(m);
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * This method will add the special action listener to the JButton.
|
---|
88 | * (Precondition: button != null)
|
---|
89 | * @param button its the JButton we want to get the information from.
|
---|
90 | */
|
---|
91 | public void getButtonInfo (JButton button)
|
---|
92 | {
|
---|
93 | button.removeActionListener(m);
|
---|
94 | button.addActionListener(m);
|
---|
95 | }
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * This method will get add the special change listener to the JProgressBar.
|
---|
99 | * (Precondition: bar != null)
|
---|
100 | * @param bar its the JProgressBar we want to get information from.
|
---|
101 | */
|
---|
102 | public void getProgressBarInfo (JProgressBar bar)
|
---|
103 | {
|
---|
104 | bar.removeChangeListener(m);
|
---|
105 | bar.addChangeListener(m);
|
---|
106 | }
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * This method will add the special change listener to the JSlider.
|
---|
110 | * (Precondition: slider != null)
|
---|
111 | * @param slider its the JSlider we want to get information from.
|
---|
112 | */
|
---|
113 | public void getSliderInfo (JSlider slider)
|
---|
114 | {
|
---|
115 | slider.removeChangeListener(m);
|
---|
116 | slider.addChangeListener(m);
|
---|
117 | }
|
---|
118 |
|
---|
119 | /**
|
---|
120 | * This method will add the special change listener to the JSpinner.
|
---|
121 | * (Precondition: spinner != null)
|
---|
122 | * @param spinner its the JSpinner we want to the information from.
|
---|
123 | */
|
---|
124 | public void getSpinnerInfo (JSpinner spinner)
|
---|
125 | {
|
---|
126 | spinner.removeChangeListener(m);
|
---|
127 | spinner.addChangeListener(m);
|
---|
128 | }
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * Dummy method to get JLabel.
|
---|
132 | */
|
---|
133 | public void getLabelInfo(JLabel lbl)
|
---|
134 | {}
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * This method will add the special action listener to the JComboBox.
|
---|
138 | * (Precondition: box != null)
|
---|
139 | * @param box its the JComboBox we want to get information from.
|
---|
140 | */
|
---|
141 | public void getComboBoxInfo(JComboBox box)
|
---|
142 | {
|
---|
143 | ComboBoxModel cm;
|
---|
144 | cm = box.getModel();
|
---|
145 |
|
---|
146 | box.removeActionListener(m);
|
---|
147 | box.addActionListener(m);
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * This method will add the special action listener to the JToggleButton.
|
---|
152 | * (Precondition: button != null)
|
---|
153 | * @param button its a JToggleButton inside the window.
|
---|
154 | */
|
---|
155 | public void getToggleButtonInfo (JToggleButton button)
|
---|
156 | {
|
---|
157 | button.removeActionListener(m);
|
---|
158 | button.addActionListener(m);
|
---|
159 | }
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * This method will add the special action listener to the JMenuItem.
|
---|
163 | * (Precondition: menuitem != null)
|
---|
164 | * @param menuitem its the JMenuItem we want to get the information from.
|
---|
165 | */
|
---|
166 | public void getMenuItemInfo (JMenuItem menuitem)
|
---|
167 | {
|
---|
168 | menuitem.removeActionListener(m);
|
---|
169 | menuitem.addActionListener(m);
|
---|
170 | }
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * This method will get all the components inside JMenuBar.
|
---|
174 | * (Precondition: menubar != null)
|
---|
175 | * @param menubar its the JMenuBar we want to get the information from.
|
---|
176 | */
|
---|
177 | public void getMenuBarInfo (JMenuBar menubar)
|
---|
178 | {
|
---|
179 | int i;
|
---|
180 | for (i= 0 ; i < menubar.getMenuCount() ; i++)
|
---|
181 | {
|
---|
182 | getInside(menubar.getMenu(i));
|
---|
183 | }
|
---|
184 | }
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * This method will add the special action and menu listener to the JMenu and
|
---|
188 | * get the components inside JMenu.
|
---|
189 | * (Precondition: menu != null)
|
---|
190 | * @param menu its the JMenu we want to the the information from.
|
---|
191 | */
|
---|
192 | public void getMenuInfo (JMenu menu)
|
---|
193 | {
|
---|
194 | menu.removeActionListener(m);
|
---|
195 | menu.removeMenuListener(m);
|
---|
196 | menu.addActionListener(m);
|
---|
197 | menu.addMenuListener(m);
|
---|
198 |
|
---|
199 | int i;
|
---|
200 | for (i= 0 ; i < menu.getMenuComponentCount() ; i++)
|
---|
201 | {
|
---|
202 | getInside((Container)menu.getMenuComponent(i));
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * This method will get all the components inside the JApplet.
|
---|
208 | * (Precondition: applet != null)
|
---|
209 | * @param applet its the JApplet we want to get the information from.
|
---|
210 | */
|
---|
211 | public void getAppletInfo (JApplet applet)
|
---|
212 | {
|
---|
213 | Component[] group;
|
---|
214 | group = applet.getComponents();
|
---|
215 | int i;
|
---|
216 |
|
---|
217 | if (group != null)
|
---|
218 | {
|
---|
219 | for (i = 0; i < group.length ; i++)
|
---|
220 | {
|
---|
221 | getInside((Container)applet.getComponent(i));
|
---|
222 | }
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * This method will get all the components inside the JWindow.
|
---|
228 | * (Precondition: window != null)
|
---|
229 | * @param window its the JWindow we want to get the information from.
|
---|
230 | */
|
---|
231 | public void getWindowInfo (JWindow window)
|
---|
232 | {
|
---|
233 | Component[] group;
|
---|
234 | group = window.getComponents();
|
---|
235 | int i;
|
---|
236 |
|
---|
237 | if (group != null)
|
---|
238 | {
|
---|
239 | for (i = 0; i < group.length ; i++)
|
---|
240 | {
|
---|
241 | getInside((Container)window.getComponent(i));
|
---|
242 | }
|
---|
243 | }
|
---|
244 | }
|
---|
245 |
|
---|
246 | /**
|
---|
247 | * This method will get all the components inside the JDialog.
|
---|
248 | * (Precondition: dialog != null)
|
---|
249 | * @param dialog its the JDialog we want to get the information from.
|
---|
250 | */
|
---|
251 | public void getDialogInfo (JDialog dialog)
|
---|
252 | {
|
---|
253 | Component[] group;
|
---|
254 | group = dialog.getComponents();
|
---|
255 | int i;
|
---|
256 |
|
---|
257 | if (group != null)
|
---|
258 | {
|
---|
259 | for (i = 0; i < group.length ; i++)
|
---|
260 | {
|
---|
261 | getInside((Container)dialog.getComponent(i));
|
---|
262 | }
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * This method will get all the components inside the JInternalFrame.
|
---|
268 | * (Precondition: frame != null)
|
---|
269 | * @param frame its the JInternalFrame we want to get the information from.
|
---|
270 | */
|
---|
271 | public void getInternalFrameInfo (JInternalFrame frame)
|
---|
272 | {
|
---|
273 | Component[] group;
|
---|
274 | group = frame.getComponents();
|
---|
275 | int i;
|
---|
276 |
|
---|
277 | if (group != null)
|
---|
278 | {
|
---|
279 | for (i = 0; i < group.length ; i++)
|
---|
280 | {
|
---|
281 | getInside((Container)frame.getComponent(i));
|
---|
282 | }
|
---|
283 | }
|
---|
284 | }
|
---|
285 |
|
---|
286 | /**
|
---|
287 | * This method will get all the components inside the JFrame.
|
---|
288 | * (Precondition: frame != null)
|
---|
289 | * @param frame its the JFrame we want to get the information from.
|
---|
290 | */
|
---|
291 | public void getFrameInfo (JFrame frame)
|
---|
292 | {
|
---|
293 | Component[] group;
|
---|
294 | group = frame.getComponents();
|
---|
295 | int i;
|
---|
296 |
|
---|
297 | if (group != null)
|
---|
298 | {
|
---|
299 | for (i = 0; i < group.length ; i++)
|
---|
300 | {
|
---|
301 | getInside((Container)frame.getComponent(i));
|
---|
302 | }
|
---|
303 | }
|
---|
304 | }
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * This method will get all the components inside the JPanel.
|
---|
308 | * (Precondition: pane != null)
|
---|
309 | * @param pane its the JPanel we want to get the information from.
|
---|
310 | */
|
---|
311 | public void getPanelInfo (JPanel pane)
|
---|
312 | {
|
---|
313 | Component[] group;
|
---|
314 | group = pane.getComponents();
|
---|
315 | int i;
|
---|
316 |
|
---|
317 | if (group != null)
|
---|
318 | {
|
---|
319 | for (i = 0; i < group.length ; i++)
|
---|
320 | {
|
---|
321 | getInside((Container)pane.getComponent(i));
|
---|
322 | }
|
---|
323 | }
|
---|
324 | }
|
---|
325 |
|
---|
326 | /**
|
---|
327 | * This method will get all the components inside the JScrollPane.
|
---|
328 | * (Precondition: scroll != null)
|
---|
329 | * @param scroll its the JScrollPane we want to get the information from.
|
---|
330 | */
|
---|
331 | public void getScrollInfo (JScrollPane scroll)
|
---|
332 | {
|
---|
333 | Component[] group;
|
---|
334 | group = scroll.getComponents();
|
---|
335 | int i;
|
---|
336 |
|
---|
337 | if (group != null)
|
---|
338 | {
|
---|
339 | for (i = 0; i < group.length ; i++)
|
---|
340 | {
|
---|
341 | getInside((Container)group[i]);
|
---|
342 | }
|
---|
343 | }
|
---|
344 | }
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * This method will add special change listener to the JTabbedPane and get all
|
---|
348 | * the components inside it.
|
---|
349 | * (Precondition: tab != null)
|
---|
350 | * @param tab its the JTabbedPane we want to get the information from.
|
---|
351 | */
|
---|
352 | public void getTabbedPaneInfo (JTabbedPane tab)
|
---|
353 | {
|
---|
354 | int j;
|
---|
355 |
|
---|
356 | tab.removeChangeListener(m);
|
---|
357 | tab.addChangeListener(m);
|
---|
358 |
|
---|
359 | for (j = 0 ; j < tab.getTabCount(); j++)
|
---|
360 | {
|
---|
361 |
|
---|
362 | Component group = tab.getComponentAt(j);
|
---|
363 | getInside((Container)group);
|
---|
364 |
|
---|
365 | }
|
---|
366 | }
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * This is the dummy method to ge the option pane info.
|
---|
370 | */
|
---|
371 | public void getOptionPaneInfo (JOptionPane op)
|
---|
372 | {}
|
---|
373 |
|
---|
374 | /**
|
---|
375 | * This method will get components inside the JViewPort.
|
---|
376 | * (Precondition: vp != null)
|
---|
377 | * @param vp its the JViewPort we want to get the information from.
|
---|
378 | */
|
---|
379 | public void getViewPortInfo (JViewport vp)
|
---|
380 | {
|
---|
381 | Component[] group;
|
---|
382 | group = vp.getComponents();
|
---|
383 | int i;
|
---|
384 |
|
---|
385 | if (group != null)
|
---|
386 | {
|
---|
387 | for (i = 0; i < group.length ; i++)
|
---|
388 | {
|
---|
389 | getInside((Container)group[i]);
|
---|
390 | }
|
---|
391 | }
|
---|
392 | }
|
---|
393 |
|
---|
394 | /**
|
---|
395 | * This method will get components inside the Box.
|
---|
396 | * (Precondition: box != null)
|
---|
397 | * @param box its the Box we want to get the information from.
|
---|
398 | */
|
---|
399 | public void getBoxInfo (Box box)
|
---|
400 | {
|
---|
401 | Component[] group;
|
---|
402 | group = box.getComponents();
|
---|
403 | int i;
|
---|
404 |
|
---|
405 | if (group != null)
|
---|
406 | {
|
---|
407 | for (i = 0; i < group.length ; i++)
|
---|
408 | {
|
---|
409 | getInside((Container)group[i]);
|
---|
410 | }
|
---|
411 | }
|
---|
412 | }
|
---|
413 |
|
---|
414 | /**
|
---|
415 | * This method will get components inside the JSplitPane.
|
---|
416 | * (Precondition: split != null)
|
---|
417 | * @param split its the JSplitPane we want to get the information from.
|
---|
418 | */
|
---|
419 | public void getSplitPaneInfo (JSplitPane split)
|
---|
420 | {
|
---|
421 | Component[] group;
|
---|
422 | group = split.getComponents();
|
---|
423 | int i;
|
---|
424 |
|
---|
425 | if (group != null)
|
---|
426 | {
|
---|
427 | for (i = 0; i < group.length ; i++)
|
---|
428 | {
|
---|
429 | getInside((Container)group[i]);
|
---|
430 | }
|
---|
431 | }
|
---|
432 | }
|
---|
433 |
|
---|
434 | /**
|
---|
435 | * This method will get add special list selection listener to the JList.
|
---|
436 | * (Precondition: list != null)
|
---|
437 | * @param list its the JList we want to get the information from.
|
---|
438 | */
|
---|
439 | public void getListInfo (JList list)
|
---|
440 | {
|
---|
441 | ListModel ls;
|
---|
442 | ls = list.getModel();
|
---|
443 |
|
---|
444 | list.removeListSelectionListener(m);
|
---|
445 | list.addListSelectionListener(m);
|
---|
446 |
|
---|
447 | if (ls != null)
|
---|
448 | {
|
---|
449 | if (hash.containsKey(ls) == false)
|
---|
450 | hash.put(ls,list);
|
---|
451 | ls.removeListDataListener(m);
|
---|
452 | ls.addListDataListener(m);
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * This method will add special change listener to the JColorChooser.
|
---|
458 | * (Precondition: color != null)
|
---|
459 | * @param color its the JColorChooser we want to get the information from.
|
---|
460 | */
|
---|
461 | public void getColorInfo (JColorChooser color)
|
---|
462 | {
|
---|
463 | ColorSelectionModel cm;
|
---|
464 | cm = color.getSelectionModel();
|
---|
465 |
|
---|
466 | if (cm != null)
|
---|
467 | {
|
---|
468 | if (hash.containsKey(cm) == false)
|
---|
469 | hash.put(cm,color);
|
---|
470 | cm.removeChangeListener(m);
|
---|
471 | cm.addChangeListener(m);
|
---|
472 | }
|
---|
473 |
|
---|
474 | getInside((Container) color.getPreviewPanel());
|
---|
475 | }
|
---|
476 |
|
---|
477 | /**
|
---|
478 | * This method will add special action listener to the JFileChooser.
|
---|
479 | * (Precondition: fc != null)
|
---|
480 | * @param fc its the JFileChooser we want to get the information from.
|
---|
481 | */
|
---|
482 | public void getFileChooserInfo (JFileChooser fc)
|
---|
483 | {
|
---|
484 | fc.removeActionListener(m);
|
---|
485 | fc.addActionListener(m);
|
---|
486 | }
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * This method will add special list selection and column model listener
|
---|
490 | * to the JTable.
|
---|
491 | * (Precondition: table != null)
|
---|
492 | * @param table its the JTable we want to get the information from.
|
---|
493 | */
|
---|
494 | public void getTableInfo (JTable table)
|
---|
495 | {
|
---|
496 | TableModel tm;
|
---|
497 | tm = table.getModel();
|
---|
498 |
|
---|
499 | TableColumnModel tcm;
|
---|
500 | tcm = table.getColumnModel();
|
---|
501 | ListSelectionModel lm;
|
---|
502 | lm = table.getSelectionModel();
|
---|
503 |
|
---|
504 | if (lm != null)
|
---|
505 | {
|
---|
506 | if (hash.containsKey(lm) == false)
|
---|
507 | hash.put(lm,table);
|
---|
508 | lm.removeListSelectionListener(m);
|
---|
509 | lm.addListSelectionListener(m);
|
---|
510 | }
|
---|
511 |
|
---|
512 | if (tcm != null)
|
---|
513 | {
|
---|
514 | if (hash.containsKey(tcm) == false)
|
---|
515 | hash.put(tcm,table);
|
---|
516 | tcm.removeColumnModelListener(m);
|
---|
517 | tcm.addColumnModelListener(m);
|
---|
518 | }
|
---|
519 | }
|
---|
520 |
|
---|
521 | /**
|
---|
522 | * This is a dummy method to get the JScrollBar.
|
---|
523 | */
|
---|
524 | public void getScrollBarInfo (JScrollBar scroll)
|
---|
525 | {
|
---|
526 | }
|
---|
527 |
|
---|
528 | /**
|
---|
529 | * This method will add special tree selection listener to the JTree.
|
---|
530 | * (Precondition: tree != null)
|
---|
531 | * @param tree its the JTree we want to get the information from.
|
---|
532 | */
|
---|
533 | public void getTreeInfo (JTree tree)
|
---|
534 | {
|
---|
535 | TreeModel tm;
|
---|
536 | tm = tree.getModel();
|
---|
537 |
|
---|
538 | tree.removeTreeSelectionListener(m);
|
---|
539 | tree.addTreeSelectionListener(m);
|
---|
540 |
|
---|
541 | if (tm != null)
|
---|
542 | {
|
---|
543 | if (hash.containsKey(tm) == false)
|
---|
544 | hash.put(tm,tree);
|
---|
545 | tm.removeTreeModelListener(m);
|
---|
546 | tm.addTreeModelListener(m);
|
---|
547 | }
|
---|
548 | }
|
---|
549 |
|
---|
550 | /**
|
---|
551 | * This method is a dummy method to get Container.
|
---|
552 | */
|
---|
553 | public void getCompInfo (Container pane)
|
---|
554 | {
|
---|
555 | }
|
---|
556 |
|
---|
557 | /**
|
---|
558 | * This method will get all components inside the JPopupMenu.
|
---|
559 | * (Precondition: popup != null)
|
---|
560 | * @param popup its the JPopUpMenu we want to get the information from.
|
---|
561 | */
|
---|
562 | public void getPopUpMenuInfo (JPopupMenu popup)
|
---|
563 | {
|
---|
564 | Component[] group;
|
---|
565 | group = popup.getComponents();
|
---|
566 | SingleSelectionModel sm;
|
---|
567 | sm = popup.getSelectionModel();
|
---|
568 | int i;
|
---|
569 |
|
---|
570 | if (group != null)
|
---|
571 | {
|
---|
572 | for (i = 0; i < group.length ; i++)
|
---|
573 | {
|
---|
574 | getInside((Container)popup.getComponent(i));
|
---|
575 | }
|
---|
576 | }
|
---|
577 | }
|
---|
578 |
|
---|
579 | /**
|
---|
580 | * This method will get all the components inside the JRootPane.
|
---|
581 | * (Precondition: pane != null)
|
---|
582 | * @param pane its the JRootPane we want to get the information from.
|
---|
583 | */
|
---|
584 | public void getRootPaneInfo (JRootPane pane)
|
---|
585 | {
|
---|
586 | Component[] group;
|
---|
587 | group = pane.getComponents();
|
---|
588 | int i;
|
---|
589 |
|
---|
590 | if (group != null)
|
---|
591 | {
|
---|
592 | for (i = 0; i < group.length ; i++)
|
---|
593 | {
|
---|
594 |
|
---|
595 | getInside((Container)pane.getComponent(i));
|
---|
596 | }
|
---|
597 | }
|
---|
598 | }
|
---|
599 |
|
---|
600 | /**
|
---|
601 | * This method will get all the components inside the JLayeredPane.
|
---|
602 | * (Precondition: pane != null)
|
---|
603 | * @param pane its the JLayeredPane we want to get the information from.
|
---|
604 | */
|
---|
605 | public void getLayeredPaneInfo (JLayeredPane pane)
|
---|
606 | {
|
---|
607 | Component[] group;
|
---|
608 | group = pane.getComponents();
|
---|
609 | int i;
|
---|
610 |
|
---|
611 | if (group != null)
|
---|
612 | {
|
---|
613 | for (i = 0; i < group.length ; i++)
|
---|
614 | {
|
---|
615 | getInside((Container)pane.getComponent(i));
|
---|
616 | }
|
---|
617 | }
|
---|
618 | }
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * This is a dummy method to get BasicInternalFrameTitlePane.
|
---|
622 | */
|
---|
623 | public void getInternalFrameTitleInfo (BasicInternalFrameTitlePane pane)
|
---|
624 | {
|
---|
625 | }
|
---|
626 |
|
---|
627 | /**
|
---|
628 | * This method will add special column model and list selection
|
---|
629 | * listener to JTableHeader.
|
---|
630 | * (Precondition: header != null)
|
---|
631 | * @param header its the JTableHeader we want to get the information from.
|
---|
632 | */
|
---|
633 | public void getTableHeaderInfo (JTableHeader header)
|
---|
634 | {
|
---|
635 | TableColumnModel tcm;
|
---|
636 | tcm = header.getColumnModel();
|
---|
637 | ListSelectionModel lm;
|
---|
638 | lm = tcm.getSelectionModel();
|
---|
639 |
|
---|
640 | if (tcm != null)
|
---|
641 | {
|
---|
642 | if (hash.containsKey(tcm) == false)
|
---|
643 | hash.put(tcm,header);
|
---|
644 | tcm.removeColumnModelListener(m);
|
---|
645 | tcm.addColumnModelListener(m);
|
---|
646 | }
|
---|
647 |
|
---|
648 | if (lm != null)
|
---|
649 | {
|
---|
650 | if (hash.containsKey(lm) == false)
|
---|
651 | hash.put(lm,header);
|
---|
652 | lm.removeListSelectionListener(m);
|
---|
653 | lm.addListSelectionListener(m);
|
---|
654 | }
|
---|
655 | }
|
---|
656 |
|
---|
657 | /**
|
---|
658 | * This method will get all components inside the JToolBar.
|
---|
659 | * (Precondition: tool != null)
|
---|
660 | * @param tool its the JToolBar we want to get the information from.
|
---|
661 | */
|
---|
662 | public void getToolBarInfo (JToolBar tool)
|
---|
663 | {
|
---|
664 | Component[] group;
|
---|
665 | group = tool.getComponents();
|
---|
666 | int i;
|
---|
667 |
|
---|
668 | if (group != null)
|
---|
669 | {
|
---|
670 | for (i = 0; i < group.length ; i++)
|
---|
671 | {
|
---|
672 | getInside((Container)tool.getComponent(i));
|
---|
673 | }
|
---|
674 | }
|
---|
675 | }
|
---|
676 |
|
---|
677 | /**
|
---|
678 | * This method will get all the components inside the JToolTip.
|
---|
679 | * (Precondition: tip != null)
|
---|
680 | * @param tip its the JToolTip we want to get the information from.
|
---|
681 | */
|
---|
682 | public void getToolTipInfo (JToolTip tip)
|
---|
683 | {
|
---|
684 | Component group;
|
---|
685 | group = tip.getComponent();
|
---|
686 | int i;
|
---|
687 |
|
---|
688 | if (group != null)
|
---|
689 | {
|
---|
690 | getInside((Container) group);
|
---|
691 | }
|
---|
692 | }
|
---|
693 |
|
---|
694 | /**
|
---|
695 | * This is the dummy method to get JSeparator.
|
---|
696 | */
|
---|
697 | public void getSeparatorInfo (JSeparator sept)
|
---|
698 | {
|
---|
699 | }
|
---|
700 |
|
---|
701 | /**
|
---|
702 | * This method will get all the components inside the JDesktopPane.
|
---|
703 | * (Precondition: pane != null)
|
---|
704 | * @param pane its the JDesktopPane we want to get the information from.
|
---|
705 | */
|
---|
706 | public void getDesktopPaneInfo (JDesktopPane pane)
|
---|
707 | {
|
---|
708 | JInternalFrame[] group;
|
---|
709 | group = pane.getAllFrames();
|
---|
710 |
|
---|
711 | if (group != null)
|
---|
712 | {
|
---|
713 | int i;
|
---|
714 |
|
---|
715 | for ( i = 0 ; i < group.length ; i++ )
|
---|
716 | {
|
---|
717 | getInside((Container) group[i]);
|
---|
718 | }
|
---|
719 | }
|
---|
720 | }
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * This is a dummy method to catch null components.
|
---|
724 | */
|
---|
725 | public void getNullInfo ()
|
---|
726 | {
|
---|
727 | }
|
---|
728 |
|
---|
729 | /**
|
---|
730 | * This method will add a special listener to a container and components inside it.
|
---|
731 | * This method is the gateway to all other methods in this class.
|
---|
732 | * @param comp its the Container we want to get the information from.
|
---|
733 | */
|
---|
734 | public void getInside(Container comp)
|
---|
735 | {
|
---|
736 | if (comp == null)
|
---|
737 | {
|
---|
738 | getNullInfo();
|
---|
739 | return;
|
---|
740 | }
|
---|
741 | else if (comp instanceof JApplet)
|
---|
742 | {
|
---|
743 | getAppletInfo ((JApplet) comp);
|
---|
744 | return;
|
---|
745 | }
|
---|
746 | else if (comp instanceof JSeparator)
|
---|
747 | {
|
---|
748 | getSeparatorInfo ((JSeparator) comp);
|
---|
749 | return;
|
---|
750 | }
|
---|
751 | else if (comp instanceof JWindow)
|
---|
752 | {
|
---|
753 | getWindowInfo((JWindow) comp);
|
---|
754 | return;
|
---|
755 | }
|
---|
756 | else if (comp instanceof JDialog)
|
---|
757 | {
|
---|
758 | getDialogInfo((JDialog) comp);
|
---|
759 | return;
|
---|
760 | }
|
---|
761 | else if (comp instanceof JComboBox)
|
---|
762 | {
|
---|
763 | getComboBoxInfo((JComboBox) comp);
|
---|
764 | return;
|
---|
765 | }
|
---|
766 | else if (comp instanceof JLabel)
|
---|
767 | {
|
---|
768 | getLabelInfo((JLabel) comp);
|
---|
769 | return;
|
---|
770 | }
|
---|
771 | else if (comp instanceof JTextComponent)
|
---|
772 | {
|
---|
773 | getTextAreaInfo((JTextComponent) comp);
|
---|
774 | return;
|
---|
775 | }
|
---|
776 | else if (comp instanceof JFrame)
|
---|
777 | {
|
---|
778 | getFrameInfo((JFrame) comp);
|
---|
779 | return;
|
---|
780 | }
|
---|
781 | else if (comp instanceof JPanel)
|
---|
782 | {
|
---|
783 | getPanelInfo((JPanel) comp);
|
---|
784 | return;
|
---|
785 | }
|
---|
786 | else if (comp instanceof JScrollPane)
|
---|
787 | {
|
---|
788 | getScrollInfo((JScrollPane) comp);
|
---|
789 | return;
|
---|
790 | }
|
---|
791 | else if (comp instanceof JScrollBar)
|
---|
792 | {
|
---|
793 | getScrollBarInfo ((JScrollBar) comp);
|
---|
794 | return;
|
---|
795 | }
|
---|
796 | else if (comp instanceof JViewport)
|
---|
797 | {
|
---|
798 | getViewPortInfo((JViewport) comp);
|
---|
799 | return;
|
---|
800 | }
|
---|
801 | else if (comp instanceof JTabbedPane)
|
---|
802 | {
|
---|
803 | getTabbedPaneInfo((JTabbedPane) comp);
|
---|
804 | return;
|
---|
805 | }
|
---|
806 | else if (comp instanceof Box)
|
---|
807 | {
|
---|
808 | getBoxInfo((Box) comp);
|
---|
809 | return;
|
---|
810 | }
|
---|
811 | else if (comp instanceof JToggleButton)
|
---|
812 | {
|
---|
813 | getToggleButtonInfo((JToggleButton) comp);
|
---|
814 | return;
|
---|
815 | }
|
---|
816 | else if (comp instanceof JSplitPane)
|
---|
817 | {
|
---|
818 | getSplitPaneInfo ((JSplitPane) comp);
|
---|
819 | return;
|
---|
820 | }
|
---|
821 | else if (comp instanceof JList)
|
---|
822 | {
|
---|
823 | getListInfo ((JList) comp);
|
---|
824 | return;
|
---|
825 | }
|
---|
826 | else if (comp instanceof JTree)
|
---|
827 | {
|
---|
828 | getTreeInfo ((JTree) comp);
|
---|
829 | return;
|
---|
830 | }
|
---|
831 | else if (comp instanceof JTable)
|
---|
832 | {
|
---|
833 | getTableInfo ((JTable) comp);
|
---|
834 | return;
|
---|
835 | }
|
---|
836 | else if (comp instanceof JSlider)
|
---|
837 | {
|
---|
838 | getSliderInfo ((JSlider) comp);
|
---|
839 | return;
|
---|
840 | }
|
---|
841 | else if (comp instanceof JSpinner)
|
---|
842 | {
|
---|
843 | getSpinnerInfo ((JSpinner) comp);
|
---|
844 | return;
|
---|
845 | }
|
---|
846 | else if (comp instanceof JProgressBar)
|
---|
847 | {
|
---|
848 | getProgressBarInfo ((JProgressBar) comp);
|
---|
849 | return;
|
---|
850 | }
|
---|
851 | else if (comp instanceof JButton)
|
---|
852 | {
|
---|
853 | getButtonInfo ((JButton) comp);
|
---|
854 | return;
|
---|
855 | }
|
---|
856 | else if (comp instanceof JMenu)
|
---|
857 | {
|
---|
858 | getMenuInfo ((JMenu) comp);
|
---|
859 | return;
|
---|
860 | }
|
---|
861 | else if (comp instanceof JMenuBar)
|
---|
862 | {
|
---|
863 | getMenuBarInfo ((JMenuBar) comp);
|
---|
864 | return;
|
---|
865 | }
|
---|
866 | else if (comp instanceof JMenuItem)
|
---|
867 | {
|
---|
868 | getMenuItemInfo ((JMenuItem) comp);
|
---|
869 | return;
|
---|
870 | }
|
---|
871 | else if (comp instanceof JOptionPane)
|
---|
872 | {
|
---|
873 | getOptionPaneInfo ((JOptionPane) comp);
|
---|
874 | return;
|
---|
875 | }
|
---|
876 | else if (comp instanceof BasicInternalFrameTitlePane)
|
---|
877 | {
|
---|
878 | getInternalFrameTitleInfo ((BasicInternalFrameTitlePane) comp);
|
---|
879 | return;
|
---|
880 | }
|
---|
881 | else if (comp instanceof JColorChooser)
|
---|
882 | {
|
---|
883 | getColorInfo ((JColorChooser) comp);
|
---|
884 | return;
|
---|
885 | }
|
---|
886 | else if (comp instanceof JFileChooser)
|
---|
887 | {
|
---|
888 | getFileChooserInfo ((JFileChooser) comp);
|
---|
889 | return;
|
---|
890 | }
|
---|
891 | else if (comp instanceof JDesktopPane)
|
---|
892 | {
|
---|
893 | getDesktopPaneInfo ((JDesktopPane) comp);
|
---|
894 | return;
|
---|
895 | }
|
---|
896 | else if (comp instanceof JInternalFrame)
|
---|
897 | {
|
---|
898 | getInternalFrameInfo ((JInternalFrame) comp);
|
---|
899 | return;
|
---|
900 | }
|
---|
901 | else if (comp instanceof JLayeredPane)
|
---|
902 | {
|
---|
903 | getLayeredPaneInfo ((JLayeredPane) comp);
|
---|
904 | return;
|
---|
905 | }
|
---|
906 | else if (comp instanceof JPopupMenu)
|
---|
907 | {
|
---|
908 | getPopUpMenuInfo ((JPopupMenu) comp);
|
---|
909 | return;
|
---|
910 | }
|
---|
911 | else if (comp instanceof JRootPane)
|
---|
912 | {
|
---|
913 | getRootPaneInfo ((JRootPane) comp);
|
---|
914 | return;
|
---|
915 | }
|
---|
916 | else if (comp instanceof JTableHeader)
|
---|
917 | {
|
---|
918 | getTableHeaderInfo ((JTableHeader) comp);
|
---|
919 | return;
|
---|
920 | }
|
---|
921 | else if (comp instanceof JToolBar)
|
---|
922 | {
|
---|
923 | getToolBarInfo ((JToolBar) comp);
|
---|
924 | return;
|
---|
925 | }
|
---|
926 | else if (comp instanceof JToolTip)
|
---|
927 | {
|
---|
928 | getToolTipInfo ((JToolTip) comp);
|
---|
929 | return;
|
---|
930 | }
|
---|
931 | else
|
---|
932 | {
|
---|
933 | getCompInfo (comp);
|
---|
934 | return;
|
---|
935 | }
|
---|
936 | }
|
---|
937 | }
|
---|
938 |
|
---|
939 |
|
---|
940 |
|
---|
941 |
|
---|
942 |
|
---|
943 |
|
---|
944 |
|
---|