Search in sources :

Example 1 with IObservableList

use of org.eclipse.core.databinding.observable.list.IObservableList 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 2 with IObservableList

use of org.eclipse.core.databinding.observable.list.IObservableList in project InformationSystem by ObeoNetwork.

the class ExportProjectAsLibraryManifestPage method initDataBindings.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    // 
    IObservableValue observeTextTxtProjectIdObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtProjectId);
    IObservableValue projectIdWizardgetModelObserveValue = PojoProperties.value("projectId").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtProjectIdObserveWidget, projectIdWizardgetModelObserveValue, null, null);
    // 
    IObservableValue observeTextTxtVersionObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtVersion);
    IObservableValue versionWizardgetModelObserveValue = PojoProperties.value("version").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtVersionObserveWidget, versionWizardgetModelObserveValue, null, null);
    // 
    IObservableValue observeTextTxtCommentObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtComment);
    IObservableValue commentWizardgetModelObserveValue = PojoProperties.value("comment").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtCommentObserveWidget, commentWizardgetModelObserveValue, null, null);
    // 
    ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    IObservableMap[] observeMaps = PojoObservables.observeMaps(listContentProvider.getKnownElements(), MManifest.class, new String[] { "version", "projectId", "comment" });
    tableViewer.setLabelProvider(new ObservableMapLabelProvider(observeMaps));
    tableViewer.setContentProvider(listContentProvider);
    // 
    IObservableList previousVersionsWizardgetModelObserveList = PojoProperties.list("previousVersions").observe(wizard.getModel());
    tableViewer.setInput(previousVersionsWizardgetModelObserveList);
    // 
    return bindingContext;
}
Also used : IObservableMap(org.eclipse.core.databinding.observable.map.IObservableMap) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ObservableMapLabelProvider(org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 3 with IObservableList

use of org.eclipse.core.databinding.observable.list.IObservableList in project InformationSystem by ObeoNetwork.

the class ExportProjectAsLibraryProjectSelectionPage method initDataBindings.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    // 
    ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    IObservableMap observeMap = PojoObservables.observeMap(listContentProvider.getKnownElements(), ModelingProject.class, "project.name");
    listViewer.setLabelProvider(new ObservableMapLabelProvider(observeMap));
    listViewer.setContentProvider(listContentProvider);
    // 
    IObservableList modelingProjectsWizardgetModelObserveList = PojoProperties.list("modelingProjects").observe(wizard.getModel());
    listViewer.setInput(modelingProjectsWizardgetModelObserveList);
    // 
    IObservableValue observeSingleSelectionListViewer_1 = ViewerProperties.singleSelection().observe(listViewer);
    IObservableValue selectedModelingProjectWizardgetModelObserveValue = PojoProperties.value("selectedModelingProject").observe(wizard.getModel());
    bindingContext.bindValue(observeSingleSelectionListViewer_1, selectedModelingProjectWizardgetModelObserveValue, null, null);
    // 
    IObservableValue observeTextTxtMarFileObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtMarFile);
    IObservableValue filePathWizardgetModelObserveValue = PojoProperties.value("filePath").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtMarFileObserveWidget, filePathWizardgetModelObserveValue, null, null);
    // 
    return bindingContext;
}
Also used : IObservableMap(org.eclipse.core.databinding.observable.map.IObservableMap) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ObservableMapLabelProvider(org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 4 with IObservableList

use of org.eclipse.core.databinding.observable.list.IObservableList in project InformationSystem by ObeoNetwork.

the class ImportLibraryIntoProjectFileSelectionPage method initDataBindings.

protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    // 
    ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    IObservableMap observeMap = PojoObservables.observeMap(listContentProvider.getKnownElements(), ModelingProject.class, "project.name");
    comboViewer.setLabelProvider(new ObservableMapLabelProvider(observeMap));
    comboViewer.setContentProvider(listContentProvider);
    // 
    IObservableList modelingProjectsWizardgetModelObserveList = PojoProperties.list("modelingProjects").observe(wizard.getModel());
    comboViewer.setInput(modelingProjectsWizardgetModelObserveList);
    // 
    IObservableValue observeTextTxtMarFileObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtMarFile);
    IObservableValue filepathWizardgetModelObserveValue = PojoProperties.value("filepath").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtMarFileObserveWidget, filepathWizardgetModelObserveValue, null, null);
    // 
    IObservableValue observeTextTxtProjectIdObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtProjectId);
    IObservableValue projectIDWizardgetModelObserveValue = PojoProperties.value("projectID").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtProjectIdObserveWidget, projectIDWizardgetModelObserveValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    // 
    IObservableValue observeTextTxtVersionObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtVersion);
    IObservableValue versionWizardgetModelObserveValue = PojoProperties.value("version").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtVersionObserveWidget, versionWizardgetModelObserveValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    // 
    IObservableValue observeTextTxtCommentObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtComment);
    IObservableValue commentWizardgetModelObserveValue = PojoProperties.value("comment").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtCommentObserveWidget, commentWizardgetModelObserveValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    // 
    IObservableValue observeTextTxtCreationDateObserveWidget = WidgetProperties.text(SWT.Modify).observe(txtCreationDate);
    IObservableValue creationDateWizardgetModelObserveValue = PojoProperties.value("creationDate").observe(wizard.getModel());
    bindingContext.bindValue(observeTextTxtCreationDateObserveWidget, creationDateWizardgetModelObserveValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    // 
    IObservableValue observeSingleSelectionComboViewer = ViewerProperties.singleSelection().observe(comboViewer);
    IObservableValue modelingProjectWizardgetModelObserveValue = PojoProperties.value("modelingProject").observe(wizard.getModel());
    bindingContext.bindValue(observeSingleSelectionComboViewer, modelingProjectWizardgetModelObserveValue, null, null);
    // 
    return bindingContext;
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) IObservableMap(org.eclipse.core.databinding.observable.map.IObservableMap) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ObservableMapLabelProvider(org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 5 with IObservableList

use of org.eclipse.core.databinding.observable.list.IObservableList in project jbosstools-openshift by jbosstools.

the class FormPresenterSupport method init.

/**
 * @noreference This method is not intended to be referenced by clients.
 */
protected void init() {
    ObservableTracker.setIgnore(true);
    try {
        aggregateStatusProvider = new MaxSeverityValidationStatusProvider(dbc);
    } finally {
        ObservableTracker.setIgnore(false);
    }
    aggregateStatusProvider.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            statusProviderChanged();
        }
    });
    formPresenter.getControl().addListener(SWT.Dispose, new Listener() {

        @Override
        public void handleEvent(Event event) {
            dispose();
        }
    });
    aggregateStatusProvider.addStaleListener(new IStaleListener() {

        @Override
        public void handleStale(StaleEvent staleEvent) {
            currentStatusStale = true;
            handleStatusChanged();
        }
    });
    statusProviderChanged();
    dbc.getValidationStatusProviders().addListChangeListener(validationStatusProvidersListener);
    for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
        ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
        IObservableList targets = validationStatusProvider.getTargets();
        targets.addListChangeListener(validationStatusProviderTargetsListener);
        for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
            ((IObservable) iter.next()).addChangeListener(uiChangeListener);
        }
    }
}
Also used : IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) StaleEvent(org.eclipse.core.databinding.observable.StaleEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) IChangeListener(org.eclipse.core.databinding.observable.IChangeListener) Listener(org.eclipse.swt.widgets.Listener) IStaleListener(org.eclipse.core.databinding.observable.IStaleListener) IListChangeListener(org.eclipse.core.databinding.observable.list.IListChangeListener) IStaleListener(org.eclipse.core.databinding.observable.IStaleListener) Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) StaleEvent(org.eclipse.core.databinding.observable.StaleEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) Event(org.eclipse.swt.widgets.Event) ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ChangeEvent(org.eclipse.core.databinding.observable.ChangeEvent) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Aggregations

IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)10 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)7 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)7 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)6 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)4 IObservableMap (org.eclipse.core.databinding.observable.map.IObservableMap)4 Iterator (java.util.Iterator)3 IObservable (org.eclipse.core.databinding.observable.IObservable)3 ObservableMapLabelProvider (org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider)3 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)2 IListChangeListener (org.eclipse.core.databinding.observable.list.IListChangeListener)2 ISWTObservableValue (org.eclipse.jface.databinding.swt.ISWTObservableValue)2 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IResource (com.openshift.restclient.model.IResource)1 IRoute (com.openshift.restclient.model.route.IRoute)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1