Extension SDK 10.1.2

oracle.ide.model
Class DefaultFolder

java.lang.Object
  extended byoracle.ide.model.DefaultDisplayable
      extended byoracle.ide.model.DefaultElement
          extended byoracle.ide.model.DefaultFolder
All Implemented Interfaces:
Data, Displayable, Element, Folder
Direct Known Subclasses:
BaseConnections, Connections, DataFolder, HierarchicalFolder, Preferences

public class DefaultFolder
extends DefaultElement
implements Folder

DefaultFolder is a complete, default implementation of the Folder interface. This is a convenient starting point for the implementation of data classes which can be integrated with the IDE framework.

If a subclass of DefaultFolder adheres to the JavaBeans API, it can also interoperate with the IDE's marshalling framework, which is used for persistence. Such a subclass can be persisted automatically (i.e. no custom persistence code needs to be written), so long as the subclass implementation follows the guidelines of the marshalling framework. For details, see the documentation for the oracle.ide.marshal package and its subpackages.

A JavaBean also has the advantage of interoperating with the property inspector. Newer APIs are also being considered which leverage the JavaBeans API, so implementing a DefaultFolder subclass to follow the JavaBeans API will also result in compatibility with future features.

See Also:
DefaultElement, Folder, oracle.ide.marshal, oracle.ide.marshal.xml, Object2Dom

Field Summary
protected  java.util.ArrayList _children
          The "final" modifier makes it possible to synchronize on the _children object, since its value can never change.
 
Constructor Summary
DefaultFolder()
          Creates a new DefaultFolder instance.
 
Method Summary
 boolean add(Element element)
          Part of the Folder interface.
 boolean canAdd(Element element)
          Part of the Folder interface.
 boolean canRemove(Element element)
          Part of the Folder interface.
 boolean containsChild(Element child)
          Returns true if the folder contains the specified child Element; returns false otherwise.
protected  void copyToImpl(DefaultFolder copy)
          Design pattern for supporting strongly typed copying.
protected  boolean equalsImpl(DefaultFolder defaultFolder)
          This is a helper method for Object.equals(Object) that can also be used by subclasses that implement Object.equals(Object).
 java.util.Iterator getChildren()
          Part of the Element interface.
 javax.swing.Icon getIcon()
          Part of Element interface.
 boolean mayHaveChildren()
          Part of the Element interface.
 boolean remove(Element element)
          Part of the Folder interface.
 void removeAll()
          Removes all children from the folder.
 int size()
          Returns the current number of children in the folder.
 
Methods inherited from class oracle.ide.model.DefaultElement
getAttributes, getData
 
Methods inherited from class oracle.ide.model.DefaultDisplayable
getLongLabel, getShortLabel, getToolTipText, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.ide.model.Element
getAttributes
 
Methods inherited from interface oracle.ide.model.Data
getData
 
Methods inherited from interface oracle.ide.model.Displayable
getLongLabel, getShortLabel, getToolTipText, toString
 

Field Detail

_children

protected final java.util.ArrayList _children
The "final" modifier makes it possible to synchronize on the _children object, since its value can never change. All subclasses that directly access the _children field are responsible for first synchronizing on the _children object before accessing its contents and and for managing the state of the dirty flag when changes are made.

Constructor Detail

DefaultFolder

public DefaultFolder()
Creates a new DefaultFolder instance.

Subclasses that are designed to operate as a JavaBean must implement a public default constructor.

Method Detail

mayHaveChildren

public boolean mayHaveChildren()
Part of the Element interface. This implementation always returns true.

Specified by:
mayHaveChildren in interface Element
Overrides:
mayHaveChildren in class DefaultElement
See Also:
Element.mayHaveChildren()

getChildren

public java.util.Iterator getChildren()
Part of the Element interface. This implementation returns an Iterator over the current list of children.

Specified by:
getChildren in interface Element
Overrides:
getChildren in class DefaultElement
See Also:
Element.getChildren()

getIcon

public javax.swing.Icon getIcon()
Part of Element interface. The default implementation returns null, which causes a default folder icon to be used.

Specified by:
getIcon in interface Displayable
Overrides:
getIcon in class DefaultDisplayable
See Also:
Displayable.getIcon()

canAdd

public boolean canAdd(Element element)
Part of the Folder interface. The default implementation returns true if and only if the specified Element is not null.

Specified by:
canAdd in interface Folder
Parameters:
element - the Element that is about to be added to this Folder.
Returns:
true if and only if the specified Element is not null.
See Also:
Folder.canAdd(Element)

add

public boolean add(Element element)
Part of the Folder interface. The specified Element is added to the end of the child list. However, if the Element is null, this method does nothing.

In order for the UI to get updated correctly, an appropriate UpdateMessage will need to be sent to Observers of the DefaultFolder. The policy in the IDE is that the class that changes the state of an object is responsible for firing the UpdateMessages for those changes. UpdageMessages are not fired by the changed object itself.

For a single UpdateMessage corresponding to add(Element), you can fire the UpdateMessage using code like:

UpdateMessage.fireChildAdded(folder, newlyAddedChild);

Specified by:
add in interface Folder
See Also:
Folder.add(oracle.ide.model.Element)

canRemove

public boolean canRemove(Element element)
Part of the Folder interface. The default implementation returns true if and only if the specified Element is not null.

Specified by:
canRemove in interface Folder
Parameters:
element - the Element that is about to be removed from this Folder.
Returns:
true if and only if the specified Element is not null.
See Also:
Folder.canRemove(Element)

remove

public boolean remove(Element element)
Part of the Folder interface. The specified Element is removed from the child list. However, if the Element is null, this method does nothing. If the Element occurs more than once in the child list, then only the first instance is removed.

In order for the UI to get updated correctly, an appropriate UpdateMessage will need to be sent to Observers of the DefaultFolder. The policy in the IDE is that the class that changes the state of an object is responsible for firing the UpdateMessages for those changes. UpdateMessages are not fired by the changed object itself.

For a single UpdateMessage corresponding to remove(Element), you can fire the UpdateMessage using code like:

UpdateMessage.fireChildRemoved(folder, removedChild);

Specified by:
remove in interface Folder
Parameters:
element - The child object to remove.
See Also:
Folder.remove(Element)

containsChild

public boolean containsChild(Element child)
Description copied from interface: Folder
Returns true if the folder contains the specified child Element; returns false otherwise.

Specified by:
containsChild in interface Folder

size

public int size()
Description copied from interface: Folder
Returns the current number of children in the folder.

Specified by:
size in interface Folder

removeAll

public void removeAll()
Description copied from interface: Folder
Removes all children from the folder.

Specified by:
removeAll in interface Folder

equalsImpl

protected final boolean equalsImpl(DefaultFolder defaultFolder)
This is a helper method for Object.equals(Object) that can also be used by subclasses that implement Object.equals(Object). It assumes that the argument is not null.


copyToImpl

protected final void copyToImpl(DefaultFolder copy)
Design pattern for supporting strongly typed copying.

This method is intended to be helper method that subclasses can use, if they implement the Copyable interface. The copy of the children list is a shallow copy. That is, the children themselves are not copied, but the list is copied.


Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.