01: /*
02: * Copyright 2006 JBoss Inc
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.drools.eclipse.editors.rete.part;
17:
18: import java.beans.PropertyChangeEvent;
19: import java.beans.PropertyChangeListener;
20:
21: import org.drools.eclipse.editors.rete.figure.ConnectionFigure;
22: import org.drools.eclipse.editors.rete.model.ModelElement;
23: import org.eclipse.draw2d.IFigure;
24: import org.eclipse.draw2d.PolylineConnection;
25: import org.eclipse.draw2d.PolylineDecoration;
26: import org.eclipse.gef.EditPolicy;
27: import org.eclipse.gef.editparts.AbstractConnectionEditPart;
28: import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
29:
30: /**
31: * Edit part for Connection model elements.
32: */
33: class ConnectionEditPart extends AbstractConnectionEditPart implements
34: PropertyChangeListener {
35:
36: /* (non-Javadoc)
37: * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
38: */
39: public void activate() {
40: if (!isActive()) {
41: super .activate();
42: ((ModelElement) getModel()).addPropertyChangeListener(this );
43: }
44: }
45:
46: /* (non-Javadoc)
47: * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
48: */
49: protected void createEditPolicies() {
50: installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
51: new ConnectionEndpointEditPolicy());
52: }
53:
54: /* (non-Javadoc)
55: * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
56: */
57: protected IFigure createFigure() {
58: PolylineConnection connection = new ConnectionFigure();
59: PolylineDecoration decoration = new PolylineDecoration();
60: connection.setTargetDecoration(decoration);
61: return connection;
62: }
63:
64: /* (non-Javadoc)
65: * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
66: */
67: public void deactivate() {
68: if (isActive()) {
69: super .deactivate();
70: ((ModelElement) getModel())
71: .removePropertyChangeListener(this );
72: }
73: }
74:
75: /* (non-Javadoc)
76: * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
77: */
78: public void propertyChange(PropertyChangeEvent evt) {
79: // Doing nothing
80: }
81:
82: }
|