01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2003 Jennifer Lhotak
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * 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;
23: import java.util.Iterator;
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 selected file
33: */
34: public class SootConfigFileLauncher extends SootFileLauncher {
35:
36: public void run(IAction action) {
37:
38: super .run(action);
39: super .handleMultipleFiles();
40:
41: if (isDoNotContinue())
42: return;
43: window = SootPlugin.getDefault().getWorkbench()
44: .getActiveWorkbenchWindow();
45:
46: SootConfigManagerDialog manager = new SootConfigManagerDialog(
47: window.getShell());
48: manager.setEclipseDefList(setEclipseDefs());
49: manager.setLauncher(this );
50: manager.open();
51:
52: }
53:
54: public void launch(String name, String mainClass) {
55:
56: IDialogSettings settings = SootPlugin.getDefault()
57: .getDialogSettings();
58:
59: setSootCommandList(new SootCommandList());
60:
61: SootSavedConfiguration ssc = new SootSavedConfiguration(name,
62: settings.getArray(name));
63: ssc.setEclipseDefs(setEclipseDefs());
64:
65: getSootCommandList().addSingleOpt(ssc.toRunArray());
66:
67: Iterator it = getToProcessList().iterator();
68: while (it.hasNext()) {
69: getSootCommandList().addSingleOpt((String) it.next());
70: }
71:
72: getSootCommandList().printList();
73:
74: if ((mainClass == null) || (mainClass.length() == 0)) {
75: runSootDirectly();
76: } else {
77: runSootDirectly(mainClass);
78: }
79: runFinish();
80: }
81:
82: private HashMap setEclipseDefs() {
83:
84: HashMap defs = new HashMap();
85: defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
86:
87: defs.put(LaunchCommands.SOOT_CLASSPATH, getClasspathAppend());
88:
89: if (isSrcPrec()) {
90: defs.put(LaunchCommands.SRC_PREC, getSrcPrec());
91: }
92: defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
93:
94: defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
95:
96: return defs;
97: }
98:
99: }
|