KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > explorer > view > ViewTooltips


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.explorer.view;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Component JavaDoc;
24 import java.awt.Dimension JavaDoc;
25 import java.awt.Graphics JavaDoc;
26 import java.awt.Graphics2D JavaDoc;
27 import java.awt.Insets JavaDoc;
28 import java.awt.KeyboardFocusManager JavaDoc;
29 import java.awt.Point JavaDoc;
30 import java.awt.Rectangle JavaDoc;
31 import java.awt.event.ComponentEvent JavaDoc;
32 import java.awt.event.ComponentListener JavaDoc;
33 import java.awt.event.HierarchyBoundsListener JavaDoc;
34 import java.awt.event.HierarchyEvent JavaDoc;
35 import java.awt.event.HierarchyListener JavaDoc;
36 import java.awt.event.MouseAdapter JavaDoc;
37 import java.awt.event.MouseEvent JavaDoc;
38 import java.awt.event.MouseMotionListener JavaDoc;
39 import java.awt.geom.AffineTransform JavaDoc;
40 import java.awt.image.BufferedImage JavaDoc;
41 import java.beans.PropertyChangeEvent JavaDoc;
42 import java.beans.PropertyChangeListener JavaDoc;
43 import javax.swing.JComponent JavaDoc;
44 import javax.swing.JList JavaDoc;
45 import javax.swing.JScrollPane JavaDoc;
46 import javax.swing.JTree JavaDoc;
47 import javax.swing.ListCellRenderer JavaDoc;
48 import javax.swing.Popup JavaDoc;
49 import javax.swing.PopupFactory JavaDoc;
50 import javax.swing.SwingUtilities JavaDoc;
51 import javax.swing.border.Border JavaDoc;
52 import javax.swing.event.ChangeEvent JavaDoc;
53 import javax.swing.event.ChangeListener JavaDoc;
54 import javax.swing.event.ListDataEvent JavaDoc;
55 import javax.swing.event.ListDataListener JavaDoc;
56 import javax.swing.event.ListSelectionEvent JavaDoc;
57 import javax.swing.event.ListSelectionListener JavaDoc;
58 import javax.swing.event.TreeModelEvent JavaDoc;
59 import javax.swing.event.TreeModelListener JavaDoc;
60 import javax.swing.event.TreeSelectionEvent JavaDoc;
61 import javax.swing.event.TreeSelectionListener JavaDoc;
62 import javax.swing.tree.TreePath JavaDoc;
63 import org.openide.util.Lookup;
64 import org.openide.util.Utilities;
65
66 /**
67  * Displays pseudo-tooltips for tree and list views which don't have enough
68  * space. This class is not NB specific, and can be used with any
69  * JTree or JList.
70  *
71  * @author Tim Boudreau
72  */

