comparison org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/masterdetail/MasterDetailObservables.d @ 95:6208d4f6a277

Added trees for databinding.beans and observable
author Frank Benoit <benoit@tionex.de>
date Tue, 21 Apr 2009 10:55:51 +0200
parents
children b74ac5dfcc06
comparison
equal deleted inserted replaced
94:1d37a7813832 95:6208d4f6a277
1 /*******************************************************************************
2 * Copyright (c) 2006, 2008 IBM Corporation 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 * IBM Corporation - initial API and implementation
10 * Brad Reynolds - bug 147515
11 * Matthew Hall - bug 221704
12 *******************************************************************************/
13
14 package org.eclipse.core.databinding.observable.masterdetail;
15
16 import org.eclipse.core.databinding.observable.list.IObservableList;
17 import org.eclipse.core.databinding.observable.map.IObservableMap;
18 import org.eclipse.core.databinding.observable.set.IObservableSet;
19 import org.eclipse.core.databinding.observable.value.IObservableValue;
20 import org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableList;
21 import org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableMap;
22 import org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableSet;
23 import org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableValue;
24
25 /**
26 * Allows for the observation of an attribute, the detail, of an observable
27 * representing selection or another transient instance, the master.
28 *
29 * @since 1.0
30 */
31 public class MasterDetailObservables {
32
33 /**
34 * Creates a detail observable value from a master observable value and a
35 * factory. This can be used to create observable values that represent a
36 * property of a selected object in a table.
37 *
38 * @param master
39 * the observable value to track
40 * @param detailFactory
41 * a factory for creating {@link IObservableValue} instances
42 * given a current value of the master
43 * @param detailType
44 * the value type of the detail observable value, typically of
45 * type java.lang.Class and can be <code>null</code>
46 * @return an observable value of the given value type that, for any current
47 * value of the given master value, behaves like the observable
48 * value created by the factory for that current value.
49 */
50 public static IObservableValue detailValue(IObservableValue master,
51 IObservableFactory detailFactory, Object detailType) {
52 return new DetailObservableValue(master, detailFactory, detailType);
53 }
54
55 /**
56 * Creates a detail observable list from a master observable value and a
57 * factory. This can be used to create observable lists that represent a
58 * list property of a selected object in a table.
59 *
60 * @param master
61 * the observable value to track
62 * @param detailFactory
63 * a factory for creating {@link IObservableList} instances given
64 * a current value of the master
65 * @param detailElementType
66 * the element type of the detail observable list, typically of
67 * type java.lang.Class and can be <code>null</code>
68 * @return an observable list with the given element type that, for any
69 * current value of the given master value, behaves like the
70 * observable list created by the factory for that current value.
71 */
72 public static IObservableList detailList(IObservableValue master,
73 IObservableFactory detailFactory, Object detailElementType) {
74 return new DetailObservableList(detailFactory, master,
75 detailElementType);
76 }
77
78 /**
79 * Creates a detail observable set from a master observable value and a
80 * factory. This can be used to create observable sets that represent a set
81 * property of a selected object in a table.
82 *
83 * @param master
84 * the observable value to track
85 * @param detailFactory
86 * a factory for creating {@link IObservableSet} instances given
87 * a current value of the master
88 * @param detailElementType
89 * the element type of the detail observable set, typically of
90 * type java.lang.Class and can be <code>null</code>
91 * @return an observable set with the given element type that, for any
92 * current value of the given master value, behaves like the
93 * observable set created by the factory for that current value.
94 */
95 public static IObservableSet detailSet(IObservableValue master,
96 IObservableFactory detailFactory, Object detailElementType) {
97 return new DetailObservableSet(detailFactory, master, detailElementType);
98 }
99
100 /**
101 * Creates a detail observable map from a master observable value and a
102 * factory. This can be used to create observable maps that represent a map
103 * property of a selected object in a table.
104 *
105 * @param master
106 * the observable value to track
107 * @param detailFactory
108 * a factory for createing {@link IObservableMap} instances given
109 * a current value of the master
110 * @return an observable map that, for any current value of the given master
111 * value, behaves like the observable map created by the factory for
112 * that current value.
113 * @since 1.1
114 */
115 public static IObservableMap detailMap(IObservableValue master,
116 IObservableFactory detailFactory) {
117 return new DetailObservableMap(detailFactory, master);
118 }
119 }