Example usage for org.eclipse.jface.databinding.swt SWTObservables observeText

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeText

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables observeText.

Prototype

@Deprecated
public static ISWTObservableValue observeText(Control control, int event) 

Source Link

Document

Returns an observable observing the text attribute of the provided control.

Usage

From source file:com.netxforge.netxstudio.callflow.screens.nodetypes.NewEditNodeType.java

License:Open Source License

public EMFDataBindingContext initDataBindings_() {
    EMFDataBindingContext context = new EMFDataBindingContext();

    // Binding of name and Description
    IObservableValue nameObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtName, SWT.Modify));
    IObservableValue leafObservable = SWTObservables.observeSelection(btnLeafNode);

    IEMFValueProperty nameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.NODE_TYPE__NAME);
    IEMFValueProperty leafProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.NODE_TYPE__LEAF_NODE);

    context.bindValue(nameObservable, nameProperty.observe(nodeType), null, null);
    context.bindValue(leafObservable, leafProperty.observe(nodeType), null, null);

    //      final NodeTypeSummary totals = (NodeTypeSummary) stateModel
    //            .summary(nodeType);

    //      this.frmTextNumberOfFunctions.setText(
    //            totals.getFunctionCountAsString(), false, false);
    //      this.frmTextNumberOfEquipments.setText(
    //            totals.getEquipmentCountAsString(), false, false);
    //      this.frmTextNumberOfResources.setText(totals.getResourCountAsString(),
    //            false, false);
    return context;
}

From source file:com.netxforge.netxstudio.callflow.screens.protocols.NewEditProtocol.java

License:Open Source License

public EMFDataBindingContext initDataBindings_() {
    EMFDataBindingContext context = new EMFDataBindingContext();

    // text widgets. 

    IObservableValue nameObservable = SWTObservables.observeText(txtName, SWT.Modify);

    IObservableValue specificationObservable = SWTObservables.observeText(this.txtSpecification, SWT.Modify);

    IObservableValue descriptionObservable = SWTObservables.observeText(txtDescription, SWT.Modify);

    // Properties
    IEMFValueProperty nameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            ProtocolsPackage.Literals.PROTOCOL__NAME);

    IEMFValueProperty descriptionProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            ProtocolsPackage.Literals.PROTOCOL__DESCRIPTION);

    IEMFValueProperty specificationProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            ProtocolsPackage.Literals.PROTOCOL__SPECIFICATION);

    context.bindValue(nameObservable, nameProperty.observe(protocol), null, null);
    context.bindValue(descriptionObservable, descriptionProperty.observe(protocol), null, null);
    context.bindValue(specificationObservable, specificationProperty.observe(protocol), null, null);

    // Combo viewer. 

    cmbLevelViewer.setContentProvider(new ArrayContentProvider());
    cmbLevelViewer.setLabelProvider(new LabelProvider());
    cmbLevelViewer.setInput(OSIType.VALUES);

    IEMFValueProperty osiProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            ProtocolsPackage.Literals.PROTOCOL__OSI);
    IValueProperty selectionProperty = ViewerProperties.singleSelection();

    context.bindValue(selectionProperty.observe(cmbLevelViewer), osiProperty.observe(protocol), null, null);

    return context;
}

From source file:com.netxforge.netxstudio.screens.ch9.NewEditExpression.java

License:Open Source License

/**
 * Converted to new EMF API.//from w  w w .j  a  v  a 2 s.c o m
 * 
 * @return
 */
public EMFDataBindingContext initDataBindings_() {

    EMFUpdateValueStrategy expressionStrategy = ValidationService.getStrategyfactory()
            .strategyBeforeSetStringNotEmpty("Expression name is required");

    EMFDataBindingContext bindingContext = new EMFDataBindingContext();

    IObservableValue txtNameObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtExpressionName, SWT.Modify));

    IEMFValueProperty expressionNameObserveValue_1 = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.EXPRESSION__NAME);
    bindingContext.bindValue(txtNameObserveTextObserveWidget, expressionNameObserveValue_1.observe(expression),
            expressionStrategy, null);

    return bindingContext;
}

From source file:com.netxforge.netxstudio.screens.ch9.ObjectExpressions.java

License:Open Source License

private void bindExpression(DataBindingContext context, Expression expression) {

    if (bindValue != null) {
        context.removeBinding(bindValue);
    }//  w w w  . j  a v a  2 s .co m

    EMFUpdateValueStrategy expressionStrategy = ValidationService.getStrategyfactory()
            .strategyBeforeSetStringNotEmpty("Expression name is required");

    IObservableValue txtNameObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtExpressionName, SWT.Modify));

    IEMFValueProperty expressionNameObserveValue_1 = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.EXPRESSION__NAME);
    bindValue = context.bindValue(txtNameObserveTextObserveWidget,
            expressionNameObserveValue_1.observe(expression), expressionStrategy, null);
    context.updateTargets();
}

