edu.rice.cs.util.docnavigation
Interface IDocumentNavigator<ItemT extends INavigatorItem>

All Superinterfaces:
IAWTContainerNavigatorActor
All Known Implementing Classes:
JTreeSortNavigator

public interface IDocumentNavigator<ItemT extends INavigatorItem>
extends IAWTContainerNavigatorActor

IDocumentNavigator provides a framework through which individual IDocuments can be navigated.


Field Summary
static String MODEL_INITIATED_PROPERTY_NAME
          The name of the client property that determines whether a change is model- or user-initiated.
 
Method Summary
 void addDocument(ItemT doc)
          Adds an IDocuemnt to this navigator.
 void addDocument(ItemT doc, String path)
          Adds an INavigatorItem into this navigator in a position relative to a given path.
 void addFocusListener(FocusListener e)
          Add FocusListener to navigator.
 void addNavigationListener(INavigationListener<? super ItemT> listener)
          Adds an INavigationListener to this navigator.
 void addTopLevelGroup(String name, INavigatorItemFilter<? super ItemT> f)
          Adds the top level group with the specified name and filter.
 Container asContainer()
           
 void clear()
          Removes all INavigatorItems from this IDocumentNavigator.
 boolean contains(ItemT doc)
          Tests to see if a given document is contained in this navigator.
<InType,ReturnType>
ReturnType
execute(IDocumentNavigatorAlgo<ItemT,InType,ReturnType> algo, InType input)
          Visitor pattern hook method.
 ItemT getCurrent()
          Returns the currently selected navigator item, or null if no navigator item is selected.
 int getDocumentCount()
          Returns the number of INavigatorItems contained by this IDocumentNavigator
 ArrayList<ItemT> getDocuments()
          Returns all the IDocuments in the collection in enumeration order.
 int getDocumentSelectedCount()
           
 ArrayList<ItemT> getDocumentsInBin(String binName)
          Returns all the IDocuments contained in the specified bin.
 ItemT getFirst()
           
 FocusListener[] getFocusListeners()
          Gets the FocustListeners.
 int getGroupSelectedCount()
           
 ItemT getLast()
           
 Object getModelLock()
          Returns the model lock for this navigator.
 Set<String> getNamesOfSelectedTopLevelGroup()
          Returns the names of the top level groups that the selected items descend from.
 Collection<INavigationListener<? super ItemT>> getNavigatorListeners()
          Returns a collection of all listeners registered with this navigator.
 ItemT getNext(ItemT doc)
          The following five operations impose a natural ordering on the documents in the navigator.
 ItemT getPrevious(ItemT doc)
           
 List<ItemT> getSelectedDocuments()
           
 List<File> getSelectedFolders()
           
 int getSelectionCount()
           
 boolean isDocumentSelected()
           
 boolean isEmpty()
          Returns whether this IDocumentNavigator contains any INavigatorItems.
 boolean isGroupSelected()
           
 boolean isNextChangeModelInitiated()
           
 boolean isRootSelected()
          Returns true if the root is selected.
 boolean isSelectedAt(int x, int y)
          Returns true if the item at the x,y coordinate of the navigator pane is currently selected.
 boolean isSelectedInGroup(ItemT i)
           
 boolean isTopLevelGroupSelected()
          Returns true if at least one top level group is selected, false otherwise.
 void refreshDocument(ItemT doc, String path)
          Resets a given INavigatorItem in the tree.
 ItemT removeDocument(ItemT doc)
          Removes a given INavigatorItem from this navigator.
 void removeFocusListener(FocusListener e)
          Remove FocusListener from navigator.
 void removeNavigationListener(INavigationListener<? super ItemT> listener)
          Removes the given listener from observing this navigator.
 void repaint()
          The standard swing repaint() method.
 void requestSelectionUpdate(ItemT i)
          Switches the selection to the given INavigatorItem if the current selection is not already on an INavigatorItem.
 void selectDocument(ItemT doc)
          Sets the active document as specified.
 boolean selectDocumentAt(int x, int y)
          Selects the document at the x,y coordinates of the navigator pane and makes it the active document.
 void setNextChangeModelInitiated(boolean b)
          Marks the next selection change as model-initiated (true) or user-initiated (false; default).
 
