KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.HashMap JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 import org.eclipse.jface.action.IAction;
26 import ca.mcgill.sable.soot.*;
27 import ca.mcgill.sable.soot.ui.SootConfigManagerDialog;
28
29 import org.eclipse.jface.dialogs.*;
30
31
32 /**
33  * Launches a saved Soot configuration on the selected file
34  */

35 public class SootConfigFromJavaFileLauncher extends SootFileLauncher {
36
37     public void run(IAction action) {
38         
39         super.run(action);
40         super.setIsSrcPrec(true);
41         super.setSrcPrec(LaunchCommands.JAVA_IN);
42         super.handleMultipleFiles();
43         
44         if (isDoNotContinue()) return;
45         window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
46         
47         SootConfigManagerDialog manager = new SootConfigManagerDialog(window.getShell());
48         manager.setEclipseDefList(setEclipseDefs());
49         manager.setLauncher(this);
50         manager.open();
51         
52         
53     }
54     
55     public void launch(String JavaDoc name, String JavaDoc mainClass) {
56         
57         IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
58         
59         setSootCommandList(new SootCommandList());
60         
61         
62         SootSavedConfiguration ssc = new SootSavedConfiguration(name, settings.getArray(name));
63         ssc.setEclipseDefs(setEclipseDefs());
64         
65         getSootCommandList().addSingleOpt(ssc.toRunArray());
66         Iterator JavaDoc it = getToProcessList().iterator();
67         while (it.hasNext()){
68             getSootCommandList().addSingleOpt((String JavaDoc)it.next());
69         }
70         
71         if ((mainClass == null) || (mainClass.length() == 0)){
72             runSootDirectly();
73         }
74         else {
75             runSootDirectly(mainClass);
76         }
77         runFinish();
78     }
79     
80     private HashMap JavaDoc setEclipseDefs() {
81         
82         HashMap JavaDoc defs = new HashMap JavaDoc();
83         defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
84         
85         defs.put(LaunchCommands.SOOT_CLASSPATH, getClasspathAppend());
86         
87         if (isSrcPrec()) {
88             defs.put(LaunchCommands.SRC_PREC, getSrcPrec());
89         }
90         defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean JavaDoc(true));
91
92         defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean JavaDoc(true));
93     
94         return defs;
95     }
96
97     
98 }
99
Popular Tags