Search in sources :

Example 1 with UpdateValueStrategy

use of org.eclipse.core.databinding.UpdateValueStrategy in project linuxtools by eclipse.

the class AddBoxPage method createControl.

@Override
public void createControl(Composite parent) {
    ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollTop.setExpandVertical(true);
    scrollTop.setExpandHorizontal(true);
    final Composite container = new Composite(scrollTop, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(container);
    // Box name
    final Label boxNameLabel = new Label(container, SWT.NONE);
    boxNameLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.name.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxNameLabel);
    final Text boxNameText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(boxNameText);
    boxNameText.setToolTipText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.name.tooltip"));
    // Name binding
    final IObservableValue<String> boxNameObservable = BeanProperties.value(AddBoxPageModel.class, AddBoxPageModel.BOX_NAME).observe(model);
    dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxNameText), boxNameObservable, new UpdateValueStrategy(), null);
    // Box location
    final Label boxLocLabel = new Label(container, SWT.NONE);
    boxLocLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.loc.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxLocLabel);
    final Text boxLocText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(boxLocText);
    boxLocText.setToolTipText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.loc.tooltip"));
    // Location binding
    final IObservableValue<String> imageNameObservable = BeanProperties.value(AddBoxPageModel.class, AddBoxPageModel.BOX_LOC).observe(model);
    dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxLocText), imageNameObservable, new UpdateValueStrategy(), null);
    // search
    final Button searchButton = new Button(container, SWT.NONE);
    searchButton.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.search.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchButton);
    searchButton.addSelectionListener(onSearchImage());
    dbc.addValidationStatusProvider(new CreateBoxValidationStatusProvider(boxNameObservable, imageNameObservable));
    // setup validation support
    WizardPageSupport.create(this, dbc);
    scrollTop.setContent(container);
    Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrollTop.setSize(point);
    scrollTop.setMinSize(point);
    setControl(container);
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point)

Example 2 with UpdateValueStrategy

use of org.eclipse.core.databinding.UpdateValueStrategy in project linuxtools by eclipse.

the class ImagePullPage method createImageNameSelectionControls.

@SuppressWarnings("unchecked")
void createImageNameSelectionControls(final Composite parent) {
    // Image name
    final Label imageNameLabel = new Label(parent, SWT.NONE);
    imageNameLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePullPushPage.name.label"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(imageNameLabel);
    final Text imageNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(imageNameText);
    imageNameText.setToolTipText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.name.tooltip"));
    // search
    final Button searchButton = new Button(parent, SWT.NONE);
    searchButton.setText(// $NON-NLS-1$
    WizardMessages.getString("ImagePull.search.label"));
    GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(false, false).applyTo(searchButton);
    searchButton.addSelectionListener(onSearchImage());
    // binding
    final IObservableValue<String> imgeNameObservable = BeanProperties.value(ImagePullPushPageModel.class, ImagePullPushPageModel.SELECTED_IMAGE_NAME).observe(getModel());
    dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(imageNameText), imgeNameObservable, new UpdateValueStrategy().setAfterConvertValidator(new ImageNameValidator()), null);
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 3 with UpdateValueStrategy

use of org.eclipse.core.databinding.UpdateValueStrategy in project linuxtools by eclipse.

the class ImageSearchPage method createControl.

