|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.ui.TableModel
ewe.data.FieldTableModel
This is a very useful class that allows the display of public fields of an object within cells of the table - even allowing you to edit the fields within the table.
Once you create a new FieldTableModel, you call the setFields() method to specify which fields to display. There is a setFields() method that allows you to specify that all the object fields should be displayed.
The objects member is a Vector that holds the list of objects to display - call setObjects() to set it. However if you do not wish to use a Vector then you will need to override two methods: calculateNumRows() and loadObjectAtRow(int row)
The constructor FieldTableModel(Object anObject,Vector objectList) is the quickest way to display a set of objects in a table. After calling this constructor you can call getTableForm() to get a Form that contains a scrollable table that uses this FieldTableModel.
| Nested Class Summary |
| Nested classes inherited from class ewe.ui.TableModel |
TableModel.CellControl, TableModel.ControlProxy |
| Field Summary | |
MultiListSelect.SingleListSelect |
allColumns
This is a list of all the possible fields that can be displayed by the model. |
int |
cacheSize
The number of objects to cache - 20 by default. |
Vector |
displayFields
This holds the list of fields that are being displayed. |
boolean |
dontCacheObjects
Set this true if you don't want objects to be cached. |
protected Lock |
getLock
|
Reflect |
objectClass
This is a Reflect that represents the class of the objects being displayed. |
Object |
objectData
This is an example (an instance of) the objectClass. |
Vector |
objects
This can be used to hold the objects being displayed (one per row) - however implementations are free to ignore this and use some other method of accessing the object for a particular row. |
boolean |
readOnly
Set this true to have a read-only display. |
| Fields inherited from interface ewe.ui.UIConstants |
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN |
| Fields inherited from interface ewe.ui.CellConstants |
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST |
| Fields inherited from interface ewe.ui.ControlConstants |
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown |
| Constructor Summary | |
FieldTableModel()
Create an empty FieldTableModel. |
|
FieldTableModel(Object anObject,
Vector objects)
Create a new FieldTableModel using an instance of a specific object and an array of objects. |
|
| Method Summary | |
protected void |
cacheObject(int row,
Object obj)
Assign the specified object to the cache for a particular row. |
int |
calculateColWidth(int col)
This returns the full width of the column. |
protected int |
calculateNumRows()
This calculates the number of rows in the table. |
int |
calculateRowHeight(int row)
This returns the full height of the row. |
protected int |
calculateTextCharsInColumn(int col)
This is called by calculateColWidth(). |
int |
countEntries()
This calls calculateNumRows() which is what you should override. |
protected void |
dataChanged(FieldTransfer ft,
Point cell)
|
protected void |
dataChanged(Object obj,
int row,
String fieldName)
|
void |
doColumnSelection()
|
boolean |
doHotKey(KeyEvent ev)
|
void |
entriesChanged()
Call this to notify the table that the entries to be displayed have been changed in some way. |
void |
entriesChanged(int selectIndex)
This calls entriesChanged and then selects a specified row. |
Vector |
getAllFields()
Get all the available fields as a list of FieldData objects. |
protected Object |
getCachedObject(int row)
|
TableCellAttributes |
getCellAttributes(int row,
int col,
boolean sel,
TableCellAttributes tca)
Get the attributes for a cell. |
protected TableModel.CellControl |
getCellControlFor(Point p)
Get a Control to edit data within a particular cell within a CellControl object. |
Object |
getCellText(int row,
int col)
This may return a String or an array of Strings (for multiline text) or it may return null. |
Editor |
getColumnSelector(MultiListSelect.SingleListSelect columns)
Get an Editor that you can use to decide which columns are being displayed in the table. |
Control |
getColumnSelectorButton(boolean textLabel)
|
Task |
getExportTask(FieldTableExportSpecs specs)
Get a TaskObject that will, when started, export the data as specified in the provided FieldTableExportSpecs. |
FieldData |
getField(String fieldName)
Get the FieldData for a particular field name. |
FieldData |
getFieldData(int col)
Get the field data for a particular column. |
Object |
getFieldValue(FieldData fd,
int row)
Get the value of a field at the specified row. |
protected int |
getMaxColWidth(int col)
If this returns -1 there will be no maximum. |
protected int |
getMinColWidth(int col)
|
Object |
getNew()
Get a new instance of the object being edited if possible. |
protected Object |
getObjectAtRow(int row)
Don't override this, you should override loadObjectAtRow() instead. |
int |
getSelectedEntry()
If only one entry is selected, return the row index of that entry. |
Control |
getTableExportButton(boolean textLabel)
|
Editor |
getTableExporter()
Get an Editor that can be used to allow the user to export the table data. |
Form |
getTableForm(Form f)
Get a Form that contains a scrollable Table with this FieldTableModel. |
Form |
getTableForm(Form f,
boolean putExtraControls)
Get a Form that contains a scrollable Table with this FieldTableModel. |
void |
invalidateCache()
|
void |
invalidateCachedObject()
Deprecated. use invalidateCache() or invalidateCachedObject(int row); |
void |
invalidateCachedObject(int row)
|
protected Object |
loadObjectAtRow(int row)
Override this to use a different method of retrieving the object at a particular row. |
void |
made()
This is called after the TableControl has been made. |
static void |
main(String[] args)
This allows you to execute the following command line: |
FieldTableModel |
modifyFields(Object objectOrReflect,
String headersAndFields)
This can be used to modify any of the fields. |
void |
onEvent(Event ev)
|
void |
rowChanged(int row)
|
void |
selectEntry(int index)
Select a particular row and make it visible if it is not so already. |
void |
setFields(MultiListSelect.SingleListSelect fields)
|
FieldTableModel |
setFields(Object objectOrReflect)
This can be used to set all the fields. |
FieldTableModel |
setFields(Object objectOrReflect,
int[] initial)
This can be used to set all the fields. |
void |
setFields(Object objectOrReflect,
String[] fieldProperties,
int[] initialChoices)
Set all the fields given a set of String encoded properties for each field. |
FieldTableModel |
setFields(Object objectOrReflect,
String headersAndFields,
int[] initial)
This can be used to set all the fields. |
void |
setFields(Vector allFields,
int[] initialChoices)
Set all the fields. |
FieldTableModel |
setObjects(Vector objs)
This sets the "objects" variable which is usually used to get the object for each row. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
public Vector displayFields
public Vector objects
public MultiListSelect.SingleListSelect allColumns
public Reflect objectClass
public Object objectData
public boolean readOnly
protected Lock getLock
public boolean dontCacheObjects
public int cacheSize
| Constructor Detail |
public FieldTableModel()
public FieldTableModel(Object anObject,
Vector objects)
anObject - An instance of the object to be displayed.objects - A list of objects to display.| Method Detail |
public FieldTableModel setFields(Object objectOrReflect,
String headersAndFields,
int[] initial)
[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor]
separated by commas OR
[headerName]|[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor]
separated by '|' symbols.
[flags] should be a combination of: 'r' for Read-Only
[alignment] should be one of: L, R [anchor] should be one of: N, S, E, W, H, h, V, v, F
objectOrReflect - The object being edited or the class of the object.headersAndFields - The list of headers and fields with optional formatting info.initial - the list of field indexes to show initially. This can be null in which case
all the fields are shown.
public FieldTableModel modifyFields(Object objectOrReflect,
String headersAndFields)
[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor]
separated by commas OR
[headerName]|[fieldName];[length[:height]];[flags];[alignment|anchor];[control anchor]
separated by '|' symbols.
[flags] should be a combination of: 'r' for Read-Only
[alignment] should be one of: L, R [anchor] should be one of: N, S, E, W, H, h, V, v, F
objectOrReflect - The object being edited or the class of the object.headersAndFields - The list of headers and fields with optional formatting info.
public FieldTableModel setFields(Object objectOrReflect,
int[] initial)
objectOrReflect - The object being edited or the class of the object.initial - the list of field indexes to show initially. This can be null in which case
public FieldTableModel setFields(Object objectOrReflect)
objectOrReflect - The object being edited or the class of the object.
public void setFields(Vector allFields,
int[] initialChoices)
allFields - The fields stored in a Vector.initialChoices - the indexes of the field that will be displayed initially. This can be null.
public void setFields(Object objectOrReflect,
String[] fieldProperties,
int[] initialChoices)
objectOrReflect - The data object or the Class/Reflect object for the data object.fieldProperties - An array of String encoded properties for the fields.initialChoices - the indexes of the field that will be displayed initially. This can be null.public void setFields(MultiListSelect.SingleListSelect fields)
public FieldTableModel setObjects(Vector objs)
public Object getNew()
public Form getTableForm(Form f,
boolean putExtraControls)
f - A destination form to add to, which can be null.putExtraControls - If this is true then a "Column Selector" button and a "Table Export"
button will be added.
public Form getTableForm(Form f)
f - A destination form to add to, which can be null.
public Editor getColumnSelector(MultiListSelect.SingleListSelect columns)
protected int getMinColWidth(int col)
getMinColWidth in class TableModelprotected int getMaxColWidth(int col)
TableModel
getMaxColWidth in class TableModelpublic Vector getAllFields()
public FieldData getField(String fieldName)
public Editor getTableExporter()
public Task getExportTask(FieldTableExportSpecs specs)
public Control getTableExportButton(boolean textLabel)
public void doColumnSelection()
public Control getColumnSelectorButton(boolean textLabel)
protected Object loadObjectAtRow(int row)
throws Exception
Exception
protected void cacheObject(int row,
Object obj)
protected Object getCachedObject(int row)
public void invalidateCachedObject(int row)
public void rowChanged(int row)
public void invalidateCachedObject()
public void invalidateCache()
protected Object getObjectAtRow(int row)
public FieldData getFieldData(int col)
public TableCellAttributes getCellAttributes(int row,
int col,
boolean sel,
TableCellAttributes tca)
TableModel
getCellAttributes in class TableModel
public Object getFieldValue(FieldData fd,
int row)
public Object getCellText(int row,
int col)
TableModel
getCellText in class TableModelpublic int calculateRowHeight(int row)
TableModel
calculateRowHeight in class TableModelpublic int calculateColWidth(int col)
TableModel
calculateColWidth in class TableModelpublic void made()
TableModel
made in class TableModel
protected void dataChanged(Object obj,
int row,
String fieldName)
protected void dataChanged(FieldTransfer ft,
Point cell)
public void onEvent(Event ev)
onEvent in interface EventListeneronEvent in class TableModelprotected TableModel.CellControl getCellControlFor(Point p)
TableModel
getCellControlFor in class TableModelp - the cell the CellControl is for.
protected int calculateNumRows()
public void entriesChanged()
protected int calculateTextCharsInColumn(int col)
TableModel
calculateTextCharsInColumn in class TableModelpublic void entriesChanged(int selectIndex)
selectIndex - the row to select, or -1 to clear the selection.
public int getSelectedEntry()
public void selectEntry(int index)
public int countEntries()
public boolean doHotKey(KeyEvent ev)
doHotKey in class TableModel
public static void main(String[] args)
throws Exception
ewe ewe.data.FieldTableModel
to bring up a demo/test Table that will display/edit the public fields of the specified object. Try it out on: ewe ewe.data.FieldTableModel ewe.sys.MemoryStatus 10
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||