KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 import org.eclipse.core.resources.IFile;
26 import org.eclipse.core.resources.IFolder;
27 import org.eclipse.core.resources.IProject;
28 import org.eclipse.core.resources.IResource;
29 import org.eclipse.core.runtime.CoreException;
30 import org.eclipse.ui.IEditorPart;
31 import org.eclipse.ui.IWorkbenchPage;
32 import org.eclipse.ui.IWorkbenchWindow;
33 import org.eclipse.ui.part.*;
34
35 import ca.mcgill.sable.soot.SootPlugin;
36
37 /**
38  * Handles Soot ouptut dir. Potentially will do something with
39  * Soot generated files such as open them automatically.
40  */

41 public class SootOutputFilesHandler {
42
43     private IFolder sootOutputFolder;
44     private ArrayList JavaDoc oldFilelist;
45     private ArrayList JavaDoc newFilelist;
46     private IWorkbenchWindow window;
47     private ArrayList JavaDoc beforeFileList;
48     
49     
50     /**
51      * Constructor for SootOutputFilesHandler.
52      */

53     public SootOutputFilesHandler(IWorkbenchWindow window) {
54         super();
55         setWindow(window);
56     }
57     
58     
59         
60     public void resetSootOutputFolder(IProject project) {
61         try {
62             setSootOutputFolder(project.getFolder("sootOutput"));
63             if (!getSootOutputFolder().exists()) {
64                 getSootOutputFolder().create(false, true, null);
65             }
66         }
67         catch (Exception JavaDoc e1) {
68             System.out.println(e1.getMessage());
69         }
70     }
71     
72     public void refreshAll(IProject project){
73         try{
74             project.refreshLocal(IResource.DEPTH_INFINITE, null);
75         }
76         catch(CoreException e){
77             System.out.println(e.getMessage());
78         }
79     }
80     
81     public void refreshFolder() {
82         try {
83             getSootOutputFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
84         }
85         catch (CoreException e1) {
86             System.out.println(e1.getMessage());
87         }
88     }
89     
90     public void handleFilesChanged() {
91         
92         // files that were showing close
93
if (getOldFilelist() != null) {
94             Iterator JavaDoc it = getOldFilelist().iterator();
95             while (it.hasNext()) {
96                 Object JavaDoc temp = it.next();
97                 if (temp instanceof IEditorPart) {
98                     getWindow().getActivePage().closeEditor((IEditorPart)temp, true);
99                 }
100             }
101         }
102     
103         try {
104             IResource [] children = getSootOutputFolder().members();
105         
106             IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
107         }
108         catch (Exception JavaDoc e) {
109             System.out.println("Open Editor ex: "+e.getMessage());
110             System.out.println(e.getStackTrace());
111         }
112         // new files show
113
}
114     
115     /**
116      * Returns the sootOuputFolder.
117      * @return IFolder
118      */

119     public IFolder getSootOutputFolder() {
120         return sootOutputFolder;
121     }
122
123     /**
124      * Sets the sootOuputFolder.
125      * @param sootOuputFolder The sootOuputFolder to set
126      */

127     public void setSootOutputFolder(IFolder sootOutputFolder) {
128         this.sootOutputFolder = sootOutputFolder;
129     }
130
131
132     /**
133      * Returns the newFilelist.
134      * @return ArrayList
135      */

136     public ArrayList JavaDoc getNewFilelist() {
137         return newFilelist;
138     }
139
140     /**
141      * Returns the oldFilelist.
142      * @return ArrayList
143      */

144     public ArrayList JavaDoc getOldFilelist() {
145         return oldFilelist;
146     }
147
148     /**
149      * Sets the newFilelist.
150      * @param newFilelist The newFilelist to set
151      */

152     public void setNewFilelist(ArrayList JavaDoc newFilelist) {
153         this.newFilelist = newFilelist;
154     }
155
156     /**
157      * Sets the oldFilelist.
158      * @param oldFilelist The oldFilelist to set
159      */

160     public void setOldFilelist(ArrayList JavaDoc oldFilelist) {
161         this.oldFilelist = oldFilelist;
162     }
163
164     /**
165      * Returns the window.
166      * @return IWorkbenchWindow
167      */

168     public IWorkbenchWindow getWindow() {
169         return window;
170     }
171
172     /**
173      * Sets the window.
174      * @param window The window to set
175      */

176     public void setWindow(IWorkbenchWindow window) {
177         this.window = window;
178     }
179
180 }
181
Popular Tags