Class AbstractInplaceEditorWrapper
- java.lang.Object
-
- ro.sync.ecss.extensions.api.editor.AbstractInplaceEditorWrapper
-
- All Implemented Interfaces:
InplaceEditor
,Extension
@API(type=EXTENDABLE, src=PUBLIC) public abstract class AbstractInplaceEditorWrapper extends java.lang.Object implements InplaceEditor
It can be used when more than one editor types are needed depending on the received context and it can choose at runtime an appropriate editor implementation. For example if in the CSS oxy_editor() function we have a test parameter with more possible values and we must provide a different editor implementation for each one.- Since:
- 14.1
-
-
Constructor Summary
Constructors Constructor Description AbstractInplaceEditorWrapper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.void
commitValue()
Commit the given value inside the document without stopping the editing.protected abstract InplaceEditor
createEditor(AuthorInplaceContext context)
Depending of the received context, create an editor.java.lang.String
getDescription()
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.boolean
insertContent(java.lang.String xmlContent)
An insert text event was received by the author page and redirected to this currently active form control.void
refresh(AuthorInplaceContext context)
While this editor is inside an editing session a document change was detected that didn't originated form this editor.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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ro.sync.ecss.extensions.api.editor.InplaceEditor
allowsRepostingEvents
-
-
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
Extension.getDescription()
-
createEditor
protected abstract InplaceEditor createEditor(AuthorInplaceContext context)
Depending of the received context, create an editor.- Parameters:
context
- Editing context.- Returns:
- An in-place editor.
-
getEditorComponent
public final java.lang.Object getEditorComponent(AuthorInplaceContext context, Rectangle allocation, Point mouseInvocationLocation)
Description copied from interface:InplaceEditor
Prepare and return the editor component.- Specified by:
getEditorComponent
in interfaceInplaceEditor
- Parameters:
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.
OBS: This is the very first call received by an editor. This ensures that the editor is properly initialized for the subsequent calls (like aInplaceEditor.requestFocus()
call).
OBS: An editor implementation will have to add listeners onto itself like:- a
KeyListener
for handling key events like: ENTER to stop editing (by callingInplaceEditingListener.editingStopped(EditingEvent)
) and ESCAPE to cancel it (by callingInplaceEditingListener.editingCanceled()
). - a
FocusListener
to stop editing when the focus is given to a component that is not part of the editor (by callingInplaceEditingListener.editingStopped(EditingEvent)
). - a
DocumentListener
to fireInplaceEditingListener.editingOccured()
events (If the editor has a document).
- a
- Returns:
- The component that performs the editing. For the Standalone distribution this should be a java.awt.JComponent implementation. For the Eclipse plugin distribution, an org.eclipse.swt.widgets.Control is expected.
- See Also:
InplaceEditor.getEditorComponent(ro.sync.ecss.extensions.api.editor.AuthorInplaceContext, ro.sync.exml.view.graphics.Rectangle, ro.sync.exml.view.graphics.Point)
-
getScrollRectangle
public final Rectangle getScrollRectangle()
Description copied from interface:InplaceEditor
Returns a rectangle that should be made visible after the editor is shown. The coordinate should be relative to the editor itself. The default behavior is to make the entire editor visible but if the editor is bigger than the viewport the visible part might not be the right one. For example is the editor is a text field the caret might not be visible. This is when this method is useful. The caret rectangle should be returned so that the part of the editor with the caret is presented.- Specified by:
getScrollRectangle
in interfaceInplaceEditor
- Returns:
- A rectangle to be made visible or
null
to make the entire editor visible. - See Also:
InplaceEditor.getScrollRectangle()
-
addEditingListener
public final void addEditingListener(InplaceEditingListener editingListener)
Description copied from interface:InplaceEditor
Adds a listener to receive edit notifications: -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 aInplaceEditingListener.editingStopped(EditingEvent)
is received. -InplaceEditingListener.editingStopped(EditingEvent)
to end editing and commit it's value if needed. The value is usually committed ONLY if aInplaceEditingListener.editingOccured()
was fired. SeeInplaceEditingListener.editingStopped(EditingEvent)
for more information.- Specified by:
addEditingListener
in interfaceInplaceEditor
- Parameters:
editingListener
- Editing listener.- See Also:
InplaceEditor.addEditingListener(ro.sync.ecss.extensions.api.editor.InplaceEditingListener)
-
requestFocus
public final void requestFocus()
Description copied from interface:InplaceEditor
Requests focus inside the editing component.- Specified by:
requestFocus
in interfaceInplaceEditor
- See Also:
InplaceEditor.requestFocus()
-
getValue
public final java.lang.Object getValue()
Description copied from interface:InplaceEditor
Gets the value that the user entered.- Specified by:
getValue
in interfaceInplaceEditor
- Returns:
- The value that the user entered.
- See Also:
InplaceEditor.getValue()
-
stopEditing
public final void stopEditing()
Description copied from interface:InplaceEditor
Stops the editing and commits the current value. The editor should release any held resources and notifyInplaceEditingListener.editingStopped(EditingEvent)
. OBS: The current value will be committed only if at least oneInplaceEditingListener.editingOccured()
event was issued before this moment.- Specified by:
stopEditing
in interfaceInplaceEditor
- See Also:
InplaceEditor.stopEditing()
-
commitValue
public void commitValue()
Description copied from interface:InplaceEditor
Commit the given value inside the document without stopping the editing. Will only commit if a new string value is provided and only if the value that must be committed is different from the current value.- Specified by:
commitValue
in interfaceInplaceEditor
- See Also:
InplaceEditor.commitValue()
-
cancelEditing
public final void cancelEditing()
Description copied from interface:InplaceEditor
Cancels the editing process. The editor should release any held resources and notifyInplaceEditingListener.editingCanceled()
.- Specified by:
cancelEditing
in interfaceInplaceEditor
- See Also:
InplaceEditor.cancelEditing()
-
removeEditingListener
public final void removeEditingListener(InplaceEditingListener editingListener)
Description copied from interface:InplaceEditor
Removes a listener that receives editing events.- Specified by:
removeEditingListener
in interfaceInplaceEditor
- Parameters:
editingListener
- Editing listener.- See Also:
InplaceEditor.removeEditingListener(ro.sync.ecss.extensions.api.editor.InplaceEditingListener)
-
refresh
public void refresh(AuthorInplaceContext context)
Description copied from interface:InplaceEditor
While this editor is inside an editing session a document change was detected that didn't originated form this editor. In this situation it might be good for the editor to refresh the presented data.
Currently this method is called if:- This editor edits an attribute and the same attribute was externally modified. In this situation is recommended for the editor to update the current value.
- Specified by:
refresh
in interfaceInplaceEditor
- Parameters:
context
- An updated editing context for this editor.- See Also:
InplaceEditor.refresh(ro.sync.ecss.extensions.api.editor.AuthorInplaceContext)
-
insertContent
public boolean insertContent(java.lang.String xmlContent)
Description copied from interface:InplaceEditor
An insert text event was received by the author page and redirected to this currently active form control. The form control should insert this text as it sees fit. For example a text field might insert it at the caret position. An example when this event comes is when the user uses the Character Map Dialog to insert characters directly into a form control.- Specified by:
insertContent
in interfaceInplaceEditor
- Parameters:
xmlContent
- Content to be inserted.- Returns:
true
if the event was handled orfalse
if the form control can do nothing with the string. For example a text field can insert the text inside it but a check box form control can do nothing with it. Iffalse
is returned the form control editing session will be stopped and the author page will handle the event instead.- See Also:
InplaceEditor.insertContent(java.lang.String)
-
-