KickJava   Java API By Example, From Geeks To Geeks.

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


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.cfg.editParts;
22
23 import java.beans.PropertyChangeEvent JavaDoc;
24 import java.beans.PropertyChangeListener JavaDoc;
25
26 import org.eclipse.draw2d.*;
27 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
28 import org.eclipse.gef.*;
29 import ca.mcgill.sable.soot.cfg.editpolicies.*;
30 import ca.mcgill.sable.soot.cfg.model.*;
31 import ca.mcgill.sable.soot.*;
32 import org.eclipse.swt.graphics.*;
33 import org.eclipse.swt.*;
34
35 public class FlowInfoEditPart
36     extends AbstractGraphicalEditPart
37     implements PropertyChangeListener JavaDoc {
38
39     Font f = new Font(null, "Arial", 8, SWT.NORMAL);
40     
41
42     public FlowInfoEditPart() {
43         super();
44     }
45
46     /* (non-Javadoc)
47      * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
48      */

49     protected IFigure createFigure() {
50         return new Label();
51     }
52
53     /* (non-Javadoc)
54      * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
55      */

56     protected void createEditPolicies() {
57         installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,new FlowSelectPolicy());
58     
59     }
60
61     /* (non-Javadoc)
62      * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
63      */

64     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
65         if (evt.getPropertyName().equals(CFGElement.FLOW_INFO)){
66             
67             ((Label)getFigure()).setText(evt.getNewValue().toString());
68             ((Label)getFigure()).setFont(f);
69             ((Label)getFigure()).setForegroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0,153,0)));
70             ((Label)getFigure()).setSize(evt.getNewValue().toString().length()*7, getFigure().getBounds().height);
71             ((PartialFlowDataEditPart)getParent()).updateSize(evt.getNewValue().toString().length()*7+10);
72             
73         }
74     }
75     
76     public void resetColors(){
77         ((Label)getFigure()).setForegroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0, 0, 0)));
78     }
79
80     /**
81      * @return
82      */

83     public CFGFlowInfo getFlowInfo() {
84         return (CFGFlowInfo)getModel();
85     }
86
87
88
89     public void activate(){
90         super.activate();
91         getFlowInfo().addPropertyChangeListener(this);
92     }
93     
94     public void deactivate(){
95         super.deactivate();
96         getFlowInfo().removePropertyChangeListener(this);
97     }
98     
99     public void handleClickEvent(Object JavaDoc evt){
100         System.out.println(getParent().getClass());
101         ((PartialFlowDataEditPart)getParent()).handleClickEvent(evt);
102     }
103 }
104
Popular Tags