|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.util.docnavigation.JListNavigator<ItemT>
class JListNavigator<ItemT extends INavigatorItem>
This class is an extension of JList that adds data shadowing the model embedded in a JList. Since all changes to the model (except for the selected item!) must go through this interface, we can support access to methods from non-event threads as long as these methods do not modify the model. However, all of the public methods that access and modify the model (the latter only running in the event thread) must be atomic relative to each other, so synchronization is required in most cases. TODO: generify this class and IDocumentNavigator with respect to its element type once JList is.
| Nested Class Summary | |
|---|---|
private static class |
JListNavigator.CustomListCellRenderer
The cell renderer for this list. |
| Field Summary | |
|---|---|
private ItemT |
_current
The current selection value. |
protected |
_model
The list model (extending AbstractListModel) for this JList. |
private JListNavigator.CustomListCellRenderer |
_renderer
The cell renderer for this JList |
private ArrayList<INavigationListener<? super ItemT>> |
navListeners
the collection of INavigationListeners listening to this JListNavigator |
| Fields inherited from interface edu.rice.cs.util.docnavigation.IDocumentNavigator |
|---|
MODEL_INITIATED_PROPERTY_NAME |
| Constructor Summary | |
|---|---|
JListNavigator()
Standard constructor. |
|
| Method Summary | ||
|---|---|---|
void |
addDocument(ItemT doc)
Adds the document doc to this navigator. |
|
void |
addDocument(ItemT doc,
String path)
Adds the document to this navigator and ignores the specified path. |
|
void |
addNavigationListener(INavigationListener<? super ItemT> listener)
Adds listener to the collection of listeners. |
|
void |
addTopLevelGroup(String name,
INavigatorItemFilter<? super ItemT> f)
|
|
Container |
asContainer()
Returns a Container representation of this navigator |
|
void |
clear()
Clears the navigator and removes all documents. |
|
boolean |
contains(ItemT doc)
Returns whether or not the navigator contains the document |
|
|
execute(IDocumentNavigatorAlgo<ItemT,InType,ReturnType> algo,
InType input)
Executes the list case of the visitor. |
|
ItemT |
getCurrent()
Returns the currently selected item, or null if none. |
|
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()
Gets the first document in the series. |
|
protected ItemT |
getFromModel(int i)
A typesafe version of _model.get(i). |
|
int |
getGroupSelectedCount()
|
|
ItemT |
getLast()
Gets the first document in the series. |
|
Object |
getModelLock()
Returns the model lock. |
|
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)
Gets the next document after doc in the series. |
|
ItemT |
getPrevious(ItemT doc)
Gets the previous document in the series. |
|
Component |
getRenderer()
|
|
List<ItemT> |
getSelectedDocuments()
|
|
List<File> |
getSelectedFolders()
|
|
int |
getSelectionCount()
|
|
private void |
init(
|
|
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 |
|
ItemT |
removeDocument(ItemT doc)
Removes the document from the navigator. |
|
void |
removeNavigationListener(INavigationListener<? super ItemT> listener)
Unregisters the listener listener |
|
void |
requestSelectionUpdate(ItemT doc)
Since in the JListNavigator it is impossible to select anything but an INavigatorItem, this method doesn't need to do anything. |
|
void |
selectDocument(ItemT doc)
Sets the specified document as selected in the navigator. |
|
boolean |
selectDocumentAt(int x,
int y)
Selects the document at the x,y coordinate of the navigator pane and sets it to be the currently active document. |
|
void |
setNextChangeModelInitiated(boolean b)
Marks the next selection change as model-initiated (true) or user-initiated (false; default). |
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface edu.rice.cs.util.docnavigation.IDocumentNavigator |
|---|
addDocument, addDocument, addFocusListener, addNavigationListener, addTopLevelGroup, contains, execute, getFocusListeners, getNext, getPrevious, isSelectedInGroup, refreshDocument, removeDocument, removeFocusListener, removeNavigationListener, repaint, requestSelectionUpdate, selectDocument |
| Field Detail |
|---|
protected volatile_model
private volatile ItemT extends INavigatorItem _current
private volatile JListNavigator.CustomListCellRenderer _renderer
private final ArrayList<INavigationListener<? super ItemT extends INavigatorItem>> navListeners
| Constructor Detail |
|---|
public JListNavigator()
| Method Detail |
|---|
private void init(m)
public void addDocument(ItemT doc)
doc - the document to add
public void addDocument(ItemT doc,
String path)
doc - the document to add -- assumed to be of type Tpath - unused parameter in this classprotected ItemT getFromModel(int i)
_model.get(i). This is a workaround for the
non-generic implementation of DefaultListModel, and should be removed once that
is fixed.
public ItemT getNext(ItemT doc)
doc - the document to reference from
public ItemT getPrevious(ItemT doc)
doc - to reference from
public ItemT getFirst()
getFirst in interface IDocumentNavigator<ItemT extends INavigatorItem>public ItemT getLast()
getLast in interface IDocumentNavigator<ItemT extends INavigatorItem>public ItemT getCurrent()
getCurrent in interface IDocumentNavigator<ItemT extends INavigatorItem>public Object getModelLock()
getModelLock in interface IDocumentNavigator<ItemT extends INavigatorItem>public ItemT removeDocument(ItemT doc)
doc - the document to remove
public void refreshDocument(ItemT doc,
String path)
INavigatorItem in the tree. This may affect the placement of the item or its
display to reflect any changes made in the model. Should only be executed in event thread.
- Parameters:
doc - the docment to be refreshed
- Throws:
IllegalArgumentException - if this navigator contains no document that is equal to the passed document.
public void selectDocument(ItemT doc)
doc - the document to selectpublic boolean contains(ItemT doc)
doc - the document to find
public ArrayList<ItemT> getDocuments()
IDocumentNavigatorIDocuments in the collection in enumeration order.
getDocuments in interface IDocumentNavigator<ItemT extends INavigatorItem>public ArrayList<ItemT> getDocumentsInBin(String binName)
IDocuments contained in the specified bin. Always empty.
getDocumentsInBin in interface IDocumentNavigator<ItemT extends INavigatorItem>binName - name of bin
INavigatorItem enumeration of this navigator's contents.public int getDocumentCount()
IDocumentNavigatorINavigatorItems contained by this IDocumentNavigator
getDocumentCount in interface IDocumentNavigator<ItemT extends INavigatorItem>public boolean isEmpty()
IDocumentNavigatorIDocumentNavigator contains any INavigatorItems.
isEmpty in interface IDocumentNavigator<ItemT extends INavigatorItem>public void addNavigationListener(INavigationListener<? super ItemT> listener)
listener - public void removeNavigationListener(INavigationListener<? super ItemT> listener)
listener - public Collection<INavigationListener<? super ItemT>> getNavigatorListeners()
IDocumentNavigator
getNavigatorListeners in interface IDocumentNavigator<ItemT extends INavigatorItem>public void clear()
clear in interface IDocumentNavigator<ItemT extends INavigatorItem>
public <InType,ReturnType> ReturnType execute(IDocumentNavigatorAlgo<ItemT,InType,ReturnType> algo,
InType input)
algo - the visitor to executeinput - the input to run on the visitorpublic Container asContainer()
asContainer in interface IAWTContainerNavigatorActorasContainer in interface IDocumentNavigator<ItemT extends INavigatorItem>
public boolean selectDocumentAt(int x,
int y)
selectDocumentAt in interface IDocumentNavigator<ItemT extends INavigatorItem>x - the x coordinate of the navigator paney - the y coordinate of the navigator pane
public boolean isSelectedAt(int x,
int y)
isSelectedAt in interface IDocumentNavigator<ItemT extends INavigatorItem>x - the x coordinate of the navigator paney - the y coordinate of the navigator pane
public Component getRenderer()
getRenderer in interface IAWTContainerNavigatorActorpublic int getSelectionCount()
getSelectionCount in interface IDocumentNavigator<ItemT extends INavigatorItem>public boolean isGroupSelected()
isGroupSelected in interface IDocumentNavigator<ItemT extends INavigatorItem>public int getGroupSelectedCount()
getGroupSelectedCount in interface IDocumentNavigator<ItemT extends INavigatorItem>public List<File> getSelectedFolders()
getSelectedFolders in interface IDocumentNavigator<ItemT extends INavigatorItem>public boolean isDocumentSelected()
isDocumentSelected in interface IDocumentNavigator<ItemT extends INavigatorItem>public int getDocumentSelectedCount()
getDocumentSelectedCount in interface IDocumentNavigator<ItemT extends INavigatorItem>public List<ItemT> getSelectedDocuments()
getSelectedDocuments in interface IDocumentNavigator<ItemT extends INavigatorItem>public boolean isRootSelected()
isRootSelected in interface IDocumentNavigator<ItemT extends INavigatorItem>public boolean isSelectedInGroup(ItemT i)
public void addTopLevelGroup(String name,
INavigatorItemFilter<? super ItemT> f)
public boolean isTopLevelGroupSelected()
IDocumentNavigator
isTopLevelGroupSelected in interface IDocumentNavigator<ItemT extends INavigatorItem>
public Set<String> getNamesOfSelectedTopLevelGroup()
throws GroupNotSelectedException
getNamesOfSelectedTopLevelGroup in interface IDocumentNavigator<ItemT extends INavigatorItem>GroupNotSelectedExceptionpublic void requestSelectionUpdate(ItemT doc)
public String toString()
public void setNextChangeModelInitiated(boolean b)
setNextChangeModelInitiated in interface IDocumentNavigator<ItemT extends INavigatorItem>public boolean isNextChangeModelInitiated()
isNextChangeModelInitiated in interface IDocumentNavigator<ItemT extends INavigatorItem>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||