KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > looks > ProxyLook


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.netbeans.spi.looks;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.datatransfer.Transferable JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.Arrays JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Enumeration JavaDoc;
29 import java.util.HashMap JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.LinkedList JavaDoc;
32 import java.util.List JavaDoc;
33 import javax.swing.Action JavaDoc;
34 import org.netbeans.modules.looks.LookListener;
35 import org.netbeans.modules.looks.LookEvent;
36 import org.openide.nodes.Node;
37 import org.openide.nodes.Sheet;
38 import org.openide.util.Enumerations;
39 import org.openide.util.HelpCtx;
40 import org.openide.util.Lookup;
41 import org.openide.util.datatransfer.NewType;
42 import org.openide.util.datatransfer.PasteType;
43
44 /** This is base class for delegating to other looks. All methods are
45  * enumerated by numeric constants and by overriding
46  * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object)}
47  * method subclasses can easily decide which methods and where to delegate.
48  * <P>
49  * It is not suggested to switch the looks that is being delegated to
50  * during different calls, because it can also result in calls to a look
51  * that has not have been attached by calling attachTo.
52  * <p>It is also not suggested to base the delegation on some changeable attribute
53  * of the representedObject.
54  * In such cases developer are encouraged to write new LookSelector and pass
55  * it as parameter into the constructor of the ProxyLook.
56  * <P>
57  * It is possible to change the represented object for a look
58  * those are being delegated to (see method
59  * {@link #delegateObject} )
60  * <P>
61  * The default implementation of all methods share similar logic. If
62  * single value is returned from the method e.g. String or boolean all sublooks are
63  * consulted until one them returns diffrent value than null of false the
64  * value is returned from the ProxyLook (See Look for neutral values
65  * definition). If none of the sublooks returns non-neutral value then null or
66  * false is returned. In case of mutilvalued attributes e.g. Collections or
67  * Arrays the ProxyLook takes care of merging the values.
68  *
69  * @author Jaroslav Tulach
70  */

71 public abstract class ProxyLook extends Look {
72
73     private final LookSelector content;
74
75     private ProxyLookEventTranslator eventTranslator = new ProxyLookEventTranslator();
76
77     /** Creates new instance of look does no work.
78      * @param content LookSelector containing Looks the ProxyLook should
79      * delegate to.
80      */

81     public ProxyLook( String JavaDoc name, LookSelector content ) {
82         super( name );
83         this.content = content;
84         // Start listening on the selector
85
// Pending this should be elewhere and it also should be deregistered
86
org.netbeans.modules.looks.Accessor.DEFAULT.addSelectorListener( content, eventTranslator );
87         
88     }
89
90     /** A heart of this class - method which can decide where to delegate
91      * particular call.
92      *
93      * <P>
94      * The default implementation ignores all parameters and just returns true,
95      * which means that by default all methods are delegated.<BR>
96      * Subclasses might override this method with implementation that bases its
97      * decision on different criteria.
98      * @param method One of the constants defined here that identifies the method
99      * we want to delegate to
100      * @param look The look we want to delegate to
101      * @param representedObject The Look.NodeSubstitute of the node.
102      * @return <CODE>true</CODE> if method identified by the constant should be
103      * delegated to given Look with given substitute.
104      *
105      */

106     protected boolean delegateTo( long method, Look look, Object JavaDoc representedObject ) {
107         return true;
108     }
109
110     private Enumeration JavaDoc delegateTo (final long method, final Object JavaDoc representedObject ) {
111         return Enumerations.filter(content.getLooks(delegateObject(representedObject)), new Enumerations.Processor() {
112             public Object JavaDoc process(Object JavaDoc object, Collection JavaDoc ignore) {
113                 if (!(object instanceof Look)) {
114                     return null;
115                 } else {
116                     return delegateTo(method, (Look) object, representedObject) ? object : null;
117                 }
118             }
119         });
120     }
121
122
123
124     /** Controls whether we delegate to all looks just the first one that returns
125      * a value.
126      * <p>Useful for methods that return an array of objects. By default all sublooks
127      * are consulted and the result is a merge of all values returned by
128      * the sublooks. Overriding this method may disallow merging and force
129      * mutlivalued attributes of the node (e.g. properties, children, etc,) to
130      * behave like singlevalued attributes (e.g. name or icon). It means that
131      * the first sublook will "win" and will provide the values.
132      * @param method One of the constants defined here that identifies the method
133      * we want to delegate to
134      * @param representedObject Represented object the look should work with.
135      * @return <CODE>true</CODE> if the merge should happen <CODE>false</CODE> otherwise
136      */

137     protected boolean delegateAll (long method, Object JavaDoc representedObject) {
138         return true;
139     }
140
141     /**
142      * Permits changing the represented object when delegating to sublooks.
143      * <P>
144      * The default implementation just returns the same object, but
145      * subclasses might use this method to change the represented object
146      * for the look they delegate to.
147      * <P>
148      * When overriding this object make sure you implement the
149      * {@link #undelegateObject} method correctly.
150      * @param representedObject Represented object which should be translated
151      * @return The represented object for the sub-look (not <CODE>null</CODE>)
152      */

153     protected Object JavaDoc delegateObject (Object JavaDoc representedObject) {
154         return representedObject;
155     }
156     
157     /** Performs reverse transformation from delegated object to original
158      * represented object.
159      * <P>
160      * The default implementation simply retruns the delegate.
161      * <P>
162      * This method has to be implemented correctly when the
163      * {@link #delegateObject} method is overridden.
164      * @param delegate The delegate
165      * @return Original represented object
166      */

167     protected Object JavaDoc undelegateObject( Object JavaDoc delegate ) {
168         return delegate;
169     }
170
171     // General methods ---------------------------------------------------------
172

173
174     private static Look extractLook (Enumeration JavaDoc en) {
175         Object JavaDoc obj = en.nextElement();
176         return obj instanceof Look ? (Look)obj : null;
177     }
178
179         
180     // Methods for FUNCTIONALITY EXTENSIONS ------------------------------------
181

182     public Collection JavaDoc getLookupItems(Object JavaDoc representedObject, Lookup oldEnv ) {
183         Enumeration JavaDoc delegates = delegateTo (GET_LOOKUP_ITEMS, representedObject );
184
185         if (delegates == null) {
186             return null;
187         }
188
189         boolean merge = delegateAll (GET_LOOKUP_ITEMS, representedObject );
190
191         Collection JavaDoc lookupItems = null;
192
193         // Create list of subarrays
194
for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
195             Look delegate = extractLook (delegates);
196             if (delegate == null) {
197                 continue;
198             }
199
200             Look look = (Look)delegate;
201
202             Collection JavaDoc data = look.getLookupItems (delegateObject( representedObject ), oldEnv );
203             if (data == null || data.size() == 0 ) {
204                 continue;
205             }
206
207             if (!merge) {
208                 // we are not merging and need keys just by one look
209
return data;
210             }
211
212             // add all those objects into array
213
if ( lookupItems == null ) {
214                 lookupItems = new LinkedList JavaDoc( data );
215             } else {
216                 lookupItems.addAll( data );
217             }
218         }
219
220         return lookupItems;
221     }
222
223     // Methods for STYLE -------------------------------------------------------
224