From source file:com.netxforge.netxstudio.screens.f1.details.NewEditServiceTree.java

License:Open Source License

private void bindInfoSection(EMFDataBindingContext context) {
    IObservableValue nameObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtName, SWT.Modify));

    IObservableValue descriptionObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtDescription, SWT.Modify));

    IEMFValueProperty nameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            ServicesPackage.Literals.SERVICE__SERVICE_NAME);

    IEMFValueProperty descriptionProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            ServicesPackage.Literals.SERVICE__SERVICE_DESCRIPTION);

    context.bindValue(nameObservable, nameProperty.observe(service), null, null);
    context.bindValue(descriptionObservable, descriptionProperty.observe(service), null, null);
}

From source file:com.netxforge.netxstudio.screens.f1.NewEditDerivedResource.java

License:Open Source License

public EMFDataBindingContext initDataBindings_() {
    EMFDataBindingContext context = new EMFDataBindingContext();

    // Widget observables.
    IObservableValue shortNameTargetObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(this.txtShortName, SWT.Modify));
    IObservableValue longNameTargetObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(this.txtLongName, SWT.Modify));
    IObservableValue expressionNameTargetObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(this.txtExpressionName, SWT.Modify));
    IObservableValue unitTargetObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(this.txtUnit, SWT.Modify));

    IEMFValueProperty shortNameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.BASE_RESOURCE__SHORT_NAME);
    IEMFValueProperty longNameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.BASE_RESOURCE__LONG_NAME);
    IEMFValueProperty expressionNameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.BASE_RESOURCE__EXPRESSION_NAME);

    IEMFValueProperty unitProperty = EMFEditProperties.value(editingService.getEditingDomain(), FeaturePath
            .fromList(LibraryPackage.Literals.BASE_RESOURCE__UNIT_REF, LibraryPackage.Literals.UNIT__CODE));

    context.bindValue(shortNameTargetObservable, shortNameProperty.observe(derivedResource), null, null);
    context.bindValue(longNameTargetObservable, longNameProperty.observe(derivedResource), null, null);
    context.bindValue(expressionNameTargetObservable, expressionNameProperty.observe(derivedResource), null,
            null);//from  w  w w.  ja va 2s  .c  o  m
    context.bindValue(unitTargetObservable, unitProperty.observe(derivedResource), null, null);

    // Set enablement for interval links.

    //      hprlnkDaily.setEnabled(false);
    //      hprlnkWeekly.setEnabled(false);
    //      hprlnkMonthly.setEnabled(false);
    hprlnkValues.setEnabled(false);
    //      hprlnkCapcity.setEnabled(false);
    //      hprlnkUtilization.setEnabled(false);

    if (derivedResource.getValues().size() > 0) {
        hprlnkValues.setEnabled(true);
        hprlnkValues.setText(hprlnkValues.getText() + " (" + derivedResource.getValues().size() + ")");
    }

    return context;
}

From source file:com.netxforge.netxstudio.screens.f2.details.AbstractNewEditComponent.java

License:Open Source License

public EMFDataBindingContext bindResourcesSection(EMFDataBindingContext context) {
    IObservableValue capExpressionObservable = SWTObservables.observeText(this.txtCapExpression, SWT.Modify);

    IObservableValue utilExpressionObservable = SWTObservables.observeText(this.txtUtilExpression, SWT.Modify);

    IEMFValueProperty capacityExpressionProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(LibraryPackage.Literals.COMPONENT__CAPACITY_EXPRESSION_REF,
                    LibraryPackage.Literals.EXPRESSION__NAME));

    IEMFValueProperty utilExpressionProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(LibraryPackage.Literals.COMPONENT__UTILIZATION_EXPRESSION_REF,
                    LibraryPackage.Literals.EXPRESSION__NAME));
    context.bindValue(capExpressionObservable, capacityExpressionProperty.observe(comp), null, null);
    context.bindValue(utilExpressionObservable, utilExpressionProperty.observe(comp), null, null);

    // binding of resources

    ObservableListContentProvider resourceListContentProvider = new ObservableListContentProvider();
    resourceTableViewer.setContentProvider(resourceListContentProvider);
    IObservableMap[] observeResourceMaps = EMFObservables.observeMaps(
            resourceListContentProvider.getKnownElements(),
            new EStructuralFeature[] { LibraryPackage.Literals.BASE_RESOURCE__SHORT_NAME,
                    LibraryPackage.Literals.BASE_RESOURCE__EXPRESSION_NAME });
    resourceTableViewer.setLabelProvider(new ObservableMapLabelProvider(observeResourceMaps));
    IEMFListProperty resourcesListProperty = EMFEditProperties.list(editingService.getEditingDomain(),
            LibraryPackage.Literals.COMPONENT__RESOURCE_REFS);
    resourceTableViewer.setInput(resourcesListProperty.observe(comp));

    return context;
}