Methods inherited from interface edu.rice.cs.util.docnavigation.IAWTContainerNavigatorActor
getRenderer
 

Field Detail

MODEL_INITIATED_PROPERTY_NAME

static final String MODEL_INITIATED_PROPERTY_NAME
The name of the client property that determines whether a change is model- or user-initiated.

See Also:
Constant Field Values
Method Detail

asContainer

Container asContainer()
Specified by:
asContainer in interface IAWTContainerNavigatorActor
Returns:
an AWT component which interacts with this document navigator

addDocument

void addDocument(ItemT doc)
Adds an IDocuemnt to this navigator.

Parameters:
doc - the document to be added into this navigator.

addDocument

void addDocument(ItemT doc,
                 String path)
Adds an INavigatorItem into this navigator in a position relative to a given path.

Parameters:
doc - the document to be added into this navigator.
path - the relative path to insert this INavigatorItem at.

getCurrent

ItemT getCurrent()
Returns the currently selected navigator item, or null if no navigator item is selected.


getModelLock

Object getModelLock()
Returns the model lock for this navigator. Only used for locking in code external to the implementing class.


removeDocument

ItemT removeDocument(ItemT doc)
Removes a given INavigatorItem from this navigator. Removes all INavigatorItems from this navigator that are "equal" (.equals(...)) to the passed argument. Any of the removed documents may be returned by this method.

Parameters:
doc - the docment to be removed
Returns:
doc a document removed from this navigator as a result of invoking this method.
Throws:
IllegalArgumentException - if this navigator contains no document equal to the passed document.

refreshDocument

void refreshDocument(ItemT doc,
                     String path)
Resets a given INavigatorItem in the tree. This may affect the placement of the item or its display to reflect any changes made in the model.

Parameters:
doc - the docment to be refreshed
Throws:
IllegalArgumentException - if this navigator contains no document that is equal to the passed document.

selectDocument

void selectDocument(ItemT doc)
Sets the active document as specified.

Parameters:
doc - the document to select

getNext

ItemT getNext(ItemT doc)
The following five operations impose a natural ordering on the documents in the navigator. For lists, it is order of insertion. For trees, it is depth-first enumeration. This convention supports operations setActiveNextDocument() in the global model of DrJava

Parameters:
doc - the INavigatorItem of interest
Returns:
the INavigatorItem which comes after doc

getPrevious

ItemT getPrevious(ItemT doc)
Parameters:
doc - the INavigatorItem of interest
Returns:
the INavigatorItem which comes before doc

getFirst

ItemT getFirst()
Returns:
the INavigatorItem which comes first in the enumeration.

getLast

ItemT getLast()
Returns:
the INavigatorItem which comes last in the enumeration

getDocuments

ArrayList<ItemT> getDocuments()
Returns all the IDocuments in the collection in enumeration order.

Returns:
an INavigatorItem enumeration of this navigator's contents.

getDocumentsInBin

ArrayList<ItemT> getDocumentsInBin(String binName)
Returns all the IDocuments contained in the specified bin.

Parameters:
binName - name of bin
Returns:
an INavigatorItem enumeration of this navigator's contents.

contains

boolean contains(ItemT doc)
Tests to see if a given document is contained in this navigator.

Parameters:
doc - the document to test for containment.
Returns:
true if this contains a document "equal" (.equals(...) method) to the passed document, else false.

getDocumentCount

int getDocumentCount()
Returns the number of INavigatorItems contained by this IDocumentNavigator

Returns:
the number of documents within this navigator.

isEmpty

boolean isEmpty()
Returns whether this IDocumentNavigator contains any INavigatorItems.

Returns:
true if this navigator contains one or more documents, else false.

clear

void clear()
Removes all INavigatorItems from this IDocumentNavigator.


addNavigationListener

