KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > cfg > model > CFGGraph


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 package ca.mcgill.sable.soot.cfg.model;
21
22 import java.util.*;
23 import org.eclipse.ui.*;
24 import org.eclipse.jface.resource.*;
25 import org.eclipse.core.runtime.*;
26 import org.eclipse.draw2d.graph.*;
27 import org.eclipse.core.resources.*;
28
29 public class CFGGraph extends CFGElement implements IEditorInput {
30
31     private String JavaDoc name;
32     private ArrayList children = new ArrayList();
33     private IResource resource;
34     
35     
36     public CFGGraph() {
37     }
38
39     
40     public void addChild(CFGNode child){
41         children.add(child);
42         fireStructureChange(CHILDREN, child);
43     }
44         
45     
46     /**
47      * @return
48      */

49     public String JavaDoc getName() {
50         return name;
51     }
52
53     
54     
55     /**
56      * @param string
57      */

58     public void setName(String JavaDoc string) {
59         name = string;
60     }
61
62     
63
64     public boolean exists(){
65         return false;
66     }
67     
68     public ImageDescriptor getImageDescriptor(){
69         return null;
70     }
71     
72     public IPersistableElement getPersistable(){
73         return null;
74     }
75     
76     public String JavaDoc getToolTipText(){
77         return getName();
78     }
79     
80     public Object JavaDoc getAdapter(Class JavaDoc c){
81         if (c == IResource.class){
82             return getResource();
83         }
84         return null;
85     }
86         
87     /**
88      * @return
89      */

90     public ArrayList getChildren() {
91         return children;
92     }
93
94     /**
95      * @param list
96      */

97     public void setChildren(ArrayList list) {
98         children = list;
99     }
100
101     /**
102      * @return
103      */

104     public IResource getResource() {
105         return resource;
106     }
107
108     /**
109      * @param resource
110      */

111     public void setResource(IResource resource) {
112         this.resource = resource;
113     }
114     
115     public void newFlowData(){
116         firePropertyChange(CFGElement.NEW_FLOW_DATA, null);
117     }
118
119     public void handleClickEvent(Object JavaDoc evt){
120         Iterator it = getChildren().iterator();
121         while (it.hasNext()){
122             CFGNode child = (CFGNode)it.next();
123             ArrayList list = child.getData().getText();
124             if (list.size() == 1){
125                 if (list.get(0).equals(evt)){
126                     child.handleClickEvent(evt);
127                 }
128             }
129         }
130     }
131 }
132
Popular Tags