|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpl.netanel.swt.matrix.ZoneEditor<X,Y>
X
- indexing type for the horizontal axisY
- indexing type for vertical axispublic class ZoneEditor<X extends java.lang.Number,Y extends java.lang.Number>
Provides editing support for zone cells.
Constructor Summary | |
---|---|
ZoneEditor(Zone<X,Y> zone)
Default constructor, facilitates editing of the specified zone. |
Method Summary | |
---|---|
Control |
activate(X indexX,
Y indexY)
Shows a control to edit the value of the specified cell. |
void |
apply(Control control)
Applies the editor value to the model by invoking setModelValue(Number, Number, Object) and if successful then calls
cancel(Control) , otherwise leaves the editor control active. |
void |
cancel(Control control)
Deactivates the editor control. |
void |
copy()
Copies selected cells to the clipboard. |
protected Control |
createControl(X indexX,
Y indexY)
Creates a control to edit the value of the specified cell. |
protected Control |
createControl(X indexX,
Y indexY,
char ch)
|
void |
cut()
Cuts the selected cells by copying them to the clipboard and setting null value to them. |
boolean |
delete()
Sets the null value to the selected cells. |
protected java.lang.String |
format(X indexX,
Y indexY)
Returns the label for the specified cell to be included in the clipboard copying. |
protected java.lang.Object[] |
getCheckboxEmulation(X indexX,
Y indexY)
Returns the check box emulation data. |
Control |
getControl(X indexX,
Y indexY)
Returns editor control associated with the given cell or null
if cell does not have editor control created, which may happen when it is
not visible or the editor has not been activated. |
protected java.lang.Object[] |
getDefaultCheckboxLabels()
Returns the default labels to emulate check boxes. |
protected java.lang.Object |
getEditorValue(Control control)
Returns a value from the specified edit control. |
Control |
getEmbeddedControl(X indexX,
Y indexY)
Returns a control embedded in the cell with the given coordinates or null if the cell does not have an embedded control or the control is not visible. |
java.lang.Object |
getModelValue(X indexX,
Y indexY)
Returns value from the model referring to the given cell coordinates. |
Zone<X,Y> |
getZone()
Returns zone of the editor. |
protected boolean |
hasEmbeddedControl(X indexX,
Y indexY)
Returns true if the cell editor control for the specified cell
is embedded in the cell, or false if it is a pop-up. |
void |
layoutControls()
|
protected java.lang.Object |
parse(X indexX,
Y indexY,
java.lang.String s)
Parses a text for the specified cell during paste operation. |
boolean |
paste()
Pastes from the clipboard to the zone starting from the focus cell. |
void |
redraw()
Makes the embedded controls to be recreated. |
protected void |
removeControl(Control control)
Disposes the edit control. |
protected void |
setBounds(X indexX,
Y indexY,
Control control)
Sets the bounds of the specified edit control in the specified cell. |
protected void |
setEditorValue(Control control,
java.lang.Object value)
Sets the value in the cell editor control. |
boolean |
setModelValue(X indexX,
Y indexY,
java.lang.Object value)
Sets the specified value to the model. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ZoneEditor(Zone<X,Y> zone)
zone
- Method Detail |
---|
public java.lang.Object getModelValue(X indexX, Y indexY)
Painter.text
after calling
Painter.setupSpatial(Number, Number)
method of the zone's
Painter.NAME_CELLS painter, which is always String
, while some edit
controls require other types, like Boolean
or Date
. If the
Painter.NAME_CELLS painter does not exist in the zone it always returns
null.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
public boolean setModelValue(X indexX, Y indexY, java.lang.Object value)
false
if the value
is not valid, and true
otherwise
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axisvalue
- to set in the model
false
if the value is not valid, and true
otherwiseprotected java.lang.Object getEditorValue(Control control)
String
from Text
and Combo
controls
Date
from a DateTime
control
Boolean
from a Button
control
not null and not diposed
setEditorValue(Control, Object)
protected void setEditorValue(Control control, java.lang.Object value)
Date
for a DateTime
control
Boolean
for a Button
Text
and Combo
controls
control
not null and not diposed
control
- to set the value forvalue
- to set in the controlgetEditorValue(Control)
public Control getControl(X indexX, Y indexY)
null
if cell does not have editor control created, which may happen when it is
not visible or the editor has not been activated.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
public void apply(Control control)
setModelValue(Number, Number, Object)
and if successful then calls
cancel(Control)
, otherwise leaves the editor control active.
control
- editor control to apply the data from.public void cancel(Control control)
removeControl(Control)
. Regardless of that is sets the focus
back to the Matrix.
control
- public Control activate(X indexX, Y indexY)
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
protected Control createControl(X indexX, Y indexY)
Text
control by default. The method should return null
to make the cell read only.
The parent
argument is always the parent of Matrix
component. It is passed explicitly to discourage creating edit controls as
children of Matrix
which would block the matrix from receiving
focus and thus any key or mouse events.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
createControl(Number, Number)
protected Control createControl(X indexX, Y indexY, char ch)
protected void removeControl(Control control)
createControl(Number, Number)
method to show the control instead
of creating a new one in that case.
control
- createControl(Number, Number)
protected void setBounds(X indexX, Y indexY, Control control)
Control#setBounds(Rectangle)
method, unless the control is a check
button whose size is not modified. Then the control location is centralized
relating to the cell.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axiscontrol
- to set the bounds forprotected boolean hasEmbeddedControl(X indexX, Y indexY)
true
if the cell editor control for the specified cell
is embedded in the cell, or false
if it is a pop-up.
By default this function returns false
.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
public Control getEmbeddedControl(X indexX, Y indexY)
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
public boolean delete()
null
value to the selected cells.
false
if the cell modifications was invalid.setModelValue(Number, Number, Object)
public void copy()
format(Number, Number)
method and separated with '\t',
while lines are separated with System.getProperty("line.separator").
public boolean paste()
isBulkEditAtomic
returns true
and:
setModelValue
returning false)
getEditHistoryLimit()
. A runtime exception is thrown is such
case as well.
false
if the cell modifications was invalid.setModelValue(Number, Number, Object)
public void cut()
null
value to them.
Invokes copy
and delete
, so all the rules for
those methods apply here.
copy()
,
delete()
protected java.lang.String format(X indexX, Y indexY)
Painter.text
field
after calling Painter.setupSpatial(Number, Number)
.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
copy()
protected java.lang.Object parse(X indexX, Y indexY, java.lang.String s)
getEditorValue(Control)
.
By default it returns the s
argument.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axiss
- text to parse from
paste()
public Zone<X,Y> getZone()
protected java.lang.Object[] getCheckboxEmulation(X indexX, Y indexY)
String
elements for a true value label and false value label, or
two Image
elements for a true value image and a false value image.
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axis
getDefaultCheckboxLabels()
protected final java.lang.Object[] getDefaultCheckboxLabels()
true
value, the second one
is null
for the false
value.
getCheckboxEmulation(Number, Number)
public void redraw()
public void layoutControls()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |