KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > testing > OptionsDialog


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20
21
22 /*
23  * This library is free software; you can redistribute it and/or
24  * modify it under the terms of the GNU Lesser General Public
25  * License as published by the Free Software Foundation; either
26  * version 2.1 of the License, or (at your option) any later version.
27  *
28  * This library is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31  * Lesser General Public License for more details.
32  *
33  * You should have received a copy of the GNU Lesser General Public
34  * License along with this library; if not, write to the
35  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
36  * Boston, MA 02111-1307, USA.
37  *
38  * This class is generated automajically from xml - DO NO EDIT - as
39  * changes will be over written
40  *
41  * The purpose of this class is to automajically generate a options
42  * dialog in the event that options change
43  *
44  * Taking options away - should not damage the dialog
45  * Adding new sections of options - should not damage the dialog
46  * Adding new otpions to sections (of known option type) - should not
47  * damage the dialog
48  *
49  * Adding new option types will break the dialog (option type widgets
50  * will need to be created)
51  *
52  */

53
54 package ca.mcgill.sable.soot.testing;
55
56 //import org.eclipse.jface.dialogs.IDialogSettings;
57
import org.eclipse.swt.widgets.*;
58 //import org.eclipse.swt.*;
59
//import org.eclipse.swt.layout.*;
60
//import ca.mcgill.sable.soot.SootPlugin;
61

