KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > cfg > editParts > PartialFlowDataEditPart


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.editParts;
21
22 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
23
24 import java.beans.PropertyChangeEvent JavaDoc;
25 import java.beans.PropertyChangeListener JavaDoc;
26
27 import org.eclipse.draw2d.*;
28 import ca.mcgill.sable.soot.cfg.figures.*;
29 import ca.mcgill.sable.soot.cfg.model.*;
30 import java.util.*;
31 import org.eclipse.draw2d.geometry.*;
32
33 public class PartialFlowDataEditPart
34     extends AbstractGraphicalEditPart
35     implements PropertyChangeListener JavaDoc {
36
37     
38     /* (non-Javadoc)
39      * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
40      */

41     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
42         if (evt.getPropertyName().equals(CFGElement.PART_FLOW_CHILDREN)){
43             refreshChildren();
44             refreshVisuals();
45         }
46     }
47     
48     
49     protected void refreshVisuals(){
50         Iterator it = getChildren().iterator();
51         while (it.hasNext()){
52             Object JavaDoc next = it.next();
53             if (next instanceof FlowInfoEditPart){
54                 ((CFGPartialFlowFigure)getFigure()).add(((FlowInfoEditPart)next).getFigure());
55             }
56             
57         }
58     }
59     
60     
61     public void updateSize(int width){
62         int w = ((CFGPartialFlowFigure)getFigure()).getBounds().width;
63         
64         w += width;
65         
66         ((FlowDataEditPart)getParent()).updateSize(w+10);
67         ((CFGPartialFlowFigure)getFigure()).setSize(w+10, getFigure().getBounds().height);
68         
69     }
70     
71     public void resetChildColors(){
72         Iterator it = getChildren().iterator();
73         while (it.hasNext()){
74             Object JavaDoc next = it.next();
75             if (next instanceof FlowInfoEditPart){
76                 ((FlowInfoEditPart)next).resetColors();
77             }
78         }
79     }
80     
81     /* (non-Javadoc)
82      * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
83      */

84     protected IFigure createFigure() {
85         return new CFGPartialFlowFigure();
86     }
87
88     /* (non-Javadoc)
89      * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
90      */

91     protected void createEditPolicies() {
92             
93     }
94
95     public List getModelChildren(){
96         return getPartialFlowData().getChildren();
97     }
98     
99     public void activate(){
100         super.activate();
101         getPartialFlowData().addPropertyChangeListener(this);
102     }
103     
104     public void deactivate(){
105         super.deactivate();
106         getPartialFlowData().removePropertyChangeListener(this);
107     }
108     /**
109      * @return
110      */

111     public CFGPartialFlowData getPartialFlowData() {
112         return (CFGPartialFlowData)getModel();
113     }
114
115     
116     public void handleClickEvent(Object JavaDoc evt){
117         System.out.println(getParent().getClass());
118         ((FlowDataEditPart)getParent()).handleClickEvent(evt);
119     }
120 }
121
Popular Tags