Class HighlightChangesWidget

java.lang.Object
com.orchestranetworks.ui.form.widget.UICustomWidget
com.orchestranetworks.ui.form.widget.UISimpleCustomWidget
com.apgar.common.lib.ui.widget.highlightwidget.HighlightChangesWidget
All Implemented Interfaces:
com.orchestranetworks.ui.form.widget.UIWidget

public class HighlightChangesWidget extends com.orchestranetworks.ui.form.widget.UISimpleCustomWidget
Highlight Changes Widget Class which highlight the changes for a record in a child dataspace and this same record in its parent dataspace (snapshot).

Usage:

  • Position the widget on each field as needed and set the "master" flag on the field to be displayed first.
  • The master is the one that will process the comparison.
  • Other widgets will try to retrieve the master.
  • The lowest level of detail achievable by this widget is at the level of the field.

Some notes to consider:

  1. Only one master field set to "true" is necessary per table, because this flag will perform a comparison between child and parent dataspaces, create a hidden div, and display it based on this boolean.
  2. If the widget is set on an association, make sure to apply "true" to the master field only if it is displayable on the outside (in the association table columns), otherwise the highlight will not appear.
  3. If there is a need to use a second widget, the customWidgetClass param can be set to this second widget class. This widget class needs to extend the CustomWidget class.

The following is an overview of the different use cases of this widget class.

 <!-- Case of field in Association Update (Record is assosciated to a different Record) : Highlight All Fields -->
 <div style='display:none' id='master + PK'>
   <div id='REC_ + PK'>
       <span id='MASTER_ + FIELDPATH1 + PK'>null</span>
       <span id='MASTER_ + FIELDPATH2 + PK'>null</span>
       <!-- All fields to be highlighted -->
   </div>
 </div>

 <!-- Case of field in Association Update : Highlight Changed Fields only -->
 <div style='display:none' id='master + PK'>
   <div id='REC_ + PK'>
       <span id='MASTER_ + FIELDPATH1 + PK'>Old Value 1</span>
       <span id='MASTER_ + FIELDPATH2 + PK'>Old Value 2</span>
   </div>
 </div>

 <!-- Case of normal fields Update -->
 <div style='display:none' id='master + PK'>
   <div id='REC_ + PK'>
       <span id='MASTER_ + FIELDPATH1 + PK'>Old Value 1</span>
       <span id='MASTER_ + FIELDPATH2 + PK'>Old Value 2</span>
   </div>
 </div>

 <!-- Case of record creation -->
 <div style='display:none' id='master + PK'>
   <div id='REC_ + PK'>
       <span id='MASTER_ + FIELDPATH1 + PK'>null</span>
       <span id='MASTER_ + FIELDPATH2 + PK'>null</span>
       <!-- All fields to be highlighted -->
   </div>
 </div>

 <!-- Case of record not yet created -->
 <div style='display:none' id='master + PK'>
 </div>
  
 <!-- When Drawing a Field -->
 <span id='span + SLAVE_ + FIELDPATH + PK'>
   <div id='SLAVE_ + FIELDPATH + PK'>
       <!-- Field Rendering Goes Here -->
   </div>
 </span>

 <!-- slaveId = 'SLAVE_ + FIELDPATH + PK' -->
 <!-- masterId = 'MASTER_ + FIELDPATH + PK' -->
 <!-- recordId = 'REC_ + PK' -->

 <script>
   highlightField+PK('SLAVE_ + FIELDPATH + PK', 'MASTER_ + FIELDPATH + PK', 'REC_ + PK', isListField);
 </script>
 
