org.eclipse.core.databinding.observable.value.ValueChangeEvent Java Examples

The following examples show how to use org.eclipse.core.databinding.observable.value.ValueChangeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createGeneralFirstNameField(final Composite detailsInfoComposite) {
    final Label firstName = new Label(detailsInfoComposite, SWT.NONE);
    firstName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    firstName.setText(Messages.firstName);

    final Text firstNameText = new Text(detailsInfoComposite, SWT.BORDER);
    firstNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    firstNameText.setMessage(Messages.firstNameHint);

    final IObservableValue firstNameUserValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            userSingleSelectionObservable,
            OrganizationPackage.Literals.USER__FIRST_NAME);
    context.bindValue(SWTObservables.observeText(firstNameText, SWT.Modify), firstNameUserValue);

    firstNameUserValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            handleFirstNameChange(event);
        }
    });
}
 
Example #2
Source File: ProcessElementNameContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void createBinding(final EMFDataBindingContext context) {
    observable = SWTObservables.observeDelayedValue(250, SWTObservables.observeText(text, SWT.Modify));

    final IObservableValue nameObservable = EMFEditObservables.observeValue(editingDomain, element,
            ProcessPackage.Literals.ELEMENT__NAME);
    nameObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            updatePropertyTabTitle();
            updatePartName((String) event.diff.getNewValue(), Display.getDefault());
        }
    });
    context.bindValue(observable,
            nameObservable);
    final MultiValidator validationStatusProvider = nameValidationStatusProvider(observable);
    context.addValidationStatusProvider(validationStatusProvider);
    ControlDecorationSupport.create(validationStatusProvider, SWT.LEFT);
    bindingInitialized = true;
}
 
Example #3
Source File: OperationViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void updateVisibilityOfActionExpressionControl(final IObservableValue operationObservableValue) {
    operationObservableValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            final IObservableValue observableValue = event.getObservableValue();
            final Operation operation = (Operation) observableValue.getValue();
            final boolean isLeftOperandABusinessData = operation != null
                    && isExpressionReferenceABusinessData(operation.getLeftOperand());
            final Control control = getActionExpression().getControl();
            if (!control.isDisposed()) {
                control.setVisible(
                        !ExpressionConstants.DELETION_OPERATOR.equals(operation.getOperator().getType())
                                || !isLeftOperandABusinessData);
            }
        }
    });

}
 
Example #4
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createGeneralLastNameField(final Composite detailsInfoComposite) {
    final Label lastName = new Label(detailsInfoComposite, SWT.NONE);
    lastName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    lastName.setText(Messages.lastName);

    final Text lastNameText = new Text(detailsInfoComposite, SWT.BORDER);
    lastNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    lastNameText.setMessage(Messages.lastNameHint);

    final IObservableValue lastNameUserValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            userSingleSelectionObservable,
            OrganizationPackage.Literals.USER__LAST_NAME);
    context.bindValue(SWTObservables.observeText(lastNameText, SWT.Modify), lastNameUserValue);

    lastNameUserValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            handleLastNameChange(event);
        }
    });
}
 
Example #5
Source File: CreateContractInputFromBusinessObjectWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void setTitle() {
    if (selectedDataObservable.getValue() != null) {
        setTitle(Messages.bind(Messages.selectFieldToGenerateTitle,
                ((Element) selectedDataObservable.getValue()).getName()));
        EMFObservables
                .observeDetailValue(Realm.getDefault(), selectedDataObservable,
                        ProcessPackage.Literals.ELEMENT__NAME)
                .addValueChangeListener(
                        new IValueChangeListener() {

                            @Override
                            public void handleValueChange(final ValueChangeEvent event) {
                                setTitle(Messages.bind(Messages.selectFieldToGenerateTitle,
                                        event.diff.getNewValue()));
                            }
                        });
    }
}
 
