Mercurial > projects > dwt2
comparison org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/swt/AbstractSWTObservableValue.d @ 78:0a55d2d5a946
Added file for databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 14 Apr 2009 11:35:29 +0200 |
parents | |
children | 6be48cf9f95c |
comparison
equal
deleted
inserted
replaced
76:f05e6e8b2f2d | 78:0a55d2d5a946 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2006 The Pampered Chef, Inc. 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 * The Pampered Chef, Inc. - initial API and implementation | |
10 ******************************************************************************/ | |
11 | |
12 module org.eclipse.jface.internal.databinding.provisional.swt.AbstractSWTObservableValue; | |
13 | |
14 import java.lang.all; | |
15 | |
16 import org.eclipse.core.databinding.observable.Realm; | |
17 import org.eclipse.core.databinding.observable.value.AbstractObservableValue; | |
18 import org.eclipse.jface.databinding.swt.ISWTObservableValue; | |
19 import org.eclipse.jface.databinding.swt.SWTObservables; | |
20 import org.eclipse.swt.events.DisposeEvent; | |
21 import org.eclipse.swt.events.DisposeListener; | |
22 import org.eclipse.swt.widgets.Widget; | |
23 | |
24 /** | |
25 * NON-API - An abstract superclass for observable values that gurantees that the | |
26 * observable will be disposed when the control to which it is attached is | |
27 * disposed. | |
28 * | |
29 * @since 1.1 | |
30 */ | |
31 public abstract class AbstractSWTObservableValue : AbstractObservableValue , ISWTObservableValue { | |
32 | |
33 private final Widget widget; | |
34 | |
35 /** | |
36 * Standard constructor for an SWT ObservableValue. Makes sure that | |
37 * the observable gets disposed when the SWT widget is disposed. | |
38 * | |
39 * @param widget | |
40 */ | |
41 protected this(Widget widget) { | |
42 this(SWTObservables.getRealm(widget.getDisplay()), widget); | |
43 } | |
44 | |
45 /** | |
46 * Constructor that allows for the setting of the realm. Makes sure that the | |
47 * observable gets disposed when the SWT widget is disposed. | |
48 * | |
49 * @param realm | |
50 * @param widget | |
51 * @since 1.2 | |
52 */ | |
53 protected this(Realm realm, Widget widget) { | |
54 super(realm); | |
55 this.widget = widget; | |
56 widget.addDisposeListener(disposeListener); | |
57 } | |
58 | |
59 private DisposeListener disposeListener = new class() DisposeListener { | |
60 public void widgetDisposed(DisposeEvent e) { | |
61 this.outer.dispose(); | |
62 } | |
63 }; | |
64 | |
65 /** | |
66 * @return Returns the widget. | |
67 */ | |
68 public Widget getWidget() { | |
69 return widget; | |
70 } | |
71 } |