Class EditorState<T>
- java.lang.Object
-
- com.hybris.cockpitng.editor.extendedmultireferenceeditor.state.EditorState<T>
-
- All Implemented Interfaces:
DesktopAware
public class EditorState<T> extends java.lang.Object implements DesktopAware
Keeps a state ofDefaultExtendedMultiReferenceEditor.
-
-
Constructor Summary
Constructors Constructor Description EditorState(java.lang.String path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RowState<T>addRowState(T row)Adds new row state bound to provided row object.voidafterDesktopChanged()Method that is fired when desktop is changed i.e.ValidationResultcollectValidationResult()Creates new instance ofValidationResultthat contains validation violations for all rows.static java.lang.StringgetArrayPath(java.lang.String path)Parses full attribute path for i.e.java.util.Collection<java.util.Map.Entry<T,RowState>>getEntries()Gets states of all rows with object bound to themjava.util.Optional<ListheaderSortState>getListheaderSortState()protected com.hybris.cockpitng.editor.extendedmultireferenceeditor.state.EditorState.ValidationObservablegetObservable()TgetRow(int index)Gets an object bound to row on specified indexstatic intgetRowIndex(java.lang.String path)Parses full attribute path for i.e.intgetRowIndex(T row)Gets index of row bound to provided objectjava.lang.StringgetRowPath(int rowIndex)Gets a path to specified row, relative to current editor.static java.lang.StringgetRowPath(java.lang.String path)Parses full attribute path for i.e.RowState<T>getRowState(T row)Gets a state of row bound to provided object.java.util.Collection<RowState>getRowStates()Gets states of all rows defined for editorObservablegetValidationObservable()ValidationResultgetValidationResult(T row)Gets validation result of specified rowvoidrefreshRowStateReference(T row)voidremoveAllRowStates()Resets all row statesvoidremoveRowState(T row)Removes a row bound to provided row objectvoidsetListheaderSortState(ListheaderSortState listheaderSortState)ValidationResultupdateValidationResult(T row, java.util.List<ValidationInfo> validationInfos)Sets new validation violations of specified rowvoidvalidationChanged(java.lang.String path)Notifies all validation observers about changes in violations.
-
-
-
Method Detail
-
getRowIndex
public static int getRowIndex(java.lang.String path)
Parses full attribute path for i.e. editor or validation violation and extracts index of row which matches the path.- Parameters:
path- full attribute path- Returns:
- index of row or
-1, if path does not match
-
getRowPath
public static java.lang.String getRowPath(java.lang.String path)
Parses full attribute path for i.e. editor or validation violation and extracts a path relative to single row object from it.- Parameters:
path- full attribute path- Returns:
- row object path, empty string if a path point exactly to object or
nullif path does not match row object path
-
getArrayPath
public static java.lang.String getArrayPath(java.lang.String path)
Parses full attribute path for i.e. editor or validation violation and extracts a path that points to property containing array value.- Parameters:
path- full attribute path- Returns:
- array path or
nullif path does not match row object path
-
setListheaderSortState
public void setListheaderSortState(ListheaderSortState listheaderSortState)
-
getListheaderSortState
public java.util.Optional<ListheaderSortState> getListheaderSortState()
-
removeRowState
public void removeRowState(T row)
Removes a row bound to provided row object- Parameters:
row- row object
-
removeAllRowStates
public void removeAllRowStates()
Resets all row states
-
addRowState
public RowState<T> addRowState(T row)
Adds new row state bound to provided row object. If editor's state already contains a row for this object, then nothing is changed and it's state is returned.- Parameters:
row- row object to be added- Returns:
- state of row bound to provided row object
-
refreshRowStateReference
public void refreshRowStateReference(T row)
-
getRowState
public RowState<T> getRowState(T row)
Gets a state of row bound to provided object.- Parameters:
row- row object- Returns:
- state of row or
nullif no row is bound to provided object
-
getRowIndex
public int getRowIndex(T row)
Gets index of row bound to provided object- Parameters:
row- row object- Returns:
- index of row or
-1if no row is bound to provided object
-
getRowPath
public java.lang.String getRowPath(int rowIndex)
Gets a path to specified row, relative to current editor.- Parameters:
rowIndex- index of row- Returns:
- path to object bound to specified row
-
updateValidationResult
public ValidationResult updateValidationResult(T row, java.util.List<ValidationInfo> validationInfos)
Sets new validation violations of specified row- Parameters:
row- row objectvalidationInfos- new violations- Returns:
- validation result of row after modification
-
collectValidationResult
public ValidationResult collectValidationResult()
Creates new instance ofValidationResultthat contains validation violations for all rows. Violations for each row is available under prefix equal to its index.- Returns:
- collected validation results for all rows
-
getValidationResult
public ValidationResult getValidationResult(T row)
Gets validation result of specified row- Parameters:
row- row object- Returns:
- validation result of row bound to provided object or
ValidationResult.EMPTYif no row bound to object
-
validationChanged
public void validationChanged(java.lang.String path)
Notifies all validation observers about changes in violations.- Parameters:
path- path relative to current editor- See Also:
getRowPath(int)
-
getObservable
protected com.hybris.cockpitng.editor.extendedmultireferenceeditor.state.EditorState.ValidationObservable getObservable()
-
getValidationObservable
public Observable getValidationObservable()
-
getRowStates
public java.util.Collection<RowState> getRowStates()
Gets states of all rows defined for editor- Returns:
- states of all rows
-
getEntries
public java.util.Collection<java.util.Map.Entry<T,RowState>> getEntries()
Gets states of all rows with object bound to them- Returns:
- entries representing a row object with its state
-
getRow
public T getRow(int index)
Gets an object bound to row on specified index- Parameters:
index- row index- Returns:
- object bound to row or
nullif no row is defined on specified index
-
afterDesktopChanged
public void afterDesktopChanged()
Description copied from interface:DesktopAwareMethod that is fired when desktop is changed i.e. this method is called only when the desktop is changed on the client side.Note: This method isn't invoked by framework i.e. it has to be called within custom code.
- Specified by:
afterDesktopChangedin interfaceDesktopAware
-
-