Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 31fd95aa48403c521b5f56238161c7b721a750c2 (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
/*****************************************************************************
 * 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *  Thibault Le Ouay t.leouay@sherpa-eng.com - Add binding implementation
 *****************************************************************************/
package org.eclipse.papyrus.views.properties.modelelement;

import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.util.INameResolutionHelper;
import org.eclipse.papyrus.infra.widgets.util.IPapyrusConverter;

/**
 * An interface representing Model Elements. A ModelElement is associated to a
 * DataContextElement, and should provide access to all properties for a given
 * object, though the mean of {@link IObservable}s. It should also be able to
 * provide informations about each property, such as a ContentProvider for
 * references.
 *
 * @author Camille Letavernier
 */
public interface ModelElement {

	/**
	 * Returns an IObservable for the given propertyPath. The IObservable
	 * may be either an IObservableValue or an IObservableList.
	 * The IObservable objects returned by this method may be shared by
	 * many instances, which means they should not be disposed directly.
	 * They will be disposed when this ModelElement is disposed.
	 *
	 * @param propertyPath
	 *            The property for which we need an IObservable
	 * @return
	 *         The IObservable corresponding to the given propertyPath
	 */
	public IObservable getObservable(String propertyPath);

	/**
	 * Returns an IStaticContentProvider for the given propertyPath. The
	 * returned value should not be null. If there is no content provider,
	 * use {@link EmptyContentProvider#instance}
	 *
	 * @param propertyPath
	 *            The name of the property for which we want a Content provider
	 * @return
	 *         The IStaticContentProvider containing the available values for
	 *         the given property
	 */
	public IStaticContentProvider getContentProvider(String propertyPath);

	/**
	 * Returns an ILabelProvider for the given propertypath, or null if
	 * a default LabelProvider should be used.
	 *
	 * @param propertyPath
	 * @return
	 *         the LabelProvider for the given path
	 */
	public ILabelProvider getLabelProvider(String propertyPath);

	/**
	 * Returns true if the given property should be ordered. Only relevant
	 * for Collection properties.
	 *
	 * @param propertyPath
	 * @return
	 *         true is the property should be ordered
	 */
	public boolean isOrdered(String propertyPath);

	/**
	 * Returns true if the elements from the given property should be unique.
	 * Only relevant for Colleciton properties.
	 *
	 * @param propertyPath
	 * @return
	 *         true if the elements should be unique
	 */
	public boolean isUnique(String propertyPath);

	/**
	 * Returns true if the given property is Mandatory.
	 *
	 * @param propertyPath
	 * @return true if the property is mandatory
	 */
	public boolean isMandatory(String propertyPath);

	/**
	 * Returns true if the given property is editable.
	 *
	 * @param propertyPath
	 * @return true if the given property is editable.
	 */
	public boolean isEditable(String propertyPath);

	/**
	 * Returns true if the given property should be refreshed each time a
	 * change occurs in the property view. This may help when the IObservable
	 * doesn't catch some change events (For example, for some Ecore derived
	 * properties).
	 *
	 * @param propertyPath
	 * @return true if the refresh should be forced
	 */
	public boolean forceRefresh(String propertyPath);

	/**
	 * Sets the DataSource associated to this model element
	 *
	 * @param source
	 *            The DataSource to associate to this model element
	 */
	public void setDataSource(DataSource source);

	/**
	 * @param propertyPath
	 *            the propertyPath to lookup
	 * @return the default factory used to handle operations such as object
	 *         creation or edition, or null if these operations are not supported.
	 *         This factory will typically be used by Multiple value editors, to
	 *         create or edit a single entry.
	 */
	public ReferenceValueFactory getValueFactory(String propertyPath);

	/**
	 * @param propertyPath
	 * @return The default value for the property
	 */
	public Object getDefaultValue(String propertyPath);

	/**
	 * Indicates if the widget should be use the direct creation.
	 * The direct edition will disable the possibility to browse
	 * existing elements when the "add" button is pressed.
	 *
	 * This is essentially relevant for containment references : this method
	 * should return false if the widget should only allow creation of new
	 * elements.
	 *
	 * @param propertyPath
	 * @return True if the widget should use the direct edition option for the given property
	 *
	 */
	public boolean getDirectCreation(String propertyPath);

	/**
	 * Disposes this ModelElement
	 * All created IObservable will be disposed
	 */
	public void dispose();


	/**
	 * return the Validator of a given String propertyPath
	 *
	 * @param propertyPath
	 * @return
	 */
	public IValidator getValidator(String propertyPath);

	/**
	 * return the INameResolutionHelper to use for completion
	 * 
	 * @param propertyPath
	 * @return
	 */
	public INameResolutionHelper getNameResolutionHelper(String propertyPath);

	/**
	 * return the Papyrus Converter to convert the object to edit or display string and to find the object from a string
	 * 
	 * @param localPropertyPath
	 * @return
	 */
	public IPapyrusConverter getPapyrusConverter(String localPropertyPath);
}

Back to the top