void addNavigationListener(INavigationListener<? super ItemT> listener)
Adds an INavigationListener to this navigator. After invoking this method, the passed listener will observe events generated this navigator. If the provided listener is already observing this navigator (==), no action is taken.

Parameters:
listener - the listener to be added to this navigator.

removeNavigationListener

void removeNavigationListener(INavigationListener<? super ItemT> listener)
Removes the given listener from observing this navigator. After invoking this method, all observers watching this navigator "equal" (==) will no longer receive observable dispatches.

Parameters:
listener - the listener to be removed from this navigator

addFocusListener

void addFocusListener(FocusListener e)
Add FocusListener to navigator.


removeFocusListener

void removeFocusListener(FocusListener e)
Remove FocusListener from navigator.


getFocusListeners

FocusListener[] getFocusListeners()
Gets the FocustListeners.


getNavigatorListeners

Collection<INavigationListener<? super ItemT>> getNavigatorListeners()
Returns a collection of all listeners registered with this navigator.

Returns:
the collection of nav listeners listening to this navigator.

selectDocumentAt

boolean selectDocumentAt(int x,
                         int y)
Selects the document at the x,y coordinates of the navigator pane and makes it the active document.

Parameters:
x - the x coordinate of the navigator pane
y - the y coordinate of the navigator pane

isSelectedAt

boolean isSelectedAt(int x,
                     int y)
Returns true if the item at the x,y coordinate of the navigator pane is currently selected.

Parameters:
x - the x coordinate of the navigator pane
y - the y coordinate of the navigator pane
Returns:
true if the item is currently selected

execute

<InType,ReturnType> ReturnType execute(IDocumentNavigatorAlgo<ItemT,InType,ReturnType> algo,
                                       InType input)
Visitor pattern hook method.

Parameters:
algo - the algorithm to run on this navigator
input - the input to the algorithm

getSelectionCount

int getSelectionCount()
Returns:
the number of selected items.

isGroupSelected

boolean isGroupSelected()
Returns:
true if at least one group of INavigatorItems is selected.

getGroupSelectedCount

int getGroupSelectedCount()
Returns:
the number of groups selected.

getSelectedFolders

List<File> getSelectedFolders()
Returns:
the folders currently selected.

isDocumentSelected

boolean isDocumentSelected()
Returns:
true if at least one document is selected.

getDocumentSelectedCount

int getDocumentSelectedCount()
Returns:
the number of documents selected.

getSelectedDocuments

List<ItemT> getSelectedDocuments()
Returns:
the documents currently selected.

isRootSelected

boolean isRootSelected()
Returns true if the root is selected. Only runs in event thread.


isSelectedInGroup

boolean isSelectedInGroup(ItemT i)
Returns:
true if the INavigatorItem is in a selected group, if at least one group is selected.

addTopLevelGroup

void addTopLevelGroup(String name,
                      INavigatorItemFilter<? super ItemT> f)
Adds the top level group with the specified name and filter.


isTopLevelGroupSelected

boolean isTopLevelGroupSelected()
Returns true if at least one top level group is selected, false otherwise.


getNamesOfSelectedTopLevelGroup

Set<String> getNamesOfSelectedTopLevelGroup()
                                            throws GroupNotSelectedException
Returns the names of the top level groups that the selected items descend from. Throws a GroupNotSelectedException if no top level group is selected

Throws:
GroupNotSelectedException

requestSelectionUpdate

void requestSelectionUpdate(ItemT i)
Switches the selection to the given INavigatorItem if the current selection is not already on an INavigatorItem. Since it may be possible that the currently selected item in the navigator does not correspond to an INavigatorItem, this method forces the navigator to select an item that does; specifically the one given. If the navigator already has an INavigatorItem selected, this method does nothing.

Parameters:
i - The suggested current INavigatorItem.

repaint

void repaint()
The standard swing repaint() method.


setNextChangeModelInitiated

void setNextChangeModelInitiated(boolean b)
Marks the next selection change as model-initiated (true) or user-initiated (false; default).


isNextChangeModelInitiated

boolean isNextChangeModelInitiated()
Returns:
whether the next selection change is model-initiated (true) or user-initiated (false).