Author:
APGAR Consulting
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Prefix of the master field used when drawing the widget.
    static final String
    Prefix of the slave used when drawing the widget.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HighlightChangesWidget(com.orchestranetworks.schema.Path nodePath, com.orchestranetworks.ui.form.widget.WidgetFactoryContext widgetFactoryContext, HighlightChangesWidgetFactory factoryInstance)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setColorCodeOnAssociationChange(String colorCodeOnAssociationChange)
    Sets a custom color code to identify associationChange.
    void
    setColorCodeOnCreate(String colorCodeOnCreate)
    Sets a custom color code to identify creations.
    void
    setColorCodeOnUpdate(String colorCodeOnUpdate)
    Sets a custom color code to identify updates.
    void
    setCustomWidget(boolean isCustomWidget)
    Sets the isCustomWidget, which specifies that a second widget is used.
    void
    setCustomWidgetClass(String customWidgetClass)
    Sets the customWidgetClass, which specifies the second widget used.
    void
    setCustomWidgetModuleName(String customWidgetModuleName)
    Sets the customWidgetModuleName, which is the module name from which the custom widget class is loaded.
    void
    setCustomWidgetParams(String customWidgetParams)
    Sets the customWidgetParams, which will be used to draw the widget in case of isCustomWidget = true.
    void
    Sets the instance of the factory class of the widget.
    void
    setFieldOnChangeJSMethod(String fieldOnChangeJSMethod)
    Sets the name of the JavaScript Method called on field change.
    void
    setFkInAssociation(Boolean fkInAssociation)
    Sets the fkInAssociation field which detects changes in an association when the PK of the associated records is not a FK to the main record.
    void
    setLinkToRecord(boolean isLinkToRecord)
    Sets the isLinkToRecord field which specifies that a "Link to record" widget is drawn.
    void
    setLinkToRecordBranch(String linkToRecordBranch)
    Sets the linkToRecordBranch field which is the target dataspace of the record to be linked through the widget.
    void
    setLinkToRecordContainer(String linkToRecordContainer)
    Sets the linkToRecordContainer field which is the target dataset of the record to be linked through the widget.
    void
    setLinkToRecordKeyFieldPath(String linkToRecordKeyFieldPath)
    Sets the linkToRecordKeyFieldPath field which is a field of the target record to be linked through the widget based on this field's value.
    void
    setLinkToRecordTablePath(String linkToRecordTablePath)
    Sets the linkToRecordTablePath field which is the target table path of the record to be linked through the widget.
    void
    setMaster(boolean isMaster)
    Sets the master flag used to compare between the parent and child dataspace to perform the highlighting accordingly.
    void
    setReadOnly(boolean isReadOnly)
    Sets the widget to be read-only.
    void
    setReadOnlyCondition(String readOnlyCondition)
    Sets the condition for setting the widget to be read-only.
    void
    setReadOnlyFieldToCheck(String readOnlyFieldToCheck)
    Sets the field to be checked, if it meets the isReadOnlyOnCondition, the widget will be read-only.
    void
    setReadOnlyOnCondition(boolean isReadOnlyOnCondition)
    Sets the widget to be read-only if a condition is verified.
    void
    setUseEbxDefaultColor(boolean useEbxDefaultColor)
    Sets the useEbxDefaultColor field which if true, the widget attempts to use the default EBX color.
    void
    write(com.orchestranetworks.ui.form.widget.WidgetWriter widgetWriter, com.orchestranetworks.ui.form.widget.WidgetDisplayContext displayContext)
    Defines and draws the widget depending on the parameters of the HighlightChangesWidgetFactory instance.

    Methods inherited from class com.orchestranetworks.ui.form.widget.UISimpleCustomWidget

    validate

    Methods inherited from class com.orchestranetworks.ui.form.widget.UICustomWidget

    isDisplayingCustomWidgetValidationMessage, isEditorDisabled, setEditorDisabled, zza, zza, zzb

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MASTER_FIELD_PREFIX

      public static final String MASTER_FIELD_PREFIX
      Prefix of the master field used when drawing the widget.
      See Also:
    • SLAVE_FIELD_PREFIX

      public static final String SLAVE_FIELD_PREFIX
      Prefix of the slave used when drawing the widget.
      See Also:
  • Constructor Details

    • HighlightChangesWidget

      public HighlightChangesWidget(com.orchestranetworks.schema.Path nodePath, com.orchestranetworks.ui.form.widget.WidgetFactoryContext widgetFactoryContext, HighlightChangesWidgetFactory factoryInstance)
      Constructor.
      Parameters:
      nodePath - Path
      widgetFactoryContext - WidgetFactoryContext
      factoryInstance - Instance of HighlightChangesWidgetFactory
  • Method Details

    • write

      public void write(com.orchestranetworks.ui.form.widget.WidgetWriter widgetWriter, com.orchestranetworks.ui.form.widget.WidgetDisplayContext displayContext)
      Defines and draws the widget depending on the parameters of the HighlightChangesWidgetFactory instance.
      Specified by:
      write in class com.orchestranetworks.ui.form.widget.UISimpleCustomWidget
      Parameters:
      widgetWriter - WidgetWriter
      displayContext - WidgetDisplayContext
    • setFactoryInstance

      public void setFactoryInstance(HighlightChangesWidgetFactory factoryInstance)
      Sets the instance of the factory class of the widget.
      Parameters:
      factoryInstance - HighlightChangesWidgetFactory
    • setMaster

      public void setMaster(boolean isMaster)
      Sets the master flag used to compare between the parent and child dataspace to perform the highlighting accordingly.
      Parameters:
      isMaster - Boolean value
    • setFkInAssociation

      public void setFkInAssociation(Boolean fkInAssociation)
      Sets the fkInAssociation field which detects changes in an association when the PK of the associated records is not a FK to the main record.
      Parameters:
      fkInAssociation - Boolean value
    • setReadOnly

      public void setReadOnly(boolean isReadOnly)
      Sets the widget to be read-only.
      Parameters:
      isReadOnly - Boolean value
    • setReadOnlyOnCondition

      public void setReadOnlyOnCondition(boolean isReadOnlyOnCondition)
      Sets the widget to be read-only if a condition is verified.
      Parameters:
      isReadOnlyOnCondition - Boolean value
    • setReadOnlyFieldToCheck

      public void setReadOnlyFieldToCheck(String readOnlyFieldToCheck)
      Sets the field to be checked, if it meets the isReadOnlyOnCondition, the widget will be read-only.
      Parameters:
      readOnlyFieldToCheck - Path of field to check
    • setReadOnlyCondition

      public void setReadOnlyCondition(String readOnlyCondition)
      Sets the condition for setting the widget to be read-only.
      Parameters:
      readOnlyCondition - String value which the readOnlyFieldToCheck value will be compared to.
    • setCustomWidget

      public void setCustomWidget(boolean isCustomWidget)
      Sets the isCustomWidget, which specifies that a second widget is used.
      Parameters:
      isCustomWidget - Boolean value
    • setCustomWidgetClass

      public void setCustomWidgetClass(String customWidgetClass)
      Sets the customWidgetClass, which specifies the second widget used.
      Parameters:
      customWidgetClass - Class in binary name format
    • setCustomWidgetModuleName

      public void setCustomWidgetModuleName(String customWidgetModuleName)
      Sets the customWidgetModuleName, which is the module name from which the custom widget class is loaded.
      Parameters:
      customWidgetModuleName - Module Name as String
    • setCustomWidgetParams

      public void setCustomWidgetParams(String customWidgetParams)
      Sets the customWidgetParams, which will be used to draw the widget in case of isCustomWidget = true.
      Parameters:
      customWidgetParams - Parameters as JSON String.
    • setLinkToRecord

      public void setLinkToRecord(boolean isLinkToRecord)
      Sets the isLinkToRecord field which specifies that a "Link to record" widget is drawn.
      Parameters:
      isLinkToRecord - Boolean value
    • setLinkToRecordBranch

      public void setLinkToRecordBranch(String linkToRecordBranch)
      Sets the linkToRecordBranch field which is the target dataspace of the record to be linked through the widget.
      Parameters:
      linkToRecordBranch - Record Branch name as a String
    • setLinkToRecordContainer

      public void setLinkToRecordContainer(String linkToRecordContainer)
      Sets the linkToRecordContainer field which is the target dataset of the record to be linked through the widget.
      Parameters:
      linkToRecordContainer - Record Container name as a String
    • setLinkToRecordTablePath

      public void setLinkToRecordTablePath(String linkToRecordTablePath)
      Sets the linkToRecordTablePath field which is the target table path of the record to be linked through the widget.
      Parameters:
      linkToRecordTablePath - Record Table path as a String
    • setLinkToRecordKeyFieldPath

      public void setLinkToRecordKeyFieldPath(String linkToRecordKeyFieldPath)
      Sets the linkToRecordKeyFieldPath field which is a field of the target record to be linked through the widget based on this field's value.
      Parameters:
      linkToRecordKeyFieldPath - Record Key field path as a String
    • setFieldOnChangeJSMethod

      public void setFieldOnChangeJSMethod(String fieldOnChangeJSMethod)
      Sets the name of the JavaScript Method called on field change.
      Parameters:
      fieldOnChangeJSMethod - String name of the JavaScript Method for field change
    • setColorCodeOnUpdate

      public void setColorCodeOnUpdate(String colorCodeOnUpdate)
      Sets a custom color code to identify updates.
      Parameters:
      colorCodeOnUpdate - Color code in String format
    • setColorCodeOnCreate

      public void setColorCodeOnCreate(String colorCodeOnCreate)
      Sets a custom color code to identify creations.
      Parameters:
      colorCodeOnCreate - Color code in String format
    • setColorCodeOnAssociationChange

      public void setColorCodeOnAssociationChange(String colorCodeOnAssociationChange)
      Sets a custom color code to identify associationChange.
      Parameters:
      colorCodeOnAssociationChange - Color code in String format
    • setUseEbxDefaultColor

      public void setUseEbxDefaultColor(boolean useEbxDefaultColor)
      Sets the useEbxDefaultColor field which if true, the widget attempts to use the default EBX color.
      Parameters:
      useEbxDefaultColor - Boolean value