KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > internal > swt > TextEditableObservableValue


1 /*******************************************************************************
2  * Copyright (c) 2007 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  ******************************************************************************/

11
12 package org.eclipse.jface.internal.databinding.internal.swt;
13
14 import org.eclipse.jface.internal.databinding.provisional.swt.AbstractSWTObservableValue;
15 import org.eclipse.swt.widgets.Text;
16
17 /**
18  * Observable value for the editable property of a Text.
19  *
20  * @since 1.1
21  */

22 public class TextEditableObservableValue extends AbstractSWTObservableValue {
23     private Text text;
24     
25     /**
26      * @param text
27      */

28     public TextEditableObservableValue(Text text) {
29         super(text);
30         
31         this.text = text;
32     }
33
34     /* (non-Javadoc)
35      * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue()
36      */

37     protected Object JavaDoc doGetValue() {
38         return (text.getEditable()) ? Boolean.TRUE : Boolean.FALSE;
39     }
40     
41     /* (non-Javadoc)
42      * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType()
43      */

44     public Object JavaDoc getValueType() {
45         return Boolean.TYPE;
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object)
50      */

51     protected void doSetValue(Object JavaDoc value) {
52         if (Boolean.TRUE.equals(value)) {
53             text.setEditable(true);
54         } else if (Boolean.FALSE.equals(value)) {
55             text.setEditable(false);
56         }
57     }
58 }
59
Popular Tags