73 final class ViewTooltips extends MouseAdapter JavaDoc implements MouseMotionListener JavaDoc {
74     /** The default instance, reference counted */
75     private static ViewTooltips INSTANCE = null;
76     /** A reference count for number of comps listened to */
77     private int refcount = 0;
78     /** The last known component we were invoked against, nulled on hide() */
79     private JComponent JavaDoc inner = null;
80     /** The last row we were invoked against */
81     private int row = -1;
82     /** An array of currently visible popups */
83     private Popup JavaDoc[] popups = new Popup JavaDoc[2];
84     /** A component we'll reuse to paint into the popups */
85     private ImgComp painter = new ImgComp();
86     /** Nobody should instantiate this */
87     private ViewTooltips() {
88     }
89     
90     /**
91      * Register a child of a JScrollPane (only JList or JTree supported
92      * for now) which should show helper tooltips. Should be called
93      * from the component's addNotify() method.
94      */

95     static void register (JComponent JavaDoc comp) {
96         if (INSTANCE == null) {
97             INSTANCE = new ViewTooltips();
98         }
99         INSTANCE.attachTo (comp);
100     }
101     
102     /**
103      * Unregister a child of a JScrollPane (only JList or JTree supported
104      * for now) which should show helper tooltips. Should be called
105      * from the component's removeNotify() method.
106      */

107     static void unregister (JComponent JavaDoc comp) {
108         assert INSTANCE != null : "Unregister asymmetrically called";
109         if (INSTANCE.detachFrom (comp) == 0) {
110             INSTANCE.hide();
111             INSTANCE = null;
112         }
113     }
114
115     /** Start listening to mouse motion on the passed component */
116     private void attachTo (JComponent JavaDoc comp) {
117         assert comp instanceof JTree JavaDoc || comp instanceof JList JavaDoc;
118         comp.addMouseListener (this);
119         comp.addMouseMotionListener (this);
120         refcount++;
121     }
122     
123     /** Stop listening to mouse motion on the passed component */
124     private int detachFrom (JComponent JavaDoc comp) {
125         assert comp instanceof JTree JavaDoc || comp instanceof JList JavaDoc;
126         comp.removeMouseMotionListener (this);
127         comp.removeMouseListener (this);
128         return refcount--;
129     }
130     
131     public void mouseMoved(MouseEvent JavaDoc e) {
132         Point JavaDoc p = e.getPoint();
133         JComponent JavaDoc comp = (JComponent JavaDoc) e.getSource();
134         JScrollPane JavaDoc jsp = (JScrollPane JavaDoc)
135             SwingUtilities.getAncestorOfClass(JScrollPane JavaDoc.class, comp);
136         if (jsp != null) {
137             p = SwingUtilities.convertPoint (comp, p, jsp);
138             show(jsp, p);
139         }
140     }
141
142     public void mouseDragged(MouseEvent JavaDoc e) {
143         hide();
144     }
145
146     public void mouseEntered(MouseEvent JavaDoc e) {
147         hide();
148     }
149
150     public void mouseExited(MouseEvent JavaDoc e) {
151         hide();
152     }
153     
154     /** Shows the appropriate popups given the state of the scroll pane and
155      * its view.
156      * @param view The scroll pane owning the component the event happened on
157      * @param pt The point at which the mouse event happened, in the coordinate
158      * space of the scroll pane.
159      */

160     void show (JScrollPane JavaDoc view, Point JavaDoc pt) {
161         if (view.getViewport().getView() instanceof JTree JavaDoc) {
162             showJTree (view, pt);
163         } else if (view.getViewport().getView() instanceof JList JavaDoc) {
164             showJList (view, pt);
165         } else {
166             assert false : "Bad component type registered: " + view.getViewport().getView();
167         }
168     }
169     
170     private void showJList (JScrollPane JavaDoc view, Point JavaDoc pt) {
171         JList JavaDoc list = (JList JavaDoc) view.getViewport().getView();
172         Point JavaDoc p = SwingUtilities.convertPoint(view, pt.x, pt.y, list);
173         int row = list.locationToIndex(p);
174         if (row == -1) {
175             hide();
176             return;
177         }
178         Rectangle JavaDoc bds = list.getCellBounds(row,
179                 row);
180         //GetCellBounds returns a width that is the
181
//full component width; we want only what
182
//the renderer really needs.
183
ListCellRenderer JavaDoc ren = list.getCellRenderer();
184         Dimension JavaDoc rendererSize =
185                 ren.getListCellRendererComponent(list,
186                 list.getModel().getElementAt(row),
187                 row, false, false).getPreferredSize();
188         
189         bds.width = rendererSize.width;
190         if (bds == null || !bds.contains(p)) {
191             hide();
192             return;
193         }
194         if (setCompAndRow (list, row)) {
195             Rectangle JavaDoc visible = getShowingRect (view);
196             Rectangle JavaDoc[] rects = getRects (bds, visible);
197             if (rects.length > 0) {
198                 ensureOldPopupsHidden();
199                 painter.configure(
200                         list.getModel().getElementAt(row),
201                         view, list, row);
202                 showPopups (rects, bds, visible, list, view);
203             } else {
204                 hide();
205             }
206         }
207     }
208     
209     private void showJTree (JScrollPane JavaDoc view, Point JavaDoc pt) {
210         JTree JavaDoc tree = (JTree JavaDoc) view.getViewport().getView();
211         Point JavaDoc p = SwingUtilities.convertPoint(view,
212                 pt.x, pt.y, tree);
213         
214         int row = tree.getClosestRowForLocation(
215                 p.x, p.y);
216         
217         TreePath JavaDoc path =
218                 tree.getClosestPathForLocation(p.x,
219                 p.y);
220         
221         Rectangle JavaDoc bds = tree.getPathBounds(path);
222         if (bds == null || !bds.contains(p)) {
223             hide();
224             return;
225         }
226         if (setCompAndRow (tree, row)) {
227             Rectangle JavaDoc visible = getShowingRect (view);
228             Rectangle JavaDoc[] rects = getRects (bds, visible);
229             if (rects.length > 0) {
230                 ensureOldPopupsHidden();
231                 painter.configure(
232                         path.getLastPathComponent(),
233                         view, tree, path, row);
234                 showPopups (rects, bds, visible, tree, view);
235             } else {
236                 hide();
237             }
238         }
239     }
240     
241     /**
242      * Set the currently shown component and row, returning true if they are
243      * not the same as the last known values.
244      */

245     private boolean setCompAndRow (JComponent JavaDoc inner, int row) {
246         boolean rowChanged = row != this.row;
247         boolean compChanged = inner != this.inner;
248         this.inner = inner;
249         this.row = row;
250         return (rowChanged || compChanged);
251     }
252     
253     /**
254      * Hide all popups and discard any references to the components the
255      * popups were showing for.
256      */

257     void hide() {
258         ensureOldPopupsHidden();
259         if (painter != null) {
260             painter.clear();
261         }
262         setHideComponent (null, null);
263         inner = null;
264         row = -1;
265     }
266     
267     private void ensureOldPopupsHidden() {
268         for (int i=0; i < popups.length; i++) {
269             if (popups[i] != null) {
270                 popups[i].hide();
271                 popups[i] = null;
272             }
273         }
274     }
275
276     /**
277      * Gets the sub-rectangle of a JScrollPane's area that
278      * is actually showing the view
279      */

280     private Rectangle JavaDoc getShowingRect (JScrollPane JavaDoc pane) {
281         Insets JavaDoc ins1 = pane.getViewport().getInsets();
282         Border JavaDoc inner = pane.getViewportBorder();
283         Insets JavaDoc ins2;
284         if (inner != null) {
285             ins2 = inner.getBorderInsets(pane);
286         } else {
287             ins2 = new Insets JavaDoc (0,0,0,0);
288         }
289         Insets JavaDoc ins3 = new Insets JavaDoc(0,0,0,0);
290         if (pane.getBorder() != null) {
291             ins3 = pane.getBorder().getBorderInsets(pane);
292         }
293         
294         Rectangle JavaDoc r = pane.getViewportBorderBounds();
295         r.translate(-r.x, -r.y);
296         r.width -= ins1.left + ins1.right;
297         r.width -= ins2.left + ins2.right;
298         r.height -= ins1.top + ins1.bottom;
299         r.height -= ins2.top + ins2.bottom;
300         r.x -= ins2.left;
301         r.x -= ins3.left;
302         Point JavaDoc p = pane.getViewport().getViewPosition();
303         r.translate (p.x, p.y);
304         r = SwingUtilities.convertRectangle(pane.getViewport(), r, pane);
305         return r;
306     }
307     
308     /**
309      * Fetches an array or rectangles representing the non-overlapping
310      * portions of a cell rect against the visible portion of the component.
311      * @bds The cell's bounds, in the coordinate space of the tree or list
312      * @vis The visible area of the tree or list, in the tree or list's coordinate space
313      */

314     private static final Rectangle JavaDoc[] getRects(final Rectangle JavaDoc bds, final Rectangle JavaDoc vis) {
315         Rectangle JavaDoc[] result;
316         if (vis.contains(bds)) {
317             result = new Rectangle JavaDoc[0];
318         } else {
319             if (bds.x < vis.x && bds.x + bds.width > vis.x + vis.width) {
320                 Rectangle JavaDoc a = new Rectangle JavaDoc (bds.x, bds.y, vis.x - bds.x, bds.height);
321                 Rectangle JavaDoc b = new Rectangle JavaDoc (vis.x + vis.width, bds.y, (bds.x + bds.width) - (vis.x + vis.width), bds.height);
322                 result = new Rectangle JavaDoc[] {a, b};
323             } else if (bds.x < vis.x) {
324                 result = new Rectangle JavaDoc[] {
325                     new Rectangle JavaDoc (bds.x, bds.y, vis.x - bds.x, bds.height)
326                 };
327             } else if (bds.x + bds.width > vis.x + vis.width) {
328                 result = new Rectangle JavaDoc[] {
329                     new Rectangle JavaDoc (vis.x + vis.width, bds.y, (bds.x + bds.width) - (vis.x + vis.width), bds.height)
330                 };
331             } else {
332                 result = new Rectangle JavaDoc[0];
333             }
334         }
335         return result;
336     }
337
338     /**
339      * Show popups for each rectangle, using the now configured painter.
340      */

341     private void showPopups(Rectangle JavaDoc[] rects, Rectangle JavaDoc bds, Rectangle JavaDoc visible, JComponent JavaDoc comp, JScrollPane JavaDoc view) {
342         boolean shown = false;
343         for (int i=0; i < rects.length; i++) {
344             Rectangle JavaDoc sect = rects[i];
345             sect.translate (-bds.x, -bds.y);
346             ImgComp part = painter.getPartial(sect, bds.x + rects[i].x < visible.x);
347             Point JavaDoc pos = new Point JavaDoc (bds.x + rects[i].x, bds.y + rects[i].y);
348             SwingUtilities.convertPointToScreen(pos, comp);
349             if (comp instanceof JList JavaDoc) {
350                 //XXX off by one somewhere, only with JLists - where?
351
pos.y--;
352             }
353             if (pos.x > 0) { //Mac OS will reposition off-screen popups to x=0,
354
//so don't try to show them
355
popups[i] = getPopupFactory().getPopup(view,
356                         part, pos.x, pos.y);
357                 popups[i].show();
358                 shown = true;
359             }
360         }
361         if (shown) {
362             setHideComponent (comp, view);
363         } else {
364             setHideComponent (null, null); //clear references
365
}
366     }
367     
368     private static PopupFactory JavaDoc getPopupFactory() {
369         if (Utilities.isMac()) {
370             
371             // See ide/applemenu/src/org/netbeans/modules/applemenu/ApplePopupFactory
372
// We have a custom PopupFactory that will consistently use
373
// lightweight popups on Mac OS, since HW popups get a drop
374
// shadow. By default, popups returned when a heavyweight popup
375
// is needed (SDI mode) are no-op popups, since some hacks
376
// are necessary to make it really work.
377

378             // To enable heavyweight popups which have no drop shadow
379
// *most* of the time on mac os, run with
380
// -J-Dnb.explorer.hw.completions=true
381

382             // To enable heavyweight popups which have no drop shadow
383
// *ever* on mac os, you need to put the cocoa classes on the
384
// classpath - modify netbeans.conf to add
385
// System/Library/Java on the bootclasspath. *Then*
386
// run with the above line switch and
387
// -J-Dnb.explorer.hw.cocoahack=true
388

389             PopupFactory JavaDoc result = (PopupFactory JavaDoc) Lookup.getDefault().lookup (
390                     PopupFactory JavaDoc.class);
391             return result == null ? PopupFactory.getSharedInstance() : result;
392         } else {
393             return PopupFactory.getSharedInstance();
394         }
395     }
396     
397     private Hider hider = null;
398     /**
399      * Set a component (JList or JTree) which should be listened to, such that if
400      * a model, selection or scroll event occurs, all currently open popups
401      * should be hidden.
402      */

403     private void setHideComponent (JComponent JavaDoc comp, JScrollPane JavaDoc parent) {
404         if (hider != null) {
405             if (hider.isListeningTo(comp)) {
406                 return;
407             }
408         }
409         if (hider != null) {
410             hider.detach();
411         }
412         if (comp != null) {
413             hider = new Hider (comp, parent);
414         } else {
415             hider = null;
416         }
417     }
418     
419     /**
420      * A JComponent which creates a BufferedImage of a cell renderer and can
421      * produce clones of itself that display subrectangles of that cell
422      * renderer.
423      */

424     private static final class ImgComp extends JComponent JavaDoc {
425         private BufferedImage JavaDoc img;
426         private Dimension JavaDoc d = null;
427         
428         private Color JavaDoc bg = Color.WHITE;
429         private JScrollPane JavaDoc comp = null;
430         
431         private Object JavaDoc node = null;
432         
433         private AffineTransform JavaDoc at = AffineTransform.getTranslateInstance(0d, 0d);
434         boolean isRight = false;
435         
436         ImgComp() {}
437         
438         /**
439          * Create a clone with a specified backing image
440          */

441         ImgComp (BufferedImage JavaDoc img, Rectangle JavaDoc off, boolean right) {
442             this.img = img;
443             at = AffineTransform.getTranslateInstance(-off.x, 0);
444             d = new Dimension JavaDoc (off.width, off.height);
445             isRight = right;
446         }
447         
448         public ImgComp getPartial (Rectangle JavaDoc bds, boolean right) {
449             assert img != null;
450             return new ImgComp (img, bds, right);
451         }
452         
453         /** Configures a tree cell renderer and sets up sizing and the
454          * backing image from it */

455         public boolean configure (Object JavaDoc nd, JScrollPane JavaDoc tv, JTree JavaDoc tree, TreePath JavaDoc path, int row) {
456             boolean sameVn = setLastRendereredObject(nd);
457             boolean sameComp = setLastRenderedScrollPane (tv);
458             Component JavaDoc renderer = null;
459             bg = tree.getBackground();
460             boolean sel = tree.isSelectionEmpty() ? false :
461                 tree.getSelectionModel().isPathSelected(path);
462             boolean exp = tree.isExpanded(path);
463             boolean leaf = !exp && tree.getModel().isLeaf(nd);
464             boolean lead = path.equals(tree.getSelectionModel().getLeadSelectionPath());
465             renderer = tree.getCellRenderer().getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead);
466             if (renderer != null) {
467                 setComponent (renderer);
468             }
469             return true;
470         }
471         
472         /** Configures a list cell renderer and sets up sizing and the
473          * backing image from it */

474         public boolean configure (Object JavaDoc nd, JScrollPane JavaDoc tv, JList JavaDoc list, int row) {
475             boolean sameVn = setLastRendereredObject(nd);
476             boolean sameComp = setLastRenderedScrollPane (tv);
477             Component JavaDoc renderer = null;
478             bg = list.getBackground();
479             boolean sel = list.isSelectionEmpty() ? false :
480                 list.getSelectionModel().isSelectedIndex(row);
481             renderer = list.getCellRenderer().getListCellRendererComponent(list, nd, row, sel, false);
482             if (renderer != null) {
483                 setComponent (renderer);
484             }
485             return true;
486         }
487         
488         private boolean setLastRenderedScrollPane (JScrollPane JavaDoc comp) {
489             boolean result = comp != this.comp;
490             this.comp = comp;
491             return result;
492         }
493         
494         private boolean setLastRendereredObject (Object JavaDoc nd) {
495             boolean result = node != nd;
496             if (result) {
497                 node = nd;
498             }
499             return result;
500         }
501         
502         void clear() {
503             comp = null;
504             node = null;
505         }
506         
507         /**
508          * Set the cell renderer we will proxy.
509          */

510         public void setComponent (Component JavaDoc jc) {
511             Dimension JavaDoc d = jc.getPreferredSize();
512             BufferedImage JavaDoc nue = new BufferedImage JavaDoc (d.width, d.height + 2,
513                     BufferedImage.TYPE_INT_ARGB_PRE);
514             SwingUtilities.paintComponent(nue.getGraphics(), jc, this, 0, 0, d.width, d.height + 2);
515             setImage (nue);
516         }
517         
518         public Rectangle JavaDoc getBounds() {
519             Dimension JavaDoc dd = getPreferredSize();
520             return new Rectangle JavaDoc (0, 0, dd.width, dd.height);
521         }
522         
523         private void setImage(BufferedImage JavaDoc img) {
524             this.img = img;
525             d = null;
526         }
527         
528         public Dimension JavaDoc getPreferredSize() {
529             if (d == null) {
530                 d = new Dimension JavaDoc (img.getWidth(), img.getHeight());
531             }
532             return d;
533         }
534         
535         public Dimension JavaDoc getSize() {
536             return getPreferredSize();
537         }
538         
539         public void paint (Graphics JavaDoc g) {
540             g.setColor (bg);
541             g.fillRect (0, 0, d.width, d.height);
542             Graphics2D JavaDoc g2d = (Graphics2D JavaDoc) g;
543             g2d.drawRenderedImage (img, at);
544             g.setColor (Color.GRAY);
545             g.drawLine (0, 0, d.width, 0);
546             g.drawLine (0, d.height-1, d.width, d.height-1);
547             if (isRight) {
548                 g.drawLine (0, 0, 0, d.height-1);
549             } else {
550                 g.drawLine (d.width-1, 0, d.width-1, d.height-1);
551             }
552         }
553         
554         public void firePropertyChange (String JavaDoc s, Object JavaDoc a, Object JavaDoc b) {}
555         public void invalidate() {}
556         public void validate() {}
557         public void revalidate() {}
558     }
559     
560     /**
561      * A listener that listens to just about everything in the known universe
562      * and hides all currently displayed popups if anything happens.
563      */