From source file:com.netxforge.netxstudio.screens.f2.details.NewEditEquipment.java

License:Open Source License

public EMFDataBindingContext initDataBindings_() {
    EMFDataBindingContext context = super.initDataBindings_();

    bindResourcesSection(context);/* www.  j a va 2 s . c  o  m*/
    bindToleranceSection();
    bindMetricSection();

    IObservableValue codeObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtCode, SWT.Modify));

    IEMFValueProperty codeProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.EQUIPMENT__EQUIPMENT_CODE);

    context.bindValue(codeObservable, codeProperty.observe(comp), null, null);

    IObservableValue descriptionObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtDescription, SWT.Modify));

    IEMFValueProperty componentDescriptionProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            LibraryPackage.Literals.COMPONENT__DESCRIPTION);

    context.bindValue(descriptionObservable, componentDescriptionProperty.observe(comp), null, null);

    bindDurationSection(context);

    return context;
}

From source file:com.netxforge.netxstudio.screens.f2.details.NewEditEquipmentLink.java

License:Open Source License

private void bindEquipmentLinkSection(EMFDataBindingContext context) {
    // Binding of sub relationships

    IObservableValue Equipment1Observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtEquipment1, SWT.Modify));

    IObservableValue Equipment2Observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtEquipment2, SWT.Modify));

    // combineEquipmentIDValue = new WritableValue();

    IEMFValueProperty linkEquipment1Property = EMFEditProperties.value(editingService.getEditingDomain(),
            OperatorsPackage.Literals.EQUIPMENT_RELATIONSHIP__EQUIPMENT1_REF);

    IEMFValueProperty linkEquipment2Property = EMFEditProperties.value(editingService.getEditingDomain(),
            OperatorsPackage.Literals.EQUIPMENT_RELATIONSHIP__EQUIPMENT2_REF);

    EMFUpdateValueStrategy equipmentToTarget = new EMFUpdateValueStrategy();
    equipmentToTarget.setConverter(new IConverter() {

        public Object getFromType() {
            return Equipment.class;
        }/*from  w  ww  .j a va 2  s  .  c  o m*/

        public Object getToType() {
            return String.class;
        }

        public Object convert(Object fromObject) {

            if (fromObject instanceof Equipment) {
                StringBuffer buf = new StringBuffer();
                if (((Equipment) fromObject).eIsSet(LibraryPackage.Literals.COMPONENT__NAME)) {
                    buf.append(((Equipment) fromObject).getName());
                }
                buf.append(" -  ");
                if (((Equipment) fromObject).eIsSet(LibraryPackage.Literals.EQUIPMENT__EQUIPMENT_CODE)) {
                    buf.append(((Equipment) fromObject).getEquipmentCode());
                }
                return buf.toString();
            }
            return null;
        }

    });

    context.bindValue(Equipment1Observable, linkEquipment1Property.observe(relationship), null,
            equipmentToTarget);
    context.bindValue(Equipment2Observable, linkEquipment2Property.observe(relationship), null,
            equipmentToTarget);
}

From source file:com.netxforge.netxstudio.screens.f2.details.NewEditFunctionLink.java

License:Open Source License

private void bindFunctionLinkSection(EMFDataBindingContext context) {
    // Binding of sub relationships

    IObservableValue function1Observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtFunction1, SWT.Modify));

    IObservableValue function2Observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtFunction2, SWT.Modify));

    IEMFValueProperty linkFunction1Property = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.FUNCTION_RELATIONSHIP__FUNCTION1_REF,
                    LibraryPackage.Literals.COMPONENT__NAME));

    IEMFValueProperty linkFunction2Property = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.FUNCTION_RELATIONSHIP__FUNCTION2_REF,
                    LibraryPackage.Literals.COMPONENT__NAME));

    context.bindValue(function1Observable, linkFunction1Property.observe(relationship), null, null);
    context.bindValue(function2Observable, linkFunction2Property.observe(relationship), null, null);
}