org.objectweb.jac.aspects.gui.web
Class AbstractCollection

java.lang.Object
  extended byorg.objectweb.jac.aspects.gui.web.AbstractView
      extended byorg.objectweb.jac.aspects.gui.web.AbstractCollection
All Implemented Interfaces:
CollectionListener, CollectionView, FieldView, HTMLViewer, View, ViewIdentity
Direct Known Subclasses:
ChoiceCollection, CompactList, IndicesSelector, List, Table

public abstract class AbstractCollection
extends AbstractView
implements CollectionListener, CollectionView, HTMLViewer

Base class for collection views (list, table, etc)


Field Summary
protected  boolean autoUpdate
           
protected  CollectionItem collection
           
protected  TableFilter filter
           
protected  boolean isEditor
           
protected  CollectionItemView itemView
           
protected  CollectionModel model
           
protected  ObjectChooser rowsPerPageChooser
           
protected  TableSorter sorter
           
protected  Object substance
           
protected  boolean viewableItems
           
 
Fields inherited from class org.objectweb.jac.aspects.gui.web.AbstractView
column, context, description, height, isCellViewer, label, parentView, row, table, width
 
Constructor Summary
AbstractCollection()
           
AbstractCollection(ViewFactory factory, DisplayContext context, CollectionItem collection, Object substance, CollectionModel model, CollectionItemView itemView)
           
 
Method Summary
protected  void checkRange()
          Ensures that startIndex is not ouf of range
protected  void genHeader(PrintWriter out)
           
protected  void genHeader(PrintWriter out, boolean div)
          Generate HTML for adder, remover, prev/next buttons, ...
 CollectionModel getCollectionModel()
          Gets the associated collection model.
 FieldItem getField()
           
protected  Object getObject(int index)
          Gets object at a given index
 Object getSubstance()
          Gets the substance object holding the field
protected  void init()
          Initialization to be performed before sort()
 boolean isEditor()
          Tells wether the view allows to edit the collection (i.e it has add/remove buttons)
 boolean isEnabled()
           
 void onAddExistingToCollection()
          Called when the user wants to add an object to the collection, without creating a new one even if the collection is "autocreate".
 void onAddToCollection()
          Called when the user wants to add an object to the collection.
 void onFirst()
          Display to the first page of items
 void onLast()
          Display to the last page of items
 void onNext()
          Display the next page of items
 void onPrevious()
          Display the previous page of items
 void onRefreshCollection()
          Call when a parameter of the view has changed and the view should be refresh to take it into account.
 void onRemove(int index)
          Called when the user selects an item to remove it.
 void onRemoveFromCollection()
          Called when the user wants to remove an object to the collection.
 void onTableInvoke(int index, String methodName)
          Called when a method is called on an object belonging to the collection.
 void onView(int index)
          Called when the user selects an item to view it.
 void onView(Object object)
           
 void onViewObject(String name)
          Called when the user selects an item to view it.
protected  String removeLink(int position)
          Returns an HTML link to remove the element at a given position.
 void setAutoUpdate(boolean autoUpdate)
          Sets the auto-update property of the view.
 void setEditor(boolean isEditor)
          Set the "editability" of the view.
 void setEnabled(boolean enabled)
           
 void setField(FieldItem field)
          Sets the field being displayed
protected  void setRowsPerPage(int rowsPerPage)
           
 void setSelected(int index)
          Sets the selected index of the collection view.
 void setSubstance(Object substance)
          Sets the substance object holding the field
 void setValue(Object value)
          Sets the value to display
protected  boolean showRefreshButton()
          Tells whether a refesh button must be shown
abstract  void sort()
          Sorts the collection with the column index stored in the context if any.
protected  String sortLink(int column, String text)
          Build an HTML link with an image showing if a column is used to sort the collection
 void updateModel(Object substance)
          Updates the collection model
