use of org.eclipse.n4js.ui.wizard.workspace.WorkspaceWizardModelValidator.ValidationResult 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());
}
});
}
use of org.eclipse.n4js.ui.wizard.workspace.WorkspaceWizardModelValidator.ValidationResult in project n4js by eclipse.
the class PreviewableWizardPage method createPreview.
/**
* Creates the right pane content, which is the preview area.
*/
private void createPreview(Composite parent) {
wizardContentPreview = previewProvider.create(parent, SWT.NONE);
wizardContentPreview.setLayoutData(PREVIEW_GRID_DATA_FACTORY.create());
// Connect a delayed property change listener to the model
getModel().addPropertyChangeListener(propertyChange -> {
ValidationResult result = getValidator().getValidationResult();
// Don't update if the preview is hidden
if (!previewVisible) {
return;
}
if (result.valid) {
wizardContentPreview.setEnabled(true);
updateContentPreview(wizardContentPreview);
} else {
wizardContentPreview.setEnabled(false);
wizardContentPreview.setInfo("");
}
});
}
Aggregations