|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.zaval.util.ValidationObject | +--org.zaval.lw.LwCanvas | +--org.zaval.lw.LwPanel | +--org.zaval.lw.grid.LwGrid | +--org.zaval.lw.grid.LwTreeGrid
This is light weight tree grid component. The functionality of the component bases on light weight grid component, but there are several essential differences:
getTreeModel
and setTreeModel
methods to work with
the tree model and use getModel
to get the matrix model. Draw
attention that it is impossible to redefine the matrix model because
the model has specific implementation to be associated with the tree model.
getRows
method) of
the matrix model is equals to number of item in the tree model.
put
method of the model
will be called for the purpose, than runtime exception will be thrown.
getGridRows
method. The model rows is a total number of tree items. Returned by
getGridRows
method number of rows is the number of rows that is rendered by
the component. For example, some of tree items can be collapsed, in this case
the getGridRows
method returns number of rows that is less than
the matrix model rows. The component has special method to convert the displayed
row to the appropriate model row - getModelRow
method.
setRowHeight
method of
the component, because the tree items metric defines the rows heights. It is possible
to extend cell height by setExtraRowHeight
method.
getSelectedItem
method.
... LwTreeGrid tg = new LwTreeGrid(); // Creates tree model Item root = new Item(new Item("root")); TreeModel model = new Tree(root); model.add (root, new Item("Item 1")); model.add (root, new Item("Item 2")); model.add (root, new Item("Item 3")); // Sets tree model tg.setTreeModel(model); // Fills grid cells tg.getModel().put (0, 1, "Column[1] bound with root"); tg.getModel().put (0, 2, "Column[2] bound with root"); tg.getModel().put (1, 1, "Column[1] bound with item 1"); // Sets cells editor provider tg.setEditorProvider(new LwDefEditors()); // Adds top grid caption LwGridCaption cap = LwGridCaption(tg); tg.add (LwGrid.TOP_CAPTION_EL, cap); ...
Fields inherited from class org.zaval.lw.grid.LwGrid |
colWidths, DEF_COLWIDTH, DEF_ROWHEIGHT, DRAW_HLINES, DRAW_VLINES, dx, dy, EDITOR_EL, ENABLE_COLRESIZE, LEFT_CAPTION_EL, rowHeights, TOP_CAPTION_EL, USE_PSMETRIC |
Fields inherited from class org.zaval.lw.LwPanel |
children |
Fields inherited from class org.zaval.lw.LwCanvas |
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y |
Fields inherited from class org.zaval.util.ValidationObject |
isValidFlag |
Constructor Summary | |
LwTreeGrid()
Constructs the component with the default data model and tree model. |
|
LwTreeGrid(TreeModel model)
Constructs the component with the specified tree data model. |
Method Summary | |
void |
actionPerformed(LwActionEvent e)
Invoked when an action event occured. |
void |
addMatrixListener(MatrixListener m)
Adds the matrix listener to be notified whenever the matrix cell has been updated or the matrix dimension has been changed. |
boolean |
catchInput(LwComponent child)
Checks if input events for the specified child component should be caught. |
protected java.lang.Object |
dataToPaint(int row,
int col)
Invoked whenever the component paints the specified cell to fetch data from the grid data model. |
java.lang.Object |
get(int row,
int col)
Gets the value of the specified cell. |
java.awt.Color |
getCellColor(int row,
int col)
Gets the the specified grid cell color. |
int |
getCols()
Gets the number of columns. |
protected java.lang.Object |
getDataToEdit(int row,
int col)
Invoked whenever the component wants fetch data from the data model for the specified cell editing. |
int |
getGridCols()
Gets the number of the grid columns. |
int |
getGridRows()
Gets the number of the grid rows. |
Item |
getItemByRow(int row)
Returns the tree item by the specified model row. |
int |
getModelRow(int gridRow)
Converts and returns the model row by the specified grid row. |
int |
getRows()
Gets the number of rows. |
Item |
getSelectedItem()
Gets the selected tree item. |
TreeModel |
getTreeModel()
Gets the tree model. |
LwView |
getView(int row,
int col,
java.lang.Object o)
Gets the view of the specified cell and the given data model value. |
LwGridViewProvider |
getViewProvider()
Gets the view provider. |
int |
getXAlignment(int row,
int col)
Gets the horizontal alignment for the specified grid cell. |
int |
getYAlignment(int row,
int col)
Gets the vertical alignment for the specified grid cell. |
void |
itemInserted(TreeEvent e)
Invoked when the item has been inserted as a memeber of the source tree. |
void |
itemModified(TreeEvent e)
Invoked when the item of the source tree has been modified. |
void |
itemRemoved(TreeEvent e)
Invoked when the item has been removed from the source tree. |
void |
keyPressed(LwKeyEvent e)
Invoked when a key has been pressed. |
void |
layout(LayoutContainer target)
Lays out the child layoutable components inside the layout container. |
void |
mousePressed(LwMouseEvent e)
Invoked when the mouse button has been pressed on a light weight component. |
protected void |
perform(MatrixEvent e)
Performs the specified matrix event. |
void |
put(int row,
int col,
java.lang.Object o)
Updates the specified cell with the specified value. |
void |
put(Item item,
int row,
int col,
java.lang.Object o)
|
protected void |
rCustomMetric()
Invoked by vMetric method to calculate custom metric type. |
void |
removeMatrixListener(MatrixListener l)
Removes the matrix listener. |
protected int |
rowHeight(int r)
Returns the specified row height. |
protected void |
rPsMetric()
Invoked by vMetric method to calculate preferred size metric type. |
protected void |
setEditedData(int row,
int col,
java.lang.Object value)
Invoked whenever the component wants applies the edited value (for the specified cell) to the grid data model. |
void |
setExtraRowHeight(int h)
Sets the extra rows height. |
void |
setModel(MatrixModel m)
Sets the matrix model. |
void |
setRowHeight(int row,
int h)
It is impossible to use the method to define the row height. |
void |
setSOLocation(int dx,
int dy)
Sets the specified scroll object location. |
void |
setTreeElView(int id,
LwView v)
Sets the specified view for the specified tree view element. |
void |
setTreeModel(TreeModel m)
Sets the tree model. |
void |
setTreeViewProvider(LwViewProvider p)
|
void |
setViewProvider(LwGridViewProvider p)
Sets the view provider. |
void |
startEditing(int row,
int col)
Starts editing of the specified grid cell. |
Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, indexOf, insert, insert, recalc, remove, remove, removeAll, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs |
Methods inherited from class org.zaval.lw.LwCanvas |
getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, viewManChanged, vrp |
Methods inherited from class org.zaval.util.ValidationObject |
isValid |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.zaval.lw.LwContainer |
add, add, getLwLayout, indexOf, insert, paintOnTop, remove, removeAll, setLwLayout |
Methods inherited from interface org.zaval.lw.LwComponent |
canHaveFocus, getLwComponentAt, getLwParent, getViewMan, getVisiblePart, setBackground, setEnabled, setLwParent, setViewMan, setVisible |
Methods inherited from interface org.zaval.lw.Drawable |
getBackground, getOrigin, isEnabled, isOpaque, paint, repaint, repaint, setOpaque, update |
Methods inherited from interface org.zaval.util.Validationable |
invalidate, isValid, validate |
Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
Methods inherited from interface org.zaval.lw.LayoutContainer |
count, get, getLayoutOffset |
Constructor Detail |
public LwTreeGrid()
public LwTreeGrid(TreeModel model)
model
- the specified tree data model.Method Detail |
public void setModel(MatrixModel m)
setModel
in class LwGrid
m
- the matrix model.public boolean catchInput(LwComponent child)
LwComposite
catchInput
in interface LwComposite
org.zaval.lw.LwComposite
child
- the specified child component.true
if input events for the child component should be caught by this
component; false
otherwise.public void setExtraRowHeight(int h)
h
- the extra rows height.public LwGridViewProvider getViewProvider()
LwGrid
getViewProvider
in class LwGrid
org.zaval.lw.grid.LwGrid
public void setTreeViewProvider(LwViewProvider p)
public void setTreeElView(int id, LwView v)
id
- the specified element id.v
- the specified view.public void setViewProvider(LwGridViewProvider p)
LwGrid
setViewProvider
in class LwGrid
org.zaval.lw.grid.LwGrid
p
- the view provider.public void mousePressed(LwMouseEvent e)
LwMouseListener
mousePressed
in class LwGrid
org.zaval.lw.event.LwMouseListener
e
- the specified mouse event.public void keyPressed(LwKeyEvent e)
LwKeyListener
keyPressed
in class LwGrid
org.zaval.lw.event.LwKeyListener
e
- the specified key event.public void layout(LayoutContainer target)
LwLayout
layout
in class LwGrid
org.zaval.lw.LwLayout
target
- the layout container that needs to be laid out.public LwView getView(int row, int col, java.lang.Object o)
LwGridViewProvider
getView
in interface LwGridViewProvider
org.zaval.lw.grid.LwGridViewProvider
row
- the specified cell row.col
- the specified cell column.o
- the specified data model value.public int getXAlignment(int row, int col)
LwGridViewProvider
getXAlignment
in interface LwGridViewProvider
org.zaval.lw.grid.LwGridViewProvider
row
- the specified cell row.col
- the specified cell column.public int getYAlignment(int row, int col)
LwGridViewProvider
getYAlignment
in interface LwGridViewProvider
org.zaval.lw.grid.LwGridViewProvider
row
- the specified cell row.col
- the specified cell column.public java.awt.Color getCellColor(int row, int col)
LwGridViewProvider
null
.getCellColor
in interface LwGridViewProvider
org.zaval.lw.grid.LwGridViewProvider
row
- the specified cell row.col
- the specified cell column.public void setTreeModel(TreeModel m)
m
- the tree model.public TreeModel getTreeModel()
public int getRows()
MatrixModel
getRows
in interface MatrixModel
org.zaval.data.MatrixModel
public int getCols()
MatrixModel
getCols
in interface MatrixModel
org.zaval.data.MatrixModel
public int getGridRows()
LwGridMetrics
getGridRows
in class LwGrid
org.zaval.lw.grid.LwGridMetrics
public int getGridCols()
LwGridMetrics
getGridCols
in class LwGrid
org.zaval.lw.grid.LwGridMetrics
public java.lang.Object get(int row, int col)
MatrixModel
get
in interface MatrixModel
org.zaval.data.MatrixModel
row
- the specified row.col
- the specified column.public void actionPerformed(LwActionEvent e)
LwActionListener
actionPerformed
in interface LwActionListener
org.zaval.lw.event.LwActionListener
e
- the specified action event.public void put(int row, int col, java.lang.Object o)
MatrixModel
put
in interface MatrixModel
org.zaval.data.MatrixModel
row
- the specified row.col
- the specified column.obj
- the specified value to update the cell value.public void put(Item item, int row, int col, java.lang.Object o)
public void addMatrixListener(MatrixListener m)
MatrixModel
addMatrixListener
in interface MatrixModel
org.zaval.data.MatrixModel
l
- the matrix listener.public void removeMatrixListener(MatrixListener l)
MatrixModel
removeMatrixListener
in interface MatrixModel
org.zaval.data.MatrixModel
l
- the matrix listener.public void itemInserted(TreeEvent e)
TreeListener
itemInserted
in interface TreeListener
org.zaval.data.event.TreeListener
e
- the specified event.public void itemRemoved(TreeEvent e)
TreeListener
itemRemoved
in interface TreeListener
org.zaval.data.event.TreeListener
e
- the specified event.public void itemModified(TreeEvent e)
TreeListener
itemModified
in interface TreeListener
org.zaval.data.event.TreeListener
e
- the specified event.public void setSOLocation(int dx, int dy)
ScrollObj
setSOLocation
in class LwGrid
org.zaval.misc.ScrollObj
x
- the specified x coordinate.y
- the specified y coordinate.public void setRowHeight(int row, int h)
setRowHeight
in class LwGrid
org.zaval.lw.grid.LwGridMetrics
row
- the specified row.h
- the specified height.public int getModelRow(int gridRow)
gridRow
- the specified grid row.public Item getSelectedItem()
public void startEditing(int row, int col)
LwGrid
startEditing
in class LwGrid
org.zaval.lw.grid.LwGrid
row
- the specified cell row.col
- the specified cell column.public Item getItemByRow(int row)
row
- the specified model row.protected void perform(MatrixEvent e)
e
- the specified matrix event.protected void rCustomMetric()
LwGrid
vMetric
method to calculate custom metric type.rCustomMetric
in class LwGrid
protected void rPsMetric()
LwGrid
vMetric
method to calculate preferred size metric type.rPsMetric
in class LwGrid
protected java.lang.Object dataToPaint(int row, int col)
LwGrid
dataToPaint
in class LwGrid
org.zaval.lw.grid.LwGrid
row
- the specified row.col
- the specified column.protected java.lang.Object getDataToEdit(int row, int col)
LwGrid
getDataToEdit
in class LwGrid
org.zaval.lw.grid.LwGrid
row
- the specified row.col
- the specified column.protected void setEditedData(int row, int col, java.lang.Object value)
LwGrid
setEditedData
in class LwGrid
org.zaval.lw.grid.LwGrid
row
- the specified row.col
- the specified column.value
- the specified edited value.protected int rowHeight(int r)
LwGrid
rowHeight
in class LwGrid
org.zaval.lw.grid.LwGrid
row
- the specified row.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |