List of usage examples for org.eclipse.jface.databinding.swt.typed WidgetProperties text
public static <S extends Widget> IWidgetValueProperty<S, String> text()
From source file:org.eclipse.jface.examples.databinding.snippets.Snippet030DateAndTimeObservableValue.java
License:Open Source License
private void bindUI() { DataBindingContext dbc = new DataBindingContext(); IObservableValue<Date> model = WritableValue.withValueType(Date.class); model.setValue(new Date()); dbc.bindValue(WidgetProperties.text().observe(modelText), model); final IObservableValue<Date> timeSelection = WidgetProperties.dateTimeSelection().observe(time); dbc.bindValue(/*www . j av a 2 s.c o m*/ new DateAndTimeObservableValue(WidgetProperties.dateTimeSelection().observe(date), timeSelection), model); dbc.bindValue(new DateAndTimeObservableValue(WidgetProperties.dateTimeSelection().observe(calendar), timeSelection), model); syncTime.addListener(SWT.Selection, new Listener() { Runnable runnable = new Runnable() { @Override public void run() { if (syncTime.getSelection()) { timeSelection.setValue(new Date()); Display.getCurrent().timerExec(100, this); } } }; @Override public void handleEvent(Event event) { time.setEnabled(!syncTime.getSelection()); if (syncTime.getSelection()) { runnable.run(); } } }); }
From source file:org.eclipse.jface.examples.databinding.snippets.Snippet035PostSelectionProvider.java
License:Open Source License
private void createFieldSection(Composite parent) { final Group section = createSectionGroup(parent, 2); // normal selection Label selectionLabel = createLabelField(section, "Selection:"); IViewerObservableValue<String> selectionObservable = ViewerProperties.singleSelection(String.class) .observe(listViewer);/*from w w w .j a va 2 s.c o m*/ dbc.bindValue(WidgetProperties.text().observe(selectionLabel), selectionObservable); // post selection Label postSelectionLabel = createLabelField(section, "Post selection:"); IViewerObservableValue<String> postSelectionObservable = ViewerProperties.singlePostSelection(String.class) .observe(listViewer); dbc.bindValue(WidgetProperties.text().observe(postSelectionLabel), postSelectionObservable); }