Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » CDateTime Databinding
CDateTime Databinding [message #550115] Thu, 29 July 2010 04:06 Go to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Hello together,

i have a question for the CDateTime databinding. Why it doesn't work? What is the mistake? Model gets alwasys the value null
CDateTime cDateTime = new CDateTime(parent, CDT.BORDER | CDT.COMPACT | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_MEDIUM);
 
DataBindingContext m_bindingContext = new DataBindingContext();
         
          m_bindingContext.bindValue(new CDateTimeObservableValue(cDateTime), BeansObservables.observeValue(model, MyModel.PROP_BIRTHDAY), 
                     null, null);
 
public class MyModel {
           public static final String PROP_BIRTHDAY  = "birthday"; 
           private Date   m_birthday;
         
           public Date getBirthday(){
              return m_birthday;
           }
         
           public void setBirthday(final Date newValue){
              Date oldValue = getBirthday();
              m_birthday = newValue;
              m_propertyChangeSupport.firePropertyChange(PROP_BIRTHDAY, oldValue, newValue);
           }
Re: CDateTime Databinding [message #550116 is a reply to message #550115] Thu, 29 July 2010 04:16 Go to previous message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Is this a bug??
The current Listener in CDateTimeObserverable is:
	private SelectionListener listener = new SelectionListener() {
		public void widgetDefaultSelected(SelectionEvent e) {
			if (!updating) {
				Date newSelection = CDateTimeObservableValue.this.dateTime.getSelection();
				fireValueChange(Diffs.createValueDiff(currentSelection, newSelection));
				currentSelection = newSelection;
			}
		}
		public void widgetSelected(SelectionEvent e) {
			// skip
		}


But the widgetDefaultSelected method is never called, if i switch the code, it works:

	private SelectionListener listener = new SelectionListener() {
		public void widgetDefaultSelected(SelectionEvent e) {
			//Skip
		}
		public void widgetSelected(SelectionEvent e) {
			if (!updating) {
				Date newSelection = CDateTimeObservableValue.this.dateTime.getSelection();
				fireValueChange(Diffs.createValueDiff(currentSelection, newSelection));
				currentSelection = newSelection;
			}
		}
	};
Previous Topic:Scientific notation in formattedtext
Next Topic:CDateTime Databinding
Goto Forum:
  


Current Time: Thu Jul 24 09:18:01 EDT 2014

Powered by FUDForum. Page generated in 0.03434 seconds