Class ObjectEditor<T extends StoredObject>
- Type Parameters:
T
- Type of the object.
- All Implemented Interfaces:
Executable
,Reentrant
,HasLogic
,ObjectSetter<T>
,AlertHandler
,ObjectChangedListener<T>
,ObjectEditorListener
,ObjectProvider<T>
,Transactional
,TransactionCreator
,ClickHandler
,ExecutableView
,HasContainer
,ValueChangeHandler
,com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<? extends com.vaadin.flow.component.Component>>
,com.vaadin.flow.component.HasValue.ValueChangeListener
,Serializable
,Runnable
,EventListener
,Consumer<T>
- Direct Known Subclasses:
AbstractInvoiceEditor
,AbstractTextContentEditor
,ApplicationModuleEditor
,AssignStoresAndLocations
,BrowserDeviceLayoutEditor
,ControlScheduleEditor
,EntityEditor
,EntityRoleEditor
,GRNEditor
,ItemTypeEditor
,JavaClassEditor
,JournalVoucherEditor
,ManageExternalUsers
,ManageMailSenders
,ManageMailSenders.ManageGMailSenders
,MediaFileEditor
,MemoSystem.MemoEditor
,MemoTypeEditor
,MessageEditor
,MQTTEditor
,PackingUnitEditor
,PermissionEditor
,PersonRoleEditor
,POEditor
,POItemEditor
,ReportEditor
,SerialConfiguratorEditor
,SerialPatternEditor
,SetPasswordPolicy
,SystemUserEditor
,TableDefinitionEditor
StoredObject
classes. If you want to instantiate this class from within your code, it is recommended to use one of
the static create methods (create(Class, int, String)
, create(Class, int)
, create(Class)
)
rather than using the constructors directly.- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.storedobject.vaadin.AbstractDataEditor
AbstractDataEditor.DForm
Nested classes/interfaces inherited from class com.storedobject.vaadin.AbstractDataForm
AbstractDataForm.FieldError
Nested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Button
Button - Add.protected Button
Button - Audit.protected com.vaadin.flow.component.HasComponents
The layout where buttons are displayed.protected Button
Button - Cancel.protected Button
Button - Delete.protected Button
Button - Edit.protected Button
Button - Exit.protected Button
Button - Post Ledgerprotected PrintButton
Print button if defined.protected Button
Button - Report.protected Button
Button - Save.protected Button
Button - Search.Fields inherited from class com.storedobject.vaadin.AbstractDataForm
form
-
Constructor Summary
ConstructorsModifierConstructorDescriptionObjectEditor
(Class<T> objectClass) Constructor.ObjectEditor
(Class<T> objectClass, int actions) Constructor.ObjectEditor
(Class<T> objectClass, int actions, String caption) Constructor.protected
ObjectEditor
(Class<T> objectClass, int actions, String caption, String allowedActions) Constructor.ObjectEditor
(String className) Constructor. -
Method Summary
Modifier and TypeMethodDescription<L extends StoredObject>
booleanacceptValueChange
(ObjectLinkField<L> linkField, L item, int changeAction) Accept a change in the link field value.boolean
actionAllowed
(String action) Check whether a specific action is allowed or not.void
add
(com.vaadin.flow.component.Component... components) Add components to the form's field container.protected void
This method is invoked whenever an instance of the object is set.protected void
This method is invoked whenever an instance of the object is added/edited.void
Add a new object.void
Add a new object.void
Add a new object.com.vaadin.flow.shared.Registration
addObjectChangedListener
(ObjectChangedListener<T> listener) Add an "object changed" listener to track object changes in the editor.com.vaadin.flow.shared.Registration
addObjectEditorListener
(ObjectEditorListener listener) Add an "object editor" listener to track editing changes.com.vaadin.flow.shared.Registration
addValidator
(Predicate<T> validator) Add a validator that will be checked for validating the object instance.protected static String
allowedActions
(String className) Determine the allowed actions from the decorated class name passed.void
This method is invoked when anchor fields are created for the first time.protected void
This method will be invoked if the "Cancel" button is pressed on the anchor form.protected void
This method is invoked when anchor values are set via the anchor form and if any exception is thrown from this method, anchor values will be asked again.protected void
attachField
(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field) Attach a field to the form.protected void
attachLinkField
(ObjectLinkField<?> field) Attach the link field.boolean
canAdd()
Check whether add operation is allowed or not.boolean
canAllowAction
(String action) Same asactionAllowed(String)
except that this shows a message to the user about it if the action is not allowed.boolean
Check whether delete operation is allowed for the current object instance.boolean
canEdit()
Check whether edit operation is allowed for the current object instance.boolean
Check whether ledger can be posted or not.boolean
Check whether search operation is allowed or not.boolean
Check whether ledger can be viewed or not.void
clean()
Close resources if any that are left opened.void
clicked
(com.vaadin.flow.component.Component c) Default implementation, does nothing.static <O extends StoredObject>
ObjectEditor<O> create
(ObjectInput<O> formField) Create an editor for the purpose of embedding an object field.static <O extends StoredObject>
ObjectEditor<O> Create an instance of the editor from the parameters passed.static <O extends StoredObject>
ObjectEditor<O> Create an instance of the editor from the parameters passed.static <O extends StoredObject>
ObjectEditor<O> Create an instance of the editor from the parameters passed.protected void
This method is invoked at the time of creating the UI and this is where extra buttons need t be created to display as extra buttons on thebuttonPanel
.<O extends StoredObject>
ObjectEditor<O> createFormFieldEditor
(String fieldName, Class<O> fieldClass) Create the editor to be used for a givenObjectFormField
.protected LinkGrid
<?> createLinkFieldGrid
(String fieldName, ObjectLinkField<?> field) Typically, "grids" for "link fields" are created automatically.final T
Create a new instance of the data class.protected T
Create an instance of the object.protected void
customizeLinkField
(ObjectLinkField<?> field) Customize the link field if needed.protected boolean
delete()
Do the delete operation of the current object instance.void
This method is invoked whenever a new object is deleted in the database.void
Delete the current object.void
deleteObject
(T object) Delete an object.void
doAdd()
This is equivalent to pressing the "Add" button.void
doAudit()
This is equivalent to pressing the "Audit" button.void
doCancel()
This is equivalent to pressing the "Cancel" button while editing the instance.void
doDelete()
This is equivalent to pressing the "Delete" button.void
doEdit()
This is equivalent to pressing the "Edit" button.void
doReport()
This is equivalent to pressing the "Report" button.void
doSave()
Save the current object being edited if the editor is in the editing mode.void
doSearch()
This is equivalent to pressing the "Search" button.void
Invoked when editing is cancelled.void
Invoked when editing is ended.void
Invoked when editing is started.void
editObject
(T object) Edit an object.void
editObject
(T object, View parent) Edit an object.void
editObject
(T object, View parent, boolean doNotLock) Edit an object.protected void
enablePrintButtons
(boolean viewing) This method is invoked whenever an instance of the object is set.void
Execute the "anchor form".void
executeAnchorForm
(Runnable action) Execute the "anchor form" and run some specified action.void
extraInfoCreated
(StoredObject extraInfo) This is invoked when an "Extra Information" instance is created.void
extraInfoLoaded
(StoredObject extraInfo) This is invoked when an existing "Extra Information" instance is loaded for the current object.protected final void
fieldAttached
(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field) This method is invoked whenever a field is attached to the form.protected int
filterActions
(int actions) Get the filtered result of actions.protected String
Prefix string that is added to the "action" string to determine the actualUIAction
to be checked.Get the caption name to be used on the alert action button.Get the icon name to be used for showing the alert action button.com.vaadin.flow.component.HasValue
<?, ?> getAnchorField
(String fieldName) Get the anchor field.Get the anchor filter associated with this editor.Get the application that's tied to this View.getAttachmentField
(String fieldName) Get the attachment field.com.vaadin.flow.component.HasValue
<?, String> getContactField
(String fieldName) Get the contact field.com.vaadin.flow.component.HasComponents
Get the field container of the form.com.vaadin.flow.component.HasValue
<?, StoredObjectLink<?>> Get the extra info field if exists.com.vaadin.flow.component.HasValue
<?, ?> Get a field associated with a field name.final String
final com.vaadin.flow.component.grid.Grid
<T> getGrid()
Get the grid associated with this editor.getLinkField
(String fieldName) Get the link field.final Logic
getLogic()
Get the logic.Get the instance of the currently editing object.getObjectFieldType
(String fieldName) Get theObjectField.Type
for a given field.final int
Get the link type of the parent object previously set viasetParentObject(StoredObject, int)
.final StoredObject
Get the parent object previously set viasetParentObject(StoredObject, int)
.Get the searcher for this editor.protected String
getTabName
(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field) Get the tab name for a given field.final Transaction
getTransaction
(boolean create) Get the transaction.void
Handle the alert.protected boolean
handleValueSetError
(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field, Object fieldValue, Object objectValue, Throwable error) Handle errors while setting (committing) values.protected void
initUI()
This method is invoked when the view wants to determine its "content" to be displayed and nothing exists at that moment.void
This method is invoked whenever a new object is inserted in the database.final boolean
Check whether the editor is in buffered mode or not.boolean
Check whether "Do not save" option is allowed or not.boolean
Is editing? (Editing may not have started even ifisReadOnly()
returnsfalse
).boolean
isFieldEditable
(String fieldName) This method is invoked to determine if a field needs to be made editable or not.boolean
Is read-only?final boolean
Check whether the editor is in "view only" mode.List
<ObjectLinkField<?>> void
Post ledger entries.void
postLedger
(T object) Post ledger entries.void
refreshMe
(ObjectListGrid<T> grid) Ask the editor to refresh the given grid whenever object on the editor is changed (inserted/updated/deleted).void
reload()
Reload the current object instance.void
remove
(com.vaadin.flow.component.Component... components) Remove components from the form's field container.void
removeObjectChangedListener
(ObjectChangedListener<T> listener) void
void
removeSetNotAllowed
(String fieldName) Remove the "set not allowed" flag set viasetSetNotAllowed(String)
.void
removeValidator
(Predicate<T> validator) void
Reset the anchor values so that it will be asked again for the next add/search actions.protected boolean
save()
Save the current instance to the database.void
save
(Transaction t) Save the current instance to the database.protected void
saveObject
(Transaction t, T object) Save the given object.void
savingExtraInfo
(StoredObject extraInfo) This is invoked when an existing "Extra Information" instance is being saved.void
setAllowDoNotSave
(boolean allowDoNotSave) Allow/disallow "Do not save" option.void
setAnchorFieldReadOnly
(String... anchorFields) Set the anchor fields in read-only mode.void
setBuffered
(boolean buffered) Set the buffered mode.void
setCaption
(String caption) Set caption for this view.void
setColumns
(int columns) Set number of responsive columns for the form.void
setContactData
(ContactData contactData) For internal use only.void
setDeleter
(Function<ObjectEditor<T>, Boolean> deleter) Set a "deleter" that will be used for deleting the object.final void
setDoNotSave
(boolean on) For internal use only.void
setExtraInfo
(ExtraInfo<?> extraInfo) For internal use only.void
setFieldContainerProvider
(HasContainer fieldContainerProvider) Set the field container provider for this form so thatAbstractDataForm.createFieldContainer()
} can provide the component container from this.final void
Set the logic.void
setNewObjectGenerator
(NewObject<T> newObject) Set the "new object" creator so that it will be used for creating new instances.void
setNoTab()
If this method is invoked, tabbing stops and all further fields added without any tab name will go to the non-tab area of the editor.final void
Set the current object.void
setParentObject
(StoredObject parentObject, int parentLinkType) Set the parent object.void
setRawObject
(StoredObject object) Set an instance of aStoredObject
if it is compatible with this editor.void
setSaver
(Function<ObjectEditor<T>, Boolean> saver) Set a "saver" that will be used for saving the object.void
setSearchFilter
(FilterProvider filter) void
setSearchFilter
(String filter) void
setSetNotAllowed
(String fieldName) Set the "set not allowed" flag for a field so that, it will not allow changing the field-value if the value already exists.void
Create (or select if already exists) aFormLayout
instance as the tab for the editor.final void
setTransactionCreator
(TransactionCreator tranCreator) Set a "Transaction Creator" so thatTransactionCreator.getTransaction(boolean)
call will use it for creating new transactions.boolean
skipFirstFocus
(com.vaadin.flow.component.Focusable<?> skipFocus) Check if this component to be skipped while traversing the component tree to find the first focusable component or not.final void
trackValueChange
(com.vaadin.flow.component.HasValue<?, ?> field) Track value changes of a fieldHasValue
.void
This method is invoked whenever a new object is updated in the database.void
validateAnchorValues
(T object) Validate the anchor values.void
This method is invoked before saving whenever the object instance is added/edited.void
View the financial voucher for the ledger entries.void
View the current object.void
viewObject
(String actionName, Consumer<T> action) View the object that is passed.void
viewObject
(Consumer<T> action) View the object that is passed.void
viewObject
(T object) View the object that is passed.void
viewObject
(T object, View parent) View the object that is passed.void
viewObject
(T object, View parent, boolean doNotLock) View the object that is passed.void
viewObject
(T object, String actionName, Consumer<T> action) View the object that is passed.void
View the object that is passed.void
View the object that is passed.void
viewObject
(T object, Consumer<T> action) View the object that is passed.void
viewObject
(T object, Consumer<T> action, View parent) View the object that is passed.void
viewObject
(T object, Consumer<T> action, View parent, boolean doNotLock) View the object that is passed.Methods inherited from class com.storedobject.vaadin.AbstractDataEditor
addField, addField, addField, addField, addField, addField, addField, addField, constructField, createField, customizeField, getDataClass, getFieldCreator, getFieldGetMethod, getFieldNames, getFieldOrder, getFieldSetMethod, getForm, getObjectClass, includeField, isFieldIncluded, newObject, setFixedValue, setFixedValue, setFixedValues, setObject
Methods inherited from class com.storedobject.vaadin.AbstractDataForm
addConstructedListener, addField, addField, addIncludeFieldChecker, addValidator, addValidator, clearAlerts, clearError, clearErrors, clearFields, commit, connect, connect, connect, createButtonLayout, createField, createField, createFieldContainer, createLayout, detachField, fieldDetached, fireFormConstructed, formConstructed, getColumns, getColumnSpan, getContent, getData, getErrorDisplay, getFieldLabel, getFieldLabel, getFieldName, getLabel, isFieldEditable, isFieldVisible, isFieldVisible, load, markError, newLine, removeAll, removeField, removeField, removeField, setColumnSpan, setErrorDisplay, setFieldCustomizer, setFieldEditable, setFieldEditable, setFieldHidden, setFieldHidden, setFieldLabel, setFieldLabel, setFieldReadOnly, setFieldReadOnly, setFieldReadOnly, setFieldReadOnly, setFieldVisible, setFieldVisible, setFieldVisible, setFieldVisible, setIncludeFieldChecker, setReadOnly, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, setRequired, streamFieldNamesCreated, streamFieldsCreated
Methods inherited from class com.storedobject.vaadin.View
abort, aborted, addClosedListener, addOpenedListener, close, createCloseableView, createWindow, decorateComponent, execute, execute, execute, executing, focus, focus, focusAny, getCaption, getComponent, getCreatedBy, getEmbeddedView, getMenuItem, getMenuItem, getView, invoke, isFullScreen, isScrollable, isWindowMode, select, setComponent, setCreatedBy, setDefaultPadding, setEmbeddedView, setFirstFocus, setFullScreen, setScrollable, setWindowMode
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.ui.AlertHandler
handleAlert
Methods inherited from interface com.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClicked
Methods inherited from interface com.storedobject.common.Executable
act
Methods inherited from interface com.storedobject.vaadin.ExecutableView
abort, clearAlerts, close, createMenuItem, error, execute, getCaption, getMenuIconName, getMenuItem, getView, getView, invoke, isCloseable, isFullScreen, isHomeView, log, log, message, returnedFrom, run, setClickable, speak, tray, valueChanged, warning
Methods inherited from interface com.storedobject.ui.ObjectChangedListener
saved, undeleted
Methods inherited from interface com.storedobject.ui.ObjectProvider
getObjectClass, getObjectId
Methods inherited from interface com.storedobject.core.ObjectSetter
accept, getObjectClass, isAllowAny, setObject
Methods inherited from interface com.storedobject.common.Reentrant
isReentrant
Methods inherited from interface com.storedobject.ui.Transactional
commit, execute, getTransactionManager, run, transact, transact, transactControl, transactControl
Methods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
-
Field Details
-
buttonPanel
protected com.vaadin.flow.component.HasComponents buttonPanelThe layout where buttons are displayed. -
print
Print button if defined. Print button will be defined automatically. Please seePrintButton
. -
add
Button - Add. -
edit
Button - Edit. -
delete
Button - Delete. -
search
Button - Search. -
report
Button - Report. -
audit
Button - Audit. -
exit
Button - Exit. -
save
Button - Save. -
cancel
Button - Cancel. -
ledger
Button - Post Ledger
-
-
Constructor Details
-
ObjectEditor
Constructor.- Parameters:
objectClass
-StoredObject
class.
-
ObjectEditor
Constructor.- Parameters:
objectClass
-StoredObject
class.actions
-EditorAction
values ORed.
-
ObjectEditor
Constructor.- Parameters:
objectClass
-StoredObject
class.actions
-EditorAction
values ORed.caption
- Caption.
-
ObjectEditor
Constructor.- Parameters:
className
- Fully-qualified name of theStoredObject
class. The class name may be decorated to specify the allowed actions.For example, if you specify the class name like this - "(ADD,EDIT)com.storedobject.core.Person" -, it will allow only ADD and EDIT operations.
- Throws:
Exception
-
ObjectEditor
Constructor.- Parameters:
objectClass
-StoredObject
class.actions
-EditorAction
values ORed.caption
- Caption.allowedActions
- Allowed actions as comma-separated string values ofEditorAction
.
-
-
Method Details
-
create
Create an instance of the editor from the parameters passed. The returned instance would be of an extended class ofObjectEditor
if such a class exists.- Type Parameters:
O
- Type ofStoredObject
class.- Parameters:
objectClass
-StoredObject
class.- Returns:
- An instance of
ObjectEditor
or its derivative.
-
create
Create an instance of the editor from the parameters passed. The returned instance would be of an extended class ofObjectEditor
if such a class exists.- Type Parameters:
O
- Type ofStoredObject
class.- Parameters:
objectClass
-StoredObject
class.actions
-EditorAction
values ORed.- Returns:
- An instance of
ObjectEditor
or its derivative.
-
create
public static <O extends StoredObject> ObjectEditor<O> create(Class<O> objectClass, int actions, String title) Create an instance of the editor from the parameters passed. The returned instance would be of an extended class ofObjectEditor
if such a class exists.- Type Parameters:
O
- Type ofStoredObject
class.- Parameters:
objectClass
-StoredObject
class.actions
-EditorAction
values ORed.title
- Caption.- Returns:
- An instance of
ObjectEditor
or its derivative.
-
getContainer
public com.vaadin.flow.component.HasComponents getContainer()Description copied from class:AbstractDataForm
Get the field container of the form.- Specified by:
getContainer
in interfaceHasContainer
- Overrides:
getContainer
in classAbstractDataForm<T extends StoredObject>
- Returns:
- Field container.
-
create
Create an editor for the purpose of embedding an object field.- Type Parameters:
O
- Type of object.- Parameters:
formField
- Field to embed.- Returns:
- Editor.
-
setColumns
public void setColumns(int columns) Description copied from class:AbstractDataForm
Set number of responsive columns for the form.- Overrides:
setColumns
in classAbstractDataForm<T extends StoredObject>
- Parameters:
columns
- Number of responsive columns required
-
extraLinks
-
setCaption
Description copied from class:View
Set caption for this view. Caption is displayed as aMenuItem
by theApplication
so that the view can be selected (only one view is displayed at a time) by clicking it.- Specified by:
setCaption
in interfaceExecutableView
- Overrides:
setCaption
in classView
- Parameters:
caption
- Caption
-
setLogic
Description copied from interface:HasLogic
Set the logic. This will be invoked by theApplicationServer
when theLogic
is executed.- Specified by:
setLogic
in interfaceHasLogic
- Specified by:
setLogic
in interfaceTransactional
- Parameters:
logic
- Logic to set
-
getLogic
-
getGrid
Get the grid associated with this editor.- Returns:
- Associated grid. Could be null.
-
setTransactionCreator
Description copied from interface:TransactionCreator
Set a "Transaction Creator" so thatTransactionCreator.getTransaction(boolean)
call will use it for creating new transactions.- Specified by:
setTransactionCreator
in interfaceTransactionCreator
- Parameters:
tranCreator
- Transaction creator
-
getTransaction
Description copied from interface:TransactionCreator
Get the transaction.- Specified by:
getTransaction
in interfaceTransactionCreator
- Parameters:
create
- True if transaction needs to be created if not exists- Returns:
- Transaction
-
getApplication
Description copied from class:View
Get the application that's tied to this View.- Specified by:
getApplication
in interfaceExecutableView
- Overrides:
getApplication
in classView
- Returns:
- The Application.
-
filterActions
protected int filterActions(int actions) Get the filtered result of actions. This is invoked before allowing the actions and this can disable some actions allowed. The default implementation doesn't filter anything.- Parameters:
actions
- Actions to filter. (ORed values ofEditorAction
)- Returns:
- Filtered action value.
-
allowedActions
Determine the allowed actions from the decorated class name passed. See the constructorObjectEditor(String)
to understand the concept of decorated class name.- Parameters:
className
- Decorated class name.- Returns:
- Action names extracted.
-
initUI
protected void initUI()Description copied from class:View
This method is invoked when the view wants to determine its "content" to be displayed and nothing exists at that moment.View.setComponent(Component)
may be called from within this method. -
skipFirstFocus
public boolean skipFirstFocus(com.vaadin.flow.component.Focusable<?> skipFocus) Description copied from class:View
Check if this component to be skipped while traversing the component tree to find the first focusable component or not.- Overrides:
skipFirstFocus
in classView
- Parameters:
skipFocus
- The focusable component- Returns:
- False if it should not be skipped (Default implementation returns false).
-
isFieldEditable
Description copied from class:AbstractDataForm
This method is invoked to determine if a field needs to be made editable or not.- Overrides:
isFieldEditable
in classAbstractDataForm<T extends StoredObject>
- Parameters:
fieldName
- Name of the field- Returns:
- True or false.
-
setSetNotAllowed
Set the "set not allowed" flag for a field so that, it will not allow changing the field-value if the value already exists. (Typically, this is invoked by the platform itself).- Parameters:
fieldName
- Field name.
-
removeSetNotAllowed
Remove the "set not allowed" flag set viasetSetNotAllowed(String)
. (This is used only under some special circumstances by the platform itself).- Parameters:
fieldName
- Field name.
-
handleValueSetError
protected boolean handleValueSetError(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field, Object fieldValue, Object objectValue, Throwable error) Description copied from class:AbstractDataEditor
Handle errors while setting (committing) values. Default implementation returnstrue
without doing anything.- Overrides:
handleValueSetError
in classAbstractDataEditor<T extends StoredObject>
- Parameters:
fieldName
- Name of the fieldfield
- FieldfieldValue
- Field's value that's being committedobjectValue
- Value currently being in the objecterror
- Error occurred while setting the value- Returns:
- Whether the error situation is handled or not.
-
setNewObjectGenerator
Set the "new object" creator so that it will be used for creating new instances. If set, the methodcreateObjectInstance()
will return instances created by this.- Parameters:
newObject
- New object creator to set.
-
createNewInstance
Create a new instance of the data class. This is a helper method that can be typically invoked from theNewObject.newObject()
/NewObject.newObject(TransactionManager)
to create a new instance.- Returns:
- New instance of the data class.
-
createObjectInstance
Description copied from class:AbstractDataEditor
Create an instance of the object. Default implementation tries to invoke the default constructor to create an instance and fixed values will be set if defined.- Overrides:
createObjectInstance
in classAbstractDataEditor<T extends StoredObject>
- Returns:
- Newly created object.
-
getObject
Description copied from class:AbstractDataEditor
Get the instance of the currently editing object. (A new object will be created by invokingAbstractDataEditor.createObjectInstance()
if there is no current object instance set).- Specified by:
getObject
in interfaceObjectProvider<T extends StoredObject>
- Overrides:
getObject
in classAbstractDataEditor<T extends StoredObject>
- Returns:
- Instance of the currently loaded object.
-
addObjectChangedListener
public com.vaadin.flow.shared.Registration addObjectChangedListener(ObjectChangedListener<T> listener) Add an "object changed" listener to track object changes in the editor. An "object change" event is fired whenever the object is inserted/updated/deleted/saved/undeleted.- Parameters:
listener
- Listener to add.
-
removeObjectChangedListener
-
addObjectEditorListener
Add an "object editor" listener to track editing changes. An "object editor" event is fired whenever a different object is set to the editor.- Parameters:
listener
- Listener to add.
-
removeObjectEditorListener
-
addValidator
-
removeValidator
-
createExtraButtons
protected void createExtraButtons()This method is invoked at the time of creating the UI and this is where extra buttons need t be created to display as extra buttons on thebuttonPanel
. -
addExtraButtons
protected void addExtraButtons()This method is invoked whenever an instance of the object is set. Typically, "extra buttons" can be added to thebuttonPanel
by examining the object instance value. -
addExtraEditingButtons
protected void addExtraEditingButtons()This method is invoked whenever an instance of the object is added/edited. Typically, "extra buttons" can be added to thebuttonPanel
by examining the object instance value. -
enablePrintButtons
protected void enablePrintButtons(boolean viewing) This method is invoked whenever an instance of the object is set. Typically, "print buttons" can be made visible or hidden by examining the object instance value. The default implementation makes the "print" button visible if the object is non-null. (SeePrintButton
).- Parameters:
viewing
- Whether in view mode or not.
-
clean
public void clean()Description copied from class:View
Close resources if any that are left opened. This method is invoked when the view is removed from theApplication
. The default implementation does nothing.- Specified by:
clean
in interfaceExecutableView
- Overrides:
clean
in classAbstractDataForm<T extends StoredObject>
-
clicked
public void clicked(com.vaadin.flow.component.Component c) Description copied from interface:ExecutableView
Default implementation, does nothing.- Specified by:
clicked
in interfaceClickHandler
- Specified by:
clicked
in interfaceExecutableView
- Parameters:
c
- Component
-
postLedger
public void postLedger()Post ledger entries. This is equivalent to pressing the "Post Ledger" button. -
postLedger
Post ledger entries. This is equivalent to pressing the "Post Ledger" button. -
viewLedger
public void viewLedger()View the financial voucher for the ledger entries. -
isEditing
public boolean isEditing()Is editing? (Editing may not have started even ifisReadOnly()
returnsfalse
).- Returns:
- True/false.
-
isReadOnly
public boolean isReadOnly()Is read-only?- Overrides:
isReadOnly
in classAbstractDataForm<T extends StoredObject>
- Returns:
- True/false.
-
doSave
public void doSave()Save the current object being edited if the editor is in the editing mode. This is equivalent to pressing the "Save" button in editing mode. -
save
Save the current instance to the database. This method carries out the save operation set by thesetSaver(Function)
. If no such operation is specified, then, it invokessave(Transaction)
to carry out the operation.- Returns:
- True if the operation was successful. Otherwise, false is returned.
- Throws:
Exception
- Raises when save operation is not successful.
-
save
Save the current instance to the database.Note: Not only save operation includes saving the current instance, but also it includes saving the links, connected master (if any), contact data, attachments etc. So, this method may be invoked from within customized save operations too.
- Parameters:
t
- Transaction.- Throws:
Exception
- Raises when save operation is not successful.
-
saveObject
Save the given object. This is invoked from thesave(Transaction)
method to just save the object. The default implementation just saves the object by invokingStoredObject.save(Transaction)
.- Parameters:
t
- Transaction.object
- Object to be saved.- Throws:
Exception
- Raises when save operation is not successful.
-
doCancel
public void doCancel()This is equivalent to pressing the "Cancel" button while editing the instance. -
validateData
-
validateAnchorValues
Validate the anchor values. This is invoked when anchor values are set while adding a new instance.- Parameters:
object
- The instance that contains the currently accepted anchor values.- Throws:
SOException
- If thrown, the message is displayed as a warning and the add operation is aborted.
-
anchorFieldsCreated
public void anchorFieldsCreated()This method is invoked when anchor fields are created for the first time. -
resetAnchor
public void resetAnchor()Reset the anchor values so that it will be asked again for the next add/search actions. -
anchorsSet
-
anchorsCancelled
protected void anchorsCancelled()This method will be invoked if the "Cancel" button is pressed on the anchor form. -
executeAnchorForm
public void executeAnchorForm()Execute the "anchor form". -
executeAnchorForm
Execute the "anchor form" and run some specified action.- Parameters:
action
- Action to run.
-
doAdd
public void doAdd()This is equivalent to pressing the "Add" button. -
doEdit
public void doEdit()This is equivalent to pressing the "Edit" button. -
doDelete
public void doDelete()This is equivalent to pressing the "Delete" button. -
doSearch
public void doSearch()This is equivalent to pressing the "Search" button. -
doReport
public void doReport()This is equivalent to pressing the "Report" button. -
doAudit
public void doAudit()This is equivalent to pressing the "Audit" button. -
getSearcher
-
delete
-
editingStarted
public void editingStarted()Invoked when editing is started.- Specified by:
editingStarted
in interfaceObjectEditorListener
-
editingEnded
public void editingEnded()Invoked when editing is ended.- Specified by:
editingEnded
in interfaceObjectEditorListener
-
editingCancelled
public void editingCancelled()Invoked when editing is cancelled.- Specified by:
editingCancelled
in interfaceObjectEditorListener
-
canDelete
public boolean canDelete()Check whether delete operation is allowed for the current object instance.- Returns:
- True if allowed.
-
canEdit
public boolean canEdit()Check whether edit operation is allowed for the current object instance.- Returns:
- True if allowed.
-
canAdd
public boolean canAdd()Check whether add operation is allowed or not.- Returns:
- True if allowed.
-
canSearch
public boolean canSearch()Check whether search operation is allowed or not.- Returns:
- True if allowed.
-
canPostLedger
public boolean canPostLedger()Check whether ledger can be posted or not.- Returns:
- True if allowed.
-
canViewLedger
public boolean canViewLedger()Check whether ledger can be viewed or not.- Returns:
- True if allowed.
-
reload
public void reload()Reload the current object instance. -
inserted
This method is invoked whenever a new object is inserted in the database.- Specified by:
inserted
in interfaceObjectChangedListener<T extends StoredObject>
- Parameters:
object
- Object being inserted
-
updated
This method is invoked whenever a new object is updated in the database.- Specified by:
updated
in interfaceObjectChangedListener<T extends StoredObject>
- Parameters:
object
- Object being updated
-
deleted
This method is invoked whenever a new object is deleted in the database.- Specified by:
deleted
in interfaceObjectChangedListener<T extends StoredObject>
- Parameters:
object
- Object being deleted
-
viewObject
public void viewObject()View the current object. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode. -
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.
-
viewObject
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.parent
- Parent view.doNotLock
- To specify whether the parent to be locked or not.
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
actionName
- Name of the action to be allowed while viewing. This will be used only when an action is specified and is used as a label to the button for the action.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.actionName
- Name of the action to be allowed while viewing. This will be used only when an action is specified and is used as a label to the button for the action.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.actionName
- Name of the action to be allowed while viewing. This will be used only when an action is specified and is used as a label to the button for the action.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.parent
- Parent view.
-
viewObject
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.parent
- Parent view.
-
viewObject
View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.parent
- Parent view.doNotLock
- To specify whether the parent to be locked or not.
-
viewObject
public void viewObject(T object, String actionName, Consumer<T> action, View parent, boolean doNotLock) View the object that is passed. If the editor is in the editing mode, it will be cancelled and will be switched to viewing mode.- Parameters:
object
- Object to view. If null is passed, current object will be used.actionName
- Name of the action to be allowed while viewing. This will be used only when an action is specified and is used as a label to the button for the action.action
- Action to carry out. A button will be displayed and that can be pressed for invoking the action.parent
- Parent view.doNotLock
- To specify whether the parent to be locked or not.
-
editObject
Edit an object.- Parameters:
object
- Object to be edited. If null is passed, no action is taken.
-
editObject
-
editObject
-
addObject
public void addObject()Add a new object. -
addObject
-
addObject
Add a new object.- Parameters:
parent
- Parent view.doNotLock
- To specify whether the parent to be locked or not.
-
deleteObject
public void deleteObject()Delete the current object. -
deleteObject
-
setObject
Description copied from class:AbstractDataEditor
Set the current object. Fields will be loaded.- Specified by:
setObject
in interfaceObjectSetter<T extends StoredObject>
- Overrides:
setObject
in classAbstractDataEditor<T extends StoredObject>
- Parameters:
object
- Object to set
-
setParentObject
Set the parent object. This is used when this editor is used for editing links.- Parameters:
parentObject
- The parent object to be set.parentLinkType
- Link type of the object.
-
getParentObject
Get the parent object previously set viasetParentObject(StoredObject, int)
.- Returns:
- Parent object.
-
getParentLinkType
public final int getParentLinkType()Get the link type of the parent object previously set viasetParentObject(StoredObject, int)
.- Returns:
- Link type.
-
setSaver
Set a "saver" that will be used for saving the object.- Parameters:
saver
- Saver to set.
-
setDeleter
Set a "deleter" that will be used for deleting the object.- Parameters:
deleter
- Deleter to set.
-
isViewOnly
public final boolean isViewOnly()Check whether the editor is in "view only" mode. The editor is in "view only" mode if the buttons are not available for editing (maybe hidden or disabled too).- Returns:
- True/false.
-
setDoNotSave
public final void setDoNotSave(boolean on) For internal use only. If set, saving will be skipped! (It is internally used to switch on/off link editing depending on whether this is a child of another editor or not).- Parameters:
on
- True or false.
-
setAllowDoNotSave
public void setAllowDoNotSave(boolean allowDoNotSave) Allow/disallow "Do not save" option. (SeesetDoNotSave(boolean)
).- Parameters:
allowDoNotSave
- True if link editing needs to be allowed
-
isDoNotSaveAllowed
public boolean isDoNotSaveAllowed()Check whether "Do not save" option is allowed or not.- Returns:
- True/false.
-
createLinkFieldGrid
Typically, "grids" for "link fields" are created automatically. However, this method can be overridden to create customized link grids.- Parameters:
fieldName
- Field for which grid to be created.field
- Field.- Returns:
- Grid for the link field. A null may be returned so that default grid will be automatically created.
-
getTabName
Get the tab name for a given field. This method is invoked while constructing the form, and you may return a name for the tab in which the field will be added in the form.- Parameters:
fieldName
- Field name.field
- Field.- Returns:
- Name of the tab.
-
setTab
Create (or select if already exists) aFormLayout
instance as the tab for the editor. If this method is ever invoked while creating the editor, the editor will become a multi-tabbed editor. If you call this method after the editor is constructed, it will select the tab if one exists. All further fields added to the editor will go to the currently selected tab.- Parameters:
tabName
- The tab name for whichFormLayout
needs to be created or selected. Null or empty tab names will be ignored.
-
setNoTab
public void setNoTab()If this method is invoked, tabbing stops and all further fields added without any tab name will go to the non-tab area of the editor. -
add
public void add(com.vaadin.flow.component.Component... components) Description copied from class:AbstractDataForm
Add components to the form's field container.- Overrides:
add
in classAbstractDataForm<T extends StoredObject>
- Parameters:
components
- Components to add
-
remove
public void remove(com.vaadin.flow.component.Component... components) Description copied from class:AbstractDataForm
Remove components from the form's field container.- Overrides:
remove
in classAbstractDataForm<T extends StoredObject>
- Parameters:
components
- Components to remove
-
setFieldContainerProvider
Description copied from class:AbstractDataForm
Set the field container provider for this form so thatAbstractDataForm.createFieldContainer()
} can provide the component container from this.- Overrides:
setFieldContainerProvider
in classAbstractDataForm<T extends StoredObject>
- Parameters:
fieldContainerProvider
- Field container to set
-
attachField
Description copied from class:AbstractDataForm
Attach a field to the form. This is invoked whenever a field is added to the form. The default implementation adds the component of the field (if it is a component) to the field container.- Overrides:
attachField
in classAbstractDataForm<T extends StoredObject>
- Parameters:
fieldName
- Name of the fieldfield
- Field
-
fieldAttached
Description copied from class:AbstractDataForm
This method is invoked whenever a field is attached to the form.- Overrides:
fieldAttached
in classAbstractDataForm<T extends StoredObject>
- Parameters:
fieldName
- Name of the fieldfield
- Field
-
customizeLinkField
Customize the link field if needed.- Parameters:
field
- Field to customize.
-
attachLinkField
Attach the link field. By default, it will be attached as a tab at the bottom of the view.- Parameters:
field
- Field to attach.
-
getLinkField
Get the link field.- Parameters:
fieldName
- Name of the link field.- Returns:
- Field if found, otherwise null.
-
linkFields
-
getAnchorField
Get the anchor field.- Parameters:
fieldName
- Name of the anchor field.- Returns:
- Field if found, otherwise null.
-
getAttachmentField
Get the attachment field.- Parameters:
fieldName
- Name of the attachment field.- Returns:
- Field if found, otherwise null.
-
getContactField
-
getExtraInfoField
Get the extra info field if exists.- Returns:
- Field if found, otherwise null.
-
setContactData
For internal use only. Set the contact data.- Parameters:
contactData
- Contact data to be set.
-
setExtraInfo
For internal use only. Set extra info.- Parameters:
extraInfo
- Extra info to be set.
-
trackValueChange
public final void trackValueChange(com.vaadin.flow.component.HasValue<?, ?> field) Description copied from interface:ExecutableView
Track value changes of a fieldHasValue
. Whenever a value is changed,ValueChangeHandler.valueChanged(HasValue.ValueChangeEvent)
method is invoked (and that in turn, will invokeExecutableView.valueChanged(ChangedValues)
because that is the default implementation).- Specified by:
trackValueChange
in interfaceExecutableView
- Parameters:
field
- Field to be tracked.
-
handleAlert
Description copied from interface:AlertHandler
Handle the alert.- Specified by:
handleAlert
in interfaceAlertHandler
- Parameters:
so
- Associated object instance.
-
getAlertIcon
Description copied from interface:AlertHandler
Get the icon name to be used for showing the alert action button. By default, "vaadin:cog_o" is used.- Specified by:
getAlertIcon
in interfaceAlertHandler
- Returns:
- Alert icon name,
-
getAlertCaption
Description copied from interface:AlertHandler
Get the caption name to be used on the alert action button. By default, "Process" is used.- Specified by:
getAlertCaption
in interfaceAlertHandler
- Returns:
- Alert button caption.
-
getAnchorFilter
Get the anchor filter associated with this editor.Note: Anchor filter will not be available if the anchor form is not yet executed.
- Returns:
- Anchor filter if any, otherwise null.
-
setAnchorFieldReadOnly
Set the anchor fields in read-only mode.- Parameters:
anchorFields
- Anchor fields.
-
setBuffered
public void setBuffered(boolean buffered) Set the buffered mode. In buffered mode, instances will be backed up before editing and will be restored if editing is cancelled.- Parameters:
buffered
- True/false.
-
isBuffered
public final boolean isBuffered()Check whether the editor is in buffered mode or not.- Returns:
- True/false.
-
setRawObject
Set an instance of aStoredObject
if it is compatible with this editor.- Parameters:
object
- Instance of the object to set.
-
acceptValueChange
public <L extends StoredObject> boolean acceptValueChange(ObjectLinkField<L> linkField, L item, int changeAction) Accept a change in the link field value.- Type Parameters:
L
- Type of link value.- Parameters:
linkField
- Link field that is changed.item
- Item that is changed.changeAction
- Change action (One of the static values defined in theEditorAction
).- Returns:
- True if change is acceptable. If false is returned, value will be ignored.
-
setSearchFilter
-
setSearchFilter
-
extraInfoCreated
This is invoked when an "Extra Information" instance is created. At this point, you may set your own values if required.- Parameters:
extraInfo
- Newly created "Extra Information" instance.
-
extraInfoLoaded
This is invoked when an existing "Extra Information" instance is loaded for the current object. At this point, you may set your own values if required.- Parameters:
extraInfo
- The "Extra Information" instance loaded now.
-
savingExtraInfo
This is invoked when an existing "Extra Information" instance is being saved. At this point, you may set your own values if required. (validateData()
andStoredObject.validateData(TransactionManager)
are be invoked after this).If an exception is thrown from this method, the save process will not happen.
- Parameters:
extraInfo
- The "Extra Information" instance to be saved.- Throws:
Exception
- if any validation error to be notified.
-
refreshMe
Ask the editor to refresh the given grid whenever object on the editor is changed (inserted/updated/deleted).- Parameters:
grid
- Grid to refresh.
-
getField
Description copied from class:AbstractDataForm
Get a field associated with a field name.- Overrides:
getField
in classAbstractDataForm<T extends StoredObject>
- Parameters:
fieldName
- Name of the field- Returns:
- Field.
-
getObjectFieldType
Get theObjectField.Type
for a given field. This method is invoked while building the fields to determine the field type.- Parameters:
fieldName
- Name of the field.- Returns:
ObjectField.Type
. The default value isObjectField.Type.AUTO
.
-
createFormFieldEditor
public <O extends StoredObject> ObjectEditor<O> createFormFieldEditor(String fieldName, Class<O> fieldClass) Create the editor to be used for a givenObjectFormField
.- Type Parameters:
O
- Type of the field.- Parameters:
fieldName
- Name of the field.fieldClass
- Class of the field.- Returns:
- Editor created for the given field.
-
getFieldName
-
getActionPrefix
Prefix string that is added to the "action" string to determine the actualUIAction
to be checked. SeeactionAllowed(String)
. For example,POBrowser
returns the value "PO" for this method.- Returns:
- Prefix string. Default implementation returns null. That means that all the actions are allowed.
-
actionAllowed
Check whether a specific action is allowed or not. An action is defined in the UI logic as a keyword like "SEND-ITEMS", "PLACE-ORDER", "RECEIVE-ITEMS", "PRINT-VOUCHER", etc. and there could be corresponding access control applicable within the logic. The user's groups determine whether that user can carry out that action or not. This method returnstrue/false
to denote that the user can carry out the action or not. However, it is up to the logic to decide the course of action.The user's groups can be configured to allow various UI actions (
UIAction
. EachUIAction
represents a unique "action" string (UIAction.getAction()
) and that value should be equal togetActionPrefix()
+ "-" + action in order to allow that action.- Parameters:
action
- Action string.- Returns:
- True/false. Please note that it will always return
true
ifgetActionPrefix()
returnsnull
.
-
canAllowAction
Same asactionAllowed(String)
except that this shows a message to the user about it if the action is not allowed.- Parameters:
action
- Action string.- Returns:
- True/false.
-