Search in sources :

Example 1 with IObservableSet

use of org.eclipse.core.databinding.observable.set.IObservableSet in project linuxtools by eclipse.

the class RunImageVolumesTab method createVolumeSettingsContainer.

private void createVolumeSettingsContainer(final Composite container) {
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).span(3, 1).applyTo(new Label(container, SWT.NONE));
    final Label volumesLabel = new Label(container, SWT.NONE);
    volumesLabel.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImageRunResourceVolVarPage.dataVolumesLabel"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(COLUMNS, 1).applyTo(volumesLabel);
    final CheckboxTableViewer dataVolumesTableViewer = createVolumesTable(container);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).hint(200, 100).applyTo(dataVolumesTableViewer.getTable());
    // update table content when selected image changes
    bind(dataVolumesTableViewer, model.getDataVolumes(), BeanProperties.values(DataVolumeModel.class, DataVolumeModel.CONTAINER_PATH, DataVolumeModel.MOUNT, DataVolumeModel.READ_ONLY_VOLUME));
    final IObservableSet selectedVolumesObservable = BeanProperties.set(ImageRunResourceVolumesVariablesModel.SELECTED_DATA_VOLUMES).observe(model);
    dbc.bindSet(ViewersObservables.observeCheckedElements(dataVolumesTableViewer, DataVolumeModel.class), selectedVolumesObservable);
    dataVolumesTableViewer.addCheckStateListener(onCheckStateChanged());
    // initializes the checkboxes selection upon loading the model.
    // remove ?
    // selectedVolumesObservable.addChangeListener(new
    // IChangeListener() {
    // 
    // @Override
    // public void handleChange(ChangeEvent event) {
    // final IObservableSet observable = (IObservableSet) event
    // .getObservable();
    // for (Iterator<?> iterator = observable.iterator(); iterator
    // .hasNext();) {
    // final DataVolumeModel volume = (DataVolumeModel) iterator
    // .next();
    // dataVolumesTableViewer.setChecked(volume, true);
    // }
    // updateLaunchConfigurationDialog();
    // }
    // });
    // buttons
    final Composite buttonsContainers = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(false, false).applyTo(buttonsContainers);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(SWT.DEFAULT, 0).applyTo(buttonsContainers);
    final Button addButton = new Button(buttonsContainers, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(addButton);
    addButton.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImageRunResourceVolVarPage.addButton"));
    addButton.addSelectionListener(onAddDataVolume(dataVolumesTableViewer));
    final Button editButton = new Button(buttonsContainers, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(editButton);
    editButton.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImageRunResourceVolVarPage.editButton"));
    editButton.addSelectionListener(onEditDataVolume(dataVolumesTableViewer));
    editButton.setEnabled(false);
    final Button removeButton = new Button(buttonsContainers, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(removeButton);
    removeButton.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImageRunResourceVolVarPage.removeButton"));
    removeButton.addSelectionListener(onRemoveDataVolumes(dataVolumesTableViewer));
    removeButton.setEnabled(false);
    // disable the edit and removeButton if the table is empty
    dataVolumesTableViewer.addSelectionChangedListener(onSelectionChanged(editButton, removeButton));
}
Also used : DataVolumeModel(org.eclipse.linuxtools.internal.docker.ui.wizards.DataVolumeModel) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Button(org.eclipse.swt.widgets.Button) IObservableSet(org.eclipse.core.databinding.observable.set.IObservableSet) Label(org.eclipse.swt.widgets.Label)

Example 2 with IObservableSet

use of org.eclipse.core.databinding.observable.set.IObservableSet in project eclipse-pmd by acanda.

the class RuleSetConfigurationTable method initDataBindings.

private void initDataBindings() {
    final DataBindingContext bindingContext = new DataBindingContext();
    // 
    final ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    tableViewer.setContentProvider(listContentProvider);
    // 
    final IObservableList ruleSetsObserveList = BeansObservables.observeList(Realm.getDefault(), model, "ruleSets");
    tableViewer.setInput(ruleSetsObserveList);
    // 
    final IObservableValue tableObserveEnabledObserveWidget = SWTObservables.observeEnabled(table);
    final IObservableValue modelPMDEnabledObserveValue = BeansObservables.observeValue(model, "PMDEnabled");
    bindingContext.bindValue(tableObserveEnabledObserveWidget, modelPMDEnabledObserveValue, null, null);
    // 
    final IObservableList tableViewerObserveMultiSelection = ViewersObservables.observeMultiSelection(tableViewer);
    final IObservableList selectedRuleSetsObserveList = BeansObservables.observeList(Realm.getDefault(), model, "selectedRuleSets");
    bindingContext.bindList(tableViewerObserveMultiSelection, selectedRuleSetsObserveList, null, null);
    // 
    final IObservableSet tableViewerObserveCheckedElements = ViewersObservables.observeCheckedElements(tableViewer, RuleSetViewModel.class);
    final IObservableSet activeConfigurationsObserveSet = BeansObservables.observeSet(Realm.getDefault(), model, "activeRuleSets");
    bindingContext.bindSet(tableViewerObserveCheckedElements, activeConfigurationsObserveSet, null, null);
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) IObservableSet(org.eclipse.core.databinding.observable.set.IObservableSet) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Aggregations

IObservableSet (org.eclipse.core.databinding.observable.set.IObservableSet)2 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)1 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)1 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)1 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)1 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)1 DataVolumeModel (org.eclipse.linuxtools.internal.docker.ui.wizards.DataVolumeModel)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1