This package provides an example of a mechanism that adds files - contained in a folder and all of its subfolders -
to a list (Record attribute). The base folder is selected by the user.
The images below show the selection of a folder and the complete list of all files contained in this folder.
![](http://www.adoxx.org/live/documents/10157/86684/File_selection_preview_1.png/c1e37e10-5006-4a51-b88e-770080cf5c7d?t=1395139281720)
![](http://www.adoxx.org/live/documents/10157/86684/File_selection_preview_2.png/74c623f1-4a34-4af2-8372-4b9f26fd1614?t=1395139282041)
DownloadsThe files below contain an example library (File selection.abl) and an example model (File selection demo model.adl). A step-by-step configuration guide is presented in the Hands-On section below. It completely describes how to build this example library and contains the code of the mechanism.
File selection.abl
File selection demo model.adl Description of the Mechanism
![](http://www.adoxx.org/live/documents/10157/86684/01_description_of_algorithm.png/db703e67-eea9-4093-9e18-5a061a065b65?t=1395849471920)
Functionality provided by ADOxx
![](http://www.adoxx.org/live/documents/10157/86684/02_adoxx_functionality.png/3b9c3e42-398e-4148-b65e-ce5363524337?t=1395849625241)
ADOxx Realisation Approach
![](http://www.adoxx.org/live/documents/10157/86684/03_realisation_on_adoxx.png/7c8b543a-49da-432a-8580-5ba50cd1cd38?t=1395849805453)
Used Modeling Language for Demonstration of the Mechanism- modeltype: File Selection Sample
- classes: A, List of files (Record class)
- attributes: Import files, List of files.
Hands-On1) PreparationsCreation of before mentioned classes & attributes for the sake of a minimal working example. This step can be skipped – import
File selection.abl instead.
a) Create new record class List of files![](http://www.adoxx.org/live/documents/10157/86684/04_create_record_class.png/7f72f5c9-b7d5-4384-b261-849249a74989?t=1395850887560)
- Go to the Library management, select an Application library and click Class hierarchy.
- Unfold Record classes, select Record classes and click New --> New record class…
- Name new record class List of files.
b) Add new attribute to record class List of files
![](http://www.adoxx.org/live/documents/10157/86684/05_attribute_for_record_class.png/655aead5-7a7f-421e-b96c-3da0eafe6d5e?t=1395851174827)
- Select record class List of files
- Click New --> New attribute...
- Name new attributes and select type according figure above: name: Filename, type: String
c) Configure AttrRep attribute of List of files record class![](http://www.adoxx.org/live/documents/10157/86684/06_conf_attrrep_rec_class.png/b2ebe3fd-74d6-433b-b52f-f27c82e019e7?t=1395851508146)
- Double click on AttrRep attribute
- Set Standard value:
1NOTEBOOK
2ATTR "Filename" width:20
d) Create class A![](http://www.adoxx.org/live/documents/10157/86684/07_create_class_A.png/dfaf5908-087c-4193-8ebe-a87abe84a316?t=1395851796647)
- Go to the dynamic library and click Class hierarchy.
- Click View and select Metamodel.
- Select __D-construct__ (Metamodel)
- Click New --> New class; name it A
e) Add new attributes to class A![](http://www.adoxx.org/live/documents/10157/86684/08_attributes_for_A.png/5492bd75-3de4-424b-a647-237791292020?t=1395852034719)
- Select class A
- Click New --> New attribute...
- Name new attributes and select type according figure above: (1) name: Import files, type: Programcall (2) name: List of Files, type: Record --> select List of files as referenced record class after clicking OK.
f) Configure Import files attribute![](http://www.adoxx.org/live/documents/10157/86684/09_conf_import_files_attribute.png/3cb5e516-3a18-4a2a-ad8f-42a44dae1e12?t=1395852572777)
- Double click on Import files attribute
- Set Standard value to Import files
- Click Facets and set EnumerationDomain to
1ITEM "Import files"
2SETG g_callingObjectID: ( objid )
3EXECUTE file: "db:\\ImportFiles.asc"
- Make sure that the file ImportFiles.asc is contained in the ADOxx database.
g) Configure AttrRep attribute (of class A)- Double click on AttrRep attribute
- Set Standard value:
1NOTEBOOK
2CHAPTER "Description"
3ATTR "Name"
4ATTR "Import files" push-button no-param
5ATTR "List of files"
h) Configure GraphRep attribute (of class A)- Go to class A.
- Double click GraphRep (Metamodel).
- Click the Dialog button.
- Enter:
1GRAPHREP
2SHADOW off
3FILL color:blue
4ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm
5ATTR "Name" x:0.00cm y:1.0cm w:c
i) Definine Modeltype![](http://www.adoxx.org/live/documents/10157/86684/10_define_mt.png/3c39829e-79f0-45d3-8981-732d18adb3cd?t=1395853279570)
- Go back to the Library management and select your current Dynamic Library.
- Click Library attributes… --> Add-ons and define the following model type according the figure above:
1MODELTYPE "File Selection Sample" from:none plural:"File Selection Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp"
2INCL "A"
2) Implementation of Mechanism with AdoScript 1
2# get objid (see "Import files" attribute)
3SET id_crtObjID: ( g_callingObjectID )
4
5#open dialog
6CC "AdoScript" DIRECTORY_DIALOG
7SETL s_selectedPath: ( path )
8
9# add file path of files contained in selected folder to the record
10IF ( endbutton = "ok") {
11 IMPORT_FROM_FOLDER ( s_selectedPath)
12}
13
14
15PROCEDURE IMPORT_FROM_FOLDER string: folderpath {
16 CC "AdoScript" DIR_LIST path: (folderpath)
17
18 SETL s_filesInPath: ( files )
19 SETL s_foldersInPath: ( dirs )
20 FOR sFileName in: (s_filesInPath) sep: ("*") {
21 CC "Core" GET_CLASS_ID objid: (id_crtObjID)
22 SETL id_crtClassID: ( classid )
23
24 CC "Core" GET_ATTR_ID classid: (id_crtClassID) attrname: ("List of files")
25 SETL id_loadedFilesAttrID: ( attrid )
26 # add new row to record
27 CC "Core" ADD_REC_ROW objid: (id_crtObjID) attrid: (id_loadedFilesAttrID)
28 SETL id_newRowID: ( rowid )
29 # write file path into new row
30 CC "Core" SET_ATTR_VAL objid: (id_newRowID) attrname: ("Filename") val: ( folderpath + sFileName) as-string
31 }
32 # apply procedure on subfolders:
33 FOR sFolderName in: (s_foldersInPath) sep: ("*") {
34 IMPORT_FROM_FOLDER (folderpath + sFolderName + "\\")
35 }
36}
Result