Example #6
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void parseArchive(ValueChangeEvent e) {
    Optional.ofNullable((String) e.diff.getNewValue()).ifPresent(filePath -> {
        File myFile = new File(filePath);
        if (urlTempPath != null && urlTempPath.getTmpPath().toFile().exists()) {
            urlTempPath.getTmpPath().toFile().delete();
            urlTempPath = null;
        }
        if (!myFile.exists()) {
            try {
                myFile = fetchArchive(filePath);
            } catch (FetchRemoteBosArchiveException ex) {
                textWidget.getValueBinding().getValidationStatus().setValue(ValidationStatus.error(String.format(Messages.cannotImportRemoteArchive,ex.getLocalizedMessage())));
                return;
            }
        }
        archiveModel = parseArchive(myFile.getAbsolutePath());
        if (archiveModel != null) {
            importActionSelector.setArchiveModel(archiveModel);
            viewer.setInput(archiveModel);
            openTree();
        }
    });
}
 
Example #7
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createDescriptionField(final Group group) {
    final Label descriptionLabel = new Label(group, SWT.NONE);
    descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).create());
    descriptionLabel.setText(Messages.description);

    final Text roleDescriptionText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    roleDescriptionText
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 80).create());
    roleDescriptionText.setMessage(Messages.descriptionHint);
    roleDescriptionText.setTextLimit(255);

    final IObservableValue roleDescriptionValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            roleSingleSelectionObservable, OrganizationPackage.Literals.ROLE__DESCRIPTION);
    context.bindValue(SWTObservables.observeText(roleDescriptionText, SWT.Modify), roleDescriptionValue);
    roleDescriptionValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            handleRoleDescriptionChange(event);
        }
    });
}
 
Example #8
Source File: PlainDataItemLabel.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void bind ()
{
    this.dbc.bindValue ( SWTObservables.observeText ( this.label ), this.model, null, new UpdateValueStrategy ().setConverter ( new VariantToStringConverter () ) );
    this.model.addValueChangeListener ( new IValueChangeListener () {

        @Override
        public void handleValueChange ( final ValueChangeEvent event )
        {
            if ( !PlainDataItemLabel.this.label.isDisposed () )
            {
                PlainDataItemLabel.this.label.getParent ().layout ();
            }
        }
    } );
}
 
Example #9
Source File: AbstractConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void setInput ( final IEditorInput input )
{
    final ConfigurationEditorInput configurationInput = (ConfigurationEditorInput)input;

    if ( !this.nested )
    {
        configurationInput.performLoad ( new NullProgressMonitor () );
    }

    this.dirtyValue = configurationInput.getDirtyValue ();
    this.dirtyValue.addValueChangeListener ( new IValueChangeListener () {

        @Override
        public void handleValueChange ( final ValueChangeEvent event )
        {
            firePropertyChange ( IEditorPart.PROP_DIRTY );
        }
    } );

    super.setInput ( input );
}
 
Example #10
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createDisplayNameField(final Group group) {
    final Label displayNameLabel = new Label(group, SWT.NONE);
    displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    displayNameLabel.setText(Messages.displayName);

    final Text displayNamedText = new Text(group, SWT.BORDER);
    displayNamedText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final IObservableValue roleDisplayNameValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            roleSingleSelectionObservable, OrganizationPackage.Literals.ROLE__DISPLAY_NAME);
    final Binding binding = context.bindValue(SWTObservables.observeText(displayNamedText, SWT.Modify),
            roleDisplayNameValue,
            updateValueStrategy().withValidator(maxLengthValidator(Messages.displayName, LONG_FIELD_MAX_LENGTH))
                    .create(),
            null);
    ControlDecorationSupport.create(binding, SWT.LEFT);

    roleDisplayNameValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent arg0) {
            handleRoleDisplayNameChange(arg0);

        }
    });
}
 
