|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.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 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. |
static int |
VIEW_SORT_BY_TYPE Flag denoting whether the leaf children should be sorted by file type and the alphabetically within the type group |
Fields inherited from class oracle.ide.model.DefaultFilter |
folderFirstComparator, folderFirstComparator2, 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. |
protected void |
addElementToChildMap(Element element, java.lang.Object key) Adds the specified child Element to the child Map in response to a call to childrenAdded(List, TNode, TreeExplorer) . |
protected void |
addFolderToChildMap(HierarchicalFolder folder, java.lang.Object key) Method called when building the childMap and the folder has no children. |
protected HierarchicalFolder |
buildOtherChildrenMap(Element element, HierarchicalFolder parent, java.util.Map otherChildrenMap, int count) |
void |
cache(TNode node) Adds the specified TNode to the node cache. |
TNode |
cacheGet(java.net.URL url) Find the TNode associated with the given url . |
protected void |
cachePut(java.net.URL key, TNode value) |
protected TNode |
cacheRemove(java.net.URL key) |
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. |
void |
closeChildren() Resets the filter. |
protected boolean |
containsChild(Element child) Check if the filter already contains the specified child. |
protected Element |
createElement(java.net.URL url) Finds or creates a child Element for the given URL . |
protected TNode |
createElementNode(java.net.URL url, Element element, TNode parent, TreeExplorer tree, javax.swing.tree.DefaultTreeModel model, boolean cacheIt) Create the TNode for the specified element. |
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 TNode |
createFolderNode(java.net.URL url, Folder folder, TNode parent, TreeExplorer tree, javax.swing.tree.DefaultTreeModel model) Create the TNode for the specified folder. |
protected java.util.List |
findOrCreateChildList(java.lang.Object key) Returns the List of children for a folder given the URL for a child element in that folder. |
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 java.lang.Object |
getFolderKey(Element element) Returns the folder key for the specified child element. |
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. |
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 . |
protected static java.net.URL |
getSourcePathEntry(java.net.URL url, URLPath sourcePath) 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 |
handleHierarchicalFolder(java.lang.Object item, java.util.Collection out) |
protected TNode |
handleOtherAdditions(java.util.Map additionsMap, TreeExplorer tree, TNode childNode) |
protected TNode |
handleOtherRemovals(java.util.Map additionsMap, TreeExplorer tree, TNode childNode) |
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 |
isHierarchicalFolder(java.lang.Object object) |
protected boolean |
isInSourcePath(java.net.URL url) Returns true if the URL is contained by an entry on the source path. |
protected boolean |
isNodeContainerInProject(TNode node) Returns true if the specified TNode 's Container is in the project. |
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 . |
boolean |
isSortByType() Returns true if the leaf children should be sorted by file type first and then alphabetically. |
protected boolean |
isSourcePathEntry(java.net.URL url) Returns true if the URL is an entry on the source path. |
protected boolean |
isStrict() Returns whether this filter should be strict as indicated by the CategoryFolder owner. |
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 |
removeElementFromChildMap(Element element, java.lang.Object key) Removes the specified child Element from the child Map in response to a call to childrenRemoved(List, TNode, TreeExplorer) . |
protected TNode |
removeElementNode(Element element, TNode parent, TreeExplorer tree, TNode rtn) |
protected void |
reset() Completely resets the filter's childrens. |
protected void |
setComparator(java.util.Comparator comparator) |
protected void |
setNodeInProject(TNode child, boolean inProject) Sets the child TNode 's in-project status; the in-project status of parent folder nodes may be affected as a result. |
void |
setOptions(int options) Sets the options bit mask used to control the filter's display. |
void |
setSortByType(boolean sortByType) When sortType is true if the leaf children are sorted by file type first and then alphabetically. |
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 . |
protected void |
updateTreeComparatorOptions() |
protected TNode |
validateParent(TNode cachedParent, TNode parent, java.net.URL parentURL, java.net.URL childURL) This method makes sure that the right parent is used to parent the child pointed by the childURL . |
Methods inherited from class oracle.ide.model.DefaultFilter |
canUpdate, checkElementAttributes, 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
public static final int VIEW_SORT_BY_TYPE
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.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 TNode cacheGet(java.net.URL url)
TNode
associated with the given url
.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 void closeChildren()
closeChildren
in interface ChildFilter
closeChildren
in class DefaultFilter
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 isSortByType()
true
if the leaf children should be sorted by file type first and then alphabetically. If the return value is false
the leaf children are sorted alphabetically only.public void setSortByType(boolean sortByType)
sortType
is true
if the leaf children are sorted by file type first and then alphabetically. If the return value is false
the leaf children are sorted alphabetically 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 viewpublic 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.public Project getProject()
Project
that owns this filter.protected void reset()
protected void addFolderToChildMap(HierarchicalFolder folder, java.lang.Object key)
folder
has no children. This implementation does nothin.protected TNode removeElementNode(Element element, TNode parent, TreeExplorer tree, TNode rtn)
protected TNode createElementNode(java.net.URL url, Element element, TNode parent, TreeExplorer tree, javax.swing.tree.DefaultTreeModel model, boolean cacheIt)
protected TNode createFolderNode(java.net.URL url, Folder folder, TNode parent, TreeExplorer tree, javax.swing.tree.DefaultTreeModel model)
TNode
for the specified folder. This method will create check whether the filter is viewing the items hierarchically and create sub-folder tnodes if necessary. If the folder
parameter is null, it creates the folder instance.protected java.lang.Object getFolderKey(Element element)
protected boolean isHierarchicalFolder(java.lang.Object object)
protected HierarchicalFolder buildOtherChildrenMap(Element element, HierarchicalFolder parent, java.util.Map otherChildrenMap, int count)
protected TNode handleOtherAdditions(java.util.Map additionsMap, TreeExplorer tree, TNode childNode)
protected TNode handleOtherRemovals(java.util.Map additionsMap, TreeExplorer tree, TNode childNode)
protected void clearChildren()
protected void add(Element element)
Element
to the collection of the filter's top-level children.protected boolean containsChild(Element child)
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 boolean handleHierarchicalFolder(java.lang.Object item, java.util.Collection out)
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 static java.net.URL getSourcePathEntry(java.net.URL url, URLPath sourcePath)
URL
for the source path entry that contains the specified URL
.url
- the URL
to get the source path entry for.sourcePath
- the URLPath
source path.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 boolean isStrict()
CategoryFolder
owner. The package filter is not strict when when used in the application navigator.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)
protected void addElementToChildMap(Element element, java.lang.Object key)
Element
to the child Map
in response to a call to childrenAdded(List, TNode, TreeExplorer)
.protected void removeElementFromChildMap(Element element, java.lang.Object key)
Element
from the child Map
in response to a call to childrenRemoved(List, TNode, TreeExplorer)
.protected void setNodeInProject(TNode child, boolean inProject)
TNode
's in-project status; the in-project status of parent folder nodes may be affected as a result.protected void cachePut(java.net.URL key, TNode value)
protected TNode cacheRemove(java.net.URL key)
protected TNode validateParent(TNode cachedParent, TNode parent, java.net.URL parentURL, java.net.URL childURL)
childURL
. This is a workaround rename bug 3323473.cachedParent
- the parent tnode found in the cache.parent
- the category node.parentURL
- the parent url.childURL
- the child url.protected boolean isNodeContainerInProject(TNode node)
true
if the specified TNode
's Container
is in the project.protected java.util.List findOrCreateChildList(java.lang.Object key)
List
of children for a folder given the URL
for a child element in that folder. Creates one if none available.protected void updateTreeComparatorOptions()
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.