Search in sources :

Example 1 with ObservableMapLabelProvider

use of org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider 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 2 with ObservableMapLabelProvider

use of org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider 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 3 with ObservableMapLabelProvider

use of org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider 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 4 with ObservableMapLabelProvider

use of org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider in project jbosstools-openshift by jbosstools.

the class ServicesAndRoutingPage method createExposedPortsControl.

private void createExposedPortsControl(Composite parent, DataBindingContext dbc) {
    Composite container = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(container);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(container);
    Label label = new Label(container, SWT.NONE);
    label.setText("Service Ports:");
    label.setToolTipText("The exposed ports of the image.");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(2, 1).applyTo(label);
    Composite tableContainer = new Composite(container, SWT.NONE);
    IObservableList<IServicePort> portsObservable = BeanProperties.list(IServiceAndRoutingPageModel.PROPERTY_SERVICE_PORTS).observe(model);
    portsViewer = createTable(tableContainer);
    ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    portsViewer.setContentProvider(contentProvider);
    ObservableMapLabelProvider labelProvider = new ObservableMapLabelProvider(Properties.observeEach(contentProvider.getKnownElements(), BeanProperties.values(ServicePortAdapter.NAME, ServicePortAdapter.PORT, ServicePortAdapter.TARGET_PORT, /* ROUTE_PORT_COLUMN_INDEX = 3 */
    ServicePortAdapter.ROUTE_PORT))) {

        @Override
        public Image getColumnImage(Object element, int columnIndex) {
            if (columnIndex == ROUTE_PORT_COLUMN_INDEX) {
                Object selected = attributeMaps[columnIndex].get(element);
                return selected != null && (boolean) selected ? OpenShiftImages.CHECKED_IMG : OpenShiftImages.UNCHECKED_IMG;
            }
            return null;
        }

        @Override
        public String getColumnText(Object element, int columnIndex) {
            if (columnIndex != ROUTE_PORT_COLUMN_INDEX) {
                Object result = attributeMaps[columnIndex].get(element);
                // $NON-NLS-1$
                return result == null ? "" : result.toString();
            }
            return null;
        }
    };
    portsViewer.setLabelProvider(labelProvider);
    GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableContainer);
    ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(portsViewer)).to(BeanProperties.value(IServiceAndRoutingPageModel.PROPERTY_SELECTED_SERVICE_PORT).observe(model)).in(dbc);
    portsViewer.setInput(portsObservable);
    dbc.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            if (portsObservable.isEmpty()) {
                return ValidationStatus.error("At least 1 port is required when generating the service for the deployed image");
            }
            return Status.OK_STATUS;
        }
    });
    portsViewer.getTable().addMouseListener(onTableCellClicked());
    Button btnEdit = new Button(container, SWT.PUSH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(btnEdit);
    btnEdit.setText("Edit...");
    btnEdit.setToolTipText("Edit a port to be exposed by the service.");
    btnEdit.addSelectionListener(new EditHandler());
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnEdit)).notUpdatingParticipant().to(BeanProperties.value(IServiceAndRoutingPageModel.PROPERTY_SELECTED_SERVICE_PORT).observe(model)).converting(new IsNotNull2BooleanConverter()).in(dbc);
    UIUtils.setDefaultButtonWidth(btnEdit);
    Button btnReset = new Button(container, SWT.PUSH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(btnReset);
    btnReset.setText("Reset");
    btnReset.setToolTipText("Resets the list of ports to the exposed ports of the image.");
    btnReset.addSelectionListener(onReset());
    UIUtils.setDefaultButtonWidth(btnReset);
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ObservableMapLabelProvider(org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) IServicePort(com.openshift.restclient.model.IServicePort) Button(org.eclipse.swt.widgets.Button) IsNotNull2BooleanConverter(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter)

Example 5 with ObservableMapLabelProvider

use of org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider in project eclipse-pmd by acanda.

the class AddRuleSetConfigurationWizardPage method initDataBindings.

private DataBindingContext initDataBindings() {
    final DataBindingContext bindingContext = new DataBindingContext();
    // 
    final IObservableValue locationObserveText = SWTObservables.observeDelayedValue(200, SWTObservables.observeText(location, SWT.Modify));
    final IObservableValue locationObserveValue = BeansObservables.observeValue(controller.getModel(), "location");
    bindingContext.bindValue(locationObserveText, locationObserveValue, null, null);
    // 
    final ObservableListContentProvider rulesContentProvider = new ObservableListContentProvider();
    final IObservableMap rulesObserveMap = PojoObservables.observeMap(rulesContentProvider.getKnownElements(), Rule.class, "name");
    tableViewer.setLabelProvider(new ObservableMapLabelProvider(rulesObserveMap));
    tableViewer.setContentProvider(rulesContentProvider);
    // 
    final IObservableList rulesObserveList = BeansObservables.observeList(Realm.getDefault(), controller.getModel(), "rules");
    tableViewer.setInput(rulesObserveList);
    // 
    final IObservableValue nameObserveTextObserveWidget = SWTObservables.observeDelayedValue(100, SWTObservables.observeText(name, SWT.Modify));
    final IObservableValue controllergetModelNameObserveValue = BeansObservables.observeValue(controller.getModel(), "name");
    bindingContext.bindValue(nameObserveTextObserveWidget, controllergetModelNameObserveValue, null, null);
    // 
    final IObservableValue observeVisibleBrowseObserveWidget = WidgetProperties.visible().observe(browse);
    final IObservableValue browseEnabledControllergetModelObserveValue = BeanProperties.value("browseEnabled").observe(controller.getModel());
    bindingContext.bindValue(observeVisibleBrowseObserveWidget, browseEnabledControllergetModelObserveValue, 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)

Aggregations

ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)5 ObservableMapLabelProvider (org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider)5 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)4 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)4 IObservableMap (org.eclipse.core.databinding.observable.map.IObservableMap)4 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)4 IServicePort (com.openshift.restclient.model.IServicePort)1 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)1 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)1 IStatus (org.eclipse.core.runtime.IStatus)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 IsNotNull2BooleanConverter (org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter)1