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
|
/*****************************************************************************
* 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.modelelement;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.DISPLAY_PLACE;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.HORIZONTAL;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.ICON;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.SHAPE;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.STEREOTYPE_DISPLAY;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.TEXT;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.TEXT_ALIGNMENT;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.TEXT_AND_ICON;
import static org.eclipse.papyrus.uml.properties.util.StereotypeAppearanceConstants.VERTICAL;
import static org.eclipse.papyrus.uml.tools.utils.ui.VisualInformationPapyrusConstant.STEREOTYPE_BRACE_LOCATION;
import static org.eclipse.papyrus.uml.tools.utils.ui.VisualInformationPapyrusConstant.STEREOTYPE_COMMENT_LOCATION;
import static org.eclipse.papyrus.uml.tools.utils.ui.VisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
import org.eclipse.papyrus.uml.properties.Activator;
import org.eclipse.papyrus.uml.properties.databinding.StereotypeAppearanceObservableValue;
import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
import org.eclipse.uml2.uml.Element;
/**
* A ModelElement for manipulating the stereotype appearance properties :
* - stereotypeDisplay
* - textAlignment
* - displayPlace
*
* @author Camille Letavernier
*
*/
public class StereotypeAppearanceModelElement extends AbstractModelElement implements ModelElement {
/**
* The current UML Element
*/
protected Element umlSource;
/**
* The editing domain on which the commands will be called
*/
protected EditingDomain domain;
/**
* The GMF EModelElement
*/
protected EModelElement diagramElement;
/**
*
* Constructor.
*
* @param umlSource
* The UML Element on which the stereotypes are applied
* @param domain
* The Editing Domain on which the commands will be executed
* @param diagramElement
* The GMF EModelElement
*/
public StereotypeAppearanceModelElement(Element umlSource, EditingDomain domain, EModelElement diagramElement) {
this.umlSource = umlSource;
this.domain = domain;
this.diagramElement = diagramElement;
}
@Override
public IObservable doGetObservable(String propertyPath) {
if(propertyPath.equals(STEREOTYPE_DISPLAY) || propertyPath.equals(TEXT_ALIGNMENT) || propertyPath.equals(DISPLAY_PLACE)) {
return new StereotypeAppearanceObservableValue(diagramElement, umlSource, propertyPath, domain);
}
Activator.log.warn("Unknown property : " + propertyPath); //$NON-NLS-1$
return null;
}
@Override
public IStaticContentProvider getContentProvider(String propertyPath) {
if(propertyPath.equals(STEREOTYPE_DISPLAY)) {
return new StaticContentProvider(new String[]{ TEXT, ICON, TEXT_AND_ICON, SHAPE });
} else if(propertyPath.equals(TEXT_ALIGNMENT)) {
return new StaticContentProvider(new String[]{ HORIZONTAL, VERTICAL });
} else if(propertyPath.equals(DISPLAY_PLACE)) {
return new StaticContentProvider(new String[]{ STEREOTYPE_COMPARTMENT_LOCATION, STEREOTYPE_COMMENT_LOCATION, STEREOTYPE_BRACE_LOCATION });
}
return EmptyContentProvider.instance;
}
@Override
public boolean isMandatory(String propertyPath) {
return true;
}
}
|