X
- indexing type for the horizontal axisY
- indexing type for vertical axispublic class ZoneEditor<X extends java.lang.Number,Y extends java.lang.Number>
extends java.lang.Object
Constructor and Description |
---|
ZoneEditor(Zone<X,Y> zone)
Default constructor, facilitates editing of the specified zone.
|
Modifier and Type | Method and Description |
---|---|
org.eclipse.swt.widgets.Control |
activate(X indexX,
Y indexY)
Shows a control to edit the value of the specified cell.
|
void |
apply(org.eclipse.swt.widgets.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(org.eclipse.swt.widgets.Control control)
Deactivates the editor control.
|
void |
copy()
Copies selected cells to the clipboard.
|
protected org.eclipse.swt.widgets.Control |
createControl(X indexX,
Y indexY)
Creates a control to edit the value of the specified cell.
|
void |
cut()
Cuts the selected cells by copying them to the clipboard
and setting
null value to them. |
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.
|
org.eclipse.swt.widgets.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.
|
int |
getEditHistoryLength()
Returns the length of the history of modifications to the model done with
this editor.
|
protected java.lang.Object |
getEditorValue(org.eclipse.swt.widgets.Control control)
Returns a value from the specified edit control.
|
org.eclipse.swt.widgets.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.
|
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. |
boolean |
isBulkEditAtomic()
Returns
true if bulk editor operation should be atomic and
all failing if one cell change fails. |
protected java.lang.Object |
parse(X indexX,
Y indexY,
java.lang.String s)
Parses a text for the specified cell during paste operation.
|
void |
paste()
Pastes from the clipboard to the zone starting from the focus cell.
|
void |
redo()
Redo the latest model change operation that was undone.
|
void |
redraw()
Makes the embedded controls to be recreated.
|
protected void |
removeControl(org.eclipse.swt.widgets.Control control)
Disposes the edit control.
|
protected void |
setBounds(X indexX,
Y indexY,
org.eclipse.swt.widgets.Control control)
Sets the bounds of the specified edit control in the specified cell.
|
void |
setBulkEditAtomic(boolean state)
If set to
true and #setModelValue for any cell returns
false then all the previous changes during bulk edit will be
rolled back. |
void |
setEditHistoryLength(int length)
Sets the length of the history of modifications to the model done with this
editor.
|
protected void |
setEditorValue(org.eclipse.swt.widgets.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.
|
void |
undo()
Undo the latest model change operation.
|
public java.lang.Object getModelValue(X indexX, Y indexY)
This method is usually overridden, since the default implementation returns
the 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 axispublic boolean setModelValue(X indexX, Y indexY, java.lang.Object value)
Performs the input validation and returns 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 modelprotected java.lang.Object getEditorValue(org.eclipse.swt.widgets.Control control)
It returns:
String
from Text
and Combo
controls
Date
from a DateTime
control
Boolean
from a Button
setEditorValue(Control, Object)
protected void setEditorValue(org.eclipse.swt.widgets.Control control, java.lang.Object value)
The value must of the following type:
Date
for a DateTime
control
Boolean
for a Button
Text
and Combo
controls
control
- to set the value forvalue
- to set in the controlgetEditorValue(Control)
public org.eclipse.swt.widgets.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
- indexY
- public void apply(org.eclipse.swt.widgets.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(org.eclipse.swt.widgets.Control control)
removeControl(Control)
. Regardless of that is sets the
focus back to the Matrix.control
- public org.eclipse.swt.widgets.Control activate(X indexX, Y indexY)
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axisprotected org.eclipse.swt.widgets.Control createControl(X indexX, Y indexY)
It creates a 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 axiscreateControl(Number, Number)
protected void removeControl(org.eclipse.swt.widgets.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, org.eclipse.swt.widgets.Control control)
The cell bounds are offset by 1 pixel and applied with
the 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 axispublic org.eclipse.swt.widgets.Control getEmbeddedControl(X indexX, Y indexY)
indexX
- cell index on the horizontal axisindexY
- cell index on the vertical axispublic void copy()
Only rectangular area can be copied.
public void paste()
The items in the clipboard exceeding the section item count will be ignored.
public void cut()
null
value to them.
Only rectangular area can be copied.
copy()
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 axisprotected 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 frompublic void setBulkEditAtomic(boolean state)
true
and #setModelValue for any cell returns
false
then all the previous changes during bulk edit will be
rolled back. Bulk edit operations are paste, cut, delete of selection or
regular bulk edit to apply a value from a control to a set of cells.state
- new bulk edit atomicity state to setpublic boolean isBulkEditAtomic()
true
if bulk editor operation should be atomic and
all failing if one cell change fails. Otherwise the bulk edit should continue
in chance of single cell not successful to chance the value in the model.public void setEditHistoryLength(int length)
Default is 0.
length
- public int getEditHistoryLength()
public void undo()
public void redo()
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 axisgetDefaultCheckboxLabels()
protected final java.lang.Object[] getDefaultCheckboxLabels()
true
value, the second one is null
for the false
value.getCheckboxEmulation(Number, Number)
public void redraw()
Copyright © 2011 netanel.pl. All Rights Reserved.