225     /** Gets the first display name provided by any sublook. Set of sublooks
226      * is determined by the selector associated with this look and the
227      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
228      * @param representedObject Represented object the look should work with.
229      * @param env Environement for the represented object.
230      * @return First display name returned by some of the sublooks or <CODE>null</CODE>
231      */

232     public String JavaDoc getDisplayName(Object JavaDoc representedObject, Lookup env ) {
233         Enumeration JavaDoc delegates = delegateTo (GET_DISPLAY_NAME, representedObject );
234         if (delegates != null) {
235             for ( int i[] = { 0 }; delegates.hasMoreElements(); i[0]++ ) {
236                 Look delegate = extractLook (delegates);
237                 if (delegate != null) {
238                     String JavaDoc h = ((Look)delegate).getDisplayName (delegateObject( representedObject ), env );
239                     if (h != null) {
240                         return h;
241                     }
242                 }
243             }
244         }
245         return null;
246     }
247
248     /** Gets the first name provided by any sublook. Set of sublooks
249      * is determined by the selector associated with this look and the
250      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
251      * @param representedObject Represented object the look should work with.
252      * @param env Environement for the represented object.
253      * @return First name returned by some of the sublooks or <CODE>null</CODE>
254      */

255     public String JavaDoc getName(Object JavaDoc representedObject, Lookup env ) {
256         Enumeration JavaDoc delegates = delegateTo (GET_NAME, representedObject );
257         if (delegates != null) {
258             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
259                 Look delegate = extractLook (delegates);
260                 if (delegate != null) {
261                     String JavaDoc h = ((Look)delegate).getName (delegateObject( representedObject ), env );
262                     if (h != null) {
263                         return h;
264                     }
265                 }
266             }
267         }
268         return null;
269     }
270
271
272     /** Notifies all sublooks that the object was renamed. Set of sublooks
273      * is determined by the selector associated with this look and the
274      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
275      * @param representedObject Represented object the look should work with.
276      * @param newName New name of the object.
277      * @param env Environement for the represented object.
278      */

279     public void rename(Object JavaDoc representedObject, String JavaDoc newName, Lookup env ) throws IOException JavaDoc {
280         Enumeration JavaDoc delegates = delegateTo (RENAME, representedObject );
281         if (delegates != null) {
282             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
283                 Look delegate = extractLook (delegates);
284                 if (delegate != null) {
285                     ((Look)delegate).rename (delegateObject( representedObject ), newName, env );
286                 }
287             }
288         }
289     }
290
291     /** Gets the first short description provided by any sublook. Set of sublooks
292      * is determined by the selector associated with this look and the
293      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
294      * @param representedObject Represented object the look should work with.
295      * @param env Environement for the represented object.
296      * @return First short description returned by some of the sublooks or <CODE>null</CODE>
297      */

298     public String JavaDoc getShortDescription(Object JavaDoc representedObject, Lookup env ) {
299         Enumeration JavaDoc delegates = delegateTo (GET_SHORT_DESCRIPTION, representedObject );
300         if (delegates != null) {
301             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
302                 Look delegate = extractLook (delegates);
303                 if (delegate != null) {
304                     String JavaDoc h = ((Look)delegate).getShortDescription (delegateObject( representedObject ), env );
305                     if (h != null) {
306                         return h;
307                     }
308                 }
309             }
310         }
311         return null;
312     }
313
314     /** Gets the first icon provided by any sublook. Set of sublooks
315      * is determined by the selector associated with this look and the
316      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
317      * @param representedObject Represented object the look should work with.
318      * @param type Icon type constant from {@link java.beans.BeanInfo}
319      * @param env Environement for the represented object.
320      * @return First icon returned by some of the sublooks or <CODE>null</CODE>
321      */

322     public java.awt.Image JavaDoc getIcon(Object JavaDoc representedObject, int type, Lookup env) {
323         Enumeration JavaDoc delegates = delegateTo (GET_ICON, representedObject );
324         if (delegates != null) {
325             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
326                 Look delegate = extractLook (delegates);
327                 if (delegate != null) {
328                     java.awt.Image JavaDoc h = ((Look)delegate).getIcon (delegateObject( representedObject ), type, env );
329                     if (h != null) {
330                         return h;
331                     }
332                 }
333             }
334         }
335         return null;
336     }
337
338     /** Gets the first icon for opened state provided by any sublook. Set of sublooks
339      * is determined by the selector associated with this look and the
340      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
341      * @param representedObject Represented object the look should work with.
342      * @param type Icon type constant from {@link java.beans.BeanInfo}
343      * @param env Environement for the represented object.
344      * @return First icon for opened state returned by some of the sublooks or <CODE>null</CODE>
345      */

