Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6db1c45ca0a5e6680bccdc8e4894f751e2012e87 (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
/*******************************************************************************
 * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) 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:
 *     Soyatec - initial API and implementation
 *******************************************************************************/
package org.eclipse.papyrus.xwt.databinding;

import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.papyrus.xwt.IDataBinding;
import org.eclipse.papyrus.xwt.IDataProvider;
import org.eclipse.papyrus.xwt.IValidationRule;
import org.eclipse.papyrus.xwt.IValueConverter;
import org.eclipse.papyrus.xwt.internal.core.Binding;
import org.eclipse.papyrus.xwt.internal.core.BindingExpressionPath;
import org.eclipse.papyrus.xwt.internal.core.UpdateSourceTrigger;

/**
 * 
 * @author yyang (yves.yang@soyatec.com)
 */
public abstract class AbstractDataBinding implements IDataBinding {

	private IDataProvider dataProvider;

	private Binding binding;

	private BindingExpressionPath targetPropertySegments;

	public BindingExpressionPath getSourcePropertyExpression() {
		return binding.getPathPropertySegments();
	}

	public BindingExpressionPath getTargetPropertyExpression() {
		return targetPropertySegments;
	}

	public AbstractDataBinding(Binding binding, IDataProvider dataProvider) {
		this.binding = binding;
		this.dataProvider = dataProvider;

		targetPropertySegments = new BindingExpressionPath(getTargetProperty());
	}

	/**
	 * @return the dataProvider
	 */
	public IDataProvider getDataProvider() {
		return dataProvider;
	}

	/**
	 * @param dataProvider
	 *        the dataProvider to set
	 */
	public void setDataProvider(IDataProvider dataProvider) {
		this.dataProvider = dataProvider;
	}

	/**
	 *
	 */
	public BindingMode getBindingMode() {
		return binding.getMode();
	}

	/**
	 * Returns the name of the data binding context this binding is associated
	 * with
	 * 
	 * @return
	 */
	protected IBindingContext getDataBindingContext() {
		return binding.getBindingContext();
	}

	/**
	 *
	 */
	public IValueConverter getConverter() {
		return binding.getConverter();
	}

	/**
	 * @return the target
	 */
	public Object getControl() {
		return binding.getControl();
	}

	/**
	 * @return the target
	 */
	public Object getHost() {
		return binding.getHost();
	}

	/**
	 * 
	 * @return
	 */
	public BindingMode getMode() {
		return binding.getMode();
	}

	/**
	 * 
	 * @param mode
	 */
	public void setMode(BindingMode mode) {
		binding.setMode(mode);
	}

	/**
	 * 
	 * @return
	 */
	protected String getSourceProperty() {
		return binding.getPath();
	}

	/**
	 * 
	 * @return
	 */
	protected String getTargetProperty() {
		return binding.getType();
	}

	public IValidationRule[] getValidators() {
		return binding.getValidationRules();
	}

	public UpdateSourceTrigger getUpdateSourceTrigger() {
		return binding.getUpdateSourceTrigger();
	}

	protected IObservable getObservableSource() {
		return binding.getObservableSource();
	}

	protected void setObservableSource(IObservable observableSource) {
		binding.setObservableSource(observableSource);
	}
}

Back to the top