KickJava   Java API By Example, From Geeks To Geeks.

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


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.ui.*;
28 /**
29  * Displays the Soot Options dialog and launches Soot with
30  * selected options on all class files in output dir of
31  * selected project.
32  */

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