346     public java.awt.Image JavaDoc getOpenedIcon(Object JavaDoc representedObject, int type, Lookup env) {
347         Enumeration JavaDoc delegates = delegateTo (GET_OPENED_ICON, representedObject );
348         if (delegates != null) {
349             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
350                 Look delegate = extractLook (delegates);
351                 if (delegate != null) {
352                     java.awt.Image JavaDoc h = ((Look)delegate).getOpenedIcon (delegateObject( representedObject ), type, env );
353                     if (h != null) {
354                         return h;
355                     }
356                 }
357             }
358         }
359         return null;
360     }
361
362     /** Gets the first help context provided by any sublook. Set of sublooks
363      * is determined by the selector associated with this look and the
364      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
365      * @param representedObject Represented object the look should work with.
366      * @param env Environement for the represented object.
367      * @return First help context returned by some of the sublooks or <CODE>null</CODE>
368      */

369     public HelpCtx getHelpCtx(Object JavaDoc representedObject, Lookup env ) {
370         Enumeration JavaDoc delegates = delegateTo (GET_HELP_CTX, representedObject );
371         if (delegates != null) {
372             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
373                 Look delegate = extractLook (delegates);
374                 if (delegate != null) {
375                     HelpCtx h = ((Look)delegate).getHelpCtx (delegateObject( representedObject ), env );
376                     if (h != null) {
377                         return h;
378                     }
379                 }
380             }
381         }
382         return null;
383     }
384
385     // Methods for CHILDREN ----------------------------------------------------
386

387     /** Creates list of child objects of given object.
388      * Consults the sublooks to get the resulting list
389      * of child objects.<BR>
390      * The set of consulted sublooks is determined by the selector associated with this look and the
391      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.<BR>
392      * By default the resulting set is a merge of all values returned by
393      * sublooks. However the merging behavior can be modified by overriding the
394      * @param representedObject Represented object the look should work with.
395      * @param env Environement for the represented object.
396      * @return (Merged) list of the child objects
397      */

398     public List JavaDoc getChildObjects(Object JavaDoc representedObject, Lookup env ) {
399         Enumeration JavaDoc delegates = delegateTo (GET_CHILD_OBJECTS, representedObject );
400
401         if (delegates == null) {
402             return null;
403         }
404
405         boolean merge = delegateAll (GET_CHILD_OBJECTS, representedObject );
406
407         List JavaDoc children = null;
408
409         // Create list of subarrays
410
for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
411             Look delegate = extractLook (delegates);
412             if (delegate == null) {
413                 continue;
414             }
415
416             Look look = (Look)delegate;
417
418             List JavaDoc data = look.getChildObjects (delegateObject( representedObject ), env );
419             if (data == null || data.size() == 0 ) {
420                 continue;
421             }
422
423             if (!merge) {
424                 // we are not merging and need keys just by one look
425
return data;
426             }
427
428             // add all those objects into array
429
if ( children == null ) {
430                 children = new ArrayList JavaDoc( data );
431             } else {
432                 children.addAll( data );
433             }
434         }
435
436         return children;
437     }
438
439      /** Determines if the object should be expandable by consulting the set of sublooks.
440      * The set of consulted sublooks is determined by the selector associated with this look and the
441      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
442      * <P>
443      * Notice that filtering of this method is driven by the same constant as
444      * by the {@link #getChildObjects}
445      * getChildObjects( substitute )} method i.e.
446      * {@link #GET_CHILD_OBJECTS GET_CHILD_OBJECTS}.
447        * @param representedObject Represented object the look should work with.
448      * @param env Environement for the represented object.
449
450      * @return <CODE>true</CODE> if at least one of the sublooks returns <CODE>true</CODE>,
451      * <CODE>false</CODE> otherwise.
452      */

453     public boolean isLeaf(Object JavaDoc representedObject, Lookup env ) {
454         Enumeration JavaDoc delegates = delegateTo (GET_CHILD_OBJECTS, representedObject );
455         if (delegates != null) {
456             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
457                 Look delegate = extractLook (delegates);
458                 if (delegate != null) {
459                     if ( !((Look)delegate).isLeaf (delegateObject( representedObject ), env )) {
460                         return false;
461                     }
462                 }
463             }
464         }
465         return true;
466     }
467
468     // Methods for ACTIONS & NEW TYPES -----------------------------------------
469

470     /** Creates an array of NewTypes for given node consulting the set of
471      * sublooks.
472      * The set of consulted sublooks is determined by the selector associated with this look and the
473      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.<BR>
474      * By default the resulting set is a merge of all values returned by
475      * sublooks. However the merging behavior can be modified by overriding the
476      * {@link #delegateAll} method.<BR>
477      * @param representedObject Represented object the look should work with.
478      * @param env Environement for the represented object.
479      * @return (Merged) array of the NewTypes
480      */