Example #11
Source File: OperationViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void bindOperator(EMFDataBindingContext context, IObservableValue operationObervable) {
    final UpdateValueStrategy uvsOperator = new UpdateValueStrategy();
    final IObservableValue operatorObservableValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            operationObervable,
            ExpressionPackage.Literals.OPERATION__OPERATOR);
    final IObservableValue operatorExpressionObserveValue = CustomEMFEditObservables.observeDetailValue(
            Realm.getDefault(), operatorObservableValue,
            ExpressionPackage.Literals.OPERATOR__EXPRESSION);
    final IObservableValue operatorTypeObservedValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            operatorObservableValue,
            ExpressionPackage.Literals.OPERATOR__TYPE);
    uvsOperator.setConverter(new OperatorTypeToStringLinkConverter(operatorObservableValue));
    operatorTypeObservedValue.addChangeListener(new RevalidateActionExpressionChangeListener());
    operatorTypeObservedValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            getActionExpression().setDefaultReturnType(defaultReturnTypeResolver.guessRightOperandReturnType());
        }
    });

    context.bindValue(SWTObservables.observeText(getOperatorLink()), operatorTypeObservedValue, null, uvsOperator);
    context.bindValue(SWTObservables.observeText(getOperatorLink()), operatorExpressionObserveValue, null, uvsOperator);
    context.bindValue(SWTObservables.observeTooltipText(getOperatorLink()),
            operatorExpressionObserveValue);
}
 
Example #12
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void handleGroupDisplayName(final ValueChangeEvent event) {
    final org.bonitasoft.studio.actors.model.organization.Group group = (org.bonitasoft.studio.actors.model.organization.Group) groupSingleSelectionObservable
            .getValue();
    final org.bonitasoft.studio.actors.model.organization.Group oldGroup = EcoreUtil.copy(group);
    final Object oldValue = event.diff.getOldValue();
    if (oldValue != null) {
        if (oldGroup != null) {
            oldGroup.setDisplayName(oldValue.toString());
        }

        if (getViewer() != null && !getViewer().getControl().isDisposed()) {
            getViewer().refresh(group);
        }
    }

}
 
Example #13
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleRoleDisplayNameChange(final ValueChangeEvent event) {
    final Role role = (Role) roleSingleSelectionObservable.getValue();
    final Role oldRole = EcoreUtil.copy(role);
    final Object oldValue = event.diff.getOldValue();
    if (oldValue != null) {
        if (oldRole != null) {
            oldRole.setDisplayName(oldValue.toString());
        }

        if (getViewer() != null && !getViewer().getControl().isDisposed()) {
            getViewer().refresh(role);
        }
    }
}
 
Example #14
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(final StructuredViewer viewer) {

    final TableViewer roleTableViewer = (TableViewer) viewer;
    final Table table = roleTableViewer.getTable();

    roleSingleSelectionObservable = ViewersObservables.observeSingleSelection(getViewer());
    roleSingleSelectionObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Role selectedRole = (Role) event.diff.getNewValue();
            final boolean isSelectedRole = selectedRole != null;
            setControlEnabled(getInfoGroup(), isSelectedRole);
            roleMemberShips.clear();
            for (final Membership m : membershipList) {
                if (Objects.equals(selectedRole.getName(),m.getRoleName())) {
                    roleMemberShips.add(m);
                }
            }
        }
    });

    addNameColumn(roleTableViewer);

    addDisplayNameColumn(roleTableViewer);

    addDescriptionColumn(roleTableViewer);

    addTableColumLayout(table);

    if (roleList != null && getViewer() != null) {
        getViewer().setInput(roleList);
    }

}
 
Example #15
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createNameField(final Group group) {
    final Label roleName = new Label(group, SWT.NONE);
    roleName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    roleName.setText(Messages.name + " *");

    final Text roleNameText = new Text(group, SWT.BORDER);
    roleNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(130, SWT.DEFAULT).create());

    final IObservableValue roleNameValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            roleSingleSelectionObservable, OrganizationPackage.Literals.ROLE__NAME);
    final Binding binding = context.bindValue(SWTObservables.observeText(roleNameText, SWT.Modify),
            roleNameValue,
            updateValueStrategy().withValidator(multiValidator()
                    .addValidator(mandatoryValidator(Messages.name))
                    .addValidator(maxLengthValidator(Messages.name, LONG_FIELD_MAX_LENGTH))
                    .addValidator(new UniqueRoleNameValidator()).create()).create(),
            null);

    ControlDecorationSupport.create(binding, SWT.LEFT, group, new ControlDecorationUpdater() {

        @Override
        protected void update(final ControlDecoration decoration, final IStatus status) {
            if (roleSingleSelectionObservable.getValue() != null) {
                super.update(decoration, status);
            }
        }
    });
    roleNameValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            handleRoleNameChange(event);
        }
    });
}
 
