-
Notifications
You must be signed in to change notification settings - Fork 1
/
awAct.c
728 lines (554 loc) · 22.1 KB
/
awAct.c
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 Deutches Elektronen-Synchrotron in der Helmholtz-
* Gemelnschaft (DESY).
* Copyright (c) 2002 Berliner Speicherring-Gesellschaft fuer Synchrotron-
* Strahlung mbH (BESSY).
* Copyright (c) 2002 Southeastern Universities Research Association, as
* Operator of Thomas Jefferson National Accelerator Facility.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
\*************************************************************************/
/* awAct.c */
/************************DESCRIPTION***********************************
Routines for alarm configuration tool (act) mode
**********************************************************************/
#include <stdio.h>
#include <Xm/SeparatoG.h>
#include <Xm/PushBG.h>
#include <Xm/ToggleBG.h>
#include "alh.h"
#include "ax.h"
#include "alLib.h"
#include "axArea.h"
#include "epicsVersion.h"
#include "version.h"
#define KEEP 0
#define ALH_DELETE 1
/* act menu definitions */
#define MENU_FILE_NEW 10100
#define MENU_FILE_OPEN 10101
#define MENU_FILE_OPEN_OK 10102
#define MENU_FILE_CLOSE 10103
#define MENU_FILE_CLOSEALL 10104
#define MENU_FILE_SAVE 10105
#define MENU_FILE_SAVEAS 10106
#define MENU_FILE_ALH 10107
#define MENU_FILE_PRINT 10108
#define MENU_FILE_QUIT 10109
#define MENU_VIEW_EXPANDCOLLAPSE1 10200
#define MENU_VIEW_EXPANDBRANCH 10201
#define MENU_VIEW_EXPANDALL 10202
#define MENU_VIEW_COLLAPSEBRANCH 10203
#define MENU_VIEW_PROPERTIES 10204
#define MENU_EDIT_UNDO 10600
#define MENU_EDIT_CUT 10601
#define MENU_EDIT_COPY 10602
#define MENU_EDIT_PASTE 10603
#define MENU_EDIT_CLEAR 10604
#define MENU_EDIT_CLEAR_OK 10605
#define MENU_INSERT_GROUP 10800
#define MENU_INSERT_CHANNEL 10801
#define MENU_INSERT_INCLUDE 10802
#define MENU_INSERT_FILE 10803
#define MENU_INSERT_SETTINGS 10804
#define MENU_HELP_HELP 10900
#define MENU_HELP_ABOUT 10906
/* external variables */
extern ALINK *alhArea;
extern char alhVersionString[100];
/* prototypes for static routines */
static void actFileCallback(Widget widget, XtPointer calldata, XtPointer cbs);
static void actEditCallback(Widget widget, XtPointer calldata, XtPointer cbs);
static void actInsertCallback(Widget widget, XtPointer calldata, XtPointer cbs);
static void actViewCallback(Widget widget, XtPointer calldata, XtPointer cbs);
static void actHelpCallback(Widget widget, XtPointer calldata, XtPointer cbs);
static int checkActiveSelection(ALINK *area);
static int checkActiveSelectionMainGroup(ALINK *area);
/******************************************************
Create ACT MenuBar
******************************************************/
Widget actCreateMenu(Widget parent,XtPointer user_data)
{
Widget widget;
static MenuItem file_menu[] = {
/*
{ "New", PushButtonGadgetClass, 'N', "Ctrl<Key>N", "Ctrl+N",
actFileCallback, (XtPointer)MENU_FILE_NEW, (MenuItem *)NULL },
*/
{ "Open ...", PushButtonGadgetClass, 'O', "Ctrl<Key>O", "Ctrl+O",
actFileCallback, (XtPointer)MENU_FILE_OPEN, (MenuItem *)NULL },
/*
{ "Close", PushButtonGadgetClass, 'C', NULL, NULL,
actFileCallback, (XtPointer)MENU_FILE_CLOSE, (MenuItem *)NULL },
{ "Close All", PushButtonGadgetClass, 'A', NULL, NULL,
actFileCallback, (XtPointer)MENU_FILE_CLOSEALL, (MenuItem *)NULL },
*/
{ "Save", PushButtonGadgetClass, 'S', "Ctrl<Key>S", "Ctrl+S",
actFileCallback, (XtPointer)MENU_FILE_SAVE, (MenuItem *)NULL },
{ "Save As ...",PushButtonGadgetClass, 'A', NULL, NULL,
actFileCallback, (XtPointer)MENU_FILE_SAVEAS, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Activate ALH ...", PushButtonGadgetClass, 'A', NULL, NULL,
actFileCallback, (XtPointer)MENU_FILE_ALH, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Tree Report ...", PushButtonGadgetClass, 'P', NULL, NULL,
actFileCallback, (XtPointer)MENU_FILE_PRINT, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Exit", PushButtonGadgetClass, 'X', "Ctrl<Key>X", "Ctrl+X",
actFileCallback, (XtPointer)MENU_FILE_QUIT, (MenuItem *)NULL },
{NULL},
};
static MenuItem edit_menu[] = {
/* ACCELERATORS DONT WORK YET
{ "Undo", PushButtonGadgetClass, 'U', "Alt<Key>BackSpace<Key>", "Alt+BackSpace",
actEditCallback, (XtPointer)MENU_EDIT_UNDO, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Cut", PushButtonGadgetClass, 't', "Shift<Key>Delete<Key>", "Shift+Del",
actEditCallback, (XtPointer)MENU_EDIT_CUT, (MenuItem *)NULL },
{ "Copy", PushButtonGadgetClass, 'C', "Ctrl<Key>Insert<Key>", "Ctrl+Ins",
actEditCallback, (XtPointer)MENU_EDIT_COPY, (MenuItem *)NULL },
{ "Paste", PushButtonGadgetClass, 'P', "Shift<Key>Insert<Key>", "Shift+Ins",
actEditCallback, (XtPointer)MENU_EDIT_PASTE, (MenuItem *)NULL },
*/
/* UNDO DOES NOT WORK YET
{ "Undo", PushButtonGadgetClass, 'U', NULL, NULL,
actEditCallback, (XtPointer)MENU_EDIT_UNDO, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
*/
{ "Cut", PushButtonGadgetClass, 't', NULL, NULL,
actEditCallback, (XtPointer)MENU_EDIT_CUT, (MenuItem *)NULL },
{ "Copy", PushButtonGadgetClass, 'C', NULL, NULL,
actEditCallback, (XtPointer)MENU_EDIT_COPY, (MenuItem *)NULL },
{ "Paste", PushButtonGadgetClass, 'P', NULL, NULL,
actEditCallback, (XtPointer)MENU_EDIT_PASTE, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Clear", PushButtonGadgetClass, 'e', NULL, NULL,
actEditCallback, (XtPointer)MENU_EDIT_CLEAR, (MenuItem *)NULL },
{NULL},
};
static MenuItem insert_menu[] = {
{ "Group ...", PushButtonGadgetClass, 'G', NULL, NULL,
actInsertCallback, (XtPointer)MENU_INSERT_GROUP, (MenuItem *)NULL },
{ "Channel ...", PushButtonGadgetClass, 'C', NULL, NULL,
actInsertCallback, (XtPointer)MENU_INSERT_CHANNEL, (MenuItem *)NULL },
{ "Runtime Include...", PushButtonGadgetClass, 'F', NULL, NULL,
actInsertCallback, (XtPointer)MENU_INSERT_INCLUDE, (MenuItem *)NULL },
{ "File ...", PushButtonGadgetClass, 'F', NULL, NULL,
actInsertCallback, (XtPointer)MENU_INSERT_FILE, (MenuItem *)NULL },
{NULL},
};
static MenuItem view_menu[] = {
{ "Expand One Level", PushButtonGadgetClass, 'O', "None<Key>plus", "+",
actViewCallback, (XtPointer)MENU_VIEW_EXPANDCOLLAPSE1, (MenuItem *)NULL },
{ "Expand Branch", PushButtonGadgetClass, 'B', "None<Key>asterisk", "*",
actViewCallback, (XtPointer)MENU_VIEW_EXPANDBRANCH, (MenuItem *)NULL },
{ "Expand All", PushButtonGadgetClass, 'A',"Ctrl<Key>asterisk", "Ctrl+*",
actViewCallback, (XtPointer)MENU_VIEW_EXPANDALL, (MenuItem *)NULL },
{ "Collapse Branch", PushButtonGadgetClass, 'C', "None<Key>minus", "-",
actViewCallback, (XtPointer)MENU_VIEW_COLLAPSEBRANCH, (MenuItem *)NULL },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Properties Window", ToggleButtonGadgetClass, 'W', NULL, NULL,
actViewCallback, (XtPointer)MENU_VIEW_PROPERTIES, (MenuItem *)NULL },
{NULL},
};
static MenuItem help_menu[] = {
/* HELP NOT IMPLEMENTED YET
{ "Help Topics", PushButtonGadgetClass, 'H', NULL, NULL,
actHelpCallback, (XtPointer)MENU_HELP_TOPICS, (MenuItem *)NULL },
*/
#if XmVersion && XmVersion >= 1002
{ "About ALH", PushButtonGadgetClass, 'A', NULL, NULL,
actHelpCallback, (XtPointer)MENU_HELP_ABOUT, (MenuItem *)NULL },
#endif
{NULL},
};
Widget menubar;
menubar = XmCreateMenuBar(parent, "menubar", NULL, 0);
XtVaSetValues(menubar, XmNshadowThickness, 0, NULL);
widget = buildPulldownMenu(menubar, "File", 'F', TRUE, file_menu, user_data);
widget = buildPulldownMenu(menubar, "Edit", 'E', TRUE, edit_menu, user_data);
widget = buildPulldownMenu(menubar, "Insert",'I', TRUE, insert_menu, user_data);
widget = buildPulldownMenu(menubar, "View", 'V', TRUE, view_menu, user_data);
widget = buildPulldownMenu(menubar, "Help", 'H', TRUE, help_menu, user_data);
/* Make sure Help on MenuBar item is right adjusted */
XtVaSetValues(menubar, XmNtopAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(menubar, XmNrightAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(menubar, XmNleftAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(menubar, XmNmenuHelpWidget, widget, NULL);
XtManageChild(menubar);
return(menubar);
}
/******************************************************
actFileCallback
******************************************************/
static void actFileCallback(Widget widget, XtPointer calldata, XtPointer cbs)
{
ALINK *area;
int item=(long)calldata;
XtVaGetValues(widget, XmNuserData, &area, NULL);
switch (item){
case MENU_FILE_NEW:
break;
case MENU_FILE_OPEN:
/* Display the config_changed warning dialog */
if (area->changed){
createActionDialog(area->form_main,XmDIALOG_WARNING,
"Latest configuration changes have not been saved. Continue?" ,
(XtCallbackProc)actFileCallback,(XtPointer)MENU_FILE_OPEN_OK,(XtPointer)area);
break;
}
area->managed = FALSE;
createFileDialog(area->form_main,(void *)fileSetupCallback,
(XtPointer)FILE_CONFIG,(void *)fileCancelCallback,
(XtPointer)area, (XtPointer)area, "Config File",CONFIG_PATTERN,psetup.configDir);
break;
case MENU_FILE_OPEN_OK:
area->managed = FALSE;
createFileDialog(area->form_main,(void *)fileSetupCallback,
(XtPointer)FILE_CONFIG,(void *)fileCancelCallback,
(XtPointer)area, (XtPointer)area, "Config File",CONFIG_PATTERN,psetup.configDir);
break;
case MENU_FILE_CLOSE:
break;
case MENU_FILE_CLOSEALL:
break;
case MENU_FILE_SAVEAS:
/* New Name for Save Config File */
createFileDialog(area->form_main,(void *)fileSetupCallback,
(XtPointer)FILE_SAVEAS,(void *)XtUnmanageChild,(XtPointer)0,
(XtPointer)area, "Save Config File",CONFIG_PATTERN,'\0');
break;
case MENU_FILE_SAVE:
alLogOpModMessage(0,0,
"Setup Save New Config: %s",psetup.configFile);
alWriteConfig(psetup.configFile,area->pmainGroup);
break;
case MENU_FILE_ALH:
if (alhArea) alhArea->managed = FALSE;
setupConfig("",ALH,area);
/* Display the config_changed warning dialog */
/*
if (area->changed){
createActionDialog(area->form_main,XmDIALOG_WARNING,
"Latest configuration changes have not been saved. Continue?" ,
(XtCallbackProc)actInvokeAlhCallback,
(XtPointer)area,(XtPointer)area);
break;
}
*/
break;
case MENU_FILE_PRINT:
/* Name for PrintTree Report */
createFileDialog(area->form_main,(void *)fileSetupCallback,
(XtPointer)FILE_PRINT,(void *)XtUnmanageChild,(XtPointer)0,
(XtPointer)area, "Report File ",TREEREPORT_PATTERN,'\0');
break;
case MENU_FILE_QUIT:
if (area->changed){
/* Display the config_changed warning dialog */
createActionDialog(area->form_main,XmDIALOG_WARNING,
"Latest configuration changes have not been saved! Exit Alarm Configuration Tool?",
(XtCallbackProc)exit_quit,
(XtPointer)area, (XtPointer)area);
break;
}
createActionDialog(area->form_main,XmDIALOG_WARNING,"Exit Alarm Configuration Tool?",
(XtCallbackProc)exit_quit,
(XtPointer)area, (XtPointer)area);
break;
default:
createDialog(area->form_main,XmDIALOG_INFORMATION,"Selection not implemented yet."," ");
break;
}
}
/******************************************************
actEditCallback
******************************************************/
static void actEditCallback(Widget widget, XtPointer calldata, XtPointer cbs)
{
int item=(long)calldata;
ALINK *area;
GCLINK *link;
GCLINK *next;
GCLINK *configLink;
int linkType;
int command;
GCLINK *tempLink;
int tempLinkType;
struct anyLine *treeLine;
struct anyLine *groupLine;
XtVaGetValues(widget, XmNuserData, &area, NULL);
switch (item){
case MENU_EDIT_CLEAR:
if (area->changed){
/* Display the config_changed warning dialog */
createActionDialog(area->form_main,XmDIALOG_WARNING,
"Latest configuration changes have not been saved. Continue?" ,
(XtCallbackProc)actEditCallback,
(XtPointer)MENU_EDIT_CLEAR_OK,(XtPointer)area);
break;
}
case MENU_EDIT_CLEAR_OK:
editUndoSet((GCLINK *)sllFirst(area->pmainGroup),
GROUP, NULL, MENU_EDIT_UNDO_CLEAR, ALH_DELETE);
area->managed = FALSE;
area->pmainGroup->p1stgroup = NULL;
setupConfig("",ACT,area);
break;
case MENU_EDIT_CUT:
if (checkActiveSelection(area) ) break;
if (checkActiveSelectionMainGroup(area) ) break;
link = (GCLINK *)area->selectionLink;
linkType = area->selectionType;
editClipboardSet(link, linkType);
editUndoSet(link, linkType, NULL, MENU_EDIT_UNDO_PASTE, ALH_DELETE);
editCutLink(area,link,linkType);
break;
case MENU_EDIT_COPY:
if (checkActiveSelection(area) ) break;
link = (GCLINK *)area->selectionLink;
linkType = area->selectionType;
editClipboardSet(link, linkType);
break;
case MENU_EDIT_PASTE:
if (checkActiveSelection(area) ) break;
editClipboardGet(&link, &linkType);
if (link) editPasteLink(area,link,linkType);
break;
case MENU_EDIT_UNDO:
command = editUndoGetCommand();
switch (command){
case MENU_EDIT_UNDO_UPDATE_CLIPBOARD:
editClipboardGet(&tempLink, &tempLinkType);
editUndoGet(&link, &linkType, &configLink);
editClipboardSet(link, linkType);
editUndoSet(tempLink, tempLinkType, NULL, MENU_EDIT_UNDO_UPDATE_CLIPBOARD, KEEP);
break;
case MENU_EDIT_UNDO_PASTE:
editUndoGet(&link, &linkType, &tempLink);
next = (GCLINK *)sllNext((SNODE*)link);
if (next){
((struct subWindow *)area->groupWindow)->selectionLink=next;
area->selectionLink=next;
area->selectionType=linkType;
area->selectionWindow=area->groupWindow;
} else {
((struct subWindow *)area->treeWindow)->selectionLink=link->parent;
area->selectionLink=link->parent;
area->selectionType=GROUP;
area->selectionWindow=area->treeWindow;
}
editPasteLink(area,link,linkType);
/* restore selection */
groupLine = (struct anyLine *)link->lineGroupW;
treeLine = (struct anyLine *)link->lineTreeW;
if (groupLine){
markSelectedWidget( area->groupWindow, ((WLINE *)groupLine->wline)->name);
markSelection( area->groupWindow, groupLine);
} else if (treeLine) {
markSelectedWidget( area->treeWindow, ((WLINE *)treeLine->wline)->name);
markSelection( area->treeWindow, treeLine);
}
/* update dialog windows */
axUpdateDialogs(area);
/* update undo values */
editUndoSet(NULL, linkType, link, MENU_EDIT_UNDO_CUT, KEEP);
break;
case MENU_EDIT_UNDO_PASTE_NOSELECT:
editUndoGet(&link, &linkType, &tempLink);
editPasteLink(area,link,linkType);
/* update dialog windows */
axUpdateDialogs(area);
/* update undo values */
editUndoSet(NULL, linkType, link, MENU_EDIT_UNDO_CUT_NOSELECT, KEEP);
break;
case MENU_EDIT_UNDO_CUT:
if (checkActiveSelection(area) ) break;
if (checkActiveSelectionMainGroup(area) ) break;
link = (GCLINK *)area->selectionLink;
linkType = area->selectionType;
editClipboardSet(link, linkType);
editUndoSet(link, linkType, NULL, MENU_EDIT_UNDO_PASTE, KEEP);
editCutLink(area,link,linkType);
break;
case MENU_EDIT_UNDO_CUT_NOSELECT:
editUndoGet(&tempLink, &linkType, &link);
editCutLink(area, link, linkType);
editUndoSet(link, linkType, NULL, MENU_EDIT_UNDO_PASTE_NOSELECT, KEEP);
/* update dialog windows */
axUpdateDialogs(area);
break;
case MENU_EDIT_UNDO_PROPERTIES:
propUndo(area);
break;
case MENU_EDIT_UNDO_CLEAR:
link = (GCLINK *)sllFirst(area->pmainGroup);
editUndoGet(&tempLink, &linkType, &configLink);
area->pmainGroup->p1stgroup = (GLINK *)tempLink;
editUndoSet(link, GROUP, 0, MENU_EDIT_UNDO_CLEAR, KEEP);
setParentLink(area->treeWindow,area->pmainGroup->p1stgroup);
setParentLink(area->groupWindow,area->pmainGroup->p1stgroup);
((struct subWindow *)area->treeWindow)->viewOffset = 0;
setViewConfigCount(area->treeWindow,area->pmainGroup->p1stgroup->viewCount);
/* redraw main windows */
redraw(area->treeWindow,0);
defaultTreeSelection(area);
/* update dialog windows */
axUpdateDialogs(area);
break;
default:
createDialog(area->form_main,XmDIALOG_INFORMATION,
"Selection not implemented yet."," ");
break;
}
break;
default:
createDialog(area->form_main,XmDIALOG_INFORMATION,"Selection not implemented yet."," ");
break;
}
}
/******************************************************
actInsertCallback
******************************************************/
static void actInsertCallback(Widget widget, XtPointer calldata, XtPointer cbs)
{
int item=(long)calldata;
ALINK *area;
GCLINK *link;
int linkType;
XtVaGetValues(widget, XmNuserData, &area, NULL);
switch (item){
case MENU_INSERT_GROUP:
if (checkActiveSelection(area) ) break;
/* create a new Group */
link = (GCLINK *)alCreateGroup();
link->viewCount = 1;
linkType = GROUP;
editPasteLink(area,link,linkType);
break;
case MENU_INSERT_CHANNEL:
if (checkActiveSelection(area) ) break;
/* create a new Channel */
link = (GCLINK *)alCreateChannel();
linkType = CHANNEL;
editPasteLink(area, link, linkType);
break;
case MENU_INSERT_FILE:
if (checkActiveSelection(area) ) break;
area->managed = FALSE;
createFileDialog(area->form_main,(void *)fileSetupCallback,
(XtPointer)FILE_CONFIG_INSERT,(void *)XtUnmanageChild,
(XtPointer)0,(XtPointer)area, "Config File",CONFIG_PATTERN,
psetup.configDir);
break;
default:
createDialog(area->form_main,XmDIALOG_INFORMATION,
"Selection not implemented yet."," ");
break;
}
}
/******************************************************
actViewCallback
******************************************************/
static void actViewCallback(Widget widget, XtPointer calldata, XtPointer cbs)
{
int item=(long)calldata;
ALINK *area;
void *link;
struct subWindow *treeWindow;
XtVaGetValues(widget, XmNuserData, &area, NULL);
treeWindow = (struct subWindow *)area->treeWindow;
switch (item){
case MENU_VIEW_EXPANDCOLLAPSE1:
/* Expand 1 level */
link = treeWindow->selectionLink;
if (link) displayNewViewTree(area,link,EXPANDCOLLAPSE1);
else createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group first."," ");
break;
case MENU_VIEW_EXPANDBRANCH:
/* Expand Branch */
link = treeWindow->selectionLink;
if (link )displayNewViewTree(area,link,EXPAND);
else createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group first."," ");
break;
case MENU_VIEW_EXPANDALL:
/* Expand all */
displayNewViewTree(area,(GLINK *)sllFirst(area->pmainGroup),EXPAND);
break;
case MENU_VIEW_COLLAPSEBRANCH:
/* Collapse branch */
link = treeWindow->selectionLink;
if (link )displayNewViewTree(area,link,COLLAPSE);
else createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group first."," ");
break;
case MENU_VIEW_PROPERTIES:
propShowDialog(area, widget);
break;
default:
createDialog(area->form_main,XmDIALOG_INFORMATION,
"Selection not implemented yet."," ");
break;
}
}
/******************************************************
actHelpCallback
******************************************************/
static void actHelpCallback(Widget widget, XtPointer calldata, XtPointer cbs)
{
int item=(long)calldata;
ALINK *area;
XtVaGetValues(widget, XmNuserData, &area, NULL);
switch (item){
case MENU_HELP_ABOUT:
createDialog(area->form_main,XmDIALOG_INFORMATION,
"\nAlarm Configuration Tool\n\n" ALH_CREDITS_STRING,
alhVersionString);
break;
default:
createDialog(area->form_main,XmDIALOG_INFORMATION,
"Help is not available in this release."," ");
break;
}
}
/******************************************************
checkActiveSelection
******************************************************/
static int checkActiveSelection(area)
ALINK *area;
{
if (!area->selectionLink){
createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
return 1;
}
return 0;
}
/******************************************************
checkActiveSelectionMainGroup
******************************************************/
static int checkActiveSelectionMainGroup(area)
ALINK *area;
{
GCLINK *link;
link = (GCLINK *)area->selectionLink;
if (!link->parent){
createDialog(area->form_main,XmDIALOG_ERROR,link->pgcData->name,
" is main group and cannot be deleted");
return 1;
}
return 0;
}