protected  String viewLink(int position)
           
 
Methods inherited from class org.objectweb.jac.aspects.gui.web.AbstractView
close, closeForm, equalsView, equalsView, eventURL, eventURL, genBody, genEventAndActionButton, genPage, genStyleSheets, getBaseURL, getCloseBorder, getContext, getDescription, getFactory, getId, getId, getLabel, getMessage, getOpenBorder, getParameters, getParentView, getRootView, getStyle, getType, getViewBorder, iconElement, iconElement, isClosed, isDescendantOf, isInForm, openForm, printAttributes, setAttribute, setColumn, setContext, setDescription, setFactory, setFocus, setLabel, setMessage, setParameters, setParentView, setRow, setSize, setStyle, setStyleSheet, setTable, setType, setViewBorder, showButton, showFormButtons, showFormButtons
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jac.aspects.gui.View
close, getContext, getDescription, getFactory, getLabel, getMessage, getParentView, getRootView, getStyle, getViewBorder, isClosed, isDescendantOf, setContext, setDescription, setFactory, setFocus, setLabel, setMessage, setParentView, setSize, setStyle, setViewBorder
 
Methods inherited from interface org.objectweb.jac.aspects.gui.ViewIdentity
equalsView, equalsView, getParameters, getType, setParameters, setType
 
Methods inherited from interface org.objectweb.jac.aspects.gui.web.HTMLViewer
genHTML, setStyleSheet
 

Field Detail

collection

protected CollectionItem collection

substance

protected Object substance

model

protected CollectionModel model

sorter

protected TableSorter sorter

filter

protected TableFilter filter

autoUpdate

protected boolean autoUpdate

isEditor

protected boolean isEditor

itemView

protected CollectionItemView itemView

viewableItems

protected boolean viewableItems

rowsPerPageChooser

protected ObjectChooser rowsPerPageChooser
Constructor Detail

AbstractCollection

public AbstractCollection(ViewFactory factory,
                          DisplayContext context,
                          CollectionItem collection,
                          Object substance,
                          CollectionModel model,
                          CollectionItemView itemView)

AbstractCollection

public AbstractCollection()
Method Detail

setRowsPerPage

protected void setRowsPerPage(int rowsPerPage)

setSubstance

public void setSubstance(Object substance)
Description copied from interface: FieldView
Sets the substance object holding the field

Specified by:
setSubstance in interface FieldView
Parameters:
substance - the substance
See Also:
FieldView.getSubstance()

getSubstance

public Object getSubstance()
Description copied from interface: FieldView
Gets the substance object holding the field

Specified by:
getSubstance in interface FieldView
See Also:
FieldView.setSubstance(Object)

getCollectionModel

public CollectionModel getCollectionModel()
Description copied from interface: CollectionView
Gets the associated collection model.

Specified by:
getCollectionModel in interface CollectionView

isEditor

public boolean isEditor()
Description copied from interface: CollectionView
Tells wether the view allows to edit the collection (i.e it has add/remove buttons)

Specified by:
isEditor in interface CollectionView
See Also:
CollectionView.setEditor(boolean)

setEditor

public void setEditor(boolean isEditor)
Description copied from interface: CollectionView
Set the "editability" of the view. If the view is editable, it has add/remove buttons)

Specified by:
setEditor in interface CollectionView
See Also:
CollectionView.isEditor()

setAutoUpdate

public void setAutoUpdate(boolean autoUpdate)
Description copied from interface: FieldView
Sets the auto-update property of the view. If auto-update is true (which is the default), the view registers for changes on field it displays.

Specified by:
setAutoUpdate in interface FieldView

sort

public abstract void sort()
Sorts the collection with the column index stored in the context if any.


init

protected void init()
Initialization to be performed before sort()


onView

public void onView(Object object)

genHeader

protected void genHeader(PrintWriter out)

genHeader

protected void genHeader(PrintWriter out,
                         boolean div)
Generate HTML for adder, remover, prev/next buttons, ...

