1 11 12 package org.eclipse.debug.internal.ui.views.memory; 13 14 import java.util.ArrayList ; 15 import java.util.Iterator ; 16 17 import org.eclipse.debug.core.model.IMemoryBlock; 18 import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; 19 import org.eclipse.debug.ui.DebugUITools; 20 import org.eclipse.debug.ui.memory.IMemoryRendering; 21 import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; 22 import org.eclipse.jface.action.IAction; 23 import org.eclipse.jface.viewers.ISelection; 24 import org.eclipse.jface.viewers.IStructuredSelection; 25 import org.eclipse.ui.IViewActionDelegate; 26 import org.eclipse.ui.IViewPart; 27 28 34 public class ResetMemoryBlockAction implements IViewActionDelegate{ 35 36 private IViewPart fView; 37 private ArrayList fSelectedMB = new ArrayList (); 38 39 42 public void init(IViewPart view) { 43 fView = view; 44 } 45 46 49 public void run(IAction action) { 50 if (fSelectedMB.isEmpty()) { 51 return; 52 } 53 boolean resetVisible = false; 54 String resetPref = DebugUITools.getPreferenceStore().getString(IDebugPreferenceConstants.PREF_RESET_MEMORY_BLOCK); 55 if (resetPref.equals(IDebugPreferenceConstants.RESET_VISIBLE)) { 56 resetVisible = true; 57 } 58 Iterator iter = fSelectedMB.iterator(); 59 while(iter.hasNext()) { 60 IMemoryBlock mb = (IMemoryBlock)iter.next(); 61 if (fView instanceof MemoryView) { 62 MemoryView memView = (MemoryView)fView; 63 IMemoryRenderingContainer[] containers = memView.getMemoryRenderingContainers(); 64 65 for (int i=0; i<containers.length; i++) { 66 if (containers[i] instanceof RenderingViewPane) { 67 ((RenderingViewPane)containers[i]).resetRenderings(mb, resetVisible); 68 } 69 } 70 } 71 } 72 } 73 74 77 public void selectionChanged(IAction action, ISelection selection) { 78 action.setEnabled(!selection.isEmpty()); 79 if (selection instanceof IStructuredSelection) { 80 IStructuredSelection strucSel = (IStructuredSelection) selection; 81 Object [] objs = strucSel.toArray(); 82 fSelectedMB.clear(); 83 for (int i = 0; i < objs.length; i++) { 84 if (objs[i] instanceof IMemoryBlock) 85 fSelectedMB.add(objs[i]); 86 if (objs[i] instanceof IMemoryRendering) 87 fSelectedMB.add(((IMemoryRendering) objs[i]).getMemoryBlock()); 88 } 89 } 90 } 91 92 } 93 | Popular Tags |