01: /*
02: * Created on 26 avr. 2005
03: *
04: */
05: package org.openwfe.gpe.parts;
06:
07: import java.beans.PropertyChangeEvent;
08: import java.util.Map;
09:
10: import org.eclipse.draw2d.IFigure;
11: import org.eclipse.draw2d.Label;
12: import org.eclipse.draw2d.PositionConstants;
13: import org.eclipse.draw2d.geometry.Insets;
14: import org.eclipse.draw2d.graph.CompoundDirectedGraph;
15: import org.eclipse.draw2d.graph.Node;
16: import org.eclipse.draw2d.graph.Subgraph;
17: import org.eclipse.gef.GraphicalEditPart;
18: import org.eclipse.swt.graphics.Image;
19: import org.openwfe.gpe.FlowImages;
20: import org.openwfe.gpe.figures.NoChildLabel;
21: import org.openwfe.gpe.model.AbstractFlow;
22:
23: /**
24: * @author Christelle
25: *
26: */
27: public class NoChildPart extends FlowElementPart {
28:
29: private Image image = FlowImages.noimage;
30:
31: /**
32: * @param image
33: */
34: public NoChildPart(Image image) {
35: super ();
36: this .image = image;
37: }
38:
39: public void contributeNodesToGraph(CompoundDirectedGraph graph,
40: Subgraph s, Map map) {
41: Node n = new Node(this , s);
42: //n.outgoingOffset = getAnchorOffset();
43: //n.incomingOffset = getAnchorOffset();
44: n.width = getFigure().getPreferredSize().width;
45: n.height = getFigure().getPreferredSize().height;
46: n.setPadding(new Insets(10, 8, 10, 12));
47: map.put(this , n);
48: graph.nodes.add(n);
49: }
50:
51: /**
52: * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
53: */
54: protected IFigure createFigure() {
55: Label l = new NoChildLabel();
56: l.setLabelAlignment(PositionConstants.LEFT);
57: l.setIcon(image);
58: return l;
59: }
60:
61: /* int getAnchorOffset() {
62: return 9;
63: }*/
64:
65: /* protected void performDirectEdit() {
66: if (manager == null) {
67: Label l = (Label)getFigure();
68: manager =
69: new FlowElementDirectEditManager(
70: this,
71: TextCellEditor.class,
72: new FlowElementCellEditorLocator(l), l);
73: }
74: manager.show();
75: }*/
76: public void propertyChange(PropertyChangeEvent evt) {
77: String prop = evt.getPropertyName();
78: if (AbstractFlow.CHILDREN.equals(prop))
79: refreshChildren();
80: refreshVisuals();
81: // Causes Graph to re-layout
82: ((GraphicalEditPart) (getViewer().getContents())).getFigure()
83: .revalidate();
84: }
85:
86: /**
87: * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
88: */
89: protected void refreshVisuals() {
90: ((Label) getFigure()).setText(getActivity().getName());
91: }
92:
93: }
|