JAC project
AOPSYS
CEDRIC & LIP6 labs

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

java.lang.Object
  |
  +--org.objectweb.jac.aspects.gui.web.AbstractView
        |
        +--org.objectweb.jac.aspects.gui.web.AbstractCollection
All Implemented Interfaces:
CollectionListener, CollectionView, FieldView, View, ViewIdentity
Direct Known Subclasses:
CompactList, IndicesSelector, List, Table

public abstract class AbstractCollection
extends AbstractView
implements CollectionListener, CollectionView


Field Summary
protected  boolean autoUpdate
           
protected  CollectionItem collection
           
protected  boolean isEditor
           
protected  CollectionItemView itemView
           
protected  CollectionModel model
           
protected  Object substance
           
 
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 genAdderAndRemover(PrintWriter out)
          Generate HTML for adder, remover, and prev/next buttons
 CollectionModel getCollectionModel()
          Gets the associated collection model.
 FieldItem getField()
           
 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 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
 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
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, equals, eventURL, eventURL, genBody, genPage, genStyleSheets, getCloseBorder, getContext, getDescription, getFactory, getId, getId, getLabel, getMessage, getOpenBorder, getParameters, getParentView, getRootView, getStyle, getType, getViewBorder, hashCode, iconElement, iconElement, isClosed, isDescendantOf, isInForm, printAttributes, setAttribute, setColumn, setContext, setDescription, setFactory, setFocus, setHeight, setLabel, setMessage, setParameters, setParentView, setRow, setStyle, setStyleSheet, setTable, setType, setViewBorder, setWidth, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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, setHeight, setLabel, setMessage, setParentView, setStyle, setViewBorder, setWidth, validate
 
Methods inherited from interface org.objectweb.jac.aspects.gui.ViewIdentity
getParameters, getType, setParameters, setType
 

Field Detail

collection

protected CollectionItem collection

substance

protected Object substance

model

protected CollectionModel model

autoUpdate

protected boolean autoUpdate

isEditor

protected boolean isEditor

itemView

protected CollectionItemView itemView
Constructor Detail

AbstractCollection

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

AbstractCollection

public AbstractCollection()
Method Detail

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

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.


onView

public void onView(Object object)

genAdderAndRemover

protected void genAdderAndRemover(PrintWriter out)
Generate HTML for adder, remover, and prev/next buttons

Parameters:
out - print HTML code to this writer

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

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)

Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli