Java Code Examples for org.eclipse.core.databinding.observable.value.IObservableValue#addValueChangeListener()
The following examples show how to use
org.eclipse.core.databinding.observable.value.IObservableValue#addValueChangeListener() .
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: BusinessObjectList.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void createSearchField(Composite parent, AbstractBdmFormPage formPage) { TextWidget searchWidget = createSearchWidget(parent, formPage); IObservableValue<String> searchObservableValue = searchWidget.observeText(SWT.Modify); searchObservableValue.addValueChangeListener(e -> { Display.getDefault().asyncExec(() -> { String search = searchObservableValue.getValue().toLowerCase(); List<Package> expandedElements = Arrays.asList(viewer.getExpandedElements()).stream() .filter(Package.class::isInstance).map(Package.class::cast).collect(Collectors.toList()); expandedPackages.removeIf(pkg -> !expandedElements.contains(pkg) && pkg.getBusinessObjects().stream().anyMatch(bo -> !boToFilter.contains(bo))); expandedPackages.addAll(expandedElements); boToFilter.clear(); input.getValue().getPackages().stream() .map(Package::getBusinessObjects) .flatMap(Collection::stream) .filter(bo -> !bo.getSimpleName().toLowerCase().contains(search)) .forEach(boToFilter::add); viewer.refresh(); expandedPackages.forEach(pkg -> viewer.expandToLevel(pkg, 1)); }); }); }
Example 2
Source File: DeployOrganizationControlSupplier.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void createDefaultUserTextWidget(DataBindingContext ctx, final Composite mainComposite, IObservableValue<OrganizationFileStore> fileStoreObservable) { SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(usernames()); proposalProvider.setFiltering(true); TextWidget widget = new TextWidget.Builder() .withLabel(Messages.defaultUser) .grabHorizontalSpace() .fill() .labelAbove() .withProposalProvider(proposalProvider) .withTootltip(Messages.defaultUserTooltip) .bindTo(usernameObservable) .withTargetToModelStrategy(UpdateStrategyFactory.updateValueStrategy() .withValidator(defaultUserValidator())) .inContext(ctx) .createIn(mainComposite); fileStoreObservable.addValueChangeListener(event -> { organizationChanged(event.diff.getNewValue().getContent(), proposalProvider); widget.getValueBinding().validateTargetToModel(); }); }
Example 3
Source File: UsersWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 4
Source File: RolesWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 5
Source File: DatabaseConnectorOutputWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected Control doCreateControl(final Composite parent, final EMFDataBindingContext context) { topComposite = new Composite(parent, SWT.NONE); topComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); stackLayout = new StackLayout(); topComposite.setLayout(stackLayout); defaultOutputComposite = createDefaultOuputControl(topComposite, context); singleOutputComposite = createSingleOuputControl(topComposite, context); oneRowNColsOutputComposite = createOneRowNColsOuputControl(topComposite, context); nRowsOneColumOutputComposite = createNRowsOneColumOuputControl(topComposite, context); nRowsNColumsOutputComposite = createNRowsNColsOuputControl(topComposite, context); updateStackLayout(); final ConnectorConfiguration configuration = getConnector().getConfiguration(); final Expression outputTypeExpression = (Expression) getConnectorParameter(configuration, getInput(OUTPUT_TYPE_KEY)) .getExpression(); if (outputTypeExpression != null) { final IObservableValue outputTypeObservalbe = EMFObservables.observeValue(outputTypeExpression, ExpressionPackage.Literals.EXPRESSION__CONTENT); outputTypeObservalbe.addValueChangeListener(this); } return topComposite; }
Example 6
Source File: StringSplitListObservable.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected StringSplitListObservable ( final IObservableValue value, final String delimiter, final String pattern, final Object valueType ) { super ( value.getRealm (), new LinkedList<Object> (), valueType ); this.value = value; this.pattern = pattern; this.delimiter = delimiter; value.addValueChangeListener ( this.changeListener ); value.addStaleListener ( this.staleListener ); value.addDisposeListener ( this.disposeListener ); }
Example 7
Source File: CustomUserInformationDefinitionNameEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@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 8
Source File: QueryDetailsControl.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public QueryDetailsControl(Composite parent, IObservableValue<Query> querySelectedObservable, QueryFormPage formPage, IObservableValue<BusinessObject> boSelectedObservable, TreeViewer queryViewer) { super(parent, SWT.NONE); setLayout(GridLayoutFactory.fillDefaults().create()); setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); formPage.getToolkit().adapt(this); this.formPage = formPage; this.querySelectedObservable = querySelectedObservable; this.ctx = new DataBindingContext(); this.boSelectedObservable = boSelectedObservable; this.queryViewer = queryViewer; createDescriptionSection(); createContentSection(); ctx.bindValue(WidgetProperties.visible().observe(this), new ComputedValueBuilder<Boolean>() .withSupplier( () -> querySelectedObservable.getValue() != null && isRealQuery(querySelectedObservable.getValue())) .build()); querySelectedObservable.addValueChangeListener(e -> { descriptionSection.setExpanded(!isDefault()); descriptionSection.setVisible(!isDefault()); }); ctx.bindValue(WidgetProperties.enabled().observe(deleteParameterItem), new ComputedValueBuilder<Boolean>() .withSupplier(() -> !isDefault() && !parametersMultipleSelectionObservable.isEmpty()) .build()); ctx.bindValue(WidgetProperties.enabled().observe(addParameterItem), new ComputedValueBuilder<Boolean>() .withSupplier(() -> !isDefault()) .build()); }
Example 9
Source File: InputNameObservableEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected IObservableValue doCreateElementObservable(final Object element, final ViewerCell cell) { checkArgument(element instanceof ContractInput); final IObservableValue observableValue = ((ContractInput) element).eContainer() instanceof Contract ? EMFEditWithRefactorObservables .observeValueWithRefactor( TransactionUtil.getEditingDomain(element), (EObject) element, ProcessPackage.Literals.CONTRACT_INPUT__NAME, contractInputRefactorOperationFactory, progressService) : EMFEditObservables.observeValue(TransactionUtil.getEditingDomain(element), (EObject) element, ProcessPackage.Literals.CONTRACT_INPUT__NAME); observableValue.addValueChangeListener(new ColumnViewerUpdateListener(getViewer(), element)); return observableValue; }
Example 10
Source File: CustomTextEMFObservableValueEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected IObservableValue doCreateElementObservable(final Object element, final ViewerCell cell) { checkArgument(element instanceof EObject); final IObservableValue observableValue = EMFEditObservables.observeValue(TransactionUtil.getEditingDomain(element), (EObject) element, featureToEdit); observableValue.addValueChangeListener(new ColumnViewerUpdateListener(getViewer(), element)); return observableValue; }
Example 11
Source File: IndexControl.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void createSearchField(Composite parent) { TextWidget searchWidget = createSearchWidget(parent); IObservableValue<String> searchObservableValue = searchWidget.observeText(SWT.Modify); searchObservableValue.addValueChangeListener(e -> { Display.getDefault().asyncExec(() -> { String search = searchObservableValue.getValue().toLowerCase(); indexesToFilter.clear(); indexObservable.stream() .filter(index -> !index.getName().toLowerCase().contains(search)) .forEach(indexesToFilter::add); indexViewer.refresh(); }); }); }
Example 12
Source File: CustomTextEMFObservableValueEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@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 13
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void bindExpression() { if (expressionBinding != null && externalDataBindingContext != null) { externalDataBindingContext.removeBinding(expressionBinding); expressionBinding.dispose(); } final IObservableValue nameObservable = getExpressionNameObservable(); final IObservableValue typeObservable = getExpressionTypeObservable(); final IObservableValue returnTypeObservable = getExpressionReturnTypeObservable(); final IObservableValue contentObservable = getExpressionContentObservable(); nameObservable.addValueChangeListener(this); typeObservable.addValueChangeListener(this); contentObservable.addValueChangeListener(this); returnTypeObservable.addValueChangeListener(this); final UpdateValueStrategy targetToModelNameStrategy = new UpdateValueStrategy(); if (mandatoryFieldName != null) { targetToModelNameStrategy .setBeforeSetValidator(mandatoryFieldValidator.orElse(new EmptyInputValidator(mandatoryFieldName))); } targetToModelNameStrategy.setConverter(getNameConverter()); final ISWTObservableValue textDelayedObservableValue = SWTObservables.observeDelayedValue(500, SWTObservables.observeText(textControl, SWT.Modify)); expressionBinding = internalDataBindingContext.bindValue(textDelayedObservableValue, nameObservable, targetToModelNameStrategy, updateValueStrategy().create()); bindEditableText(typeObservable); internalDataBindingContext.bindValue(ViewersObservables.observeSingleSelection(contentAssistText), getSelectedExpressionObservable()); if (externalDataBindingContext != null) { externalDataBindingContext.addBinding(expressionBinding); externalDataBindingContext.addValidationStatusProvider(expressionViewerValidator); } }
Example 14
Source File: QueryDetailsControl.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void createSearchField(Composite parent) { TextWidget searchWidget = createSearchWidget(parent); IObservableValue<String> searchObservableValue = searchWidget.observeText(SWT.Modify); searchObservableValue.addValueChangeListener(e -> { Display.getDefault().asyncExec(() -> { String search = searchObservableValue.getValue().toLowerCase(); parametersToFilter.clear(); selectedQueryParameterObservableList.stream() .filter(param -> !param.getName().toLowerCase().contains(search)) .forEach(parametersToFilter::add); parametersTableViewer.refresh(); }); }); }
Example 15
Source File: ContractInputExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void bindExpression(final EMFDataBindingContext dataBindingContext, final EObject context, final Expression inputExpression, final ViewerFilter[] filters, final ExpressionViewer expressionViewer) { editorInputExpression = inputExpression; updateViewerInput(context); final IObservableValue contentObservable = EMFObservables .observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__CONTENT); final IObservableValue nameObservable = EMFObservables.observeValue( inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME); final IObservableValue<String> returnTypeObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE); final IObservableValue referenceObservable = EMFObservables.observeValue( inputExpression, ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS); IObservableValue<ContractInput> observeSingleSelection = ViewersObservables.observeSingleSelection(viewer); dataBindingContext.bindValue(observeSingleSelection, EMFObservables.observeValue( inputExpression, ExpressionPackage.Literals.EXPRESSION__TYPE), selectionToTypeStrategy(), new UpdateValueStrategy( UpdateValueStrategy.POLICY_NEVER)); dataBindingContext.bindValue(observeSingleSelection, nameObservable, selectionToInputNameStrategy(), new UpdateValueStrategy( UpdateValueStrategy.POLICY_NEVER)); dataBindingContext.bindValue(observeSingleSelection, contentObservable, selectionToInputNameStrategy(), new UpdateValueStrategy( UpdateValueStrategy.POLICY_NEVER)); observeSingleSelection.addValueChangeListener(e -> { if (e.getObservableValue().getValue() != null) { returnTypeObservable .setValue(ExpressionHelper.getContractInputReturnType(e.getObservableValue().getValue())); } }); dataBindingContext.bindValue( observeSingleSelection, referenceObservable, selectionToContractInputStrategy(), contractInputToSelectionStrategy()); dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(typeText), returnTypeObservable); }
Example 16
Source File: N4JSNewClassifierWizardPage.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Setup additional non-component contained bindings */ protected void setupBindings() { DataBindingContext dataBindingContext = this.getDataBindingContext(); IObservableValue<String> moduleSpecifierValue = BeanProperties .value(WorkspaceWizardModel.class, WorkspaceWizardModel.MODULE_SPECIFIER_PROPERTY, String.class) .observe(getModel()); IObservableValue<Boolean> suffixVisibilityValue = BeanProperties .value(SuffixText.class, SuffixText.SUFFIX_VISIBILITY_PROPERTY, Boolean.class) .observe(workspaceWizardControl.getModuleSpecifierText()); //// Only show the suffix on input values ending with a '/' character or empty module specifiers. dataBindingContext.bindValue(suffixVisibilityValue, moduleSpecifierValue, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(m -> { String moduleSpecifier = (String) m; return (moduleSpecifier.isEmpty() || moduleSpecifier.charAt(moduleSpecifier.length() - 1) == IPath.SEPARATOR); })); //// interface name to module specifier suffix binding IObservableValue<String> interfaceNameModelValue = BeanProperties .value(N4JSClassifierWizardModel.class, N4JSClassifierWizardModel.NAME_PROPERTY, String.class) .observe(getModel()); IObservableValue<String> greySuffixValue = BeanProperties .value(SuffixText.class, SuffixText.SUFFIX_PROPERTY, String.class) .observe(workspaceWizardControl.getModuleSpecifierText()); dataBindingContext.bindValue(greySuffixValue, interfaceNameModelValue, noUpdateValueStrategy(), new UpdateValueStrategy<>(UpdateValueStrategy.POLICY_UPDATE)); //// Enable n4js <-> Definition value(external) is selected IObservableValue<Boolean> externalValue = BeanProperties .value(DefinitionFileModel.class, N4JSClassifierWizardModel.DEFINITION_FILE_PROPERTY, Boolean.class) .observe((DefinitionFileModel) getModel()); IObservableValue<Boolean> n4jsEnabled = WidgetProperties.enabled() .observe(otherClassifierModifiersComponent.getN4jsAnnotationBox()); dataBindingContext.bindValue(n4jsEnabled, externalValue, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(input -> getModel().isDefinitionFile() && AccessModifier.PRIVATE != getModel().getAccessModifier())); // One way binding of the access modifiers to the enabled state of internal checkbox IObservableValue<Boolean> internalEnabledValue = WidgetProperties.enabled() .observe(accessModifierComponent.getInternalAnnotationBox()); IObservableValue<AccessModifier> accessModifierSelectObservable = BeanProperties .value(N4JSClassifierWizardModel.class, N4JSClassifierWizardModel.ACCESS_MODIFIER_PROPERTY, AccessModifier.class) .observe(getModel()); dataBindingContext.bindValue(internalEnabledValue, accessModifierSelectObservable, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(object -> { if (object instanceof AccessModifier) { return isInternalAccessModifierEnabled((AccessModifier) object); } return false; })); // N4JS annotation checkbox disabled when access modifier is private IObservableValue<Boolean> n4jsEnabledValue = WidgetProperties.enabled() .observe(otherClassifierModifiersComponent.getN4jsAnnotationBox()); dataBindingContext.bindValue(n4jsEnabledValue, accessModifierSelectObservable, noUpdateValueStrategy(), WizardComponentDataConverters.strategyForPredicate(object -> { if (object instanceof AccessModifier) { return ((AccessModifier) object != AccessModifier.PRIVATE) && getModel().isDefinitionFile(); } return false; })); // Refresh wizard state on validation change IObservableValue<ValidationResult> observableValidationValue = BeanProperties .value(WorkspaceWizardModelValidator.VALIDATION_RESULT, ValidationResult.class) .observe(getValidator()); observableValidationValue.addValueChangeListener(new IValueChangeListener<ValidationResult>() { @Override public void handleValueChange(ValueChangeEvent<? extends ValidationResult> event) { onValidationChange(event.diff.getNewValue()); } }); }
Example 17
Source File: ScriptExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void bindExpression(final EMFDataBindingContext dataBindingContext, final EObject context, final Expression inputExpression, final ViewerFilter[] filters, final ExpressionViewer viewer) { this.inputExpression = inputExpression; final IObservableValue nameModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME); final UpdateValueStrategy opposite = new UpdateValueStrategy(); opposite.setConverter(new BooleanInverserConverter()); IObservableValue nameTextObservable = SWTObservables.observeText(expressionNameText, SWT.Modify); final UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setAfterConvertValidator(new EmptyInputValidator(Messages.name)); bindValue = dataBindingContext.bindValue(nameTextObservable, nameModelObservable, targetToModel, null); nameTextObservable.addValueChangeListener(handleValidationStatusChanged()); nameModelObservable.addValueChangeListener(event -> fireSelectionChanged()); editor.bindExpression(dataBindingContext, context, inputExpression, filters, viewer); if (inputExpression.getReturnType() != null) { typeCombo.setInput(inputExpression.getReturnType()); } else { typeCombo.setInput(new Object()); } returnTypeModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE); final String defaultReturnType = viewer.getDefaultReturnType(); if (defaultReturnType != null && !inputExpression.isReturnTypeFixed() && shouldChangeReturnType(inputExpression.getReturnType(), defaultReturnType)) { returnTypeModelObservable.setValue(defaultReturnType); } dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(typeCombo), returnTypeModelObservable); dataBindingContext.bindValue(SWTObservables.observeText(typeCombo.getCombo()), returnTypeModelObservable, updateValueStrategy().withConverter(ConverterBuilder.<String, String> newConverter() .withConvertFunction(this::toClassName) .create()) .create(), updateValueStrategy().withConverter(ConverterBuilder.<String, String> newConverter() .withConvertFunction(this::toDisplayName) .create()) .create()); typeCombo.getCombo().setEnabled(!inputExpression.isReturnTypeFixed()); browseClassesButton.setEnabled(!inputExpression.isReturnTypeFixed()); }
Example 18
Source File: UsersWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void createUserNameField(final Composite rightColumnComposite) { final Label userName = new Label(rightColumnComposite, SWT.NONE); userName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); userName.setText(Messages.userName + " *"); final Text usernameText = new Text(rightColumnComposite, SWT.BORDER); usernameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).create()); usernameText.setMessage(Messages.userNameHint); final UpdateValueStrategy stategy = new UpdateValueStrategy(); stategy.setConverter(new Converter(String.class, String.class) { @Override public Object convert(final Object from) { if (from != null && userSingleSelectionObservable != null && userSingleSelectionObservable.getValue() != null) { final User user = (User) userSingleSelectionObservable.getValue(); updateDelegueeMembership(user.getUserName(), from.toString()); } return from; } }); stategy.setAfterGetValidator(new IValidator() { @Override public IStatus validate(final Object value) { if (isNotUserSelected()) { return Status.OK_STATUS; } if (value.toString().isEmpty()) { return ValidationStatus.error(Messages.userNameIsEmpty); } if (value.toString().length() > NAME_SIZE) { return ValidationStatus.error(Messages.nameLimitSize); } final User currentUser = (User) userSingleSelectionObservable.getValue(); for (final User u : userList) { if (!u.equals(currentUser)) { if (u.getUserName().equals(value)) { return ValidationStatus.error(Messages.userNameAlreadyExists); } } } return Status.OK_STATUS; } }); final IObservableValue userNameValue = EMFObservables.observeDetailValue(Realm.getDefault(), userSingleSelectionObservable, OrganizationPackage.Literals.USER__USER_NAME); final Binding binding = context.bindValue(SWTObservables.observeText(usernameText, SWT.Modify), userNameValue, stategy, null); ControlDecorationSupport.create(binding, SWT.LEFT, rightColumnComposite, new ControlDecorationUpdater() { @Override protected void update(final ControlDecoration decoration, final IStatus status) { if (userSingleSelectionObservable.getValue() != null) { super.update(decoration, status); } } }); userNameValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { handleUserNameChange(event); } }); }
Example 19
Source File: QueryDetailsControl.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void createReturnTypeComposite(Composite parent) { Composite returnTypeComposite = formPage.getToolkit().createComposite(parent); returnTypeComposite.setLayout(GridLayoutFactory.fillDefaults().create()); returnTypeComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); Label queryResultTypeLabel = formPage.getToolkit().createLabel(returnTypeComposite, Messages.queryResultType); queryResultTypeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create()); returnTypeComboViewer = new ComboViewer(returnTypeComposite, SWT.BORDER | SWT.READ_ONLY); returnTypeComboViewer.getControl() .setLayoutData(GridDataFactory.fillDefaults().grab(false, false).hint(300, SWT.DEFAULT).create()); returnTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); returnTypeComboViewer.setLabelProvider(new QueryResultTypeLabelProvider(boSelectedObservable)); updateReturnTypeViewerInput(); Label queryResultTypeInfoLabel = formPage.getToolkit().createLabel(returnTypeComposite, Messages.queryReturnTypeWarning); queryResultTypeInfoLabel .setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(20, 0).create()); ControlDecoration typeinfo = new ControlDecoration(queryResultTypeInfoLabel, SWT.LEFT); typeinfo.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO)); typeinfo.setMarginWidth(5); querySelectedObservable.addValueChangeListener(e -> { if (isDefault()) { returnTypeComboViewer.getControl().setEnabled(false); } else { returnTypeComboViewer.getControl().setEnabled(true); } }); boSelectedObservable.addValueChangeListener(e -> updateReturnTypeViewerInput()); IObservableValue<String> returnTypeSelectionObservable = ViewerProperties.singleSelection(String.class) .observe(returnTypeComboViewer); IObservableValue<String> returnTypeObservable = EMFObservables.observeDetailValue(Realm.getDefault(), querySelectedObservable, BusinessDataModelPackage.Literals.QUERY__RETURN_TYPE); ctx.bindValue(returnTypeSelectionObservable, returnTypeObservable); returnTypeObservable.addValueChangeListener(e -> queryViewer.refresh()); // might impact the info tooltip for the count queries }
Example 20
Source File: ListeningStyledCellLabelProvider.java From neoscada with Eclipse Public License 1.0 | 3 votes |
/** * Listen to changed of the value property of an element * <p> * This will start listening to value change events and trigger a refresh of * the label provider. It will not actually take the value for displaying. * </p> * <p> * Elements that are listened to will automatically removed * </p> * * @since 1.2 * @param element * the element to listen to * @param property * the property to listen to */ protected void listenTo ( final Object element, final IValueProperty property ) { final IObservableValue obs = property.observe ( element ); this.observables.put ( element, obs ); obs.addValueChangeListener ( new IValueChangeListener () { @Override public void handleValueChange ( final ValueChangeEvent event ) { fireLabelProviderChanged ( new LabelProviderChangedEvent ( ListeningStyledCellLabelProvider.this, element ) ); } } ); }