Example #16
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleRoleNameChange(final ValueChangeEvent event) {
    Object value = roleSingleSelectionObservable.getValue();
    final Role role = (Role) value;
    if (value != null) {
        if (role != null) {
            if (getViewer() != null && !getViewer().getControl().isDisposed()) {
                getViewer().refresh(role);
            }
            final String newRoleName = (String) event.diff.getNewValue();
            roleMemberShips.stream().forEach(m -> m.setRoleName(newRoleName));
        }
    }
}
 
Example #17
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleRoleDescriptionChange(final ValueChangeEvent event) {
    final Role role = (Role) roleSingleSelectionObservable.getValue();
    final Role oldRole = EcoreUtil.copy(role);
    final Object oldValue = event.diff.getOldValue();
    if (oldValue != null) {
        oldRole.setName(oldValue.toString());

        if (getViewer() != null && !getViewer().getControl().isDisposed()) {
            getViewer().refresh(role);
        }
    }
}
 
Example #18
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleFirstNameChange(final ValueChangeEvent event) {
    final User user = (User) userSingleSelectionObservable.getValue();
    if (user != null) {
        final User oldUser = EcoreUtil.copy(user);
        final Object oldValue = event.diff.getOldValue();
        if (oldValue != null && oldUser != null) {
            oldUser.setFirstName(oldValue.toString());
            if (getViewer() != null && !getViewer().getControl().isDisposed()) {
                getViewer().refresh(user);
            }
        }
    }
}
 
Example #19
Source File: DocumentWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createSingleMultipleRadioGroup(final Composite parent, final EMFDataBindingContext emfDataBindingContext) {
    //FILLER
    final Label filler = new Label(parent, SWT.NONE);
    filler.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).create());

    final Composite radioContainer = new Composite(parent, SWT.NONE);
    radioContainer.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create());
    radioContainer.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).create());
    final Button radioButtonSingle = createRadioButtonSingle(radioContainer);
    final Button radioButtonMultiple = createRadioButtonMultiple(radioContainer);

    final SelectObservableValue isMultipleObservableValue = new SelectObservableValue(Boolean.class);
    isMultipleObservableValue.addOption(false, SWTObservables.observeSelection(radioButtonSingle));
    isMultipleObservableValue.addOption(true, SWTObservables.observeSelection(radioButtonMultiple));

    final IObservableValue multipleObserveValue = EMFObservables.observeValue(document, ProcessPackage.Literals.DOCUMENT__MULTIPLE);
    emfDataBindingContext.bindValue(
            isMultipleObservableValue,
            multipleObserveValue);
    multipleObserveValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            validate(emfDataBindingContext);
        }
    });

}
 
Example #20
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void createContent(final Composite parent) {
    context = new EMFDataBindingContext();
    final TabbedPropertySheetWidgetFactory widgetFactory = getWidgetFactory();

    final Composite composite = widgetFactory.createPlainComposite(parent, SWT.NONE);
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 5).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final SelectObservableValue recurrenceTypeObservable = createRecurrenceTypeRadioGroup(composite, widgetFactory);

    final Composite stackedComposite = widgetFactory.createPlainComposite(composite, SWT.NONE);
    stackedComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final StackLayout stackLayout = new StackLayout();
    stackedComposite.setLayout(stackLayout);

    final Composite noneComposite = widgetFactory.createComposite(stackedComposite, SWT.NONE);
    final Composite standardLoopContent = createStandardLoopContent(stackedComposite, widgetFactory);
    final Composite multiInstanceContent = createMultiInstanceContent(stackedComposite, widgetFactory);
    recurrenceTypeObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final MultiInstanceType type = (MultiInstanceType) event.diff.getNewValue();
            switch (type) {
                case NONE:
                    stackLayout.topControl = noneComposite;
                    break;
                case STANDARD:
                    stackLayout.topControl = standardLoopContent;
                    break;
                default:
                    stackLayout.topControl = multiInstanceContent;
                    break;
            }
            stackedComposite.layout();
        }
    });

}
 
