KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > graph > model > Graph


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 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.graph.model;
22 import java.util.*;
23 import org.eclipse.ui.*;
24 import org.eclipse.core.resources.*;
25 import org.eclipse.jface.resource.*;
26
27
28 public class Graph extends Element implements IEditorInput {
29
30     private ArrayList children = new ArrayList();
31     private IResource resource;
32     private String JavaDoc name;
33     
34     
35     public Graph() {
36         super();
37     }
38
39     public void addChild(SimpleNode child){
40         if (getChildren() == null){
41             setChildren(new ArrayList());
42         }
43         getChildren().add(child);
44         fireStructureChange(GRAPH_CHILD, child);
45     }
46     
47     public void removeChild(SimpleNode child){
48         if (getChildren() == null)return;
49         if (getChildren().contains(child)){
50             getChildren().remove(child);
51             fireStructureChange(GRAPH_CHILD, child);
52         }
53     }
54     
55     public void removeAllChildren(){
56         setChildren(new ArrayList());
57         fireStructureChange(GRAPH_CHILD, null);
58     }
59     
60     /**
61      * @return
62      */

63     public ArrayList getChildren() {
64         return children;
65     }
66
67     /**
68      * @param list
69      */

70     public void setChildren(ArrayList list) {
71         children = list;
72     }
73     
74     public boolean exists(){
75         return false;
76     }
77     
78     public ImageDescriptor getImageDescriptor(){
79         return null;
80     }
81     
82     public IPersistableElement getPersistable(){
83         return null;
84     }
85     
86     public String JavaDoc getToolTipText(){
87         return getName();
88     }
89     
90     public Object JavaDoc getAdapter(Class JavaDoc c){
91         if (c == IResource.class){
92             return getResource();
93         }
94         return null;
95     }
96     
97     /**
98      * @return
99      */

100     public IResource getResource() {
101         return resource;
102     }
103
104     /**
105      * @param resource
106      */

107     public void setResource(IResource resource) {
108         this.resource = resource;
109     }
110     
111     /**
112      * @return
113      */

114     public String JavaDoc getName() {
115         return name;
116     }
117
118     /**
119      * @param string
120      */

121     public void setName(String JavaDoc string) {
122         name = string;
123     }
124     
125 }
126
Popular Tags