1 19 20 package ca.mcgill.sable.soot; 21 22 import org.eclipse.ui.PlatformUI; 23 import org.eclipse.ui.plugin.*; 24 import org.eclipse.core.runtime.*; 25 import org.eclipse.core.resources.*; 26 import org.eclipse.jface.preference.*; 27 import org.eclipse.jface.resource.*; 28 import org.eclipse.jface.text.source.ISourceViewer; 29 import org.eclipse.swt.graphics.*; 30 import org.eclipse.swt.*; 31 32 import java.net.*; 33 import java.util.*; 34 35 import ca.mcgill.sable.soot.editors.ColorManager; 36 import ca.mcgill.sable.soot.launching.*; 37 import ca.mcgill.sable.soot.resources.*; 38 import ca.mcgill.sable.soot.interaction.*; 39 40 41 42 45 public class SootPlugin extends AbstractUIPlugin { 46 private static SootPlugin plugin; 48 private ResourceBundle resourceBundle; 50 51 private SootDocument soot_output_doc; 53 54 private Vector sootOutputEventListeners = new Vector(); 56 57 private ArrayList editorViewers = new ArrayList(); 59 60 private SootPartManager partManager; 61 62 private ColorManager colorManager; 63 64 private DataKeeper dataKeeper; 65 66 private Font sootFont = new Font(null, "Arial", 8, SWT.NORMAL); 67 68 private IProject currentProject; 69 70 74 public void addSootOutputEventListener(ISootOutputEventListener listener) { 75 sootOutputEventListeners.add(listener); 76 } 77 78 82 public void removeSootOutputEventListener(ISootOutputEventListener listener) { 83 sootOutputEventListeners.remove(listener); 84 } 85 86 90 public void fireSootOutputEvent(SootOutputEvent event) { 91 Iterator it = sootOutputEventListeners.iterator(); 92 while (it.hasNext()) { 93 ((ISootOutputEventListener)it.next()).handleSootOutputEvent(event); 94 } 95 } 96 97 100 public SootPlugin(IPluginDescriptor descriptor) { 101 super(descriptor); 102 plugin = this; 103 soot_output_doc = new SootDocument(); 105 soot_output_doc.startUp(); 106 107 try { 108 resourceBundle= ResourceBundle.getBundle(ISootConstants.SOOT_PLUGIN_RESOURCES_ID); 109 } catch (MissingResourceException x) { 110 resourceBundle = null; 111 } 112 113 setManager(new SootResourceManager()); 116 117 PlatformUI.getWorkbench().addWindowListener(new SootWorkbenchListener()); 118 setPartManager(new SootPartManager()); 119 } 120 121 public static ImageDescriptor getImageDescriptor(String name){ 124 try { 125 URL installURL = getDefault().getDescriptor().getInstallURL(); 126 URL iconURL = new URL(installURL, ISootConstants.ICON_PATH + name); 127 return ImageDescriptor.createFromURL(iconURL); 128 } 129 catch (MalformedURLException e){ 130 return ImageDescriptor.getMissingImageDescriptor(); 131 } 132 } 133 134 135 protected void initializeDefaultPreferences(IPreferenceStore store) { 136 store.setDefault(Messages.getString("SootPlugin.classes"), "soot.Main"); store.setDefault(Messages.getString("SootPlugin.selected"), "soot.Main"); } 141 142 private SootResourceManager manager; 143 144 147 public static SootPlugin getDefault() { 148 return plugin; 149 } 150 151 154 public static IWorkspace getWorkspace() { 155 return ResourcesPlugin.getWorkspace(); 156 } 157 158 162 public static String getResourceString(String key) { 163 ResourceBundle bundle= SootPlugin.getDefault().getResourceBundle(); 164 try { 165 return bundle.getString(key); 166 } catch (MissingResourceException e) { 167 return key; 168 } 169 } 170 171 174 public ResourceBundle getResourceBundle() { 175 return resourceBundle; 176 } 177 178 179 183 public void startUp() throws CoreException { 184 super.startup(); 185 soot_output_doc = new SootDocument(); 186 soot_output_doc.startUp(); 187 } 188 189 192 public void shutdown() throws CoreException { 193 super.shutdown(); 194 sootOutputEventListeners.removeAllElements(); 195 } 196 197 198 201 public SootResourceManager getManager() { 202 return manager; 203 } 204 205 208 public void setManager(SootResourceManager manager) { 209 this.manager = manager; 210 } 211 212 public void addEditorViewer(ISourceViewer viewer) { 213 viewer.addTextListener(getManager()); 214 getEditorViewers().add(viewer); 215 } 216 217 220 public ArrayList getEditorViewers() { 221 return editorViewers; 222 } 223 224 227 public void setEditorViewers(ArrayList list) { 228 editorViewers = list; 229 } 230 231 234 public SootPartManager getPartManager() { 235 return partManager; 236 } 237 238 241 public void setPartManager(SootPartManager manager) { 242 partManager = manager; 243 } 244 245 248 public ColorManager getColorManager() { 249 if (colorManager == null ){ 250 colorManager = new ColorManager(); 251 } 252 return colorManager; 253 } 254 255 258 public void setColorManager(ColorManager manager) { 259 colorManager = manager; 260 } 261 262 265 public DataKeeper getDataKeeper() { 266 return dataKeeper; 267 } 268 269 272 public void setDataKeeper(DataKeeper keeper) { 273 dataKeeper = keeper; 274 } 275 276 279 public Font getSootFont() { 280 return sootFont; 281 } 282 283 286 public void setSootFont(Font font) { 287 sootFont = font; 288 } 289 290 293 public IProject getCurrentProject() { 294 return currentProject; 295 } 296 297 300 public void setCurrentProject(IProject project) { 301 currentProject = project; 302 } 303 304 } 305 | Popular Tags |