blob: 0d9f3a48c17de6817937f0ed00a77383568c0144 (
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
61
62
63
64
65
66
67
68
69
70
71
72
|
package org.eclipse.papyrus.uml.diagram.component.custom.edit.part;
/*****************************************************************************
* Copyright (c) 2014 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:
* Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 440224 : Label Alignment
* Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Text alignment implementation
*
*****************************************************************************/
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.locator.IPapyrusBorderItemLocator;
import org.eclipse.papyrus.uml.diagram.component.edit.parts.PortNameEditPart;
/**
* The Class CustomPortNameEditPart.
*/
public class CustomPortNameEditPart extends PortNameEditPart {
/**
* Instantiates a new custom port name edit part.
*
* @param view
* the view
*/
public CustomPortNameEditPart(View view) {
super(view);
}
/**
* Gets the default text alignment.
*
* @return the default text alignment
*/
@Override
protected int getDefaultTextAlignment() {
return PositionConstants.LEFT;
}
/**
* Refresh Bounds of PortName EditPart
*/
@Override
public void refreshBounds() {
int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
Point offset = new Point(dx, dy);
if (borderLabelLocator == null) {
borderLabelLocator = (IPapyrusBorderItemLocator) getBorderItemLocator();
}
if (offset != null) {
borderLabelLocator.setConstraint(new Rectangle(offset.x, offset.y, 0, 0));
}
borderLabelLocator.setView((View) getModel());
borderLabelLocator.setTextAlignment(getTextAlignment());
borderLabelLocator.setEditpart(this);
getFigure().getParent().setConstraint(getFigure(), borderLabelLocator);
}
}
|