62
63 public class OptionsDialog {//extends AbstractOptionsDialog {
64

65     public OptionsDialog(Shell parentShell) {
66         //super(parentShell);
67
}
68     
69     /*/**
70      * each section gets initialize as a stack layer in pageContainer
71      * the area containing the options
72      */

73     /*protected void initializePageContainer() {
74         
75         Composite generalOptsChild = generalOptsCreate(getPageContainer());
76         
77         Composite inputOptsChild = inputOptsCreate(getPageContainer());
78         
79         Composite outputOptsChild = outputOptsCreate(getPageContainer());
80         
81         Composite processingOptsChild = processingOptsCreate(getPageContainer());
82         
83         Composite singleFileOptsChild = singleFileOptsCreate(getPageContainer());
84         
85         Composite appOptsChild = appOptsCreate(getPageContainer());
86         
87         Composite inputAttrOptsChild = inputAttrOptsCreate(getPageContainer());
88         
89         Composite annotationOptsChild = annotationOptsCreate(getPageContainer());
90         
91         Composite miscOptsChild = miscOptsCreate(getPageContainer());
92         
93     }
94
95     /**
96      * all options get saved as <alias, value> pair
97      */

98     /*protected void okPressed() {
99         IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
100
101         Control [] elements;
102         
103         settings.put(gethelp_widget().getAlias(), gethelp_widget().getButton().getSelection());
104         
105         settings.put(getversion_widget().getAlias(), getversion_widget().getButton().getSelection());
106         
107         settings.put(getverbose_widget().getAlias(), getverbose_widget().getButton().getSelection());
108         
109         settings.put(getappMode_widget().getAlias(), getappMode_widget().getButton().getSelection());
110         
111         settings.put(getclasspath_widget().getAlias(), getclasspath_widget().getText().getText());
112          
113         settings.put(getsrcPrec_widget().getAlias(), getsrcPrec_widget().getSelectedAlias());
114         
115         settings.put(getoutputDir_widget().getAlias(), getoutputDir_widget().getText().getText());
116          
117         settings.put(getoutputFormat_widget().getAlias(), getoutputFormat_widget().getSelectedAlias());
118         
119         settings.put(getoptimize_widget().getAlias(), getoptimize_widget().getButton().getSelection());
120         
121         settings.put(getwholeOptimize_widget().getAlias(), getwholeOptimize_widget().getButton().getSelection());
122         
123         settings.put(getprocPath_widget().getAlias(), getprocPath_widget().getText().getText());
124         
125         settings.put(getanalyzeContext_widget().getAlias(), getanalyzeContext_widget().getButton().getSelection());
126         
127         settings.put(getincPackage_widget().getAlias(), getincPackage_widget().getText().getText());
128         
129         settings.put(getexcPackage_widget().getAlias(), getexcPackage_widget().getText().getText());
130         
131         settings.put(getdynClasses_widget().getAlias(), getdynClasses_widget().getText().getText());
132         
133         settings.put(getdynPath_widget().getAlias(), getdynPath_widget().getText().getText());
134         
135         settings.put(getdynPackage_widget().getAlias(), getdynPackage_widget().getText().getText());
136         
137         settings.put(getkeepLineNum_widget().getAlias(), getkeepLineNum_widget().getButton().getSelection());
138         
139         settings.put(getkeepByteOffset_widget().getAlias(), getkeepByteOffset_widget().getButton().getSelection());
140         
141         settings.put(getnullPointerAnn_widget().getAlias(), getnullPointerAnn_widget().getButton().getSelection());
142         
143         settings.put(getarrayBoundsAnn_widget().getAlias(), getarrayBoundsAnn_widget().getButton().getSelection());
144         
145         settings.put(gettime_widget().getAlias(), gettime_widget().getButton().getSelection());
146         
147         settings.put(getsubGC_widget().getAlias(), getsubGC_widget().getButton().getSelection());
148         
149         super.okPressed();
150                 
151     }
152
153     
154
155     /**
156      * the initial input of selection tree corresponds to each section
157      * at some point sections will have sub-sections which will be
158      * children of branches (ie phase - options)
159      */

160     /*protected SootOption getInitialInput() {
161         SootOption root = new SootOption("");
162         
163         SootOption generalOpts_branch = new SootOption("General Options");
164         root.addChild(generalOpts_branch);
165         
166         SootOption inputOpts_branch = new SootOption("Input Options");
167         root.addChild(inputOpts_branch);
168         
169         SootOption outputOpts_branch = new SootOption("Output Options");
170         root.addChild(outputOpts_branch);
171         
172         SootOption processingOpts_branch = new SootOption("Processing Options");
173         root.addChild(processingOpts_branch);
174         
175         SootOption singleFileOpts_branch = new SootOption("Single File Mode Options");
176         root.addChild(singleFileOpts_branch);
177         
178         SootOption appOpts_branch = new SootOption("Application Mode Options");
179         root.addChild(appOpts_branch);
180         
181         SootOption inputAttrOpts_branch = new SootOption("Input Attribute Options");
182         root.addChild(inputAttrOpts_branch);
183         
184         SootOption annotationOpts_branch = new SootOption("Annotation Options");
185         root.addChild(annotationOpts_branch);
186         
187         SootOption miscOpts_branch = new SootOption("Miscellaneous Options");
188         root.addChild(miscOpts_branch);
189         
190         return root;
191     
192     }
193     
194     
195
196     /**
197      * each setion gets initalized with a composite
198      * containing widgets of option type
199      */

200     
201     /*private BooleanOptionWidget help_widget;
202     private void sethelp_widget(BooleanOptionWidget widget) {
203         help_widget = widget;
204     }
205     private BooleanOptionWidget gethelp_widget() {
206         return help_widget;
207     }
208     
209     private BooleanOptionWidget version_widget;
210     private void setversion_widget(BooleanOptionWidget widget) {
211         version_widget = widget;
212     }
213     private BooleanOptionWidget getversion_widget() {
214         return version_widget;
215     }
216     
217     private BooleanOptionWidget verbose_widget;
218     private void setverbose_widget(BooleanOptionWidget widget) {
219         verbose_widget = widget;
220     }
221     private BooleanOptionWidget getverbose_widget() {
222         return verbose_widget;
223     }
224     
225     private BooleanOptionWidget appMode_widget;
226     private void setappMode_widget(BooleanOptionWidget widget) {
227         appMode_widget = widget;
228     }
229     private BooleanOptionWidget getappMode_widget() {
230         return appMode_widget;
231     }
232     
233
234     
235     
236     private Composite generalOptsCreate(Composite parent) {
237
238         Group editGroup = new Group(parent, SWT.NONE);
239         GridLayout layout = new GridLayout();
240         editGroup.setLayout(layout);
241     
242         editGroup.setText("General Options");
243         
244         
245         
246         
247         sethelp_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Help", "h", "display help and exit")));
248         
249         setversion_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Version", "version", "output version information and exit")));
250         
251         setverbose_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Verbose", "v", "verbose mode")));
252         
253         setappMode_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Application Mode", "app", "runs in application mode")));
254         
255         
256         return editGroup;
257     }
258
259     
260     private ListOptionWidget classpath_widget;
261     private void setclasspath_widget(ListOptionWidget widget) {
262         classpath_widget = widget;
263     }
264     private ListOptionWidget getclasspath_widget() {
265         return classpath_widget;
266     }
267     
268     MultiOptionWidget srcPrec_widget;
269     private void setsrcPrec_widget(MultiOptionWidget widget) {
270         srcPrec_widget = widget;
271     }
272     private MultiOptionWidget getsrcPrec_widget() {
273         return srcPrec_widget;
274     }
275     
276
277     
278     
279     private Composite inputOptsCreate(Composite parent) {
280
281         Group editGroup = new Group(parent, SWT.NONE);
282         GridLayout layout = new GridLayout();
283         editGroup.setLayout(layout);
284     
285         editGroup.setText("Input Options");
286         
287         
288         
289         
290         
291         OptionData [] data = new OptionData [] {
292         
293         new OptionData("Class File",
294         "c",
295         "Use class for source of Soot",
296         
297         true),
298         
299         new OptionData("Jimple File",
300         "J",
301         "Use Jimple for source of Soot",
302         
303         false),
304         
305         };
306         
307                                         
308         setsrcPrec_widget(new MultiOptionWidget(editGroup, SWT.NONE, data, new OptionData("Input Source Precedence", "src-prec", "sets the source precedence for Soot")));
309         
310         setclasspath_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Soot Classpath", "cp", "uses given PATH as the classpath for finding classes for Soot processing")));
311         
312         
313         return editGroup;
314     }
315
316     
317     private StringOptionWidget outputDir_widget;
318     private void setoutputDir_widget(StringOptionWidget widget) {
319         outputDir_widget = widget;
320     }
321     private StringOptionWidget getoutputDir_widget() {
322         return outputDir_widget;
323     }
324     
325     MultiOptionWidget outputFormat_widget;
326     private void setoutputFormat_widget(MultiOptionWidget widget) {
327         outputFormat_widget = widget;
328     }
329     private MultiOptionWidget getoutputFormat_widget() {
330         return outputFormat_widget;
331     }
332     
333
334     
335     
336     private Composite outputOptsCreate(Composite parent) {
337
338         Group editGroup = new Group(parent, SWT.NONE);
339         GridLayout layout = new GridLayout();
340         editGroup.setLayout(layout);
341     
342         editGroup.setText("Output Options");
343         
344         
345         
346         
347         
348         OptionData [] data = new OptionData [] {
349         
350         new OptionData("Jimp File",
351         "j",
352         "produce .jimp (abbreviated .jimple) files",
353         
354         false),
355         
356         new OptionData("Njimple File",
357         "njimple",
358         "produce .njimple files",
359         
360         false),
361         
362         new OptionData("Jimple File",
363         "J",
364         "produce .jimple code",
365         
366         false),
367         
368         new OptionData("Baf File",
369         "B",
370         "produce .baf code",
371         
372         false),
373         
374         new OptionData("Aggregated Baf File",
375         "b",
376         "produce .b (abbreviated .baf) files",
377         
378         false),
379         
380         new OptionData("Grimp File",
381         "g",
382         "produce .grimp (abbreviated .grimple) files",
383         
384         false),
385         
386         new OptionData("Grimple File",
387         "G",
388         "produce .grimple files",
389         
390         false),
391         
392         new OptionData("Xml File",
393         "X",
394         "produce .xml files",
395         
396         false),
397         
398         new OptionData("No Output File",
399         "n",
400         "produces no output",
401         
402         false),
403         
404         new OptionData("Jasmin File",
405         "s",
406         "produce .jasmin files",
407         
408         false),
409         
410         new OptionData("Jasmin Through Grimp File",
411         "jasmin-through-grimp",
412         "produce .jasmin files using grimp as final IR?",
413         
414         false),
415         
416         new OptionData("Class File",
417         "c",
418         "produce .class files",
419         
420         true),
421         
422         new OptionData("Class Through Grimp File",
423         "class-through-grimp",
424         "produce .class files using grimp as final IR?",
425         
426         false),
427         
428         new OptionData("Dava Decompiled File",
429         "d",
430         "produce dava decompiled .java files",
431         
432         false),
433         
434         };
435         
436                                         
437         setoutputFormat_widget(new MultiOptionWidget(editGroup, SWT.NONE, data, new OptionData("Output Format", "o", "sets the source precedence for Soot")));
438         
439         setoutputDir_widget(new StringOptionWidget(editGroup, SWT.NONE, new OptionData("Output Directory", "d", "store produced files in PATH")));
440         
441         
442         return editGroup;
443     }
444
445     
446     private BooleanOptionWidget optimize_widget;
447     private void setoptimize_widget(BooleanOptionWidget widget) {
448         optimize_widget = widget;
449     }
450     private BooleanOptionWidget getoptimize_widget() {
451         return optimize_widget;
452     }
453     
454     private BooleanOptionWidget wholeOptimize_widget;
455     private void setwholeOptimize_widget(BooleanOptionWidget widget) {
456         wholeOptimize_widget = widget;
457     }
458     private BooleanOptionWidget getwholeOptimize_widget() {
459         return wholeOptimize_widget;
460     }
461     
462
463     
464     
465     private Composite processingOptsCreate(Composite parent) {
466
467         Group editGroup = new Group(parent, SWT.NONE);
468         GridLayout layout = new GridLayout();
469         editGroup.setLayout(layout);
470     
471         editGroup.setText("Processing Options");
472         
473         
474         
475         
476         setoptimize_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Optimize", "O", "perform scalar optimizations on the classfiles")));
477         
478         setwholeOptimize_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Whole Program Optimize", "W", "perform whole program optimizations on the classfiles")));
479         
480         
481         return editGroup;
482     }
483
484     
485     private ListOptionWidget procPath_widget;
486     private void setprocPath_widget(ListOptionWidget widget) {
487         procPath_widget = widget;
488     }
489     private ListOptionWidget getprocPath_widget() {
490         return procPath_widget;
491     }
492     
493
494     
495     
496     private Composite singleFileOptsCreate(Composite parent) {
497
498         Group editGroup = new Group(parent, SWT.NONE);
499         GridLayout layout = new GridLayout();
500         editGroup.setLayout(layout);
501     
502         editGroup.setText("Single File Mode Options");
503         
504         
505         
506         
507         setprocPath_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Process Path", "process-path", "process all classes on the PATH")));
508         
509         
510         return editGroup;
511     }
512
513     
514     private BooleanOptionWidget analyzeContext_widget;
515     private void setanalyzeContext_widget(BooleanOptionWidget widget) {
516         analyzeContext_widget = widget;
517     }
518     private BooleanOptionWidget getanalyzeContext_widget() {
519         return analyzeContext_widget;
520     }
521     
522     private ListOptionWidget incPackage_widget;
523     private void setincPackage_widget(ListOptionWidget widget) {
524         incPackage_widget = widget;
525     }
526     private ListOptionWidget getincPackage_widget() {
527         return incPackage_widget;
528     }
529     
530     private ListOptionWidget excPackage_widget;
531     private void setexcPackage_widget(ListOptionWidget widget) {
532         excPackage_widget = widget;
533     }
534     private ListOptionWidget getexcPackage_widget() {
535         return excPackage_widget;
536     }
537     
538     private ListOptionWidget dynClasses_widget;
539     private void setdynClasses_widget(ListOptionWidget widget) {
540         dynClasses_widget = widget;
541     }
542     private ListOptionWidget getdynClasses_widget() {
543         return dynClasses_widget;
544     }
545     
546     private ListOptionWidget dynPath_widget;
547     private void setdynPath_widget(ListOptionWidget widget) {
548         dynPath_widget = widget;
549     }
550     private ListOptionWidget getdynPath_widget() {
551         return dynPath_widget;
552     }
553     
554     private ListOptionWidget dynPackage_widget;
555     private void setdynPackage_widget(ListOptionWidget widget) {
556         dynPackage_widget = widget;
557     }
558     private ListOptionWidget getdynPackage_widget() {
559         return dynPackage_widget;
560     }
561     
562
563     
564     
565     private Composite appOptsCreate(Composite parent) {
566
567         Group editGroup = new Group(parent, SWT.NONE);
568         GridLayout layout = new GridLayout();
569         editGroup.setLayout(layout);
570     
571         editGroup.setText("Application Mode Options");
572         
573         
574         
575         
576         setanalyzeContext_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Analyze Context", "a", "label context classes as library")));
577         
578         setincPackage_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Include Package", "i", "marks classfiles in PACKAGE (e.g. java.util.)as application classes")));
579         
580         setexcPackage_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Exclude Package", "x", "marks classfiles in PACKAGE (e.g. java.) as context classes")));
581         
582         setdynClasses_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Dynamic Classes", "dynamic-classes", "marks CLASSES (separated by colons) as potentially dynamic classes")));
583         
584         setdynPath_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Dynamic Path", "dynamic-path", "marks all class files in PATH as potentially dynamic classes")));
585         
586         setdynPackage_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Dynamic Package", "dynamic-package", "marks classfiles in PACKAGES (separated by commas) as potentially dynamic classes")));
587         
588         
589         return editGroup;
590     }
591
592     
593     private BooleanOptionWidget keepLineNum_widget;
594     private void setkeepLineNum_widget(BooleanOptionWidget widget) {
595         keepLineNum_widget = widget;
596     }
597     private BooleanOptionWidget getkeepLineNum_widget() {
598         return keepLineNum_widget;
599     }
600     
601     private BooleanOptionWidget keepByteOffset_widget;
602     private void setkeepByteOffset_widget(BooleanOptionWidget widget) {
603         keepByteOffset_widget = widget;
604     }
605     private BooleanOptionWidget getkeepByteOffset_widget() {
606         return keepByteOffset_widget;
607     }
608     
609
610     
611     
612     private Composite inputAttrOptsCreate(Composite parent) {
613
614         Group editGroup = new Group(parent, SWT.NONE );
615         GridLayout layout = new GridLayout();
616         editGroup.setLayout(layout);
617     
618         editGroup.setText("Input Attribute Options");
619         
620         
621         
622         
623         setkeepLineNum_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Keep Line Number", "keep-line-number", "keep line number tables")));
624         
625         setkeepByteOffset_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Keep Bytecode Offset", "keep-bytecode-offset", "attach bytecode offset to jimple statement")));
626         
627         
628         return editGroup;
629     }
630
631     
632     private BooleanOptionWidget nullPointerAnn_widget;
633     private void setnullPointerAnn_widget(BooleanOptionWidget widget) {
634         nullPointerAnn_widget = widget;
635     }
636     private BooleanOptionWidget getnullPointerAnn_widget() {
637         return nullPointerAnn_widget;
638     }
639     
640     private BooleanOptionWidget arrayBoundsAnn_widget;
641     private void setarrayBoundsAnn_widget(BooleanOptionWidget widget) {
642         arrayBoundsAnn_widget = widget;
643     }
644     private BooleanOptionWidget getarrayBoundsAnn_widget() {
645         return arrayBoundsAnn_widget;
646     }
647     
648
649     
650     
651     private Composite annotationOptsCreate(Composite parent) {
652
653         Group editGroup = new Group(parent, SWT.NONE );
654         GridLayout layout = new GridLayout();
655         editGroup.setLayout(layout);
656     
657         editGroup.setText("Annotation Options");
658         
659         
660         
661         
662         setnullPointerAnn_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Null Pointer Annotation", "annot-nullpointer", "turn on the annotation for null pointer")));
663         
664         setarrayBoundsAnn_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Array Bounds Annotation", "annot-arraybounds", "turn on the annotation for array bounds check")));
665         
666         
667         return editGroup;
668     }
669
670     
671     private BooleanOptionWidget time_widget;
672     private void settime_widget(BooleanOptionWidget widget) {
673         time_widget = widget;
674     }
675     private BooleanOptionWidget gettime_widget() {
676         return time_widget;
677     }
678     
679     private BooleanOptionWidget subGC_widget;
680     private void setsubGC_widget(BooleanOptionWidget widget) {
681         subGC_widget = widget;
682     }
683     private BooleanOptionWidget getsubGC_widget() {
684         return subGC_widget;
685     }
686     
687
688     
689     
690     private Composite miscOptsCreate(Composite parent) {
691
692         Group editGroup = new Group(parent, SWT.NONE );
693         GridLayout layout = new GridLayout();
694         editGroup.setLayout(layout);
695     
696         editGroup.setText("Miscellaneous Options");
697         
698         
699         
700         
701         settime_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Time", "time", "print out time statistics about tranformations")));
702         
703         setsubGC_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Subtract Garbage Collection Time", "subtract-gc", "attempt to subtract the gc from the time stats")));
704         
705         
706         return editGroup;
707     }*/

708
709     
710     
711 }
712
713
Popular Tags