Package ro.sync.ecss.component.editor
Class ButtonGroupEditor
java.lang.Object
ro.sync.ecss.extensions.api.editor.AbstractInplaceEditor
ro.sync.ecss.component.editor.ButtonGroupEditor
- All Implemented Interfaces:
InplaceEditor
,InplaceRenderer
,Extension
@API(type=INTERNAL,
src=PUBLIC)
public class ButtonGroupEditor
extends AbstractInplaceEditor
implements InplaceRenderer
Inplace editor that uses a button to trigger a pop-up menu with multiple actions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Cancels the editing process.void
Commit the given value inside the document without stopping the editing.getCursorType
(int x, int y) Get a cursor to be used when the user hovers with the mouse over this renderer.getCursorType
(AuthorInplaceContext context, int x, int y) Get a cursor to be used when the user hovers with the mouse over this renderer.getEditorComponent
(AuthorInplaceContext context, Rectangle allocation, Point mouseInvocationLocation) Prepare and return the editor component.getRendererComponent
(AuthorInplaceContext context) Initialize the renderer with the given context and returns the component.getRenderingInfo
(AuthorInplaceContext context) Returns the rendering layout info.Returns a rectangle that should be made visible after the editor is shown.getTooltipText
(AuthorInplaceContext context, int x, int y) Gets a tooltip text to be presented when the cursor is over this renderer.getValue()
Gets the value that the user entered.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
Requests focus inside the editing component.void
Stops the editing and commits the current value.Methods inherited from class ro.sync.ecss.extensions.api.editor.AbstractInplaceEditor
addEditingListener, fireCommitValue, fireEditingCanceled, fireEditingOccured, fireEditingStopped, fireNextEditLocationRequested, firePreviousEditLocationRequested, getBoolean, insertContent, removeEditingListener
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
-
Constructor Details
-
ButtonGroupEditor
public ButtonGroupEditor()Constructor.
-
-
Method Details
-
getDescription
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
-
getEditorComponent
public 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:
-
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:
-
requestFocus
public void requestFocus()Description copied from interface:InplaceEditor
Requests focus inside the editing component.- Specified by:
requestFocus
in interfaceInplaceEditor
- See Also:
-
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:
-
stopEditing
public 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:
-
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
- Overrides:
commitValue
in classAbstractInplaceEditor
- See Also:
-
cancelEditing
public 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:
-
getRendererComponent
Description copied from interface:InplaceRenderer
Initialize the renderer with the given context and returns the component. It's up to the caller to use the renderer to paint.- Specified by:
getRendererComponent
in interfaceInplaceRenderer
- Parameters:
context
- The editing context.- Returns:
- The renderer. A java.awt.Component implementation.
- See Also:
-
getCursorType
Description copied from interface:InplaceRenderer
Get a cursor to be used when the user hovers with the mouse over this renderer. For a more complex renderer, the given X,Y coordinates can be used to decide what cursor to return.- Specified by:
getCursorType
in interfaceInplaceRenderer
- Parameters:
context
- The editing context. Useful if the renderer is a more complex one, like a text field with an associated button and wants to provide different cursors when the cursor is over the textfield or over the button. In this case the renderer will have to initialize itself with this context in order to decide what the cursor is hovering.x
- The x coordinate relative to the renderer bounds.y
- The y coordinate relative to the renderer bounds.- Returns:
- The type of cursor to be used or
null
to let the viewport decide. - See Also:
-
getCursorType
Description copied from interface:InplaceRenderer
Get a cursor to be used when the user hovers with the mouse over this renderer. For a more complex renderer, the given X,Y coordinates can be used to decide what cursor to return. We recommend usingInplaceRenderer.getCursorType(AuthorInplaceContext, int, int)
as you can use the provided context to get additional information.- Specified by:
getCursorType
in interfaceInplaceRenderer
- Parameters:
x
- The x coordinate relative to the renderer bounds.y
- The y coordinate relative to the renderer bounds.- Returns:
- The type of cursor to be used or
null
to let the viewport decide. - See Also:
-
getTooltipText
Description copied from interface:InplaceRenderer
Gets a tooltip text to be presented when the cursor is over this renderer. Because a renderer is reused, when this called is received, the renderer must re-initialize itself from the given context.- Specified by:
getTooltipText
in interfaceInplaceRenderer
- Parameters:
context
- The editing context.x
- The x coordinate relative to the renderer bounds.y
- The y coordinate relative to the renderer bounds.- Returns:
- A tooltip text or
null
if no tooltip. - See Also:
-
getRenderingInfo
Description copied from interface:InplaceRenderer
Returns the rendering layout info. This contains information about the baseline and the size in a certain context. The baseline is measured from the top of the component. Because a renderer is reused, when this call is received, the renderer must re-initialize itself from the given context.- Specified by:
getRenderingInfo
in interfaceInplaceRenderer
- Parameters:
context
- The editing context.- Returns:
- The rendering layout info.
- See Also:
-
refresh
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
- Overrides:
refresh
in classAbstractInplaceEditor
- Parameters:
context
- An updated editing context for this editor.- See Also:
-