481     public NewType[] getNewTypes(Object JavaDoc representedObject, Lookup env ) {
482         Enumeration JavaDoc delegates = delegateTo (GET_NEW_TYPES, representedObject );
483
484         if (delegates == null) {
485             return null;
486         }
487
488         boolean merge = delegateAll (GET_NEW_TYPES, representedObject );
489
490         Object JavaDoc arrays = null;
491
492         // Create list of subarrays
493
for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
494             Look delegate = extractLook (delegates);
495             if (delegate == null) {
496                 continue;
497             }
498
499             Look look = (Look)delegate;
500
501             NewType[] data = look.getNewTypes (delegateObject( representedObject ), env );
502             if (data == null || data.length == 0 ) {
503                 continue;
504             }
505
506             if (!merge) {
507                 // we are not merging and need keys just by one look
508
return data;
509             }
510
511             // add all those objects into array
512
if (arrays == null) {
513                 arrays = data;
514             } else {
515                 ArrayList JavaDoc l;
516                 if (arrays instanceof Object JavaDoc[]) {
517                     // arrays contains Object[] convert to ArrayList
518
Object JavaDoc[] arr = (Object JavaDoc[])arrays;
519                     l = new ArrayList JavaDoc (arr.length * 2);
520                     l.addAll (Arrays.asList (arr));
521                     arrays = l;
522                 } else {
523                     l = (ArrayList JavaDoc)arrays;
524                 }
525                 l.addAll (Arrays.asList (data));
526             }
527         }
528
529         if (arrays == null) {
530             // Return if there is nothing to merge
531
return null;
532         }
533
534         return arrays instanceof NewType[] ? (NewType[])arrays : (NewType[])((ArrayList JavaDoc)arrays).toArray (new NewType[0]);
535     }
536
537     /** Crates an array of actions for the node by consulting the set of sublooks.
538      * The set of consulted sublooks is determined by the selector associated with this look and the
539      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.<BR>
540      * By default the resulting set is a merge of all values returned by
541      * sublooks. However the merging behavior can be modified by overriding the
542      * {@link #delegateAll} method.<BR>
543      * @param representedObject Represented object the look should work with.
544      * @param env Environement for the represented object.
545      * @return (Merged) array of actions
546      */

547     public Action JavaDoc[] getActions(Object JavaDoc representedObject, Lookup env ) {
548         Enumeration JavaDoc delegates = delegateTo (GET_ACTIONS, representedObject );
549
550         if (delegates == null) {
551             return null;
552         }
553
554         boolean merge = delegateAll (GET_ACTIONS, representedObject);
555
556         Object JavaDoc arrays = null;
557
558         // Create list of subarrays
559
for (int i[] = { 0 };delegates.hasMoreElements(); i[0]++) {
560             Look delegate = extractLook (delegates);
561             if (delegate == null) {
562                 continue;
563             }
564
565             Look look = (Look)delegate;
566
567             Action JavaDoc[] data = look.getActions (delegateObject( representedObject ), env );
568             if (data == null || data.length == 0 ) {
569                 continue;
570             }
571
572             if (!merge) {
573                 // we are not merging and need keys just by one look
574
return data;
575             }
576
577             // add all those objects into array
578
if (arrays == null) {
579                 arrays = data;
580             } else {
581                 ArrayList JavaDoc l;
582                 if (arrays instanceof Object JavaDoc[]) {
583                     // arrays contains Object[] convert to ArrayList
584
Object JavaDoc[] arr = (Object JavaDoc[])arrays;
585                     l = new ArrayList JavaDoc (arr.length * 2);
586                     l.addAll (Arrays.asList (arr));
587                     arrays = l;
588                 } else {
589                     l = (ArrayList JavaDoc)arrays;
590                 }
591                 l.addAll (Arrays.asList (data));
592             }
593         }
594
595         if (arrays == null) {
596             // Return if there is nothing to merge
597
return null;
598         }
599
600         return arrays instanceof Action JavaDoc[] ? (Action JavaDoc[])arrays : (Action JavaDoc[])((ArrayList JavaDoc)arrays).toArray (new Action JavaDoc[0]);
601     }
602
603     /** Crates an array of context actions for the node by consulting the set of sublooks.
604      * The set of consulted sublooks is determined by the selector associated with this look and the
605      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.<BR>
606      * By default the resulting set is a merge of all values returned by
607      * sublooks. However the merging behavior can be modified by overriding the
608      * {@link #delegateAll} method.<BR>
609      * @param representedObject Represented object the look should work with.
610      * @param env Environement for the represented object.
611      * @return (Merged) array of context actions
612      */

613     public Action JavaDoc[] getContextActions(Object JavaDoc representedObject, Lookup env ) {
614         Enumeration JavaDoc delegates = delegateTo (GET_CONTEXT_ACTIONS, representedObject );
615
616         if (delegates == null) {
617             return null;
618         }
619
620         boolean merge = delegateAll (GET_CONTEXT_ACTIONS, representedObject );
621
622         Object JavaDoc arrays = null;
623
624         // Create list of subarrays
625
for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
626             Look delegate = extractLook (delegates);
627             if (delegate == null) {
628                 continue;
629             }
630
631             Look look = (Look)delegate;
632
633             Action JavaDoc[] data = look.getContextActions (delegateObject( representedObject ), env );
634             if (data == null || data.length == 0 ) {
635                 continue;
636             }
637
638             if (!merge) {
639                 // we are not merging and need keys just by one look
640
return data;
641             }
642
643             // add all those objects into array
644
if (arrays == null) {
645                 arrays = data;
646             } else {
647                 ArrayList JavaDoc l;
648                 if (arrays instanceof Object JavaDoc[]) {
649                     // arrays contains Object[] convert to ArrayList
650
Object JavaDoc[] arr = (Object JavaDoc[])arrays;
651                     l = new ArrayList JavaDoc (arr.length * 2);
652                     l.addAll (Arrays.asList (arr));
653                     arrays = l;
654                 } else {
655                     l = (ArrayList JavaDoc)arrays;
656                 }
657                 l.addAll (Arrays.asList (data));
658             }
659         }
660
661         if (arrays == null) {
662             // Return if there is nothing to merge
663
return null;
664         }
665
666         return arrays instanceof Action JavaDoc[] ? (Action JavaDoc[])arrays : (Action JavaDoc[])((ArrayList JavaDoc)arrays).toArray (new Action JavaDoc[0]);
667     }
668
669     /** Gets the first default action provided by any sublook. Set of sublooks
670      * is determined by the selector associated with this look and the
671      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
672      * @param representedObject Represented object the look should work with.
673      * @param env Environement for the represented object.
674      * @return First default action returned by some of the sublooks or <CODE>null</CODE>
675      */

