KickJava   Java API By Example, From Geeks To Geeks.

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


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