@API(type=EXTENDABLE, src=PUBLIC) public interface InplaceEditor extends Extension
An editor is associated with an oxy_editor CSS function and is invoked on user interaction.
It only handles edit requests while the InplaceRenderer
will handle the
painting of the value to edit.
An editor implementation is used through the oxy_editor function like this:
code { content: "Attr1: " oxy_editor(type, combo, edit, '@attr1') "Attr2: " oxy_editor(type, text, edit, '@attr2') }In the previous example a predefined combo editor is requested for editing the value of attribute attr1 and a predefined text editor for editing attribute attr2. For a custom implementation properties
InplaceEditorCSSConstants.PROPERTY_SWING_EDITOR_CLASS_NAME
and InplaceEditorCSSConstants.PROPERTY_SWT_EDITOR_CLASS_NAME
must be used:
myElement { content: oxy_editor( rendererClassName, "com.custom.editors.CustomRenderer", swingEditorClassName, "com.custom.editors.SwingCustomEditor", swtEditorClassName, "com.custom.editors.SwtCustomEditor", edit, "@my_attr" customProperty1, "customValue1", customProperty2, "customValue2" ) }In the previous example, the editor classes com.custom.editors.SwingCustomEditor and com.custom.editors.SwtCustomEditor must be added in the Classpath of the document type associated with the edited document.
It is recommended to extend the adapter class InplaceEditorRendererAdapter
or
InplaceEditorAdapter
in order to be protected from future API additions.
A SWT implementation should also implement org.eclipse.jface.text.ITextOperationTarget so that it will be delegated with events of UNDO, REDO, CUT, PASTE, SELECT ALL.
SimpleURLChooserEditor
,
URLChooserEditorSWT
Modifier and Type | Method and Description |
---|---|
void |
addEditingListener(InplaceEditingListener editingListener)
Adds a listener to receive edit notifications:
-
InplaceEditingListener.editingCanceled() to remove the editor and
cancel the edit operation. |
void |
cancelEditing()
Cancels the editing process.
|
java.lang.Object |
getEditorComponent(AuthorInplaceContext context,
Rectangle allocation,
Point mouseInvocationLocation)
Prepare and return the editor component.
|
Rectangle |
getScrollRectangle()
Returns a rectangle that should be made visible after the editor is shown.
|
java.lang.Object |
getValue()
Gets the value that the user entered.
|
void |
removeEditingListener(InplaceEditingListener editingListener)
Removes a listener that receives editing events.
|
void |
requestFocus()
Requests focus inside the editing component.
|
void |
stopEditing()
Stops the editing and commits the current value.
|
getDescription
java.lang.Object getEditorComponent(AuthorInplaceContext context, Rectangle allocation, Point mouseInvocationLocation)
context
- The context where the editor will be used.allocation
- The bounds where the editor will be shown. This is normally
the bounds of the box in which the value being edited is rendered. If the
editor requires to be presented in different bounds it should alter this parameter.
The X,Y coordinates are relative to the parent in which the editor will be added.mouseInvocationLocation
- if the editor was requested using the mouse this
parameter represents the X,Y location where the event took place. It is relative to the parent
in which the editor will be added. null
if the editor wasn't requested through
mouse interaction.
requestFocus()
call).
KeyListener
for handling key events like: ENTER to stop editing
(by calling InplaceEditingListener.editingStopped(EditingEvent)
)
and ESCAPE to cancel it (by calling InplaceEditingListener.editingCanceled()
).FocusListener
to stop editing when the focus is given to a component that is not
part of the editor (by calling InplaceEditingListener.editingStopped(EditingEvent)
).DocumentListener
to fire InplaceEditingListener.editingOccured()
events (If the editor has a document).Rectangle getScrollRectangle()
null
to make the entire editor
visible.void addEditingListener(InplaceEditingListener editingListener)
InplaceEditingListener.editingCanceled()
to remove the editor and
cancel the edit operation.
- InplaceEditingListener.editingOccured()
to signal modification in
the editor. This event marks the editor as dirty and it's value will be
committed when a InplaceEditingListener.editingStopped(EditingEvent)
is received.
- InplaceEditingListener.editingStopped(EditingEvent)
to end editing
and commit it's value if needed. The value is usually committed ONLY if
a InplaceEditingListener.editingOccured()
was fired. See
InplaceEditingListener.editingStopped(EditingEvent)
for more information.editingListener
- Editing listener.void requestFocus()
java.lang.Object getValue()
void stopEditing()
InplaceEditingListener.editingStopped(EditingEvent)
.
OBS: The current value will be committed only if at least one
InplaceEditingListener.editingOccured()
event was issued before this moment.void cancelEditing()
InplaceEditingListener.editingCanceled()
.void removeEditingListener(InplaceEditingListener editingListener)
editingListener
- Editing listener.© Copyright SyncRO Soft SRL 2002 - 2014. All rights reserved.