001: package org.osbl.client.wings.form;
002:
003: import org.wings.SComponent;
004: import org.osbl.client.action.ObjectAction;
005: import org.osbl.client.wings.shell.Environment;
006:
007: import javax.swing.*;
008: import java.util.List;
009:
010: /**
011: * An ObjectList displays a list of objects in list manner or table manner.
012: * It supports selection, navigation (link) and allows a user to perform actions on selected objects.
013: * @author hengels
014: */
015: public interface ObjectList {
016: public static final int SINGLE_SELECTION = ListSelectionModel.SINGLE_SELECTION;
017: public static final int MULTIPLE_SELECTION = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION;
018:
019: /**
020: * The environment provided by the editor.
021: */
022: Environment getEnvironment();
023:
024: /**
025: * Return the SComponent, that shows the list of objects.
026: * Consecutive calls to this method must always return the same component instance. The implementor might choose to
027: * create the component lazily on the first call.
028: *
029: * @return the component showing the list
030: */
031: SComponent getComponent();
032:
033: Class getType();
034:
035: /**
036: * The content of the list is refreshed.
037: * Call this method, if you expect, that the list's content has changed.
038: * This method might perform expensive operations.
039: */
040: void refresh();
041:
042: /**
043: * Return the current object.
044: * @return the current object
045: */
046: Object getCurrent();
047:
048: /**
049: * Set the currently selected object
050: * @param object the current object
051: */
052: void setCurrent(Object object);
053:
054: /**
055: * Tell wether there is at least one object behind the current object in the list.
056: * @return true, if the current object is not the last object, false otherwise
057: */
058: boolean hasNext();
059:
060: /**
061: * Set cursor to the the next object in the list.
062: */
063: void next();
064:
065: /**
066: * Tell wether there is at least one object before the current object in the list.
067: * @return true, if the current object is not the first object, false otherwise
068: */
069: boolean hasPrevious();
070:
071: /**
072: * Set cursor to the previous object in the list.
073: */
074: void previous();
075:
076: /**
077: * Set the selection mode.
078: * ObjectLists support single selection and multi selection. Consult the wingS- or Swing- documentation for further
079: * information on selection models.
080: *
081: * @param selectionMode either STable.SINGLE_SELECTION or STable.MULTIPLE_SELECTION
082: */
083: void setSelectionMode(int selectionMode);
084:
085: /**
086: * Set the selected object.
087: * SelectionListeners will be informed of this change!
088: * @param object the object to be selected
089: */
090: void setSelectedObject(Object object);
091:
092: /**
093: * Retrieve the currently selected object.
094: * @return the selected object or null, if nothing is selected. If there are multiple selected objects, return the
095: * first one.
096: */
097: Object getSelectedObject();
098:
099: /**
100: * Set the selected object.
101: * SelectionListeners will be informed of this change!
102: * @param objects the objects to be selected
103: */
104: void setSelectedObjects(List objects);
105:
106: /**
107: * Retrieve a list of the currently selected objects.
108: * @return a list of selected objects.
109: */
110: List getSelectedObjects();
111:
112: /**
113: * Expose an ObjectAction visually as a link.
114: * ObjectList implementations should support a link notion. That is, one column (typically the key column) is
115: * rendered in link style (ie. bold and blue). If a user clicks on a link, the ObjectAction will be called on the
116: * object in the respective row.
117: * @param name the column name (typically property name)
118: * @param linkAction the action to called on click
119: */
120: void setLinkAction(String name, ObjectAction linkAction);
121: }
|