564     private static final class Hider implements ChangeListener JavaDoc, PropertyChangeListener JavaDoc, TreeModelListener JavaDoc, TreeSelectionListener JavaDoc, HierarchyListener JavaDoc, HierarchyBoundsListener JavaDoc, ListSelectionListener JavaDoc, ListDataListener JavaDoc, ComponentListener JavaDoc {
565         private final JTree JavaDoc tree;
566         
567         private JScrollPane JavaDoc pane;
568         private final JList JavaDoc list;
569         
570         public Hider (JComponent JavaDoc comp, JScrollPane JavaDoc pane) {
571             if (comp instanceof JTree JavaDoc) {
572                 this.tree = (JTree JavaDoc) comp;
573                 this.list = null;
574             } else {
575                 this.list = (JList JavaDoc) comp;
576                 this.tree = null;
577             }
578             assert tree != null || list != null;
579             this.pane = pane;
580             attach();
581         }
582         
583         private boolean isListeningTo (JComponent JavaDoc comp) {
584             return !detached && (comp == list || comp == tree);
585         }
586         
587         private void attach() {
588             if (tree != null) {
589                 tree.getModel().addTreeModelListener(this);
590                 tree.getSelectionModel().addTreeSelectionListener(this);
591                 tree.addHierarchyBoundsListener(this);
592                 tree.addHierarchyListener(this);
593                 tree.addComponentListener(this);
594             } else {
595                 list.getSelectionModel().addListSelectionListener(this);
596                 list.getModel().addListDataListener(this);
597                 list.addHierarchyBoundsListener(this);
598                 list.addHierarchyListener(this);
599                 list.addComponentListener(this);
600             }
601             pane.getHorizontalScrollBar().getModel().addChangeListener(this);
602             pane.getVerticalScrollBar().getModel().addChangeListener(this);
603             KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);
604         }
605         
606         private boolean detached = false;
607         private void detach() {
608             KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(this);
609             if (tree != null) {
610                 tree.getSelectionModel().removeTreeSelectionListener(this);
611                 tree.getModel().removeTreeModelListener(this);
612                 tree.removeHierarchyBoundsListener(this);
613                 tree.removeHierarchyListener(this);
614                 tree.removeComponentListener(this);
615             } else {
616                 list.getSelectionModel().removeListSelectionListener(this);
617                 list.getModel().removeListDataListener(this);
618                 list.removeHierarchyBoundsListener(this);
619                 list.removeHierarchyListener(this);
620                 list.removeComponentListener(this);
621             }
622             pane.getHorizontalScrollBar().getModel().removeChangeListener(this);
623             pane.getVerticalScrollBar().getModel().removeChangeListener(this);
624             detached = true;
625         }
626         
627         private void change() {
628             if (ViewTooltips.INSTANCE != null) {
629                 ViewTooltips.INSTANCE.hide();
630             }
631             detach();
632         }
633         
634         public void propertyChange(PropertyChangeEvent JavaDoc evt) {
635             change();
636         }
637         public void treeNodesChanged(TreeModelEvent JavaDoc e) {
638             change();
639         }
640         
641         public void treeNodesInserted(TreeModelEvent JavaDoc e) {
642             change();
643         }
644         
645         public void treeNodesRemoved(TreeModelEvent JavaDoc e) {
646             change();
647         }
648         
649         public void treeStructureChanged(TreeModelEvent JavaDoc e) {
650             change();
651         }
652         
653         public void hierarchyChanged(HierarchyEvent JavaDoc e) {
654             change();
655         }
656         
657         public void valueChanged(TreeSelectionEvent JavaDoc e) {
658             change();
659         }
660         
661         public void ancestorMoved(HierarchyEvent JavaDoc e) {
662             change();
663         }
664         
665         public void ancestorResized(HierarchyEvent JavaDoc e) {
666             change();
667         }
668
669         public void stateChanged(ChangeEvent JavaDoc e) {
670             change();
671         }
672         
673         public void valueChanged(ListSelectionEvent JavaDoc e) {
674             change();
675         }
676         
677         public void intervalAdded(ListDataEvent JavaDoc e) {
678             change();
679         }
680         
681         public void intervalRemoved(ListDataEvent JavaDoc e) {
682             change();
683         }
684         
685         public void contentsChanged(ListDataEvent JavaDoc e) {
686             change();
687         }
688         
689         public void componentResized(ComponentEvent JavaDoc e) {
690             change();
691         }
692         
693         public void componentMoved(ComponentEvent JavaDoc e) {
694             change();
695         }
696         
697         public void componentShown(ComponentEvent JavaDoc e) {
698             change();
699         }
700         
701         public void componentHidden(ComponentEvent JavaDoc e) {
702             change();
703         }
704     }
705 }
706
Popular Tags