-
Notifications
You must be signed in to change notification settings - Fork 2
/
Baseline_Creator.dxl
403 lines (312 loc) · 12.1 KB
/
Baseline_Creator.dxl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/* ***************************************************************************************
\file Baseline_Creator.dxl
\brief Create baseline for selected modules
\author nguye003
\date 18.07.2019
\note (C) Copyright Leopold Kostal GmbH&Co KG \n\n
Contents and presentations are protected world-wide.\n
Any kind of using, copying etc. is prohibited without prior permission. \n
All rights - incl. industrial property rights - are reserved.
******************************************************************************************/
DB dialogBox = null
DBE frameMiniExploreDBE = null
DBE miniExplorerDBE = null
DBE frameMultiListDBE = null
DBE multiListDBE = null
DBE runButtonDBE = null
DBE addNewFolderButtonDBE = null
DBE setSuffixDBE = null
DBE setDescriptionDBE = null
DBE major_minor_baselineDBE = null
const string dummyArray[] = {}
const int MINI_EXP_LINK_MODS = 4
const string str_choice_radioBox[] = {"Major Baseline", "Minor Baseline"}
int itemMask = MINI_EXP_LINK_MODS
/******************************* Support Functions *************************************/
/** Get all module name in folder/subfolder **/
void get_all_module_name_in_folder_subfolder(Folder f, Skip &sk_module_in_folder_sub_folder, int &counter_module){
Item i
Item it
Project p
for i in f do{
if(isDeleted(i)) continue
if(type(i) == "Folder"){
//Recursion to get skip list modules
get_all_module_name_in_folder_subfolder(folder(fullName(i)), sk_module_in_folder_sub_folder, counter_module)
}
else if(type(i) == "Formal" || type(i) == "Descriptive"){
//If item is module -> save in skip list
put(sk_module_in_folder_sub_folder, fullName(i), fullName(i))
counter_module++
}
else if(type(i) == "Project"){
p = project(fullName(i))
//Get all item which is module in project
for it in p do{
if(type(it) == "Formal" || type(it) == "Descriptive"){
put(sk_module_in_folder_sub_folder, fullName(it), fullName(it))
counter_module++
}
}
}
}
}
/** add module in folder to multiListDBE **/
void add_new_folder_to_multiListDBE(string str_selected_item){
int counter_module = 0
Folder f = folder(str_selected_item)
Skip sk_module_in_folder_sub_folder = createString
get_all_module_name_in_folder_subfolder(f, sk_module_in_folder_sub_folder, counter_module)
string str_all_selected_module[counter_module]
int index_DBE = 0
string str_module_name = ""
for str_module_name in sk_module_in_folder_sub_folder do{
insert(multiListDBE, index_DBE++, str_module_name)
}
delete sk_module_in_folder_sub_folder
}
/****************************** Button Functions ***************************************/
/** Button add new project/folder/module **/
void add_new_item_to_multiListDBE(DB dialogBox){
Item i
Project p
int index_DBE = 0
string str_selected_item = getRealPath(dbSep get(miniExplorerDBE))
empty(multiListDBE)
if(type(item(str_selected_item))=="Folder"){
add_new_folder_to_multiListDBE(str_selected_item)
}else if(type(item(str_selected_item))=="Project"){
p = project(str_selected_item)
for i in p do{
if(type(i) == "Formal" || type(i) == "Descriptive"){
insert(multiListDBE, index_DBE++, fullName(i))
}
}
}else if(type(item(str_selected_item))=="Formal" || type(item(str_selected_item)) == "Descriptive"){
insert(multiListDBE, index_DBE, str_selected_item)
}
}
/** Run button **/
void run_button(DB dialogBox){
Module mod = null
Baseline b = null
string str_selected_module = ""
string str_suffix = ""
string str_description = ""
int count_selected_module = 0
int choice_radioBox = 0
int check_suffix = 0
bool bl_create_successful = true
char inappropriate_suffix
Skip sk_all_selected_module = createString
//Get all selected module. Save in skip list
for str_selected_module in multiListDBE do{
count_selected_module++
put(sk_all_selected_module, str_selected_module, str_selected_module)
}
if(count_selected_module != 0){
//Get written suffix
str_suffix = get setSuffixDBE
//Get written description
str_description = get setDescriptionDBE
//Get inappropriate char in suffix
inappropriate_suffix = getInvalidCharInSuffix(str_suffix)
//Convert inappropriate char to integer
check_suffix = intOf(inappropriate_suffix)
//Get selected major or minor
choice_radioBox = get major_minor_baselineDBE
if(check_suffix != 0){
print "Input suffix '"str_suffix "' is inappropriate.\n\n"
bl_create_successful = false
}else{
str_selected_module = ""
for str_selected_module in sk_all_selected_module do{
mod = edit(str_selected_module, false)
if(null mod){
print "Cannot open module " str_selected_module ".\n\n"
bl_create_successful = false
}else{
if(isEdit(mod)){
//Create major baseline
if(choice_radioBox == 0){
create(nextMajor str_suffix, str_description)
b = getMostRecentBaseline(mod)
print "Created successful major baseline "(major b)"."(minor b) " with suffix "(suffix b)" and description "(annotation b)" for module "str_selected_module ".\n\n"
}else{ // Create minor baseline
create(nextMinor str_suffix, str_description)
b = getMostRecentBaseline(mod)
print "Created successful minor baseline "(major b)"."(minor b) " with suffix "(suffix b)" and description "(annotation b)" for module "str_selected_module ".\n\n"
}
b = null
}else{
print "Module "str_selected_module" is not in write mode.\n\n"
bl_create_successful = false
}
//Close and save module
close(mod, true)
}
}
}
if(bl_create_successful){
infoBox "Created successful baseline for all selected modules."
}else{
ack "Error. See DXL-Interaction Window for errors."
}
}else{
ack "Select at least one module.\n"
}
delete sk_all_selected_module
}
/************************** MiniExplore Functions ***************************************/
// Returns whether or not the selected item in the tree view matches the type of module the
// tree view was created to be able to select
bool itemMatchesSelectedMask(Item itm) {
bool matchesMask = false;
if(type(itm) == "Formal" && ((itemMask & MINI_EXP_FORMAL_MODS) == MINI_EXP_FORMAL_MODS)) {
matchesMask = true;
}
else if(type(itm) == "Descriptive" && ((itemMask & MINI_EXP_DESCRIPTIVE_MODS) == MINI_EXP_DESCRIPTIVE_MODS)) {
matchesMask = true;
}
return(matchesMask);
}
// Adds a new item to the tree view.
void addItemToTree(DBE dbe, Item i) {
string displayPath = getDisplayPath(i);
// check if the path exists in the tree view
if(exists(miniExplorerDBE, displayPath) == false) {
// check that the item is not deleted or if it is, that the tree view was created with the option
// to show deleted items.
if(isDeleted(i) == false || (isDeleted(i) == true && ((itemMask & MINI_EXP_SHOW_DELETED) == MINI_EXP_SHOW_DELETED))) {
// check item type
if(type(i) == "Folder" || type(i) == "Project") {
Icon iconOpen;
Icon iconClosed;
string sDummyEntry = displayPath dbSep dummyItem;
// assign project or folder specific icons
assignIcons(i, iconOpen, iconClosed);
// add entry (plus dummy)
insert(miniExplorerDBE, displayPath, iconClosed, iconOpen);
insert(miniExplorerDBE, sDummyEntry, iconClosed, iconOpen);
}else {
if(itemMatchesSelectedMask(i)) {
insert(miniExplorerDBE, displayPath, getIcon(i), getIcon(i));
}
}
}
}
}
// Opens the selected Project or Folder in the tree view and loads its containing items.
void displaySelectedBranch(DBE dbe, string sItemPath) {
Folder fStart = folder(getRealPath(sItemPath));
if(fStart != null) {
Item i;
for i in all fStart do {
addItemToTree(miniExplorerDBE, i);
}
}
}
// DBE callback that fires when an item in the tree view is double clicked.
bool doTreeExpand(DBE dbe, string sItem) {
string sItemPath = dbSep sItem;
string sDummyItem = sItemPath dbSep dummyItem;
// check status
if(exists(miniExplorerDBE, sDummyItem) == true) {
// remove dummy
delete(miniExplorerDBE, sDummyItem);
}
// check status
if(theCurrentView == DATABASE_VIEW) {
// adjust view accordingly
displaySelectedBranch(miniExplorerDBE, sItemPath);
}
else {
Project prjOldRoot = getRootProject_();
setRootProject_(project(getRootOfPath sItemPath));
// adjust view accordingly
displaySelectedBranch(miniExplorerDBE, sItemPath);
setRootProject_(prjOldRoot);
}
return(true)
}
// Loads the tree view to start with the passed in folder opened.
void changeToStartFolder(Folder fStart) {
if(!null fStart) {
int i;
// calculate max bound for loop
int finish = length(rootName_(fStart));
// prepare initial path
string sFolderPath = ((theCurrentView == DATABASE_VIEW) ? dbDisplayRoot() : "");
string sCharacter;
// process string
for(i = 0; i <= finish; i++) {
// obtain character
sCharacter = (rootName_(fStart))[i:i]
// check status
if(sCharacter == dbSep || i == finish) {
// check status
if(theCurrentView == PROJECT_VIEW && sFolderPath == dbSep) {
continue;
}
// update explorer
displaySelectedBranch(miniExplorerDBE, sFolderPath);
}
sFolderPath = sFolderPath sCharacter;
}
// update explorer
set(miniExplorerDBE, sFolderPath);
}
else {
// default to database level
displaySelectedBranch(miniExplorerDBE, dbDisplayRoot());
set(miniExplorerDBE, dbDisplayRoot());
}
}
void main(){
string str_project_name = ""
Project projectRoot = null
dialogBox = create("Baseline Creator")
frameMiniExploreDBE = frame(dialogBox, "Select Folder: ", 400, 100)
miniExplorerDBE = treeView(dialogBox, treeViewOptionSorted, 380, 15)
miniExplorerDBE -> "left" -> "inside" -> frameMiniExploreDBE
miniExplorerDBE -> "right" -> "inside" -> frameMiniExploreDBE
miniExplorerDBE -> "top" -> "inside" -> frameMiniExploreDBE
miniExplorerDBE -> "bottom" -> "inside" -> frameMiniExploreDBE
frameMultiListDBE = frame(dialogBox, "Selected modules: ", 400, 100)
Folder f = current
Skip sk_module_in_folder_sub_folder = createString
string str_module_in_current_folder = ""
int counter_module = 0
get_all_module_name_in_folder_subfolder(f, sk_module_in_folder_sub_folder, counter_module)
string str_all_module_in_current_folder[counter_module]
int module_num = 0
for str_module_in_current_folder in sk_module_in_folder_sub_folder do{
str_all_module_in_current_folder[module_num++] = str_module_in_current_folder
}
multiListDBE = multiList(dialogBox, "", 20, str_all_module_in_current_folder, counter_module)
multiListDBE -> "top" -> "inside" -> frameMultiListDBE
multiListDBE -> "bottom" -> "inside" -> frameMultiListDBE
multiListDBE -> "left" -> "inside" -> frameMultiListDBE
multiListDBE -> "right" -> "inside" -> frameMultiListDBE
setSuffixDBE = text(dialogBox, "Set suffix", "",380, 35, false)
setDescriptionDBE = text(dialogBox, "Set Description", "",380, 35, false)
major_minor_baselineDBE = radioBox(dialogBox, "Set Baseline to modules: ", str_choice_radioBox, 0)
runButtonDBE = apply(dialogBox, "Run", run_button)
addNewFolderButtonDBE = apply(dialogBox, "Add new project/folder/module", add_new_item_to_multiListDBE)
realize dialogBox
set(miniExplorerDBE, doTreeExpand)
if(theCurrentView == DATABASE_VIEW){
insert(miniExplorerDBE, dbDisplayRoot(), iconDatabase, iconDatabase)
}else{
projectRoot = getRootProject_()
setRootProject_(null)
for str_project_name in database do{
addItemToTree(miniExplorerDBE, item(dbSep str_project_name))
}
setRootProject_(projectRoot)
}
changeToStartFolder(current Folder)
show dialogBox
delete sk_module_in_folder_sub_folder
}
main