blob: 09719e32b9dcbed1a3c2a18e49c8ca8ee3379999 (
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
|
/*****************************************************************************
* 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 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:
* 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.databinding.ImageKindObservableValue.KIND_ICON;
import static org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue.KIND_SHAPE;
import static org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue.KIND_UNDEFINED;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractModelElement;
import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.uml.properties.Activator;
import org.eclipse.papyrus.uml.properties.databinding.ImageExpressionObservableValue;
import org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue;
import org.eclipse.papyrus.uml.properties.databinding.ImageNameObservableValue;
import org.eclipse.uml2.uml.Image;
/**
* A Model Element for manipulating Stereotype icons in Papyrus
*
* @author Camille Letavernier
*/
public class CustomImageModelElement extends AbstractModelElement {
/**
* The image represented by this model element
*/
protected Image image;
/**
* The editing domain on which the commands will be executed
*/
protected EditingDomain editingDomain;
/**
* The Image::kind property
*/
public static final String KIND = "kind"; //$NON-NLS-1$
/**
* The Image::expression property
*/
public static final String EXPRESSION = "expression"; //$NON-NLS-1$
/**
* The Image::name property
*/
public static final String NAME = "name"; //$NON-NLS-1$
/**
*
* Constructor.
*
* @param umlSource
* The image represented by this model element
* @param domain
* The editing domain on which the commands will be executed
*/
public CustomImageModelElement(Image umlSource, EditingDomain domain) {
this.image = umlSource;
this.editingDomain = domain;
}
/**
* {@inheritDoc}
*/
@Override
protected IObservable doGetObservable(String propertyPath) {
if (propertyPath.equals(KIND)) {
return new ImageKindObservableValue(image, editingDomain);
} else if (propertyPath.equals(EXPRESSION)) {
return new ImageExpressionObservableValue(image, editingDomain);
} else if (propertyPath.equals(NAME)) {
return new ImageNameObservableValue(image, editingDomain);
}
Activator.log.warn("Unknown property : " + propertyPath); //$NON-NLS-1$
return null;
}
/**
* {@inheritDoc}
*/
@Override
public IStaticContentProvider getContentProvider(String propertyPath) {
if (propertyPath.equals(KIND)) {
return new AbstractStaticContentProvider() {
@Override
public Object[] getElements() {
return new String[] { KIND_UNDEFINED, KIND_ICON, KIND_SHAPE };
}
};
}
return EmptyContentProvider.instance;
}
}
|