|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.ide.model.DefaultFilter
oracle.ide.model.HierarchicalFilter
The HierarchicalFilter
defines common behavior for filters
that organize the children of a source folder into a hierarchical (tree)
structure view. The HierarchicalFilter
also defines an
abstract interface which all concrete subclasses must implement.
DirectoryFilter
,
PackageFilter
Nested Class Summary | |
protected class |
HierarchicalFilter.HierarchicalComparator
|
Nested classes inherited from class oracle.ide.model.DefaultFilter |
DefaultFilter.SortedComparator, DefaultFilter.SortedFolderFirstComparator |
Field Summary | |
protected java.util.Map |
childMap
The Map that maps a folder key to the List of project
children belonging to that folder. |
protected java.util.Collection |
children
A Collection of the top-level child Element objects
for this filter. |
protected boolean |
isOpen
Flag denoting whether the contents of the filter have been read. |
protected CategoryFolder |
miscFolder
The "Miscellaneous Files" folder that contains children that are not on the source path. |
protected WeakCache |
nodeCache
The cache mapping an URL to its respective TNode . |
protected static java.lang.Object |
NULL_KEY
Folder key constant used for the Miscellaneous Files folder. |
protected int |
options
Bit mask specifying the view options for this filter. |
protected URLPath |
sourcePath
Cached canonicalized version of the source path for the project. |
protected static java.lang.Object |
TOP_FOLDER_KEY
Folder key constant used for top-level children of the filter. |
protected java.util.Set |
uniqueNames
The Set of unique top-level child names already belonging to
this filter. |
protected URLFilter |
urlFilter
The URLFilter used to filter URL s returned by URLFileSystem.list(URL, URLFilter) . |
static int |
VIEW_HIERARCHICALLY
Flag denoting whether the filter should display its contents hierarchically or flat. |
static int |
VIEW_PROJECT_FILES_ONLY
Flag denoting whether the filter should display project files or all files. |
Fields inherited from class oracle.ide.model.DefaultFilter |
folderFirstComparator, sortedComparator |
Fields inherited from interface oracle.ide.explorer.ChildFilter |
NO_OPTIONS |
Constructor Summary | |
HierarchicalFilter()
Constructs a HierarchicalFilter . |
Method Summary | |
protected void |
add(Element element)
Add the child Element to the collection of the filter's
top-level children. |
void |
cache(TNode node)
Adds the specified TNode to the node cache. |
boolean |
canRefresh(TNode[] nodes)
Always returns true . |
TNode |
childrenAdded(java.util.List added,
TNode par,
TreeExplorer tree)
Adds the specified List of child Element objects to
the TreeExplorer . |
TNode |
childrenRemoved(java.util.List removed,
TNode par,
TreeExplorer tree)
Removes the specified List of child Element objects
from the TreeExplorer . |
protected void |
clearChildren()
Removes all top-level children of the filter. |
protected Element |
createElement(java.net.URL url)
Finds or creates a child Element for the given URL . |
protected abstract Folder |
createFolder(java.lang.Object key)
Creates the child Folder for the given folder key. |
protected abstract Folder |
createFolder(java.net.URL url)
Creates the child Folder for the given directory URL . |
protected CategoryFolder |
getCategoryFolder()
Returns the CategoryFolder that owns this filter, or null if
the filter is not owned by a CategoryFolder . |
protected abstract java.lang.String |
getChildName(java.lang.Object parentKey,
java.lang.Object childKey)
Returns just the name part of a child folder given a parent folder key and the child folder key, or null if the first folder key
is not a parent key of the second folder key. |
java.util.Iterator |
getChildren()
Returns an Iterator for traversing the top-level children of
the filter. |
protected Folder |
getFolder()
Returns the Folder that owns this filter. |
protected java.util.Iterator |
getFolderChildren(HierarchicalFolder folder)
Returns an Iterator for traversing the children belonging to
the specified HierarchicalFolder ; if the specified folder is
null , then an Iterator over the top-level
children of the filter is returned. |
protected java.util.Iterator |
getFolderChildren(java.lang.Object key)
Returns an Iterator for traversing the children belonging to
the folder corresponding to the specified folder key. |
protected abstract java.lang.Object |
getFolderKey(java.net.URL url)
Gets the folder key for the given URL that is used for mapping
a Folder to the list of project children belonging to that
folder. |
protected CategoryFolder |
getMiscFolder()
Return the "Miscellaneous Files" CategoryFolder for this
filter. |
int |
getOptions()
Gets the options bit mask used to control the filter's display. |
protected abstract java.lang.Object |
getParentKey(java.lang.Object key)
Gets the parent folder key for a given folder key. |
protected Project |
getProject()
Returns the Project that owns this filter. |
protected URLPath |
getSourcePath()
Returns the source path for the owning folder. |
protected java.net.URL |
getSourcePathEntry(java.net.URL url)
Returns the URL for the source path entry that contains the
specified URL . |
URLFilter |
getURLFilter()
Returns the URLFilter used to exclude files from the filter's
display. |
boolean |
getViewAllFiles()
Returns true if the filter is currently displaying all
files, or false if the filter is displaying project files
only. |
boolean |
getViewHierarchically()
Returns true if the filter is currently displaying its
folders in nested view, or false if the filter is
displaying its folders in flat view |
protected boolean |
hasMiscFiles()
Returns true if there are miscellaneous files to be displayed. |
protected abstract void |
initChildren()
Initializes the collection of top-level children for the filter. |
protected void |
initializeChildMap()
Initialize the Map that maps each folder by its folder key to
the List of child Element objects belonging to that
folder. |
protected void |
initMiscFolder()
Creates and initializes the Miscellaneous Files folder, if necessary. |
protected boolean |
isDirInProject(java.net.URL url)
Returns true if the URL specifies a directory
that contains at least one Element in the project; otherwise
false . |
protected boolean |
isInSourcePath(java.net.URL url)
Returns true if the URL is contained by an entry
on the source path. |
protected boolean |
isParentKey(java.lang.Object key,
java.lang.Object childKey)
Returns true if the first specified folder key is a
parent key of the second specified folder key; otherwise, returns
false . |
protected boolean |
isSourcePathEntry(java.net.URL url)
Returns true if the URL is an entry on the source
path. |
protected java.net.URL[] |
list(java.net.URL url)
Lists the children of an URL , applying this filter's current
URLFilter to the result set. |
protected java.net.URL[] |
list(URLPath urlPath)
Lists the children of an URLPath as if it were simply a single
URL . |
void |
refresh(TNode[] nodes)
Completely refreshes the filter's display. |
protected void |
remove(Element element)
Removes the child Element from the collection of the filter's
top-level children. |
protected void |
setComparator(java.util.Comparator comparator)
|
void |
setOptions(int options)
Sets the options bit mask used to control the filter's display. |
protected void |
setSourcePath(URLPath sourcePath)
Sets the source path to the specified URLPath . |
void |
setURLFilter(URLFilter urlFilter)
Sets the URLFilter used to exclude files from the filter's
display. |
void |
setViewAllFiles(boolean viewAllFiles)
Sets the filter to display all files or project files only. |
void |
setViewHierarchically(boolean viewHierarchically)
Sets the filter to display folders in nested or flat view. |
void |
uncache(TNode tnode)
Removes the specified TNode from the node cache. |
TNode |
update(TNode node,
UpdateMessage change)
Updates the filter's display in response to an UpdateMessage . |
Methods inherited from class oracle.ide.model.DefaultFilter |
getComparator, getIcon, getLongLabel, getOwner, getShortLabel, getToolTipText, getType, refreshExplorerNode, setOwner, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int VIEW_PROJECT_FILES_ONLY
public static final int VIEW_HIERARCHICALLY
protected static final java.lang.Object NULL_KEY
protected static final java.lang.Object TOP_FOLDER_KEY
protected boolean isOpen
protected int options
protected WeakCache nodeCache
URL
to its respective TNode
.
protected java.util.Map childMap
Map
that maps a folder key to the List
of project
children belonging to that folder.
protected URLFilter urlFilter
URLFilter
used to filter URL
s returned by URLFileSystem.list(URL, URLFilter)
.
protected CategoryFolder miscFolder
protected URLPath sourcePath
protected java.util.Collection children
Collection
of the top-level child Element
objects
for this filter.
protected java.util.Set uniqueNames
Set
of unique top-level child names already belonging to
this filter.
Constructor Detail |
public HierarchicalFilter()
HierarchicalFilter
.
Method Detail |
protected abstract Folder createFolder(java.net.URL url)
Folder
for the given directory URL
.
Subclasses should provide an appropriate implementation.
url
- the URL
of the Folder
to create.
Folder
instance, or null
if the Folder
could not be created for the specified URL
.protected abstract Folder createFolder(java.lang.Object key)
Folder
for the given folder key. Subclasses
should provide an appropriate implementation.
Folder
instance, or null
if the Folder
could not be created for the specified folder key.getFolderKey(URL)
,
getParentKey(Object)
protected abstract java.lang.Object getFolderKey(java.net.URL url)
URL
that is used for mapping
a Folder
to the list of project children belonging to that
folder. Subclasses should provide an appropriate implementation.
The URL
specified need not be a directory URL. Generally it
is the URL
of a Locatable
element that belongs to the
project; in this case, the parent URL
of the specified URL
is used to obtain the folder key.
Implementations should return TOP_FOLDER_KEY
when the URL
corresponds to a top-level child of the filter and NULL_KEY
when the specified URL
is not on the source path.
url
- the URL
of the Locatable
to return the
folder key for.
Object
representing the key in the Map
for
the specified folder URL
.protected abstract java.lang.Object getParentKey(java.lang.Object key)
Implementations should return TOP_FOLDER_KEY
when the parent
folder key corresponds to the top-level children of the filter and
NULL_KEY
when the parent folder key cannot be obtained or is
no longer on the source path.
key
- the folder key to get the parent key for.
Object
representing the parent key in the Map
for the specified folder key.getFolderKey(URL)
protected abstract java.lang.String getChildName(java.lang.Object parentKey, java.lang.Object childKey)
null
if the first folder key
is not a parent key of the second folder key. Subclasses should
provide an appropriate implementation.Subclasses should return the child name without a trailing '/' appended.
parentKey
- the prospective parent folder key.childKey
- the prospective child folder key.protected abstract void initChildren()
Subclasses should add Element
objects to the collection of
top-level children by calling the add(Element)
method on the
filter.
public java.util.Iterator getChildren()
Iterator
for traversing the top-level children of
the filter.
getChildren
in interface ChildFilter
getChildren
in class DefaultFilter
public TNode childrenAdded(java.util.List added, TNode par, TreeExplorer tree)
List
of child Element
objects to
the TreeExplorer
. The tree is maintained according to the
view options for this filter.
childrenAdded
in interface ChildFilter
childrenAdded
in class DefaultFilter
public TNode childrenRemoved(java.util.List removed, TNode par, TreeExplorer tree)
List
of child Element
objects
from the TreeExplorer
. The tree is maintained according to
the view options for this filter.
childrenRemoved
in interface ChildFilter
childrenRemoved
in class DefaultFilter
public void cache(TNode node)
TNode
to the node cache.
cache
in interface ChildFilter
cache
in class DefaultFilter
public void uncache(TNode tnode)
TNode
from the node cache.
uncache
in interface ChildFilter
uncache
in class DefaultFilter
public URLFilter getURLFilter()
URLFilter
used to exclude files from the filter's
display.
getURLFilter
in interface ChildFilter
getURLFilter
in class DefaultFilter
public void setURLFilter(URLFilter urlFilter)
URLFilter
used to exclude files from the filter's
display.
setURLFilter
in interface ChildFilter
setURLFilter
in class DefaultFilter
public int getOptions()
getOptions
in interface ChildFilter
getOptions
in class DefaultFilter
public void setOptions(int options)
setOptions
in interface ChildFilter
setOptions
in class DefaultFilter
public void refresh(TNode[] nodes)
refresh
in interface ChildFilter
refresh
in class DefaultFilter
nodes
- the array of TNode
s to refresh (ignored).public boolean canRefresh(TNode[] nodes)
true
.
canRefresh
in interface ChildFilter
canRefresh
in class DefaultFilter
public TNode update(TNode node, UpdateMessage change)
UpdateMessage
.
update
in interface ChildFilter
update
in class DefaultFilter
public boolean getViewAllFiles()
true
if the filter is currently displaying all
files, or false
if the filter is displaying project files
only.
public void setViewAllFiles(boolean viewAllFiles)
viewAllFiles
- if true
, the filter will display all
files; if false
, the filter will display project files
only.public boolean getViewHierarchically()
true
if the filter is currently displaying its
folders in nested view, or false
if the filter is
displaying its folders in flat view
public void setViewHierarchically(boolean viewHierarchically)
viewHierarchically
- if true
, the filter will
display folders in nested view; if false
, the filter will
display folders in flat view.protected void clearChildren()
protected void add(Element element)
Element
to the collection of the filter's
top-level children.
protected void remove(Element element)
Element
from the collection of the filter's
top-level children.
protected boolean isDirInProject(java.net.URL url)
true
if the URL
specifies a directory
that contains at least one Element
in the project; otherwise
false
.
url
- the URL
to test; if the URL
specifies a
file and not a directory, then the parent directory URL
for
the file is tested instead.protected void initializeChildMap()
Map
that maps each folder by its folder key to
the List
of child Element
objects belonging to that
folder.
protected java.util.Iterator getFolderChildren(HierarchicalFolder folder)
Iterator
for traversing the children belonging to
the specified HierarchicalFolder
; if the specified folder is
null
, then an Iterator
over the top-level
children of the filter is returned.
folder
- the HierarchicalFolder
to get the children of;
if null
, then the top-level children of the filter are
returned.getFolderChildren(Object)
protected java.util.Iterator getFolderChildren(java.lang.Object key)
Iterator
for traversing the children belonging to
the folder corresponding to the specified folder key. If the
specified folder key is TOP_FOLDER_KEY
, then an Iterator
over the top-level children of the filter is returned. If
the specified folder key is NULL_KEY
, then an Iterator
over the children that are not on the source path (the
Miscellanous Files children) is returned.
The returned Iterator
specifies all child Folder
and
Element
objects belonging to the specified folder. If the
filter is displaying folders in flat view, however, then the Iterator
will only enumerate Folder
children for the
top-level children of the filter.
This method cannot be called unless only project files are being
displayed by the filter, except when the folder key is NULL_KEY
. If all files are being displayed, then the HierarchicalFolder.list()
method should instead be used to determine
the contents of the folder.
key
- the folder key of the folder to get the children of.
Iterator
enumerating all children in the specified
folder.
java.lang.IllegalStateException
- if the VIEW_PROJECT_FILES_ONLY
filter option is not set and the specified key is not NULL_KEY
.protected URLPath getSourcePath()
canonicalized
to ensure that the filter will be able to determine later whether or
not a given child URL
is in the source path.
URLPath
that represents the owning folder's source
path.protected void setSourcePath(URLPath sourcePath)
URLPath
.
protected java.net.URL getSourcePathEntry(java.net.URL url)
URL
for the source path entry that contains the
specified URL
.
url
- the URL
to get the source path entry for.
URL
for the source path entry that contains the
specified URL
, or null
if the URL
is not
on the source path.protected boolean isInSourcePath(java.net.URL url)
true
if the URL
is contained by an entry
on the source path.
url
- the URL
to test; the URL
can correspond to
either a file or a directory.protected boolean isSourcePathEntry(java.net.URL url)
true
if the URL
is an entry on the source
path.
url
- the URL
to test; the URL
should correspond
to a directory.protected Folder getFolder()
Folder
that owns this filter.
protected CategoryFolder getCategoryFolder()
CategoryFolder
that owns this filter, or null if
the filter is not owned by a CategoryFolder
. Identical
to getFolder()
, except that the Folder
is returned as
a CategoryFolder
.
protected Project getProject()
Project
that owns this filter.
protected CategoryFolder getMiscFolder()
CategoryFolder
for this
filter. This folder contains all children of the owning folder that
are not on the source path.
protected java.net.URL[] list(java.net.URL url)
URL
, applying this filter's current
URLFilter
to the result set. The specified URL
is
assumed to correspond to a directory. If the urlFilter
is
null
, then no filtering is done.
This method generates the list of children for the specified URL
with URLFileSystem.list(URL, URLFilter)
. However, that
method may not turn up all files if those files have been created in
the IDE but not yet saved to the file system, so we also have to add
all project children of the URL
that were not in the list.
url
- the directory URL
to list.
URL
objects naming the files and
directories contained by the URL
; if the contents of this
URL
cannot be listed, then null
is returned.URLFileSystem.list(URL, URLFilter)
protected java.net.URL[] list(URLPath urlPath)
URLPath
as if it were simply a single
URL
. The contents of each URL
along the URLPath
are individually listed and merged into a single return array
with duplicate entries removed. Entries must be unique according to
the file name
part of the
URL
; if more than one entry with the same file name is found
along the URLPath
, only the first entry found is returned.
This filter's current URLFilter
is applied to the result set
of each individual list operation. If the urlFilter
is
null
, then no filtering is done.
urlPath
- the URLPath
to list.
URL
objects naming the files and
directories contained by the URLPath
; if the contents of this
URLPath
cannot be listed, then null
is returned.list(URL)
protected boolean hasMiscFiles()
protected void initMiscFolder()
protected Element createElement(java.net.URL url)
Element
for the given URL
.
If the URL
represents a directory path, then a Folder
element is created, otherwise a standard Node
element is
created.
url
- the URL
of the Element
to create.
Element
instance, or null
if the
Element
could not be created for the specified URL
.protected boolean isParentKey(java.lang.Object key, java.lang.Object childKey)
true
if the first specified folder key is a
parent key of the second specified folder key; otherwise, returns
false
.
key
- the prospective parent folder key.childKey
- the prospective child folder key.protected void setComparator(java.util.Comparator comparator)
|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright ©1997, 2003, Oracle. All rights reserved.