Skip to content

Instantly share code, notes, and snippets.

@valeriocos
Created February 16, 2017 17:20
Show Gist options
  • Save valeriocos/b487e48ec57f06bd2f7583edc244e09b to your computer and use it in GitHub Desktop.
Save valeriocos/b487e48ec57f06bd2f7583edc244e09b to your computer and use it in GitHub Desktop.
SampleDialog SWT with ISWTObservableValue
public class SampleDialog extends Dialog {
private DataBindingContext context = new DataBindingContext();
public SampleDialog(Shell parentShell) {
super(parentShell);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
Button button = new Button(container, SWT.CHECK);
button.setText("Show hidden controls");
Label label = new Label(container, SWT.NONE);
label.setText("Sample label");
ISWTObservableValue buttonObservable = WidgetProperties.selection().observe(button);
ISWTObservableValue labelObservable = WidgetProperties.visible().observe(label);
context.bindValue(labelObservable, buttonObservable);
return container;
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Selection dialog");
}
@Override
protected Point getInitialSize() {
return new Point(450, 300);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment