blob: 249cdc87439b1003c6c853ca80ccf3c2c07f9968 (
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
73
|
/**
* Copyright (c) 2015 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 472932
*/
package org.eclipse.papyrus.uml.diagram.communication.custom.edit.parts;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationStereotypeLabelEditPartCN;
import org.eclipse.papyrus.uml.diagram.communication.edit.policies.UMLTextSelectionEditPolicy;
/**
* The custom edit policy for the time observation stereotype label.
*/
public class CustomTimeObservationStereotypeLabelEditPartCN extends TimeObservationStereotypeLabelEditPartCN {
/**
* Constructor.
*
* @param view
* The view
*/
public CustomTimeObservationStereotypeLabelEditPartCN(final View view) {
super(view);
}
/**
* Redefine the refresh label to get the STEREOTYPE_LABEL_POLICY if exist and don't recalculate the text.
*
* @see org.eclipse.papyrus.uml.diagram.composite.edit.parts.PortAppliedStereotypeEditPart#refreshLabel()
*/
@Override
protected void refreshLabel() {
EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
if (maskLabelPolicy == null) {
maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL);
}
// Bug 472932 : Stereotype is always displayed
if (maskLabelPolicy == null) {
maskLabelPolicy = getEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY);
}
if (maskLabelPolicy == null) {
View view = (View) getModel();
if (view.isVisible()) {
setLabelTextHelper(getFigure(), getLabelText());
setLabelIconHelper(getFigure(), getLabelIcon());
} else {
setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$
setLabelIconHelper(getFigure(), null);
}
}
Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
}
Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
}
}
}
|