@Override
public void createControl(final Composite parent) {
    final int COLUMNS = 3;
    final Composite container = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, false).applyTo(container);
    GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(6, 6).spacing(10, 2).applyTo(container);
    // search text
    final Label searchImageLabel = new Label(container, SWT.NONE);
    searchImageLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.imageLabel"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchImageLabel);
    final Text searchImageText = new Text(container, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(searchImageText);
    searchImageText.addKeyListener(onKeyPressed());
    searchImageText.addTraverseListener(onSearchImageTextTraverse());
    final Button searchImageButton = new Button(container, SWT.NONE);
    searchImageButton.setText(// $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.search"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchImageButton);
    searchImageButton.addSelectionListener(onSearchImageButtonSelected());
    // result table
    final Label searchResultLabel = new Label(container, SWT.NONE);
    searchResultLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.searchResultLabel"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(COLUMNS, 1).applyTo(searchResultLabel);
    final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
    final TableViewer searchResultTableViewer = new TableViewer(table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.nameColumn"), SWT.NONE, SWT.RIGHT, 290, new ImageNameColumnLabelProvider());
    addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.starsColumn"), SWT.NONE, SWT.RIGHT, 70, new ImageStarsColumnLabelProvider());
    addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.officialColumn"), SWT.NONE, SWT.CENTER, 70, new ImageOfficialColumnLabelProvider());
    addTableViewerColum(searchResultTableViewer, // $NON-NLS-1$
    WizardMessages.getString("ImageSearchPage.automatedColumn"), SWT.NONE, SWT.CENTER, 70, new ImageAutomatedColumnLabelProvider());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(COLUMNS, 1).hint(200, 100).applyTo(table);
    // description text area
    final Group selectedImageDescriptionGroup = new Group(container, SWT.NONE);
    // $NON-NLS-1$
    selectedImageDescriptionGroup.setText(WizardMessages.getString("ImageSearchPage.descriptionGroup"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, true).span(COLUMNS, 1).applyTo(selectedImageDescriptionGroup);
    GridLayoutFactory.fillDefaults().margins(6, 6).spacing(10, 2).applyTo(selectedImageDescriptionGroup);
    final Label selectedImageDescription = new Label(selectedImageDescriptionGroup, SWT.WRAP);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, true).hint(200, 100).applyTo(selectedImageDescription);
    // bind the search term
    final IObservableValue observableTermModel = BeanProperties.value(ImageSearchModel.class, ImageSearchModel.TERM).observe(model);
    final ISWTObservableValue imageSearchTextObservable = WidgetProperties.text(SWT.Modify).observe(searchImageText);
    ctx.bindValue(imageSearchTextObservable, observableTermModel, new UpdateValueStrategy().setBeforeSetValidator(new SearchTermValidator(searchImageButton)), null);
    // observe the viewer content
    searchResultTableViewer.setContentProvider(new ObservableListContentProvider());
    // observe the viewer content
    final IObservableList observableSearchResultModel = BeanProperties.list(ImageSearchModel.class, ImageSearchModel.IMAGE_SEARCH_RESULT).observe(model);
    searchResultTableViewer.setInput(observableSearchResultModel);
    // observe the viewer selection
    ctx.bindValue(ViewerProperties.singleSelection().observe(searchResultTableViewer), BeanProperties.value(ImageSearchModel.SELECTED_IMAGE).observe(model));
    // observe the viewer selection to update the description label
    final IObservableValue observableSelectedImageDescription = PojoProperties.value("description", // $NON-NLS-1$
    String.class).observeDetail(ViewerProperties.singleSelection().observe(searchResultTableViewer));
    ctx.bindValue(WidgetProperties.text().observe(selectedImageDescription), observableSelectedImageDescription);
    searchImageText.setFocus();
    // attach the Databinding context status to this wizard page.
    WizardPageSupport.create(this, this.ctx);
    setControl(container);
    // trigger a search if an image name was provided
    if (model.getTerm() != null && !model.getTerm().isEmpty()) {
        searchImages();
    }
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) Group(org.eclipse.swt.widgets.Group) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList) Button(org.eclipse.swt.widgets.Button) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 4 with UpdateValueStrategy

use of org.eclipse.core.databinding.UpdateValueStrategy in project statecharts by Yakindu.

the class StatePropertySection method bindSpecificationControl.

protected void bindSpecificationControl(EMFDataBindingContext context) {
    IEMFValueProperty specificationProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject), SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
    ISWTObservableValue specificationTextProperty = WidgetProperties.text(SWT.FocusOut).observe(txtSpecification);
    context.bindValue(specificationTextProperty, specificationProperty.observe(eObject), null, new UpdateValueStrategy() {

        @Override
        protected IStatus doSet(IObservableValue observableValue, Object value) {
            if (getCompletionProposalAdapter() == null) {
                return super.doSet(observableValue, value);
            } else if (!getCompletionProposalAdapter().isProposalPopupOpen())
                return super.doSet(observableValue, value);
            return Status.OK_STATUS;
        }
    });
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) IStatus(org.eclipse.core.runtime.IStatus) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) EObject(org.eclipse.emf.ecore.EObject) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) IEMFValueProperty(org.eclipse.emf.databinding.IEMFValueProperty)

Example 5 with UpdateValueStrategy

use of org.eclipse.core.databinding.UpdateValueStrategy in project statecharts by Yakindu.

the class TransitionPropertySection method bindModel.

@Override
public void bindModel(EMFDataBindingContext context) {
    IEMFValueProperty modelProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject), SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
    ISWTObservableValue uiProperty = WidgetProperties.text(SWT.FocusOut).observe(textControl);
    context.bindValue(uiProperty, modelProperty.observe(eObject), null, new UpdateValueStrategy() {

        @Override
        protected IStatus doSet(IObservableValue observableValue, Object value) {
            if (getCompletionProposalAdapter() != null && !getCompletionProposalAdapter().isProposalPopupOpen())
                return super.doSet(observableValue, value);
            return Status.OK_STATUS;
        }
    });
    IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject), BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
    ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(documentation);
    context.bindValue(observe, property.observe(eObject));
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) IStatus(org.eclipse.core.runtime.IStatus) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) IEMFValueProperty(org.eclipse.emf.databinding.IEMFValueProperty)

Aggregations

UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)30 Label (org.eclipse.swt.widgets.Label)14 Text (org.eclipse.swt.widgets.Text)13 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)11 Composite (org.eclipse.swt.widgets.Composite)11 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)10 IValidator (org.eclipse.core.databinding.validation.IValidator)7 Button (org.eclipse.swt.widgets.Button)7 ISWTObservableValue (org.eclipse.jface.databinding.swt.ISWTObservableValue)6 IStatus (org.eclipse.core.runtime.IStatus)5 BeanProperties (org.eclipse.core.databinding.beans.BeanProperties)4 IEMFValueProperty (org.eclipse.emf.databinding.IEMFValueProperty)4 WidgetProperties (org.eclipse.jface.databinding.swt.WidgetProperties)4 LabelProvider (org.eclipse.jface.viewers.LabelProvider)4 MessageFormat (java.text.MessageFormat)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Messages (name.abuchen.portfolio.ui.Messages)3 ValidationStatus (org.eclipse.core.databinding.validation.ValidationStatus)3 EObject (org.eclipse.emf.ecore.EObject)3