KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > launching > SootOptionsFolderLauncher


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 package ca.mcgill.sable.soot.launching;
21
22
23 import java.util.ArrayList JavaDoc;
24
25 import org.eclipse.jface.action.*;
26 import org.eclipse.jface.dialogs.*;
27 import ca.mcgill.sable.soot.SootPlugin;
28 import ca.mcgill.sable.soot.ui.*;
29 /**
30  * Displays the Soot Options dialog and launches Soot with
31  * selected options on all class files in output dir of
32  * selected project.
33  */

34 public class SootOptionsFolderLauncher extends SootFolderLauncher {
35
36     public void run(IAction action) {
37         
38         super.run(action);
39         
40         window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
41         
42         PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
43         setSdc(new SootDefaultCommands(dialog));
44         presetDialog();
45         dialog.open();
46         if (dialog.getReturnCode() == Dialog.CANCEL) {
47             SavedConfigManager scm = new SavedConfigManager();
48             scm.setEditMap(dialog.getEditMap());
49             scm.handleEdits();
50         }
51         else {
52             SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
53             ssc.toSaveArray();
54             
55             
56             setCmd(ssc.toRunArray());
57             String JavaDoc mainClass = dialog.getSootMainClass();
58             if ((mainClass == null) || (mainClass.length() == 0)){
59                 runSootDirectly();
60             }
61             else {
62                 runSootDirectly(mainClass);
63             }
64             runFinish();
65             
66             // save config if nessesary
67
SavedConfigManager scm = new SavedConfigManager();
68             scm.setEditMap(dialog.getEditMap());
69             scm.handleEdits();
70         }
71     }
72     
73     private void presetDialog() {
74         getSdc().setOutputDir(getOutputLocation());
75         getSdc().setSootClassPath(getProcessPath()+getSootClasspath().getSeparator()+getClasspathAppend());
76         getSdc().setProcessPath(getProcessPath());
77         getSdc().setKeepLineNum();
78         getSdc().setPrintTags();
79         getSdc().setSootMainClass();
80     }
81     
82     // TODO use this method instaed of one with String
83
private void setCmd(ArrayList JavaDoc user_cmd){
84         getSootCommandList().addSingleOpt(user_cmd);
85     }
86     
87     private void setCmd(String JavaDoc user_cmd) {
88         
89         getSootCommandList().addSingleOpt(user_cmd);
90     
91     }
92 }
93
Popular Tags