Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 234496 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jface/databinding/viewers/ObservableValueEditingSupport.java (-3 / +45 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Hall - bug 234496
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.jface.databinding.viewers;
13
package org.eclipse.jface.databinding.viewers;
Lines 15-20 Link Here
15
import org.eclipse.core.databinding.DataBindingContext;
16
import org.eclipse.core.databinding.DataBindingContext;
16
import org.eclipse.core.databinding.UpdateValueStrategy;
17
import org.eclipse.core.databinding.UpdateValueStrategy;
17
import org.eclipse.core.databinding.observable.value.IObservableValue;
18
import org.eclipse.core.databinding.observable.value.IObservableValue;
19
import org.eclipse.core.databinding.property.value.IValueProperty;
18
import org.eclipse.core.runtime.Assert;
20
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.jface.viewers.CellEditor;
21
import org.eclipse.jface.viewers.CellEditor;
20
import org.eclipse.jface.viewers.ColumnViewer;
22
import org.eclipse.jface.viewers.ColumnViewer;
Lines 32-37 Link Here
32
 */
34
 */
33
public abstract class ObservableValueEditingSupport extends EditingSupport {
35
public abstract class ObservableValueEditingSupport extends EditingSupport {
34
	/**
36
	/**
37
	 * Returns an ObservableValueEditingSupport instance which binds the given
38
	 * cell editor property to the given element property.
39
	 * 
40
	 * @param viewer
41
	 *            the column viewer
42
	 * @param dbc
43
	 *            the DataBindingContext used for binding between the cell
44
	 *            editor and the viewer element.
45
	 * @param cellEditor
46
	 *            the cell editor
47
	 * @param cellEditorProperty
48
	 *            the cell editor property to be bound to the element.
49
	 * @param elementProperty
50
	 *            the element property to be bound to the cell editor.
51
	 * @return an ObservableValueEditingSupport instance using the given
52
	 *         arguments.
53
	 * @since 1.3
54
	 */
55
	public static EditingSupport create(ColumnViewer viewer,
56
			DataBindingContext dbc, final CellEditor cellEditor,
57
			final IValueProperty cellEditorProperty,
58
			final IValueProperty elementProperty) {
59
		return new ObservableValueEditingSupport(viewer, dbc) {
60
			protected IObservableValue doCreateCellEditorObservable(
61
					CellEditor cellEditor) {
62
				return cellEditorProperty.observe(cellEditor);
63
			}
64
65
			protected IObservableValue doCreateElementObservable(
66
					Object element, ViewerCell cell) {
67
				return elementProperty.observe(element);
68
			}
69
70
			protected CellEditor getCellEditor(Object element) {
71
				return cellEditor;
72
			}
73
		};
74
	}
75
76
	/**
35
	 * Maintains references to the instances currently imployed while editing.
77
	 * Maintains references to the instances currently imployed while editing.
36
	 * Will be <code>null</code> when not editing.
78
	 * Will be <code>null</code> when not editing.
37
	 */
79
	 */
Lines 145-153 Link Here
145
187
146
	/**
188
	/**
147
	 * Creates a new binding for the provided <code>target</code> and
189
	 * Creates a new binding for the provided <code>target</code> and
148
	 * <code>model</code>. Default
190
	 * <code>model</code>. Default {@link UpdateValueStrategy value update
149
	 * {@link UpdateValueStrategy value update strategies} are used with the
191
	 * strategies} are used with the target to model updating on
150
	 * target to model updating on {@link UpdateValueStrategy#POLICY_CONVERT}.
192
	 * {@link UpdateValueStrategy#POLICY_CONVERT}.
151
	 * 
193
	 * 
152
	 * @param target
194
	 * @param target
153
	 * @param model
195
	 * @param model
(-)src/org/eclipse/jface/internal/databinding/viewers/CellEditorControlProperty.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Matthew Hall and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Matthew Hall - initial API and implementation (bug 234496)
10
 ******************************************************************************/
11
12
package org.eclipse.jface.internal.databinding.viewers;
13
14
import org.eclipse.core.databinding.property.INativePropertyListener;
15
import org.eclipse.core.databinding.property.ISimplePropertyListener;
16
import org.eclipse.core.databinding.property.value.SimpleValueProperty;
17
import org.eclipse.jface.viewers.CellEditor;
18
import org.eclipse.swt.widgets.Control;
19
20
/**
21
 * @since 3.3
22
 * 
23
 */
24
public class CellEditorControlProperty extends SimpleValueProperty {
25
	public Object getValueType() {
26
		return Control.class;
27
	}
28
29
	protected Object doGetValue(Object source) {
30
		return ((CellEditor) source).getControl();
31
	}
32
33
	protected void doSetValue(Object source, Object value) {
34
		throw new UnsupportedOperationException();
35
	}
36
37
	public INativePropertyListener adaptListener(
38
			ISimplePropertyListener listener) {
39
		return null;
40
	}
41
42
	public String toString() {
43
		return super.toString();
44
	}
45
}
(-)src/org/eclipse/jface/databinding/viewers/CellEditorProperties.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Matthew Hall and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Matthew Hall - initial API and implementation (bug 234496)
10
 ******************************************************************************/
11
12
package org.eclipse.jface.databinding.viewers;
13
14
import org.eclipse.core.databinding.property.value.IValueProperty;
15
import org.eclipse.jface.internal.databinding.viewers.CellEditorControlProperty;
16
import org.eclipse.jface.viewers.CellEditor;
17
18
/**
19
 * A factory for creating properties of JFace {@link CellEditor cell editors}.
20
 * 
21
 * @since 1.3
22
 */
23
public class CellEditorProperties {
24
	/**
25
	 * Returns a value property for observing the control of a
26
	 * {@link CellEditor}.
27
	 * 
28
	 * @return a value property for observing the control of a
29
	 *         {@link CellEditor}.
30
	 */
31
	public static IValueProperty control() {
32
		return new CellEditorControlProperty();
33
	}
34
}

Return to bug 234496