use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ContainerLabelVariableDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerLabelVariableDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label variableNameLabel = new Label(container, SWT.NONE);
variableNameLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerLabelVariableDialog.nameLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(variableNameLabel);
final Text variableNameText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(variableNameText);
final Label variableValueLabel = new Label(container, SWT.NONE);
variableValueLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerLabelVariableDialog.valueLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(variableValueLabel);
final Text variableValueText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(variableValueText);
// error message
final Label errorMessageLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(errorMessageLabel);
// listening to changes
final ISWTObservableValue variableNameObservable = WidgetProperties.text(SWT.Modify).observe(variableNameText);
dbc.bindValue(variableNameObservable, BeanProperties.value(LabelVariableModel.class, LabelVariableModel.NAME).observe(model));
final ISWTObservableValue variableValueObservable = WidgetProperties.text(SWT.Modify).observe(variableValueText);
dbc.bindValue(variableValueObservable, BeanProperties.value(LabelVariableModel.class, LabelVariableModel.VALUE).observe(model));
variableNameObservable.addValueChangeListener(onLabelVariableSettingsChanged());
variableValueObservable.addValueChangeListener(onLabelVariableSettingsChanged());
return container;
}
use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ContainerLinkDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ContainerLinkDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label containerLabel = new Label(container, SWT.NONE);
containerLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ContainerLinkDialog.containerLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerSelectionCombo);
final ComboViewer containerSelectionComboViewer = new ComboViewer(containerSelectionCombo);
containerSelectionComboViewer.setContentProvider(new ArrayContentProvider());
containerSelectionComboViewer.setInput(model.getContainerNames());
new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() {
@Override
public void insertControlContents(Control control, String text, int cursorPosition) {
final Combo combo = (Combo) control;
final Point selection = combo.getSelection();
combo.setText(text);
selection.x = text.length();
selection.y = selection.x;
combo.setSelection(selection);
}
}, getContainerNameContentProposalProvider(containerSelectionCombo), null, null);
final Label aliasLabel = new Label(container, SWT.NONE);
aliasLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ContainerLinkDialog.aliasLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(aliasLabel);
final Text containerAliasText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerAliasText);
// error message
final Label errorMessageLabel = new Label(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(errorMessageLabel);
final ISWTObservableValue containerNameObservable = WidgetProperties.selection().observe(containerSelectionComboViewer.getCombo());
dbc.bindValue(containerNameObservable, BeanProperties.value(ContainerLinkDialogModel.class, ContainerLinkDialogModel.CONTAINER_NAME).observe(model));
final ISWTObservableValue containerAliasObservable = WidgetProperties.text(SWT.Modify).observe(containerAliasText);
dbc.bindValue(containerAliasObservable, BeanProperties.value(ContainerLinkDialogModel.class, ContainerLinkDialogModel.CONTAINER_ALIAS).observe(model));
containerNameObservable.addValueChangeListener(onContainerLinkSettingsChanged());
containerAliasObservable.addValueChangeListener(onContainerLinkSettingsChanged());
return container;
}
use of org.eclipse.jface.databinding.swt.ISWTObservableValue in project linuxtools by eclipse.
the class ImageBuildDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10).applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildDialog.explanationLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(false, false).applyTo(explanationLabel);
final Label containerLabel = new Label(container, SWT.NONE);
containerLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildDialog.connectionLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(containerLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(containerSelectionCombo);
final ComboViewer connectionSelectionComboViewer = new ComboViewer(containerSelectionCombo);
connectionSelectionComboViewer.setContentProvider(new ArrayContentProvider());
final List<String> connectionNames = model.getConnectionNames();
connectionSelectionComboViewer.setInput(connectionNames);
new ContentProposalAdapter(containerSelectionCombo, new ComboContentAdapter() {
@Override
public void insertControlContents(Control control, String text, int cursorPosition) {
final Combo combo = (Combo) control;
final Point selection = combo.getSelection();
combo.setText(text);
selection.x = text.length();
selection.y = selection.x;
combo.setSelection(selection);
}
}, getConnectionNameContentProposalProvider(containerSelectionCombo), null, null);
final Label repoNameLabel = new Label(container, SWT.NONE);
repoNameLabel.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildName.toolTip"));
// $NON-NLS-1$
repoNameLabel.setText(WizardMessages.getString("ImageBuildName.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(repoNameLabel);
final Text repoNameText = new Text(container, SWT.BORDER);
repoNameText.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImageBuildName.toolTip"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(repoNameText);
final ISWTObservableValue connnectionNameObservable = WidgetProperties.selection().observe(connectionSelectionComboViewer.getCombo());
// pre-select with first connection
if (!connectionNames.isEmpty()) {
model.setConnectionName(connectionNames.get(0));
}
// error message
final Composite errorContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(COLUMNS, 1).grab(true, true).applyTo(errorContainer);
GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(errorContainer);
final Label errorMessageIcon = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(20, SWT.DEFAULT).applyTo(errorMessageIcon);
final Label errorMessageLabel = new Label(errorContainer, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(errorMessageLabel);
dbc.bindValue(connnectionNameObservable, BeanProperties.value(ImageBuildDialogModel.class, ImageBuildDialogModel.CONNECTION_NAME).observe(model));
final ISWTObservableValue repoNameObservable = WidgetProperties.text(SWT.Modify).observe(repoNameText);
dbc.bindValue(repoNameObservable, BeanProperties.value(ImageBuildDialogModel.class, ImageBuildDialogModel.REPO_NAME).observe(model));
// must be called after bindings were set
setupValidationSupport(errorMessageIcon, errorMessageLabel);
return container;
}
Aggregations