Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d374ace68dd88bc467a75b19db61e2ca1e380f36 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*****************************************************************************
 * Copyright (c) 2015 CEA LIST and others.
 * 
 * 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:
 *   Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
 *   Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display

 *   
 *****************************************************************************/

package org.eclipse.papyrus.uml.diagram.common.stereotype.display;

import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;

/**
 * This Class Implement the interface {@link IStereotypeViewProvider} to provide Stereotype Views.
 * 
 * @see IStereotypeViewProvider
 * 
 * @author Céline JANSSENS
 *
 */
public class StereotypeViewProvider implements IStereotypeViewProvider {

	private View mainView;

	private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();

	/**
	 * Constructor.
	 *
	 * @param mainView
	 *            The View on which the Stereotype is applied (i.e: A Shape, an Edge, An Operation, ...)
	 */
	public StereotypeViewProvider(View mainView) {
		super();
		this.mainView = mainView;

	}



	/**
	 * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getProperty(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String)
	 *
	 */
	@Override
	public View getProperty(Property property, Stereotype stereotype, Enum location) {
		View propertyView = null;
		if (StereotypeLocationEnum.IN_COMPARTMENT.equals(location)) {
			propertyView = getStereotypePropertyInCompartment(mainView, stereotype, property);
		} else if (StereotypeLocationEnum.IN_BRACE.equals(location)) {
			propertyView = getStereotypePropertyInBrace(mainView, stereotype, property);
		} else if (StereotypeLocationEnum.IN_COMMENT.equals(location)) {
			propertyView = getStereotypePropertyInComment(mainView, stereotype, property);
		}
		return propertyView;
	}

	/**
	 * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getCompartment(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String)
	 *
	 */
	@Override
	public View getCompartment(Stereotype stereotype, Enum location) {
		View compartmentView = null;
		if (StereotypeLocationEnum.IN_COMPARTMENT.equals(location)) {
			compartmentView = getStereotypeCompartmentInCompartment(mainView, stereotype);
		} else if (StereotypeLocationEnum.IN_BRACE.equals(location)) {
			compartmentView = getStereotypeCompartmentInBrace(mainView, stereotype);
		} else if (StereotypeLocationEnum.IN_COMMENT.equals(location)) {
			compartmentView = getStereotypeCompartmentInComment(mainView, stereotype);
		}
		return compartmentView;
	}

	/**
	 * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getLabel(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String)
	 * 
	 */
	@Override
	public View getLabel(Stereotype stereotype) {
		return getStereotypeLabel(mainView, stereotype);

	}


	/**
	 * Retrieve the Stereotype Compartment related to a Stereotype and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @return The Compartment related to the Stereotype (existing or newly created)
	 */
	public View getStereotypeLabel(final View view, final Stereotype stereotype) {
		View label = helper.getStereotypeLabel(view, stereotype);

		return label;
	}


	/**
	 * Retrieve the Stereotype Compartment View related to a Stereotype in Compartment and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @return The Compartment related to the Stereotype (existing or newly created)
	 */
	public View getStereotypeCompartmentInCompartment(final View view, final Stereotype stereotype) {
		View compartment = helper.getStereotypeCompartment(view, stereotype);

		return compartment;
	}


	/**
	 * Retrieve the Stereotype Compartment View related to a Stereotype in Brace and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @return The Compartment related to the Stereotype (existing or newly created)
	 */
	public View getStereotypeCompartmentInBrace(final View view, final Stereotype stereotype) {
		View compartment = helper.getStereotypeBraceCompartment(view, stereotype);

		return compartment;
	}


	/**
	 * Retrieve the Stereotype Compartment View related to a Stereotype in Comment and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @return The Compartment related to the Stereotype (existing or newly created)
	 */
	public View getStereotypeCompartmentInComment(View view, Stereotype stereotype) {
		View comment = helper.getStereotypeComment(view);
		View compartment = helper.getStereotypeCompartment(comment, stereotype);

		return compartment;
	}

	/**
	 * Retrieve the Stereotype Property related to a Stereotype and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @param property
	 *            The UML Property of the Stereotype to be retrieved.
	 * 
	 * @return The Property related with the Stereotype (existing or newly created)
	 */
	public View getStereotypePropertyInCompartment(final View view, final Stereotype stereotype, final Property property) {
		View propertyView = helper.getStereotypeProperty(view, stereotype, property);


		return propertyView;
	}


	/**
	 * Retrieve the Stereotype Property View related to a Stereotype in Brace and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @param property
	 *            The UML Property of the Stereotype to be retrieved.
	 * 
	 * @return The Property related with the Stereotype (existing or newly created)
	 */
	public View getStereotypePropertyInBrace(View view, Stereotype stereotype, Property property) {

		View propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property);

		return propertyView;

	}



	/**
	 * Retrieve the Stereotype Property View related to a Stereotype in Comment and create it if null.
	 * 
	 * @param view
	 *            The view on which the Compartment is checked
	 * @param stereotype
	 *            The Stereotype of the Compartment that is retrieved.
	 * @param property
	 *            The UML Property of the Stereotype to be retrieved.
	 * 
	 * @return The Property related with the Stereotype (existing or newly created)
	 */
	public View getStereotypePropertyInComment(View view, Stereotype stereotype, Property property) {

		View propertyView = helper.getStereotypePropertyInComment(view, stereotype, property);

		return propertyView;

	}



}

Back to the top