1 19 20 21 package ca.mcgill.sable.soot.attributes; 22 23 import java.util.*; 24 25 import org.eclipse.jface.text.*; 26 import org.eclipse.swt.custom.StyleRange; 27 import org.eclipse.swt.graphics.Color; 28 import org.eclipse.swt.graphics.RGB; 29 import org.eclipse.swt.widgets.Display; 30 import org.eclipse.ui.*; 31 import org.eclipse.ui.texteditor.AbstractTextEditor; 32 33 import ca.mcgill.sable.soot.SootPlugin; 34 import ca.mcgill.sable.soot.editors.*; 35 36 public class SootAttributesJimpleColorer extends AbstractAttributesColorer implements Runnable { 37 38 39 public void run(){ 40 init(); 41 computeColors(); 42 } 43 44 public void computeColors(){ 45 if ((getHandler() == null) || (getHandler().getAttrList() == null)) return; 46 ArrayList sortedAttrs = sortAttrsByLength(getHandler().getAttrList()); 47 Iterator it = getHandler().getAttrList().iterator(); 48 49 setStyleList(new ArrayList()); 50 51 getDisplay().asyncExec( new Runnable () { 52 public void run(){ 53 setBgColor(getViewer().getTextWidget().getBackground()); 54 }; 55 }); 56 57 while (it.hasNext()) { 58 SootAttribute sa = (SootAttribute)it.next(); 60 if ((sa.getJimpleStartLn() != 0) && (sa.getJimpleEndLn() != 0)) { 61 if ((sa.getJimpleStartPos() != 0) && (sa.getJimpleEndPos() != 0)){ 62 if (sa.getColorList() != null){ 63 Iterator cit = sa.getColorList().iterator(); 64 while (cit.hasNext()){ 65 ColorAttribute ca = (ColorAttribute)cit.next(); 66 if (getHandler().isShowAllTypes()){ 67 boolean fg = ca.fg() == 1 ? true: false; 68 setAttributeTextColor(sa.getJimpleStartLn(), sa.getJimpleEndLn(), sa.getJimpleStartPos()+1, sa.getJimpleEndPos()+1, ca.getRGBColor(), fg); } 70 else { 71 if (getHandler().getTypesToShow().contains(ca.type())){ 72 boolean fg = ca.fg() == 1 ? true: false; 73 setAttributeTextColor(sa.getJimpleStartLn(), sa.getJimpleEndLn(), sa.getJimpleStartPos()+1, sa.getJimpleEndPos()+1, ca.getRGBColor(), fg); } 75 } 76 } 77 } 78 79 } 80 } 81 82 } 83 84 changeStyles(); 85 } 86 protected void setLength(SootAttribute sa, int len){ 87 sa.setJimpleLength(len); 88 } 89 90 91 } 92 | Popular Tags |