Refreshing Explorer Component Content

Date:Archived
Product/Release:Visual LANSA
Abstract:Example of how to refresh Explorer Component content i.e. new files and directories
Submitted By:LANSA Technical Support

Description:

When using two Explorer Components in a Form which are notifying each other, for example, one showing the directories and the other the files in the directory, if a new file is added to the current directory, the component displaying the files is not updated by using the UpdateDisplay Method. This issue will be resolved in a future version of Visual LANSA. In the meantime, the workaround below will achieve the same result.

Solution:

The source code provided in this example uses the F5 key to destroy and recreate the two explorer components.

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Height(662) Layoutmanager(#SPLM_1) Left(58) Top(109) Width(943)
* L A Y O U T I T E M S
Define_Com Class(#PRIM_SPLM) Name(#SPLM_1)  Orientation(Vertical)
Define_Com Class(#PRIM_PANL) Name(#PANL_1) Displayposition(1) Height(635) Layoutmanager(#ATLM_1) Left(0) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(0) Width(468)
Define_Com Class(#PRIM_PANL) Name(#PANL_2) Displayposition(2) Height(635) Layoutmanager(#ATLM_1) Left(472) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(0) Width(463)
Define_Com Class(#PRIM_SPLI) Name(#SPLI_1) Manage(#PANL_1) Parent(#SPLM_1) Weight(1)
Define_Com Class(#PRIM_SPLI) Name(#SPLI_2) Manage(#PANL_2) Parent(#SPLM_1) Weight(1)
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Parent(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_2) Attachment(Center) Parent(#ATLM_1)
Define_Com Class(#PRIM_STPG) Name(#STPG_1) Parent(#COM_OWNER) Shortcut(F5)

* D Y N A M I C R E F E R E N C E S
Define_Com Class(#prim_dcbx) Name(#exp_left) Reference(*dynamic)
Define_Com Class(#prim_dcbx) Name(#exp_Right) Reference(*dynamic)

* On creation of the form
Evtroutine Handling(#com_owner.CreateInstance)
Set Com(#com_owner) Caption(*component_desc)
Execute Subroutine(CRT_LEFT)
Execute Subroutine(CRT_RIGHT)
Endroutine

* When F5 pressed, destroy and recreate explorer components
Evtroutine Handling(#STPG_1.Pressed) Options(*NOCLEARMESSAGES *NOCLEARERRORS)

* Destroy Left hand side
If_Ref Com(#exp_left) Is_Not(*null)
Set_Ref Com(#exp_left) To(*null)
Endif

* Destroy Right hand side
If_Ref Com(#exp_right) Is_Not(*null)
Set_Ref Com(#exp_right) To(*null)
Endif

* Recreate current instance
Execute Subroutine(CRT_LEFT)
Execute Subroutine(CRT_RIGHT)
Invoke Method(#exp_left.Realize)
Invoke Method(#exp_Right.Realize)

* Resposition path to the last known Path
Set Com(#exp_left #exp_right) Path(#std_qord)
Endroutine

Subroutine Name(CRT_LEFT)

* Create Instance of an explorer component
Set_Ref Com(#exp_left) To(*Create_as #prim_dcbx)

* Specify parentControl of Right Explorer
Set Com(#exp_left) Parent(#Panl_1)

* Ensure layout item controls size
Set Com(#atli_1) Manage(#exp_left)
Endroutine

Subroutine Name(CRT_RIGHT)

* Create Instance of an explorer component
Set_Ref Com(#exp_right) To(*Create_as #prim_dcbx)

* Specify parent and Display style of List View
Set Com(#exp_Right) Parent(#PANL_2) Displaystyle(GeneralListView)

* Ensure layout item controls size
Set Com(#atli_2) Manage(#exp_right)

* Set Left side to control right side
Set Com(#exp_left) Notifycomponent(#exp_right)
Endroutine

Evtroutine Handling(#EXP_LEFT.ItemGotFocus #EXP_Right.ItemGotFocus) Path(#path) Pathtype(#Pathtype)

* When an item is Focus on either, if not an individual item, store path
If Cond('#pathtype *ne File')
Set Com(#com_owner) Caption(#path)

* Store Current path
Change Field(#STD_QORD) To('#exp_left.path')
Endif
Endroutine
End_Com