Search in sources :

Example 6 with ISWTObservableValue

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point)

Example 7 with ISWTObservableValue

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;
}
Also used : ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter) Control(org.eclipse.swt.widgets.Control) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue)

Example 8 with ISWTObservableValue

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;
}
Also used : ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter) Control(org.eclipse.swt.widgets.Control) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue)

Aggregations

ISWTObservableValue (org.eclipse.jface.databinding.swt.ISWTObservableValue)8 Composite (org.eclipse.swt.widgets.Composite)8 Label (org.eclipse.swt.widgets.Label)8 Point (org.eclipse.swt.graphics.Point)7 Text (org.eclipse.swt.widgets.Text)7 ComboContentAdapter (org.eclipse.jface.fieldassist.ComboContentAdapter)4 ContentProposalAdapter (org.eclipse.jface.fieldassist.ContentProposalAdapter)4 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)4 ComboViewer (org.eclipse.jface.viewers.ComboViewer)4 Combo (org.eclipse.swt.widgets.Combo)4 Control (org.eclipse.swt.widgets.Control)4 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)2 Button (org.eclipse.swt.widgets.Button)2 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)1 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)1 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)1 ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Group (org.eclipse.swt.widgets.Group)1 Table (org.eclipse.swt.widgets.Table)1