Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c64fdb37fcafa5c439103fb5824038afa0e7f136 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*****************************************************************************
 * Copyright (c) 2011 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:
 *  Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.table.widget.celleditors.composite;


import org.eclipse.swt.widgets.Composite;
import org.eclipse.uml2.uml.Enumeration;
import org.eclipse.uml2.uml.EnumerationLiteral;

/**
 * 
 * This Composite allows to edit the Enumeration in Papyrus table.
 * Useful to edit the property of the stereotyped element when the property is typed with an Enumeration.
 * 
 */
public class EnumerationComposite extends EnumComposite<EnumerationLiteral> {

	/**
	 * the enumeration
	 */
	private Enumeration enumeration;

	/**
	 * 
	 * Constructor.
	 * 
	 * @param parent
	 */
	public EnumerationComposite(final Composite parent) {
		super(parent);
	}

	/**
	 * 
	 * @param enumeration
	 */
	public void setEnumeration(final Enumeration enumeration) {
		this.enumeration = enumeration;
		getCombo().setItems(getEnumStrings());
	}

	/**
	 * 
	 * @see org.eclipse.emf.facet.widgets.celleditors.internal.core.composite.EnumComposite#getEnumValue(java.lang.String)
	 * 
	 *      {@inheritDoc}
	 */
	@Override
	protected EnumerationLiteral getEnumValue(final String text) {
		return this.enumeration.getOwnedLiteral(text);
	}

	/**
	 * 
	 * @see org.eclipse.emf.facet.widgets.celleditors.internal.core.composite.EnumComposite#getEnumString(java.lang.Object)
	 * 
	 *      {@inheritDoc}
	 */
	@Override
	protected String getEnumString(final EnumerationLiteral value) {
		return value.getName();
	}

	/**
	 * 
	 * @see org.eclipse.emf.facet.widgets.celleditors.internal.core.composite.EnumComposite#getEnumStrings()
	 * 
	 *      {@inheritDoc}
	 */
	@Override
	protected String[] getEnumStrings() {
		int size = this.enumeration.getOwnedLiterals().size();
		String[] strs = new String[size];
		for(int i = 0; i < size; i++) {
			strs[i] = this.enumeration.getOwnedLiterals().get(i).getName();
		}
		return strs;
	}

}

Back to the top