676     public Action JavaDoc getDefaultAction(Object JavaDoc representedObject, Lookup env ) {
677         Enumeration JavaDoc delegates = delegateTo (GET_DEFAULT_ACTION, representedObject );
678         if (delegates != null) {
679             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
680                 Look delegate = extractLook (delegates);
681                 if (delegate != null) {
682                     Action JavaDoc h = ((Look)delegate).getDefaultAction (delegateObject( representedObject ), env );
683                     if (h != null) {
684                         return h;
685                     }
686                 }
687             }
688         }
689         return null;
690     }
691
692     // Methods for PROPERTIES AND CUSTOMIZER -----------------------------------
693

694     /** Creates and array of PropertySets by consulting sublooks. The resulting array
695      * (if merging is enabled) contains all sets returned from the sublooks. If set
696      * with equal name is contained in array returned from more than one sublook,
697      * then the resulting array will contain one set of given name with all
698      * properties from the (sub)sets merged.<BR>
699      * The set of consulted sublooks is determined by the selector associated with this look and the
700      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.<BR>
701      * By default the resulting set is a merge of all values returned by
702      * sublooks. However the merging behavior can be modified by overriding the
703      * {@link #delegateAll} method.<BR>
704      * @param representedObject Represented object the look should work with.
705      * @param env Environement for the represented object.
706      * @return (Merged) array of PropertySets
707      */

708     public Node.PropertySet[] getPropertySets(Object JavaDoc representedObject, Lookup env ) {
709         Enumeration JavaDoc delegates = delegateTo (GET_PROPERTY_SETS, representedObject );
710
711         if (delegates == null) {
712             return null;
713         }
714
715         delegates = Enumerations.filter(delegates, new Enumerations.Processor() {
716             public Object JavaDoc process(Object JavaDoc o, Collection JavaDoc ignore) {
717                 return o; // We need to get rid of null values
718
}
719         });
720
721         boolean merge = delegateAll (GET_PROPERTY_SETS, representedObject );
722
723         ArrayList JavaDoc setsList = null;
724         HashMap JavaDoc nameMap = null;
725
726         // Create list of property sets and the name map
727
for (int index[] = { 0 } ; delegates.hasMoreElements(); index[0]++) {
728             Look delegate = extractLook (delegates);
729             if (delegate == null) {
730                 continue;
731             }
732
733             Look look = (Look)delegate;
734
735             Node.PropertySet[] sets = look.getPropertySets(delegateObject( representedObject ), env );
736             if ( sets == null || sets.length == 0 ) {
737                 continue; // Look does not provide any properties
738
}
739
740             if (!merge) {
741                 // no need to do merging, return the first reasonable value
742
return sets;
743             }
744
745             if (setsList == null) {
746                 if ( !delegates.hasMoreElements() ) {
747                     // I am the last look in the raw, no need to do merging
748
return sets;
749                 }
750
751                 setsList = new ArrayList JavaDoc ();
752                 nameMap = new HashMap JavaDoc (37);
753             }
754
755
756             // Merge the property sets. We use sheet sets for
757
// more comfortable work with propertySets
758
for ( int i = 0; i < sets.length; i++ ) {
759                 if ( sets[i].getName() == null ) {
760                     continue; // Ignore unnamed lists
761
}
762                 Sheet.Set es = (Sheet.Set)nameMap.get( sets[i].getName() );
763                 if ( es == null ) { //Such sheet does not exist yet
764
es = new Sheet.Set( );
765                     es.setName( sets[i].getName() );
766                     es.setDisplayName( sets[i].getDisplayName() );
767                     es.setShortDescription( sets[i].getShortDescription() );
768                     es.put( sets[i].getProperties() );
769                     setsList.add( es );
770                     nameMap.put( sets[i].getName(), es );
771                 }
772                 else { // Sheet exists => merge properties
773
Node.Property[] props = sets[i].getProperties();
774                     if ( props == null || props.length == 0 ) {
775                         continue;
776                     }
777                     else {
778                         es.put( sets[i].getProperties() );
779                     }
780                 }
781             }
782         }
783
784         if ( setsList == null || setsList.size() == 0 ) {
785             return null;
786         }
787         else {
788             Node.PropertySet[] result = new Node.PropertySet[ setsList.size() ];
789             setsList.toArray( result );
790             return result;
791         }
792     }
793
794     /** Gets the first customizer component provided by any sublook. Set of sublooks
795      * is determined by the selector associated with this look and the
796      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
797      * @param representedObject Represented object the look should work with.
798      * @param env Environement for the represented object.
799      * @return First customizer component returned by some of the sublooks or <CODE>null</CODE>
800      */

801     public Component JavaDoc getCustomizer(Object JavaDoc representedObject, Lookup env ) {
802         Enumeration JavaDoc delegates = delegateTo (GET_CUSTOMIZER, representedObject );
803         if (delegates != null) {
804             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
805                 Look delegate = extractLook (delegates);
806                 if (delegate != null) {
807                     Component JavaDoc h = ((Look)delegate).getCustomizer (delegateObject( representedObject ), env );
808                     if (h != null) {
809                         return h;
810                     }
811                 }
812             }
813         }
814         return null;
815     }
816
817     /** Determines if the node has customize element by consulting the set of sublooks.
818      * The set of consulted sublooks is determined by the selector associated with this look and the
819      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
820      * @param representedObject Represented object the look should work with.
821      * @param env Environement for the represented object.
822      * @return <CODE>true</CODE> if at least one of the sublooks returns <CODE>true</CODE>,
823      * <CODE>false</CODE> otherwise.
824      */