Example #21
Source File: DocumentWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createDocumentTypeRadioButtonComposition(final Composite parent, final EMFDataBindingContext emfDataBindingContext) {
    final Composite compo = new Composite(parent, SWT.NONE);
    compo.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).spacing(10, 5).create());
    compo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final Button radioButtonNone = createRadioButtonNone(compo);
    final Button radioButtonContract = createRadioButtonContract(compo);
    final Button radioButtonInternal = createRadioButtonInternal(compo);
    final Button radioButtonExternal = createRadioButtonExternal(compo);

    final SelectObservableValue documentTypeObservableValue = new SelectObservableValue(DocumentType.class);
    documentTypeObservableValue.addOption(DocumentType.NONE, SWTObservables.observeSelection(radioButtonNone));
    documentTypeObservableValue.addOption(DocumentType.CONTRACT, SWTObservables.observeSelection(radioButtonContract));
    documentTypeObservableValue.addOption(DocumentType.EXTERNAL, SWTObservables.observeSelection(radioButtonExternal));
    documentTypeObservableValue.addOption(DocumentType.INTERNAL, SWTObservables.observeSelection(radioButtonInternal));

    final IObservableValue documentTypeObservable = EMFObservables.observeValue(document, ProcessPackage.Literals.DOCUMENT__DOCUMENT_TYPE);
    emfDataBindingContext.bindValue(
            documentTypeObservableValue,
            documentTypeObservable);
    documentTypeObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            validate(emfDataBindingContext);
        }
    });
}
 
Example #22
Source File: DateTimeControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void bindControl(final DataBindingContext dbc, final IObservableValue modelObservable) {
    final DateTimeObservable dateObservable = new DateTimeObservable(dateControl);
    final DateTimeObservable timeObservable = new DateTimeObservable(timeControl);
    dbc.bindValue(dateObservable, modelObservable);
    dateControl.notifyListeners(SWT.Selection, new Event());
    timeObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Date newValue = (Date) event.diff.getNewValue();
            dateControl.setTime(newValue.getHours(), newValue.getMinutes(), newValue.getMinutes());
            dateControl.notifyListeners(SWT.Selection, new Event());
        }
    });
}
 
Example #23
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleUserNameChange(final ValueChangeEvent event) {
    final User user = (User) userSingleSelectionObservable.getValue();
    if (user != null) {
        final User oldUser = EcoreUtil.copy(user);
        final Object oldValue = event.diff.getOldValue();
        if (oldValue != null) {
            if (oldUser != null) {
                oldUser.setUserName(oldValue.toString());
            }
            if (getViewer() != null && !getViewer().getControl().isDisposed()) {
                getViewer().refresh(user);
            }
        }
    }
}
 
Example #24
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void handleLastNameChange(final ValueChangeEvent event) {
    final User user = (User) userSingleSelectionObservable.getValue();
    if (user != null) {
        final User oldUser = EcoreUtil.copy(user);
        final Object oldValue = event.diff.getOldValue();
        if (oldValue != null) {
            oldUser.setLastName(oldValue.toString());
            if (getViewer() != null && !getViewer().getControl().isDisposed()) {
                getViewer().refresh(user);
            }
        }
    }
}
 
