blob: a13b64bc5442c75b33127c0d7380702a2fbc6b6f (
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
|
/*****************************************************************************
* 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.properties.ui.widgets;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.util.IPapyrusConverter;
import org.eclipse.swt.widgets.Composite;
/**
* @author VL222926
*
*/
public class CompletionStyledTextReferenceDialog extends AbstractPropertyEditor {
/**
* The ReferenceDialog widget
*/
protected org.eclipse.papyrus.infra.widgets.editors.CompletionStyledTextReferenceDialog editor;
/**
* The ValueFactory used to create or edit Objects directly from
* this editor
*/
protected ReferenceValueFactory factory;
/**
* Constructor.
*
* @param parent
* The composite in which the widget will be displayed
* @param style
* The style for the widget
*/
public CompletionStyledTextReferenceDialog(Composite parent, int style) {
editor = createReferenceDialog(parent, style);
setEditor(editor);
}
/**
* Creates the reference dialog.
*
* @param parent
* The composite in which the widget will be displayed
* @param style
* The style for the widget
* @return the reference dialog.
*/
protected org.eclipse.papyrus.infra.widgets.editors.CompletionStyledTextReferenceDialog createReferenceDialog(Composite parent, int style) {
return new org.eclipse.papyrus.infra.widgets.editors.CompletionStyledTextReferenceDialog(parent, style);
}
/**
*
* @see org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor#doBinding()
*
*/
@Override
protected void doBinding() {
IStaticContentProvider provider = input.getContentProvider(propertyPath);
editor.setLabelProvider(input.getLabelProvider(propertyPath));
editor.setContentProvider(provider);
editor.setDirectCreation(input.getDirectCreation(propertyPath));
editor.setMandatory(input.isMandatory(propertyPath));
if (factory == null) { // Use the default factory from the DataSource
editor.setValueFactory(input.getValueFactory(propertyPath));
} else { // Use the factory explicitly specified
editor.setValueFactory(factory);
}
IPapyrusConverter parser = input.getPapyrusConverter(propertyPath);
if (parser != null) {
editor.setPapyrusConverter(parser);
}
super.doBinding();
}
/**
* Sets the ValueFactory used to create or edit Objects directly from
* this editor
*
* @param factory
*/
public void setFactory(ReferenceValueFactory factory) {
this.factory = factory;
editor.setValueFactory(factory);
}
/**
* @return The ValueFactory used to create or edit Objects directly from
* this editor
*/
public ReferenceValueFactory getFactory() {
return factory;
}
}
|