blob: 362a1b7fde8f71446ea40c96089387dafff5aa85 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.editpart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusConnectionEndEditPolicy;
/**
* Abstract edit part for all connection nodes.
*/
public abstract class ConnectionEditPart extends ConnectionNodeEditPart implements IPapyrusEditPart {
public ConnectionEditPart(View view) {
super(view);
}
/**
*
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart#createDefaultEditPolicies()
*
*/
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new PapyrusConnectionEndEditPolicy());
}
@Override
protected void setLineWidth(int width) {
if(width < 0) {
width = 1;
}
if(getFigure() instanceof PolylineConnectionEx) {
PolylineConnectionEx conn = (PolylineConnectionEx)getFigure();
conn.setLineWidth(getMapMode().DPtoLP(width));
}
}
@Override
protected void refreshVisuals() {
super.refreshVisuals();
refreshLineWidth();
installRouter();
}
}
|