825     public boolean hasCustomizer(Object JavaDoc representedObject, Lookup env ) {
826         Enumeration JavaDoc delegates = delegateTo (HAS_CUSTOMIZER, representedObject );
827         if (delegates != null) {
828             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
829                 Look delegate = extractLook (delegates);
830                 if (delegate != null) {
831                     if ( ((Look)delegate).hasCustomizer (delegateObject( representedObject ), env )) {
832                         return true;
833                     }
834                 }
835             }
836         }
837         return false;
838     }
839     // Methods for CLIPBOARD OPERATIONS ----------------------------------------
840

841     /** Tests whether the node permits renaming by consulting the set of sublooks.
842      * The set of consulted sublooks is determined by the selector associated with this look and the
843      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
844      * @param representedObject Represented object the look should work with.
845      * @param env Environement for the represented object.
846      * @return <CODE>true</CODE> if at least one of the sublooks returns <CODE>true</CODE>,
847      * <CODE>false</CODE> otherwise.
848      */

849     public boolean canRename(Object JavaDoc representedObject, Lookup env ) {
850         Enumeration JavaDoc delegates = delegateTo (CAN_RENAME, representedObject );
851         if (delegates != null) {
852             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
853                 Look delegate = extractLook (delegates);
854                 if (delegate != null) {
855                     boolean b = ((Look)delegate).canRename (delegateObject( representedObject ), env );
856                     if (b) {
857                         return true;
858                     }
859                 }
860             }
861         }
862         return false;
863     }
864
865     /** Tests whether the node permits the destroy operation by consulting the set of sublooks.
866      * The set of consulted sublooks is determined by the selector associated with this look and the
867      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
868      * @param representedObject Represented object the look should work with.
869      * @param env Environement for the represented object.
870      * @return <CODE>true</CODE> if at least one of the sublooks returns <CODE>true</CODE>,
871      * <CODE>false</CODE> otherwise.
872      */

873     public boolean canDestroy(Object JavaDoc representedObject, Lookup env ) {
874         Enumeration JavaDoc delegates = delegateTo (CAN_DESTROY, representedObject );
875         if (delegates != null) {
876             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
877                 Look delegate = extractLook (delegates);
878                 if (delegate != null) {
879                     boolean b = ((Look)delegate).canDestroy (delegateObject( representedObject ), env );
880                     if (b) {
881                         return true;
882                     }
883                 }
884             }
885         }
886         return false;
887     }
888
889     /** Tests whether the node permits the copy operation by consulting the set of sublooks.
890      * The set of consulted sublooks is determined by the selector associated with this look and the
891      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
892      * @param representedObject Represented object the look should work with.
893      * @param env Environement for the represented object.
894      * @return <CODE>true</CODE> if at least one of the sublooks returns <CODE>true</CODE>,
895      * <CODE>false</CODE> otherwise.
896      */

897     public boolean canCopy(Object JavaDoc representedObject, Lookup env ) {
898         Enumeration JavaDoc delegates = delegateTo (CAN_COPY, representedObject );
899         if (delegates != null) {
900             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
901                 Look delegate = extractLook (delegates);
902                 if (delegate != null) {
903                     boolean b = ((Look)delegate).canCopy (delegateObject( representedObject ), env );
904                     if (b) {
905                         return true;
906                     }
907                 }
908             }
909         }
910         return false;
911     }
912
913     /** Tests whether the node permits the cut operation by consulting the set of sublooks.
914      * The set of consulted sublooks is determined by the selector associated with this look and the
915      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
916      * @param representedObject Represented object the look should work with.
917      * @param env Environement for the represented object.
918      * @return <CODE>true</CODE> if at least one of the sublooks returns <CODE>true</CODE>,
919      * <CODE>false</CODE> otherwise.
920      */

921     public boolean canCut(Object JavaDoc representedObject, Lookup env ) {
922         Enumeration JavaDoc delegates = delegateTo (CAN_CUT, representedObject );
923         if (delegates != null) {
924             for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
925                 Look delegate = extractLook (delegates);
926                 if (delegate != null) {
927                     boolean b = ((Look)delegate).canCut (delegateObject( representedObject ), env );
928                     if (b) {
929                         return true;
930                     }
931                 }
932             }
933         }
934         return false;
935     }
936
937     /** Crates an array of allowed PasteTypes by consulting the set of sublooks.
938      * The set of consulted sublooks is determined by the selector associated with this look and the
939      * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.<BR>
940      * By default the resulting set is a merge of all values returned by
941      * sublooks. However the merging behavior can be modified by overriding the
942      * {@link #delegateAll} method.<BR>
943      * @param representedObject Represented object the look should work with.
944      * @param env Environement for the represented object.
945      * @param t The transferable
946      * @return (Merged) array of PasteTypes
947      */

