KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > attributes > SootAttrJavaIconGenerator


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20
21 package ca.mcgill.sable.soot.attributes;
22
23 import java.util.*;
24
25 import org.eclipse.core.resources.*;
26 import org.eclipse.core.runtime.CoreException;
27 import org.eclipse.ui.texteditor.MarkerUtilities;
28
29
30 public class SootAttrJavaIconGenerator implements Runnable JavaDoc{
31
32     private IFile rec;
33     private SootAttributesHandler handler;
34
35     public void run(){
36         removeOldMarkers();
37         addSootAttributeMarkers();
38     }
39     
40     private boolean typesContainsOneOf(ArrayList list){
41         boolean result = false;
42         Iterator it = list.iterator();
43         while (it.hasNext()){
44             if (getHandler().getTypesToShow().contains(it.next())) {
45                 result = true;
46                 break;
47             }
48         }
49         return result;
50     }
51     
52     public void addSootAttributeMarkers(){//SootAttributesHandler handler, IFile rec) {
53

54         if (getHandler().getAttrList() == null) return;
55         Iterator it = getHandler().getAttrList().iterator();
56         HashMap markerAttr = new HashMap();
57     
58         while (it.hasNext()) {
59             SootAttribute sa = (SootAttribute)it.next();
60             if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())) {
61                 if (((sa.getAllTextAttrs("<br>") == null) || (sa.getAllTextAttrs("<br>").length() == 0)) &&
62                     ((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue;
63                 markerAttr.put(IMarker.LINE_NUMBER, new Integer JavaDoc(sa.getJavaStartLn()));
64                 try {
65                     MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker");
66                 }
67                 catch(CoreException e) {
68                     System.out.println(e.getMessage());
69                 }
70             }
71         }
72     }
73     public void removeOldMarkers(){//IFile file){
74
try{
75             getRec().deleteMarkers("ca.mcgill.sable.soot.sootattributemarker", true, IResource.DEPTH_INFINITE);
76         }
77         catch(CoreException e){
78         }
79     }
80     /**
81      * @return
82      */

83     public SootAttributesHandler getHandler() {
84         return handler;
85     }
86
87     /**
88      * @return
89      */

90     public IFile getRec() {
91         return rec;
92     }
93
94     /**
95      * @param handler
96      */

97     public void setHandler(SootAttributesHandler handler) {
98         this.handler = handler;
99     }
100
101     /**
102      * @param file
103      */

104     public void setRec(IFile file) {
105         rec = file;
106     }
107
108 }
109
Popular Tags