001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2005 Jennifer Lhotak
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: package ca.mcgill.sable.graph.model;
021:
022: import java.util.*;
023: import org.eclipse.ui.*;
024: import org.eclipse.core.resources.*;
025: import org.eclipse.jface.resource.*;
026:
027: public class Graph extends Element implements IEditorInput {
028:
029: private ArrayList children = new ArrayList();
030: private IResource resource;
031: private String name;
032:
033: public Graph() {
034: super ();
035: }
036:
037: public void addChild(SimpleNode child) {
038: if (getChildren() == null) {
039: setChildren(new ArrayList());
040: }
041: getChildren().add(child);
042: fireStructureChange(GRAPH_CHILD, child);
043: }
044:
045: public void removeChild(SimpleNode child) {
046: if (getChildren() == null)
047: return;
048: if (getChildren().contains(child)) {
049: getChildren().remove(child);
050: fireStructureChange(GRAPH_CHILD, child);
051: }
052: }
053:
054: public void removeAllChildren() {
055: setChildren(new ArrayList());
056: fireStructureChange(GRAPH_CHILD, null);
057: }
058:
059: /**
060: * @return
061: */
062: public ArrayList getChildren() {
063: return children;
064: }
065:
066: /**
067: * @param list
068: */
069: public void setChildren(ArrayList list) {
070: children = list;
071: }
072:
073: public boolean exists() {
074: return false;
075: }
076:
077: public ImageDescriptor getImageDescriptor() {
078: return null;
079: }
080:
081: public IPersistableElement getPersistable() {
082: return null;
083: }
084:
085: public String getToolTipText() {
086: return getName();
087: }
088:
089: public Object getAdapter(Class c) {
090: if (c == IResource.class) {
091: return getResource();
092: }
093: return null;
094: }
095:
096: /**
097: * @return
098: */
099: public IResource getResource() {
100: return resource;
101: }
102:
103: /**
104: * @param resource
105: */
106: public void setResource(IResource resource) {
107: this .resource = resource;
108: }
109:
110: /**
111: * @return
112: */
113: public String getName() {
114: return name;
115: }
116:
117: /**
118: * @param string
119: */
120: public void setName(String string) {
121: name = string;
122: }
123:
124: }
|