KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Iterator JavaDoc;
25
26 import org.eclipse.jface.action.*;
27 import org.eclipse.jface.dialogs.*;
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 SootOptionsJavaProjectLauncher extends SootProjectLauncher {
35
36     public void run(IAction action) {
37         
38         super.run(action);
39         
40         
41         PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
42         setSdc(new SootDefaultCommands(dialog));
43         presetDialog();
44         dialog.open();
45         if (dialog.getReturnCode() == Dialog.CANCEL) {
46             SavedConfigManager scm = new SavedConfigManager();
47             scm.setEditMap(dialog.getEditMap());
48             scm.handleEdits();
49         }
50         else {
51             SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
52             ssc.toSaveArray();
53             
54             
55             setCmd(ssc.toRunArray());
56             String JavaDoc mainClass = dialog.getSootMainClass();
57             if ((mainClass == null) || (mainClass.length() == 0)){
58                 runSootDirectly();
59             }
60             else {
61                 runSootDirectly(mainClass);
62             }
63             runFinish();
64             
65             // save config if nessesary
66
SavedConfigManager scm = new SavedConfigManager();
67             scm.setEditMap(dialog.getEditMap());
68             scm.handleEdits();
69         }
70     }
71     
72     private void presetDialog() {
73         getSdc().setOutputDir(getOutputLocation());
74     
75         Iterator JavaDoc it = getJavaProcessPath().iterator();
76         String JavaDoc cp = (String JavaDoc)it.next();
77         while (it.hasNext()){
78             cp = cp + getSootClasspath().getSeparator() + (String JavaDoc)it.next();
79         }
80         cp = cp + getSootClasspath().getSeparator()+ getClasspathAppend();
81         getSdc().setSootClassPath(cp);
82         getSdc().setProcessPath(getJavaProcessPath());
83         getSdc().setKeepLineNum();
84         getSdc().setPrintTags();
85         getSdc().setSrcPrec("java");
86         getSdc().setSootMainClass();
87     }
88     
89     // TODO use this method instaed of one with String
90
private void setCmd(ArrayList JavaDoc user_cmd){
91         getSootCommandList().addSingleOpt(user_cmd);
92     }
93     
94     private void setCmd(String JavaDoc user_cmd) {
95         
96         getSootCommandList().addSingleOpt(user_cmd);
97     
98     }
99 }
100
Popular Tags