use of org.eclipse.n4js.ui.wizard.model.AccessModifier in project n4js by eclipse.
the class N4JSNewClassifierWizardPage method setupBindings.
/**
* Setup additional non-component contained bindings
*/
protected void setupBindings() {
DataBindingContext dataBindingContext = this.getDataBindingContext();
@SuppressWarnings("unchecked") IObservableValue<String> moduleSpecifierValue = BeanProperties.value(WorkspaceWizardModel.class, WorkspaceWizardModel.MODULE_SPECIFIER_PROPERTY).observe(getModel());
@SuppressWarnings("unchecked") IObservableValue<Boolean> suffixVisibilityValue = BeanProperties.value(SuffixText.class, SuffixText.SUFFIX_VISIBILITY_PROPERTY).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
@SuppressWarnings("unchecked") IObservableValue<String> interfaceNameModelValue = BeanProperties.value(N4JSInterfaceWizardModel.class, N4JSClassifierWizardModel.NAME_PROPERTY).observe(getModel());
@SuppressWarnings("unchecked") IObservableValue<String> greySuffixValue = BeanProperties.value(SuffixText.class, SuffixText.SUFFIX_PROPERTY).observe(workspaceWizardControl.getModuleSpecifierText());
dataBindingContext.bindValue(greySuffixValue, interfaceNameModelValue, noUpdateValueStrategy(), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));
// // Enable n4js <-> Definition value(external) is selected
@SuppressWarnings("unchecked") IObservableValue<Boolean> externalValue = BeanProperties.value(DefinitionFileModel.class, N4JSClassifierWizardModel.DEFINITION_FILE_PROPERTY).observe(getModel());
@SuppressWarnings("unchecked") 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
@SuppressWarnings("unchecked") IObservableValue<Boolean> internalEnabledValue = WidgetProperties.enabled().observe(accessModifierComponent.getInternalAnnotationBox());
@SuppressWarnings("unchecked") IObservableValue<AccessModifier> accessModifierSelectObservable = BeanProperties.value(N4JSInterfaceWizardModel.class, N4JSClassifierWizardModel.ACCESS_MODIFIER_PROPERTY).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
@SuppressWarnings("unchecked") 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
@SuppressWarnings("unchecked") IObservableValue<ValidationResult> observableValidationValue = BeanProperties.value(WorkspaceWizardModelValidator.VALIDATION_RESULT).observe(getValidator());
observableValidationValue.addValueChangeListener(new IValueChangeListener<ValidationResult>() {
@Override
public void handleValueChange(ValueChangeEvent<? extends ValidationResult> event) {
onValidationChange(event.diff.getNewValue());
}
});
}
Aggregations