| 1 19 20 21 package ca.mcgill.sable.soot.cfg; 22 23 import org.eclipse.core.resources.*; 24 import org.eclipse.core.runtime.IProgressMonitor; 25 import org.eclipse.ui.*; 26 import org.eclipse.gef.ui.parts.*; 27 import org.eclipse.gef.*; 28 import org.eclipse.gef.editparts.*; 29 import ca.mcgill.sable.soot.cfg.model.*; 30 import ca.mcgill.sable.soot.cfg.editParts.*; 31 import org.eclipse.jface.action.*; 33 import org.eclipse.gef.ui.actions.*; 34 35 public class CFGEditor extends GraphicalEditor { 36 37 private CFGGraph cfgGraph; 38 39 public CFGEditor() { 40 DefaultEditDomain defaultEditDomain = new DefaultEditDomain(this); 41 setEditDomain(defaultEditDomain); 42 43 } 44 45 48 protected void initializeGraphicalViewer() { 49 getGraphicalViewer().setContents(cfgGraph); 50 51 } 52 53 protected void configureGraphicalViewer() { 54 super.configureGraphicalViewer(); 55 ScalableRootEditPart root = new ScalableRootEditPart(); 56 getGraphicalViewer().setRootEditPart(root); 57 58 ZoomManager zManager = root.getZoomManager(); 59 double [] zoomLevels = new double[10]; 60 for (int i = 0; i < zoomLevels.length; i++){ 61 zoomLevels[i] = (i + 1) * 0.25; 62 } 63 zManager.setZoomLevels(zoomLevels); 64 IAction zoomIn = new ZoomInAction(zManager); 65 IAction zoomOut = new ZoomOutAction(((ScalableRootEditPart)getGraphicalViewer().getRootEditPart()).getZoomManager()); 66 67 getActionRegistry().registerAction(zoomIn); 68 getActionRegistry().registerAction(zoomOut); 69 70 getSite().getKeyBindingService().registerAction(zoomIn); 71 getSite().getKeyBindingService().registerAction(zoomOut); 72 73 74 getGraphicalViewer().setEditPartFactory(new CFGPartFactory()); 75 getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer())); 76 77 StopAction stop = new StopAction(this); 78 getActionRegistry().registerAction(stop); 79 this.getSelectionActions().add(stop.getId()); 80 81 UnStopAction unStop = new UnStopAction(this); 82 getActionRegistry().registerAction(unStop); 83 this.getSelectionActions().add(unStop.getId()); 84 85 86 CFGMenuProvider menuProvider = new CFGMenuProvider(getGraphicalViewer(), getActionRegistry(), this); 87 getGraphicalViewer().setContextMenu(menuProvider); 88 getSite().registerContextMenu(menuProvider, getGraphicalViewer()); 89 90 } 91 92 protected void createActions(){ 94 95 super.createActions(); 96 97 111 112 } 113 114 protected void setInput(IEditorInput input){ 115 super.setInput(input); 116 if (input instanceof CFGGraph){ 117 setCfgGraph((CFGGraph)input); 118 } 119 121 } 122 123 126 public void doSave(IProgressMonitor monitor) { 127 137 } 138 139 143 146 public void doSaveAs() { 147 149 } 150 151 154 public void gotoMarker(IMarker marker) { 155 157 } 158 159 162 public boolean isDirty() { 163 return false; 166 } 167 168 171 public boolean isSaveAsAllowed() { 172 return false; 174 } 175 176 177 180 public CFGGraph getCfgGraph() { 181 return cfgGraph; 182 } 183 184 187 public void setCfgGraph(CFGGraph graph) { 188 cfgGraph = graph; 189 } 190 191 public void setTitle(String name){ 192 super.setTitle(name); 193 } 194 195 public void setTitleTooltip(String text){ 196 super.setTitleToolTip(text); 197 } 198 199 public String getToolTipText(){ 200 return "cfg editor"; 201 } 202 203 204 205 206 } 207 | Popular Tags |