Form S_172FSN - Manage snippets

LANSA

Form S_172FSN - Manage snippets

* ===================================================================;
*;
* Component : S_172FSN;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
* ;
* Description : Manage snippets ;
*;
* Disclaimer : The following material is supplied as sample material ;
* only. No warranty concerning this material or its use ;
* in any way whatsoever is expressed or implied. ;
* ;
* ===================================================================;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) HEIGHT(552) LAYOUTMANAGER(#ATLM_1) LEFT(622) TOP(58) VISUALSTYLE(#VS_NORM) WIDTH(133);
;
DEFINE_COM CLASS(#S_172FSO) NAME(#SNIPPETEDITOR);
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#EDIT_SNIPPET) CAPTION('Edit Snippet') DISPLAYPOSITION(1) ENABLED(False) HEIGHT(18) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TOP(421) WIDTH(125);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_1) ATTACHMENT(Bottom) MANAGE(#EDIT_SNIPPET) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#NEW_SNIPPET) CAPTION('New Snippet') DISPLAYPOSITION(2) HEIGHT(18) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(2) TOP(439) WIDTH(125);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_2) ATTACHMENT(Bottom) MANAGE(#NEW_SNIPPET) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_TRVW) NAME(#TREE) DISPLAYPOSITION(3) HEIGHT(421) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(3) TOP(0) WIDTH(125);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_3) ATTACHMENT(Center) MANAGE(#TREE) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_TVCL) NAME(#TVCL_1) DISPLAYPOSITION(1) KEYPOSITION(1) LEVEL(1) PARENT(#TREE) SOURCE(#STD_TEXTS);
DEFINE_COM CLASS(#PRIM_TVCL) NAME(#TVCL_2) DISPLAYPOSITION(1) KEYPOSITION(1) LEVEL(2) PARENT(#TREE) SOURCE(#STD_TEXT);
DEFINE_COM CLASS(#PRIM_MEMO) NAME(#MEMO) CURRENTLINE(1) DISPLAYPOSITION(5) LEFT(0) MAXIMUMLINELENGTH(256) PARENT(#COM_OWNER) TABPOSITION(4) TOP(475) VISIBLE(False) WIDTH(125);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_4) ATTACHMENT(Bottom) MANAGE(#MEMO) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_MECL) NAME(#MECL_1) COLUMNROLE(Data) DISPLAYPOSITION(1) PARENT(#MEMO) SOURCE(#SYSVAR$AV) WIDTH(20);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#DELETE_SNIPPET) CAPTION('Delete Snippet') DISPLAYPOSITION(4) ENABLED(False) HEIGHT(18) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(5) TOP(457) WIDTH(125);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_5) ATTACHMENT(Bottom) MANAGE(#DELETE_SNIPPET) PARENT(#ATLM_1);
;
* Initialize this form;
;
EVTROUTINE handling(#com_owner.Initialize);
SET #com_owner caption('Snippets');
Invoke #SNIPPETEDITOR.EnumerateSnippets ;
ENDROUTINE;
;
* Handle snippet editor finding a snippet ;
;
EVTROUTINE HANDLING(#SNIPPETEDITOR.SnippetFound)SnippetGroup(#SnippetGroup) SnippetName(#SnippetName) ;
Change #Std_TextS #SnippetGroup.Value;
Change #Std_Text #SnippetName.Value;
Add_Entry #Tree;
ENDROUTINE;
;
* Handle a new snippet;
;
Evtroutine Handling(#New_Snippet.Click);
Invoke #SNIPPETEDITOR.NewSnippet SnippetGroup(#Std_Texts);
EndRoutine;
;
* Handle deleting a snippet;
;
Evtroutine Handling(#Delete_Snippet.Click);
Invoke #SNIPPETEDITOR.DeleteSnippet SnippetGroup(#Std_Texts) SnippetName(#Std_Text) ;
EndRoutine;
;
* Handle editing a snippet;
;
Evtroutine Handling(#Edit_Snippet.Click #Tree.DoubleClick);
Invoke #SNIPPETEDITOR.EditSnippet SnippetGroup(#Std_Texts) SnippetName(#Std_Text) ;
EndRoutine;
;
* Handle selection of a snippet in the tree;
;
EVTROUTINE HANDLING(#TREE.ItemGotFocus) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
If '#Tree.CurrentItem.Level = 2';
Define #OV_Retc *char 2 ;
Set (#Edit_Snippet #Delete_Snippet) Enabled(True);
Clr_list #Memo;
Invoke #SNIPPETEDITOR.MakeFileName SnippetGroup(#Std_Texts) SnippetName(#Std_Text) FileName(#SysVar$av);
USE BUILTIN(TRANSFORM_FILE) WITH_ARGS(#Memo #SysVar$av T B Y) TO_GET(#OV_RETC);
Invoke #Memo.SelectAll;
Invoke #Memo.Copy;
Else;
Set (#Edit_Snippet #Delete_Snippet) Enabled(False);
Endif;
ENDROUTINE;
;
* Handle a request to rebuild the snippets;
;
EVTROUTINE HANDLING(#SNIPPETEDITOR.SnippetModified) ;
Clr_List #Tree;
Invoke #SNIPPETEDITOR.EnumerateSnippets ;
ENDROUTINE;
;
END_COM;