Example #25
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createDisplayNameField(final Group group) {
    final Label displayNameLabel = new Label(group, SWT.NONE);
    displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    displayNameLabel.setText(Messages.displayName);

    final Text displayNamedText = new Text(group, SWT.BORDER);
    displayNamedText.setMessage(Messages.groupNameExample);
    displayNamedText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final IObservableValue displayNameValue = EMFObservables.observeDetailValue(Realm.getDefault(), groupSingleSelectionObservable,
            OrganizationPackage.Literals.GROUP__DISPLAY_NAME);
    final Binding binding = context.bindValue(SWTObservables.observeText(displayNamedText, SWT.Modify), displayNameValue,
            UpdateStrategyFactory.updateValueStrategy()
                    .withValidator(maxLengthValidator(Messages.displayName, LONG_FIELD_MAX_LENGTH)).create(),
            null);
    ControlDecorationSupport.create(binding, SWT.LEFT);

    displayNameValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            handleGroupDisplayName(event);
        }

    });

}
 
Example #26
Source File: CustomTextEMFObservableValueEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Binding createBinding(final IObservableValue target, final IObservableValue model) {
    final Binding binding = dbc.bindValue(target, model, targetToModelConvertStrategy(observedElement(model)), null);
    final IObservableValue validationStatus = binding.getValidationStatus();
    validationStatus.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            validationStatusChanged((IStatus) event.diff.getNewValue());
        }

    });
    return binding;
}
 
Example #27
Source File: CustomUserInformationDefinitionNameEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected IObservableValue doCreateElementObservable(final Object element, final ViewerCell viewerCell) {
    final IObservableValue observeValue = PojoObservables.observeValue(element, "name");
    observeValue.addValueChangeListener(new ColumnViewerUpdateListener(getViewer(), element));
    observeValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final String oldInformationName = (String) event.diff.getOldValue();
            final String newInformationName = (String) event.diff.getNewValue();
            for(final User user : organization.getUsers().getUser()){
                updateCustomUserInformationName(user, oldInformationName, newInformationName);
            }
        }

    });

    //sort the table after a modification
    observeValue.addDisposeListener(new IDisposeListener() {

        @Override
        public void handleDispose(final DisposeEvent arg0) {
            viewer.refresh();

        }
    });
    return observeValue;
}
 
Example #28
Source File: ColumnViewerUpdateListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handleValueChange(ValueChangeEvent event) {
    viewer.getControl().getDisplay().asyncExec(new Runnable() {

        @Override
        public void run() {
            viewer.update(element, null);
        }
    });

}
 
Example #29
Source File: SystemMessageExtension.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void bind ()
{
    this.model.addValueChangeListener ( new IValueChangeListener () {

        @Override
        public void handleValueChange ( final ValueChangeEvent event )
        {
            if ( !SystemMessageLabel.this.label.isDisposed () )
            {
                process ( event.diff.getNewValue () );
            }
        }
    } );
}
 
Example #30
Source File: TimeShiftActionController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public TimeShiftActionController ( final ControllerManager controllerManager, final ChartContext chartContext, final TimeShiftAction controller )
{
    super ( controllerManager.getContext (), chartContext, controller );

    final DataBindingContext ctx = controllerManager.getContext ();

    final Composite space = chartContext.getExtensionSpaceProvider ().getExtensionSpace ();
    if ( space != null )
    {
        this.button = new Button ( space, SWT.PUSH );
        this.button.addSelectionListener ( new SelectionAdapter () {
            @Override
            public void widgetSelected ( final SelectionEvent e )
            {
                action ();
            };
        } );
        addBinding ( ctx.bindValue ( PojoObservables.observeValue ( this, "milliseconds" ), EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__DIFF ) ) ); //$NON-NLS-1$
        addBinding ( ctx.bindValue ( SWTObservables.observeText ( this.button ), EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__LABEL ) ) );
        addBinding ( ctx.bindValue ( SWTObservables.observeTooltipText ( this.button ), EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__DESCRIPTION ) ) );

        this.layoutListener = new IValueChangeListener () {

            @Override
            public void handleValueChange ( final ValueChangeEvent event )
            {
                space.layout ();
            }
        };

        this.labelProperty = EMFObservables.observeValue ( controller, ChartPackage.Literals.TIME_SHIFT_ACTION__LABEL );
        this.labelProperty.addValueChangeListener ( this.layoutListener );

        space.layout ();
    }
    else
    {
        this.button = null;
    }
}