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/CellEditorObservables.java (+62 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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.observable.IObservable;
15
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
16
import org.eclipse.core.databinding.observable.value.IObservableValue;
17
import org.eclipse.jface.databinding.swt.SWTObservables;
18
import org.eclipse.jface.viewers.CellEditor;
19
import org.eclipse.jface.viewers.TextCellEditor;
20
import org.eclipse.swt.SWT;
21
22
/**
23
 * A factory for creating observables for JFace CellEditors.
24
 * 
25
 * @since 1.3
26
 * @author Matthew Hall
27
 */
28
public class CellEditorObservables {
29
	/**
30
	 * Returns an IObservableValue tracking the value of the passed in
31
	 * CellEditor.
32
	 * 
33
	 * @param cellEditor
34
	 *            the cell editor to track
35
	 * @return an IObservableValue tracking the value of the passed in
36
	 *         CellEditor.
37
	 */
38
	public static IObservableValue observeValue(CellEditor cellEditor) {
39
		if (cellEditor instanceof TextCellEditor)
40
			return SWTObservables.observeText(cellEditor.getControl(),
41
					SWT.Modify);
42
43
		throw new IllegalArgumentException(
44
				"CellEditor [" + cellEditor.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$
45
46
	}
47
48
	/**
49
	 * Returns an IObservableFactory which produces an IObservableValue which
50
	 * tracks the value of a target CellEditor.
51
	 * 
52
	 * @return an IObservableFactory which produces an IObservableValue which
53
	 *         tracks the value of a target CellEditor.
54
	 */
55
	public static IObservableFactory valueFactory() {
56
		return new IObservableFactory() {
57
			public IObservable createObservable(Object target) {
58
				return observeValue((CellEditor) target);
59
			}
60
		};
61
	}
62
}

Return to bug 234496