Parameters:
out - print HTML code to this writer

showRefreshButton

protected boolean showRefreshButton()
Tells whether a refesh button must be shown


getObject

protected Object getObject(int index)
Gets object at a given index


setSelected

public void setSelected(int index)
Description copied from interface: CollectionView
Sets the selected index of the collection view.

Specified by:
setSelected in interface CollectionView
Parameters:
index - the new selected index

setField

public void setField(FieldItem field)
Description copied from interface: FieldView
Sets the field being displayed

Specified by:
setField in interface FieldView
Parameters:
field - the field

getField

public FieldItem getField()
Specified by:
getField in interface FieldView
Returns:
the field item

setValue

public void setValue(Object value)
Description copied from interface: FieldView
Sets the value to display

Specified by:
setValue in interface FieldView
Parameters:
value - the value

updateModel

public void updateModel(Object substance)
Description copied from interface: CollectionView
Updates the collection model

Specified by:
updateModel in interface CollectionView

onView

public void onView(int index)
Description copied from interface: CollectionListener
Called when the user selects an item to view it.

Specified by:
onView in interface CollectionListener
Parameters:
index - the index of the element to view

onViewObject

public void onViewObject(String name)
Description copied from interface: CollectionListener
Called when the user selects an item to view it.

Specified by:
onViewObject in interface CollectionListener
Parameters:
name - the name of the object to view
See Also:
CollectionListener.onView(int)

onRemove

public void onRemove(int index)
Description copied from interface: CollectionListener
Called when the user selects an item to remove it.

Specified by:
onRemove in interface CollectionListener
Parameters:
index - the index of the element to remove

onTableInvoke

public void onTableInvoke(int index,
                          String methodName)
Description copied from interface: CollectionListener
Called when a method is called on an object belonging to the collection.

Specified by:
onTableInvoke in interface CollectionListener
Parameters:
index - the index of the element to view
methodName - the name of the method to invoke

onAddToCollection

public void onAddToCollection()
Description copied from interface: CollectionListener
Called when the user wants to add an object to the collection.

Specified by:
onAddToCollection in interface CollectionListener
See Also:
CollectionListener.onAddExistingToCollection()

onAddExistingToCollection

public void onAddExistingToCollection()
Description copied from interface: CollectionListener
Called when the user wants to add an object to the collection, without creating a new one even if the collection is "autocreate".

Specified by:
onAddExistingToCollection in interface CollectionListener
See Also:
CollectionListener.onAddToCollection()

onRemoveFromCollection

public void onRemoveFromCollection()
Description copied from interface: CollectionListener
Called when the user wants to remove an object to the collection.

Specified by:
onRemoveFromCollection in interface CollectionListener

onNext

public void onNext()
Description copied from interface: CollectionListener
Display the next page of items

Specified by:
onNext in interface CollectionListener

onLast

public void onLast()
Description copied from interface: CollectionListener
Display to the last page of items

Specified by:
onLast in interface CollectionListener

onPrevious

public void onPrevious()
Description copied from interface: CollectionListener
Display the previous page of items

Specified by:
onPrevious in interface CollectionListener

onFirst

public void onFirst()
Description copied from interface: CollectionListener
Display to the first page of items

Specified by:
onFirst in interface CollectionListener

onRefreshCollection

public void onRefreshCollection()
Description copied from interface: CollectionListener
Call when a parameter of the view has changed and the view should be refresh to take it into account.

Specified by:
onRefreshCollection in interface CollectionListener

checkRange

protected void checkRange()
Ensures that startIndex is not ouf of range


removeLink

protected String removeLink(int position)
Returns an HTML link to remove the element at a given position.


viewLink

protected String viewLink(int position)

sortLink

protected String sortLink(int column,
                          String text)
Build an HTML link with an image showing if a column is used to sort the collection

Parameters:
column - the index of the column
text - additional text to put in the link
Returns:
the HTML code of the link

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)