Class InplaceEditorUtil
java.lang.Object
ro.sync.ecss.extensions.commons.editor.InplaceEditorUtil
Utility methods for preparing the in-place editors for being displayed.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
addToParent
(Component component, Container parent, Supplier<T> supplier) Adds the child inside the parent, calls the given supplier and requests the results from the supplier.static Dimension
getPreferredSize
(Component component, Container parent) Get the preferred size for the component.static Dimension
getPreferredSize
(JComboBox comboBox, AuthorInplaceContext context) Computes the preferred size for the given combo box.static Dimension
getPreferredSize
(JPanel panel, AuthorInplaceContext context) Computes the preferred size for the panel.static Dimension
getPreferredSize
(JTextField textField, AuthorInplaceContext context) Computes the preferred size for the given text field.static void
relayout
(JComboBox comboBox, AuthorInplaceContext context) Computes the required size for the editor and positions the caret at the end of the text.static void
relayout
(JTextField textField, AuthorInplaceContext context) Computes the required size for the editor and positions the caret at the end of the text.static void
setCaretAtEnd
(JTextComponent textField, AuthorInplaceContext context) Sets the caret at the end of the text from the text field.
-
Method Details
-
getPreferredSize
Computes the preferred size for the panel.- Parameters:
panel
- A panel used as an editor.context
- In-place editing context.- Returns:
- The preferred size for the given context.
-
getPreferredSize
Computes the preferred size for the given combo box.- Parameters:
comboBox
- A combo box used as an editor.context
- In-place editing context.- Returns:
- The preferred size for the given context.
-
getPreferredSize
Computes the preferred size for the given text field.- Parameters:
textField
- A text field used as an editor.context
- In-place editing context.- Returns:
- The preferred size for the given context.
-
relayout
Computes the required size for the editor and positions the caret at the end of the text. The caret offset will also be scrolled to be visible.- Parameters:
comboBox
- Combo box used for editing.context
- In-place editing context.
-
relayout
Computes the required size for the editor and positions the caret at the end of the text. The caret offset will also be scrolled to be visible.- Parameters:
textField
- Text field used for editing.context
- In-place editing context.
-
setCaretAtEnd
Sets the caret at the end of the text from the text field.- Parameters:
textField
- Text field to be scrolled.context
- In-place editing context.
-
getPreferredSize
Get the preferred size for the component.- Parameters:
component
- The component.parent
- The parent component, where the component will eventually be added.- Returns:
- the baseline
-
addToParent
Adds the child inside the parent, calls the given supplier and requests the results from the supplier.- Parameters:
component
- The component.parent
- The parent component, where the component will eventually be added.supplier
- To be invoked.- Returns:
- The results from the given supplier, after the component is added inside the parent.
-