01: package org.drools.eclipse.flow.ruleflow.editor.editpart;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
20: import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
21: import org.eclipse.draw2d.ConnectionAnchor;
22: import org.eclipse.draw2d.Ellipse;
23: import org.eclipse.draw2d.EllipseAnchor;
24: import org.eclipse.draw2d.IFigure;
25: import org.eclipse.draw2d.geometry.Rectangle;
26: import org.eclipse.gef.ConnectionEditPart;
27: import org.eclipse.gef.Request;
28: import org.eclipse.swt.graphics.Color;
29: import org.eclipse.swt.widgets.Display;
30:
31: /**
32: * EditPart for a join node.
33: *
34: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
35: */
36: public class JoinEditPart extends ElementEditPart {
37:
38: private static final Color color = new Color(Display.getCurrent(),
39: 70, 130, 180);
40:
41: protected IFigure createFigure() {
42: return new JoinFigure();
43: }
44:
45: public ConnectionAnchor getSourceConnectionAnchor(
46: ConnectionEditPart connection) {
47: return new EllipseAnchor(getFigure());
48: }
49:
50: public ConnectionAnchor getTargetConnectionAnchor(
51: ConnectionEditPart connection) {
52: return new EllipseAnchor(getFigure());
53: }
54:
55: public ConnectionAnchor getSourceConnectionAnchor(Request request) {
56: return new EllipseAnchor(getFigure());
57: }
58:
59: public ConnectionAnchor getTargetConnectionAnchor(Request request) {
60: return new EllipseAnchor(getFigure());
61: }
62:
63: public class JoinFigure extends ElementFigure {
64:
65: private Ellipse ellipse;
66:
67: protected void customizeFigure() {
68: ellipse = new Ellipse();
69: add(ellipse, 0);
70: ellipse.setBackgroundColor(color);
71: ellipse.setBounds(getBounds());
72: }
73:
74: public void setBounds(Rectangle rectangle) {
75: super .setBounds(rectangle);
76: ellipse.setBounds(rectangle);
77: }
78:
79: public void setSelected(boolean b) {
80: super .setSelected(b);
81: ellipse.setLineWidth(b ? 3 : 1);
82: repaint();
83: }
84: }
85: }
|