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 21 25 public class LittleEndianAction implements IObjectActionDelegate { 26 27 AbstractIntegerRendering fRendering; 28 29 32 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 33 } 34 35 38 public void run(IAction action) { 39 40 if (fRendering == null) 41 return; 42 43 if (fRendering.getDisplayEndianess() != RenderingsUtil.LITTLE_ENDIAN){ 44 fRendering.setDisplayEndianess(RenderingsUtil.LITTLE_ENDIAN); 45 fRendering.refresh(); 46 } 47 } 48 49 52 public void selectionChanged(IAction action, ISelection selection) { 53 if (selection == null) 54 return; 55 56 if (selection instanceof IStructuredSelection) 57 { 58 Object obj = ((IStructuredSelection)selection).getFirstElement(); 59 if (obj == null) 60 return; 61 62 if (obj instanceof AbstractIntegerRendering) 63 { 64 fRendering = (AbstractIntegerRendering)obj; 65 } 66 67 int endianess = RenderingsUtil.ENDIANESS_UNKNOWN; 68 if (fRendering.getDisplayEndianess() == RenderingsUtil.ENDIANESS_UNKNOWN) 69 { 70 MemoryByte[] selectedBytes = fRendering.getSelectedAsBytes(); 71 72 for (int i=0; i<selectedBytes.length; i++) 73 { 74 if (!selectedBytes[i].isEndianessKnown()) 75 { 76 endianess = RenderingsUtil.ENDIANESS_UNKNOWN; 77 break; 78 } 79 if (i==0) 80 { 81 endianess = selectedBytes[i].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN; 82 } 83 else 84 { 85 int byteEndianess = selectedBytes[i].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN; 86 if (endianess != byteEndianess) 87 { 88 endianess = RenderingsUtil.ENDIANESS_UNKNOWN; 89 break; 90 } 91 } 92 } 93 } 94 else 95 endianess = fRendering.getDisplayEndianess(); 96 97 if (endianess == RenderingsUtil.LITTLE_ENDIAN) 98 action.setChecked(true); 99 else 100 action.setChecked(false); 101 } 102 } 103 104 } 105 | Popular Tags |