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

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

Introduction

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

Prototype

@SuppressWarnings("unchecked")
@Deprecated
public static ISWTObservableValue observeDelayedValue(int delay, ISWTObservableValue observable) 

Source Link

Document

Returns an observable which delays notification of value change events from observable until delay milliseconds have elapsed since the last change event, or until a FocusOut event is received from the underlying widget (whichever happens first).

Usage

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);
    }/*from  ww w .  j a  va2 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);/* w  ww  . ja v  a2  s .com*/
    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.NewEditEquipment.java

License:Open Source License

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

    bindResourcesSection(context);/*from  ww  w  .ja v a 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   ww  w  . j a v a  2s.  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);
}

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

License:Open Source License

public void bindNodeLinkSection(EMFDataBindingContext context) {

    IObservableValue node1Observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtNode1, SWT.Modify));

    IObservableValue node2Observable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtNode2, SWT.Modify));

    IEMFValueProperty linkNode1Property = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.RELATIONSHIP__NODE_ID1_REF,
                    OperatorsPackage.Literals.NODE__NODE_ID));

    IEMFValueProperty linkNode2Property = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.RELATIONSHIP__NODE_ID2_REF,
                    OperatorsPackage.Literals.NODE__NODE_ID));

    context.bindValue(node1Observable, linkNode1Property.observe(relationship), null, null);
    context.bindValue(node2Observable, linkNode2Property.observe(relationship), null, null);
}

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

License:Open Source License

public void bindInfoSection(EMFDataBindingContext context) {
    // Binding of name and Description

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

    IEMFValueProperty linkNameProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            OperatorsPackage.Literals.RELATIONSHIP__NAME);

    context.bindValue(nameObservable, linkNameProperty.observe(relationship), null, null);
}

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

License:Open Source License

public void bindProtocolSection(EMFDataBindingContext context) {

    IObservableValue protocolObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtProtocol, SWT.Modify));

    IEMFValueProperty protocolProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.RELATIONSHIP__PROTOCOL_REF,
                    ProtocolsPackage.Literals.PROTOCOL__NAME));

    context.bindValue(protocolObservable, protocolProperty.observe(relationship), null, null);
}

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

License:Open Source License

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

    // The Node valiation
    EMFUpdateValueStrategy nodeTypeStrategy = ValidationService.getStrategyfactory()
            .strategyAfterGet(new IValidator() {
                public IStatus validate(Object value) {
                    if (value instanceof String) {
                        return new Status(IStatus.OK, ScreensActivator.PLUGIN_ID, "Hello node");
                        // return Status.OK_STATUS;
                    } else {
                        return new Status(IStatus.WARNING, ScreensActivator.PLUGIN_ID,
                                "Original Network Element type is not set, can't add parts");
                    }//w  w  w  .j  a v a2s . c om
                }

            });

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

    // Changing the NodeID affects the underlying CDOResource for
    // NetXResource objects.
    // The format is /Node/NetXResource_[NodeID]
    IEMFValueProperty nodeIDProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            OperatorsPackage.Literals.NODE__NODE_ID);
    IObservableValue observeNodeID = nodeIDProperty.observe(node);

    EMFUpdateValueStrategy nodeIDStrategy = new EMFUpdateValueStrategy() {

        @Override
        public IStatus validateBeforeSet(Object value) {
            if (value instanceof String) {

                // Find CDOResources with this NodeID.
                CDOResource cdoResourceForNetXResources = StudioUtils.cdoResourceGet(node);
                if (cdoResourceForNetXResources != null) {
                    System.out.println("Original node is" + cdoResourceForNetXResources.getPath());

                }
            }
            return super.validateBeforeSet(value);
        }
    };

    context.bindValue(nameObservable, observeNodeID, nodeIDStrategy, null);

    IObservableValue nodeTypeObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtNodeType, SWT.Modify));

    IEMFValueProperty originalNodeTypeProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.NODE__ORIGINAL_NODE_TYPE_REF,
                    LibraryPackage.Literals.NODE_TYPE__NAME));

    context.bindValue(nodeTypeObservable, originalNodeTypeProperty.observe(node), null, nodeTypeStrategy);

    IObservableValue roomObservable = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtRoom, SWT.Modify));

    IEMFValueProperty roomProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            OperatorsPackage.Literals.NODE__LOCATION_REF);

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

        public Object getFromType() {
            return Location.class;
        }

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

        public Object convert(Object fromObject) {
            if (fromObject instanceof Location) {
                return locationName((EObject) fromObject);
            }
            return null;
        }

        String locationName(EObject locationObject) {
            String location = "";
            if (locationObject.eContainer() instanceof Location && locationObject instanceof Location) {
                String parentLocationName = this.locationName(locationObject.eContainer());
                return location = parentLocationName + "-->" + ((Location) locationObject).getName();
            }

            if (locationObject instanceof Location) {
                location += ((Location) locationObject).getName();
            }
            return location;
        }

    });

    context.bindValue(roomObservable, roomProperty.observe(node), null, modelToTargetLocationStrategy);

    // Lifecycle properties.
    IObservableValue dcProposedObservable = new DateChooserComboObservableValue(dcProposed, SWT.Modify);

    IObservableValue dcPlannedObservable = new DateChooserComboObservableValue(dcPlanned, SWT.Modify);

    IObservableValue dcConstructionObservable = new DateChooserComboObservableValue(dcConstruction, SWT.Modify);

    IObservableValue dcInServiceObservable = new DateChooserComboObservableValue(dcInService, SWT.Modify);

    IObservableValue dcOutOfServiceObservable = new DateChooserComboObservableValue(dcOutOfService, SWT.Modify);

    IEMFValueProperty proposedProperty = EMFEditProperties.value(editingService.getEditingDomain(), FeaturePath
            .fromList(OperatorsPackage.Literals.NODE__LIFECYCLE, GenericsPackage.Literals.LIFECYCLE__PROPOSED));

    IEMFValueProperty plannedProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.NODE__LIFECYCLE,
                    GenericsPackage.Literals.LIFECYCLE__PLANNED_DATE));

    IEMFValueProperty constructionProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.NODE__LIFECYCLE,
                    GenericsPackage.Literals.LIFECYCLE__CONSTRUCTION_DATE));

    IEMFValueProperty inServiceProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.NODE__LIFECYCLE,
                    GenericsPackage.Literals.LIFECYCLE__IN_SERVICE_DATE));

    IEMFValueProperty outOfServiceProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            FeaturePath.fromList(OperatorsPackage.Literals.NODE__LIFECYCLE,
                    GenericsPackage.Literals.LIFECYCLE__OUT_OF_SERVICE_DATE));

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

        public Object getFromType() {
            return XMLGregorianCalendar.class;
        }

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

        public Object convert(Object fromObject) {
            if (fromObject != null) {
                return NonModelUtils.fromXMLDate((XMLGregorianCalendar) fromObject);
            } else {
                return null;
            }
        }
    });

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

        public Object getFromType() {
            return Date.class;
        }

        public Object getToType() {

            return XMLGregorianCalendar.class;
        }

        public Object convert(Object fromObject) {
            if (fromObject != null) {
                return NonModelUtils.toXMLDate((Date) fromObject);
            } else {
                return null;
            }
        }
    });

    context.bindValue(dcProposedObservable, proposedProperty.observe(node), targetToModelUpdateStrategy,
            modelToTargetUpdateStrategy);

    context.bindValue(dcPlannedObservable, plannedProperty.observe(node), targetToModelUpdateStrategy,
            modelToTargetUpdateStrategy);

    context.bindValue(dcConstructionObservable, constructionProperty.observe(node), targetToModelUpdateStrategy,
            modelToTargetUpdateStrategy);

    context.bindValue(dcInServiceObservable, inServiceProperty.observe(node), targetToModelUpdateStrategy,
            modelToTargetUpdateStrategy);

    context.bindValue(dcOutOfServiceObservable, outOfServiceProperty.observe(node), targetToModelUpdateStrategy,
            modelToTargetUpdateStrategy);

    return context;
}