1 19 20 package ca.mcgill.sable.soot.attributes; 21 22 import java.util.*; 23 24 import org.eclipse.jface.text.*; 25 import org.eclipse.swt.custom.StyleRange; 26 import org.eclipse.swt.graphics.Color; 27 import org.eclipse.swt.graphics.RGB; 28 import org.eclipse.swt.widgets.Display; 29 import org.eclipse.swt.*; 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 SootAttributesJavaColorer extends AbstractAttributesColorer implements Runnable { 37 38 public void run(){ 39 init(); 40 computeColors(); 41 } 42 43 public void computeColors(){ 45 if ((getHandler() == null) || (getHandler().getAttrList() == null)) return; 46 ArrayList sortedAttrs = sortAttrsByLength(getHandler().getAttrList()); 47 Iterator it = sortedAttrs.iterator(); 48 49 setStyleList(new ArrayList()); 50 51 getDisplay().asyncExec( new Runnable () { 52 public void run() { 53 if ((getViewer() != null) && (getViewer().getTextWidget() != null)){ 54 setBgColor(getViewer().getTextWidget().getBackground()); 55 } 56 }; 57 }); 58 59 while (it.hasNext()) { 60 SootAttribute sa = (SootAttribute)it.next(); 62 if ((sa.getJavaStartLn() != 0) && (sa.getJavaEndLn() != 0)){ 63 if (sa.getJavaStartPos() != 0 && sa.getJavaEndPos() != 0){ 64 if (sa.getColorList() != null){ 65 Iterator cit = sa.getColorList().iterator(); 66 while (cit.hasNext()){ 67 ColorAttribute ca = (ColorAttribute)cit.next(); 68 if (getHandler().isShowAllTypes()){ 69 boolean fg = ca.fg() == 1 ? true: false; 70 setAttributeTextColor(sa.getJavaStartLn(), sa.getJavaEndLn(), sa.getJavaStartPos()+1, sa.getJavaEndPos()+1, ca.getRGBColor(), fg); } 72 else { 73 if (getHandler().getTypesToShow().contains(ca.type())){ 74 boolean fg = ca.fg() == 1 ? true: false; 75 setAttributeTextColor(sa.getJavaStartLn(), sa.getJavaEndLn(), sa.getJavaStartPos()+1, sa.getJavaEndPos()+1, ca.getRGBColor(), fg); } 77 } 78 } 79 } 80 81 } 82 } 83 84 } 85 changeStyles(); 86 } 87 88 89 protected void setLength(SootAttribute sa, int len){ 90 sa.setJavaLength(len); 91 } 92 93 } 94 | Popular Tags |