KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Launches a saved Soot configuration on the all the
33  * class files in the output dir of the selected project
34  */

35 public class SootConfigJavaProjectLauncher extends SootProjectLauncher {
36
37     public void run(IAction action) {
38         
39         super.run(action);
40         
41         SootConfigManagerDialog manager = new SootConfigManagerDialog(getWindow().getShell());
42         manager.setEclipseDefList(setEclipseDefs());
43         manager.setLauncher(this);
44         manager.open();
45         
46         
47     }
48     
49     public void launch(String JavaDoc name, String JavaDoc mainClass) {
50         
51         IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
52         
53         setSootCommandList(new SootCommandList());
54         
55         SootSavedConfiguration ssc = new SootSavedConfiguration(name, settings.getArray(name));
56         ssc.setEclipseDefs(setRunEclipseDefs());
57         
58         getSootCommandList().addSingleOpt(ssc.toRunArray());
59         
60         if ((mainClass == null) || (mainClass.length() == 0)){
61             runSootDirectly();
62         }
63         else {
64             runSootDirectly(mainClass);
65         }
66         runFinish();
67     }
68     
69     private HashMap JavaDoc setEclipseDefs() {
70         
71         HashMap JavaDoc defs = new HashMap JavaDoc();
72         defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
73         Iterator JavaDoc it = getJavaProcessPath().iterator();
74         String JavaDoc cp = (String JavaDoc)it.next();
75         while (it.hasNext()){
76             cp = cp + getSootClasspath().getSeparator() + (String JavaDoc)it.next();
77         }
78         cp = cp + getSootClasspath().getSeparator() + getClasspathAppend();
79         defs.put(LaunchCommands.SOOT_CLASSPATH, cp);
80         defs.put(LaunchCommands.PROCESS_PATH, getJavaProcessPath());
81         defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean JavaDoc(true));
82         defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean JavaDoc(true));
83         
84         defs.put(LaunchCommands.SRC_PREC, "java");
85         
86         return defs;
87     }
88     
89     private HashMap JavaDoc setRunEclipseDefs() {
90         
91         HashMap JavaDoc defs = new HashMap JavaDoc();
92         defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
93         Iterator JavaDoc it = getJavaProcessPath().iterator();
94         String JavaDoc cp = (String JavaDoc)it.next();
95         while (it.hasNext()){
96             cp = cp + getSootClasspath().getSeparator() + (String JavaDoc)it.next();
97         }
98         cp = cp + getSootClasspath().getSeparator() + getClasspathAppend();
99         defs.put(LaunchCommands.SOOT_CLASSPATH, cp);
100         Iterator JavaDoc it2 = getJavaProcessPath().iterator();
101         String JavaDoc pPath = "";
102         while (it2.hasNext()){
103             String JavaDoc next = (String JavaDoc)it2.next();
104             if (pPath.equals("")){
105                 pPath = next;
106             }
107             else {
108                 pPath = pPath + "\r\n" + next;
109             }
110             
111         }
112         defs.put(LaunchCommands.PROCESS_PATH, pPath);
113         defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean JavaDoc(true));
114         defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean JavaDoc(true));
115     
116         defs.put(LaunchCommands.SRC_PREC, "java");
117         return defs;
118     }
119     
120     
121 }
122
Popular Tags