948     public PasteType[] getPasteTypes(Object JavaDoc representedObject, Transferable JavaDoc t, Lookup env ) {
949         Enumeration JavaDoc delegates = delegateTo (GET_PASTE_TYPES, representedObject );
950
951         if (delegates == null) {
952             return null;
953         }
954
955         boolean merge = delegateAll (GET_PASTE_TYPES, representedObject );
956
957         Object JavaDoc arrays = null;
958
959         // Create list of subarrays
960
for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
961             Look delegate = extractLook (delegates);
962             if (delegate == null) {
963                 continue;
964             }
965
966             Look look = (Look)delegate;
967
968             PasteType[] data = look.getPasteTypes (delegateObject( representedObject ), t, env );
969             if (data == null || data.length == 0 ) {
970                 continue;
971             }
972
973             if (!merge) {
974                 // we are not merging and need keys just by one look
975
return data;
976             }
977
978             // add all those objects into array
979
if (arrays == null) {
980                 arrays = data;
981             } else {
982                 ArrayList JavaDoc l;
983                 if (arrays instanceof Object JavaDoc[]) {
984                     // arrays contains Object[] convert to ArrayList
985
Object JavaDoc[] arr = (Object JavaDoc[])arrays;
986                     l = new ArrayList JavaDoc (arr.length * 2);
987                     l.addAll (Arrays.asList (arr));
988                     arrays = l;
989                 } else {
990                     l = (ArrayList JavaDoc)arrays;
991                 }
992                 l.addAll (Arrays.asList (data));
993             }
994         }
995
996         if (arrays == null) {
997             // Return if there is nothing to merge
998
return null;
999         }
1000
1001        return arrays instanceof PasteType[] ? (PasteType[])arrays : (PasteType[])((ArrayList JavaDoc)arrays).toArray (new PasteType[0]);
1002    }
1003
1004    /** Gets the first PasteType from any sublook, which can provide the
1005     * paste operation. Set of sublooks
1006     * is determined by the selector associated with this look and the
1007     * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
1008     * @see org.netbeans.spi.looks.Look#getDropType
1009     * @param representedObject Represented object the look should work with.
1010     * @param t the transferable
1011     * @param action the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINK
1012     * @param index index between children the drop occurred at or -1 if not specified
1013     * @param env Environement for the represented object.
1014     * @return First PasteType returned by some of the sublooks or <CODE>null</CODE>
1015     */

1016    public PasteType getDropType(Object JavaDoc representedObject, Transferable JavaDoc t, int action, int index, Lookup env ) {
1017        Enumeration JavaDoc delegates = delegateTo (GET_DROP_TYPE, representedObject );
1018        if (delegates != null) {
1019            for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
1020                Look delegate = extractLook (delegates);
1021                if (delegate != null) {
1022                    PasteType b = ((Look)delegate).getDropType (delegateObject( representedObject ), t, action, index, env );
1023                    if (b != null) {
1024                        return b;
1025                    }
1026                }
1027            }
1028        }
1029        return null;
1030    }
1031
1032    /** Gets the first transferable from any sublook which can provide the copy
1033     * operation. Set of sublooks
1034     * is determined by the selector associated with this look and the
1035     * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
1036     * @param representedObject Represented object the look should work with.
1037     * @return First transferable returned by some of the sublooks or <CODE>null</CODE>
1038     * @param env Environement for the represented object.
1039     * @throws IOException If any of the sublooks throws the exception
1040     */

1041    public Transferable JavaDoc clipboardCopy(Object JavaDoc representedObject, Lookup env ) throws IOException JavaDoc {
1042        Enumeration JavaDoc delegates = delegateTo (CLIPBOARD_COPY, representedObject );
1043        if (delegates != null) {
1044            for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
1045                Look delegate = extractLook (delegates);
1046                if (delegate != null) {
1047                    Transferable JavaDoc b = ((Look)delegate).clipboardCopy (delegateObject( representedObject ), env );
1048                    if (b != null) {
1049                        return b;
1050                    }
1051                }
1052            }
1053        }
1054        return null;
1055    }
1056
1057    /** Gets the first transferable from any sublook which can provide the cut
1058     * operation. Set of sublooks
1059     * is determined by the selector associated with this look and the
1060     * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
1061     * @param representedObject Represented object the look should work with.
1062     * @param env Environement for the represented object.
1063     * @return First transferable returned by some of the sublooks or <CODE>null</CODE>
1064     * @throws IOException If any of the sublooks throws the exception
1065     */

1066    public Transferable JavaDoc clipboardCut(Object JavaDoc representedObject, Lookup env ) throws IOException JavaDoc {
1067        Enumeration JavaDoc delegates = delegateTo (CLIPBOARD_CUT, representedObject );
1068        if (delegates != null) {
1069            for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
1070                Look delegate = extractLook (delegates);
1071                if (delegate != null) {
1072                    Transferable JavaDoc b = ((Look)delegate).clipboardCut (delegateObject( representedObject ), env );
1073                    if (b != null) {
1074                        return b;
1075                    }
1076                }
1077            }
1078        }
1079        return null;
1080    }
1081
1082    /** Gets the first transferable from any sublook that can provide the drag operation.
1083     * Set of sublooks
1084     * is determined by the selector associated with this look and the
1085     * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
1086     * @param representedObject Represented object the look should work with.
1087     * @param env Environement for the represented object.
1088     * @return First transferable returned by some of the sublooks or <CODE>null</CODE>
1089     * @throws IOException If any of the sublooks throws the exception
1090     */

1091    public Transferable JavaDoc drag(Object JavaDoc representedObject, Lookup env ) throws IOException JavaDoc {
1092        Enumeration JavaDoc delegates = delegateTo (DRAG, representedObject );
1093        if (delegates != null) {
1094            for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
1095                Look delegate = extractLook (delegates);
1096                if (delegate != null) {
1097                    Transferable JavaDoc b = ((Look)delegate).drag (delegateObject( representedObject ), env );
1098                    if (b != null) {
1099                        return b;
1100                    }
1101                }
1102            }
1103        }
1104        return null;
1105    }
1106
1107    /** Calls the destroy method on all sublooks. The set of sublooks
1108     * is determined by the selector associated with this look and the
1109     * {@link #delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object) filtering method }.
1110     * @param representedObject Represented object the look should work with.
1111     * @param env Environement for the represented object.
1112     * @throws IOException If any of the sublooks throws the exception
1113     */

