blob: 4db9abc488e803e62d6cf24b273653f0486c5fe7 (
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
|
/*****************************************************************************
* Copyright (c) 2010 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.uml.textedit.property.xtext.ui.contributions;
import org.eclipse.papyrus.uml.alf.naming.ALFIDConverter;
import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
import org.eclipse.papyrus.uml.xtext.integration.CompletionProposalUtils;
import org.eclipse.uml2.uml.Property;
public class UMLPropertyEditorPropertyUtil extends PropertyUtil {
public static String getLabel(Property property) {
StringBuffer buffer = new StringBuffer();
// visibility
buffer.append(" ");
buffer.append(NamedElementUtil.getVisibilityAsSign(property));
// derived property
buffer.append(getDerived(property));
// name
buffer.append(" ");
buffer.append(ALFIDConverter.nameToID(getName(property)));
// type
if (property.getType() != null) {
buffer.append(" : "
+ CompletionProposalUtils.getQualifiedNameLabelWithSufficientDepth(property.getType(),
property.getNamespace()));
} else {
buffer.append(" : " + TypeUtil.UNDEFINED_TYPE_NAME);
}
// multiplicity -> do not display [1]
String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
if (!multiplicity.trim().equals("[1]")) {
buffer.append(multiplicity);
}
// property modifiers
buffer.append(" ");
buffer.append(PropertyUtil.getModifiersAsString(property, false));
// default value
if (property.getDefault() != null) {
buffer.append(" = ");
buffer.append("\"" + property.getDefault() + "\"");
}
return buffer.toString();
}
}
|