001: package visualdebugger.draw2d;
002:
003: import org.eclipse.draw2d.*;
004: import org.eclipse.jdt.core.ICompilationUnit;
005: import org.eclipse.jdt.core.dom.ASTNode;
006: import org.eclipse.swt.graphics.Color;
007:
008: import de.uka.ilkd.key.visualdebugger.VisualDebugger;
009: import de.uka.ilkd.key.visualdebugger.executiontree.ETMethodReturnNode;
010:
011: public class MethodReturnFigure extends Figure {
012:
013: private boolean selected;
014:
015: static final Color gradient1 = new Color(null, 132, 132, 240);
016:
017: static final Color gradient2 = new Color(null, 76, 84, 216);
018:
019: static final Color gradient12 = new Color(null, 202, 202, 210);
020:
021: static final Color gradient22 = new Color(null, 146, 154, 186);
022:
023: static final Color corner1 = new Color(null, 200, 208, 223);
024:
025: static final Color corner2 = new Color(null, 160, 172, 200);
026:
027: static final Color blue = new Color(null, 152, 168, 200);
028:
029: static final Color shadow = new Color(null, 202, 202, 202);
030:
031: static final int CORNER_SIZE = 00;
032:
033: final ETMethodReturnNode mrNode;
034:
035: ICompilationUnit unit;
036:
037: static final Border BORDER = new LineBorder(ColorConstants.black, 1);
038:
039: private Label label = new Label();
040:
041: public MethodReturnFigure(ETMethodReturnNode etNode) {
042: super ();
043: setBorder(BORDER);
044: setLayoutManager(new StackLayout());
045:
046: add(label);
047:
048: this .mrNode = etNode;
049:
050: String st;
051: if (mrNode.getResult() != null)
052: st = "return "
053: + VisualDebugger.getVisualDebugger().prettyPrint(
054: mrNode.getResult());
055: else
056: st = "return";
057:
058: label.setText(st);
059:
060: String toolTip = "Returned from method:\n "
061: + VisualDebugger.getMethodString(mrNode.getParent()
062: .getLastMethodInvocation().getMethod()
063: .getMethodDeclaration());
064:
065: this .setToolTip(new Label(toolTip));
066: }
067:
068: /**
069: * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
070: */
071: protected void paintFigure(Graphics g) {
072: super .paintFigure(g);
073: if (selected) {
074: g.setForegroundColor(ColorConstants.menuBackgroundSelected);
075: g.setBackgroundColor(ColorConstants.titleGradient);
076: } else {
077:
078: // g.setForegroundColor(gradient1);
079: // g.setBackgroundColor(gradient2);
080:
081: g.setForegroundColor(ColorConstants.white);
082: g.setBackgroundColor(ColorConstants.white);
083:
084: }
085: g.fillGradient(getBounds().getResized(-1, -1), true);
086:
087: }
088:
089: public void setSelected(boolean value) {
090: this .selected = value;
091: if (selected)
092: label.setForegroundColor(ColorConstants.white);
093: else
094: label.setForegroundColor(null);
095: repaint();
096: }
097:
098: /**
099: * @see java.lang.Object#toString()
100: */
101: public String toString() {
102: return ((Label) getChildren().get(0)).getText();
103: }
104:
105: public void validate() {
106: repaint();
107: super .validate();
108: }
109:
110: public ETMethodReturnNode getETNode() {
111: return mrNode;
112: }
113:
114: public ICompilationUnit getUnit() {
115: return unit;
116: }
117:
118: public ASTNode getASTNode() {
119: return null;
120: }
121:
122: }
|