1114    public void destroy(Object JavaDoc representedObject, Lookup env ) throws IOException JavaDoc {
1115        Enumeration JavaDoc delegates = delegateTo (DESTROY, representedObject );
1116        if (delegates != null) {
1117            for (int i[] = { 0 }; delegates.hasMoreElements(); i[0]++) {
1118                Look delegate = extractLook (delegates);
1119                if (delegate != null) {
1120                    ((Look)delegate).destroy (delegateObject( representedObject ), env );
1121                }
1122            }
1123        }
1124    }
1125
1126    // Package private methods -------------------------------------------------
1127

1128    
1129    void addLookListener( Object JavaDoc representedObject, LookListener listener ) {
1130    
1131        Object JavaDoc dObject = null;
1132        Enumeration JavaDoc delegates = null;
1133        
1134        if ( representedObject != null ) {
1135            dObject = delegateObject( representedObject );
1136            delegates = content.getLooks( dObject );
1137        }
1138        
1139        synchronized ( this ) {
1140            super.addLookListener( representedObject, listener );
1141
1142            // Start listening on the selector
1143
// org.netbeans.modules.looks.Accessor.DEFAULT.addSelectorListener( content, eventTranslator );
1144

1145            if (representedObject != null) {
1146                // Allow sublooks to attach to representedObject
1147

1148                List JavaDoc dList = new ArrayList JavaDoc();
1149                if (delegates != null) {
1150                    for ( int i[] = { 0 }; delegates.hasMoreElements(); i[0]++ ) {
1151                        Look delegate = extractLook (delegates);
1152                        if (delegate != null) {
1153                            RuntimeException JavaDoc ex = null;
1154                            try { // Sublooks may throw an exception
1155
((Look)delegate).addLookListener( dObject, null );
1156                                ((Look)delegate).addLookListener( null, eventTranslator );
1157                                dList.add( delegate );
1158                            }
1159                            catch ( ClassCastException JavaDoc e ) {
1160                                ex = e;
1161                            }
1162                            catch ( IllegalArgumentException JavaDoc e ) {
1163                                ex = e;
1164                            }
1165                            if ( ex != null ) { // Exception thrown
1166
// We need to detach and remove listeners
1167
for( Iterator JavaDoc it = dList.iterator(); it.hasNext(); ) {
1168                                    Look l = (Look)it.next();
1169                                    l.removeLookListener( dObject, null );
1170                                    l.removeLookListener( null, eventTranslator );
1171                                }
1172                                // and rethrow the exception
1173
throw ex;
1174                            }
1175                        }
1176                    }
1177                }
1178            }
1179        }
1180    }
1181           
1182    void removeLookListener( Object JavaDoc representedObject, LookListener listener ) {
1183    
1184        Object JavaDoc dObject = null;
1185        Enumeration JavaDoc delegates = null;
1186        
1187        if ( representedObject != null ) {
1188            dObject = delegateObject( representedObject );
1189            delegates = content.getLooks( dObject );
1190        }
1191        
1192        synchronized ( this ) {
1193            if (representedObject != null) {
1194                // Tell sublooks that they should stop listening
1195
if (delegates != null) {
1196                    for ( int i[] = { 0 }; delegates.hasMoreElements(); i[0]++ ) {
1197                        Look delegate = extractLook (delegates);
1198                        if (delegate != null) {
1199                            delegate.removeLookListener( dObject, null );
1200                        }
1201                    }
1202                }
1203            }
1204        
1205            // Stop listening on the selector
1206
// org.netbeans.modules.looks.Accessor.DEFAULT.removeSelectorListener( content, eventTranslator );
1207

1208            super.removeLookListener( representedObject, listener );
1209        }
1210    }
1211    
1212
1213    // Innerclasses ------------------------------------------------------------
1214

1215    /** Class which listens on other looks an simply resends the events.
1216     */

1217    private class ProxyLookEventTranslator implements LookListener, org.netbeans.modules.looks.SelectorListener {
1218
1219        public void change( LookEvent evt ) {
1220            fireChange( undelegateObject( evt.getSource() ), evt.getMask() );
1221        }
1222        public void propertyChange( LookEvent evt ) {
1223            firePropertyChange( undelegateObject( evt.getSource() ), evt.getPropertyName() );
1224        }
1225        
1226        // Look selector implementation ----------------------------------------
1227

1228        public void contentsChanged( org.netbeans.modules.looks.SelectorEvent evt ) {
1229            
1230            // Prepare the mask
1231
long mask = Look.ALL_METHODS;
1232            mask &= ~( Look.DESTROY | Look.RENAME );
1233            
1234            Object JavaDoc objects[] = getAllObjects(); // Read the content of the cache
1235
if ( objects == null ) {
1236                return; // Nothing to do
1237
}
1238            
1239            for( int i = 0; i < objects.length; i++ ) {
1240                Object JavaDoc dObject = delegateObject( objects[i] );
1241                Collection JavaDoc removedLooks = evt.getRemovedLooks( objects[i] );
1242                if ( !removedLooks.isEmpty() ) {
1243                    // Stop listening on the remnoved looks
1244
for( Iterator JavaDoc it = removedLooks.iterator(); it.hasNext(); ) {
1245                        ((Look)it.next()).removeLookListener( dObject, null );
1246                    }
1247                }
1248                
1249                Collection JavaDoc addedLooks = evt.getAddedLooks( objects[i] );
1250                if ( !addedLooks.isEmpty() ) {
1251                    // Start listening on the new looks
1252
for( Iterator JavaDoc it = addedLooks.iterator(); it.hasNext(); ) {
1253                        ((Look)it.next()).addLookListener( dObject, null );
1254                    }
1255                }
1256            }
1257            
1258            
1259            fireChange( null, mask );
1260            firePropertyChange( null, null );
1261        }
1262        
1263    }
1264
1265}
1266
Popular Tags