1 11 package org.eclipse.debug.internal.ui.views.memory.renderings; 12 13 import org.eclipse.debug.core.model.MemoryByte; 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.ui.IObjectActionDelegate; 18 import org.eclipse.ui.IWorkbenchPart; 19 20 23 public class BigEndianAction implements IObjectActionDelegate { 24 25 AbstractIntegerRendering fRendering; 26 27 30 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 31 } 32 33 36 public void run(IAction action) { 37 38 if (fRendering == null) 39 return; 40 41 if (fRendering.getDisplayEndianess() != RenderingsUtil.BIG_ENDIAN){ 42 fRendering.setDisplayEndianess(RenderingsUtil.BIG_ENDIAN); 43 fRendering.refresh(); 44 } 45 } 46 47 50 public void selectionChanged(IAction action, ISelection selection) { 51 52 if (selection == null) 53 return; 54 55 if (selection instanceof IStructuredSelection) 56 { 57 Object obj = ((IStructuredSelection)selection).getFirstElement(); 58 if (obj == null) 59 return; 60 61 if (obj instanceof AbstractIntegerRendering) 62 { 63 fRendering = (AbstractIntegerRendering)obj; 64 } 65 66 int endianess = RenderingsUtil.ENDIANESS_UNKNOWN; 67 if (fRendering.getDisplayEndianess() == RenderingsUtil.ENDIANESS_UNKNOWN) 68 { 69 MemoryByte[] selectedBytes = fRendering.getSelectedAsBytes(); 70 for (int i=0; i<selectedBytes.length; i++) 71 { 72 if (!selectedBytes[i].isEndianessKnown()) 73 { 74 endianess = RenderingsUtil.ENDIANESS_UNKNOWN; 75 break; 76 } 77 if (i==0) 78 { 79 endianess = selectedBytes[i].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN; 80 } 81 else 82 { 83 int byteEndianess = selectedBytes[i].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN; 84 if (endianess != byteEndianess) 85 { 86 endianess = RenderingsUtil.ENDIANESS_UNKNOWN; 87 break; 88 } 89 } 90 } 91 } 92 else 93 endianess = fRendering.getDisplayEndianess(); 94 95 if (endianess == RenderingsUtil.BIG_ENDIAN) 96 action.setChecked(true); 97 else 98 action.setChecked(false); 99 } 100 } 101 } 102 | Popular Tags |