|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.xml.tree.children; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.LinkedList; import org.netbeans.tax.*; /** * @author Libor Kramolis * @version 0.1 */ public class SubObjectListChildren extends ObjectListChildren { /** sub list or null (that degrates it to ObjectListChildren) */ private final TreeObjectList subObjectList; /** */ private final ObjectListListener olListener; /** */ private boolean wasEmpty; // // init // /** */ public SubObjectListChildren (TreeObjectList objectList, TreeObjectList subObjectList, Class[] groupTypes) { super (objectList, groupTypes); this.olListener = new ObjectListListener(); this.subObjectList = subObjectList; } // // from Children.Keys // /** */ protected void addNotify () { if ( this.subObjectList != null ) { this.subObjectList.addPropertyChangeListener (olListener); } super.addNotify(); } /* * Removes listener */ protected void removeNotify () { if ( this.subObjectList != null ) { this.subObjectList.removePropertyChangeListener (olListener); } super.removeNotify(); } // // itself // /** */ protected Collection createKeys () { if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("SubObjectListChildren::createKeys"); // NOI18N Collection keys; Collection superKeys = super.createKeys(); if (subObjectList != null) { if ( wasEmpty = subObjectList.isEmpty() ) { keys = superKeys; } else { keys = new LinkedList (); keys.add (new InstanceKey (subObjectList)); keys.addAll (superKeys); } } else { keys = superKeys; } if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (" ::createKeys: keys = " + keys); // NOI18N return keys; } // // ObjectListListener // /** * */ private class ObjectListListener implements PropertyChangeListener { /** */ public void propertyChange (PropertyChangeEvent pche) { if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("SubObjectListChildren::ObjectListListener::propertyChange: propertyName = '" + pche.getPropertyName() + "'"); // NOI18N if ( (TreeObjectList.PROP_CONTENT_INSERT.equals (pche.getPropertyName())) || (TreeObjectList.PROP_CONTENT_REMOVE.equals (pche.getPropertyName())) ) { if (SubObjectListChildren.this.subObjectList.isEmpty() != SubObjectListChildren.this.wasEmpty) { SubObjectListChildren.this.refreshKeys(); } } } } // end: class ObjectListListener } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.