| /** |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Florian Pirchner - Initial implementation |
| */ |
| package org.eclipse.osbp.ecview.core.common.editpart.emf.validation; |
| |
| import org.eclipse.osbp.ecview.core.common.context.IViewContext; |
| import org.eclipse.osbp.ecview.core.common.editpart.emf.validation.validator.MinLengthValidator; |
| import org.eclipse.osbp.ecview.core.common.editpart.validation.IMinLengthValidatorEditpart; |
| import org.eclipse.osbp.ecview.core.common.model.validation.ValidationPackage; |
| import org.eclipse.osbp.ecview.core.common.model.validation.YMinLengthValidationConfig; |
| import org.eclipse.osbp.ecview.core.common.model.validation.YMinLengthValidator; |
| import org.eclipse.osbp.ecview.core.common.validation.IValidationConfig; |
| import org.eclipse.osbp.ecview.core.common.validation.IValidator; |
| import org.eclipse.osbp.runtime.common.i18n.II18nService; |
| |
| // TODO: Auto-generated Javadoc |
| /** |
| * The Class MinLengthValidatorEditpart. |
| */ |
| public class MinLengthValidatorEditpart extends |
| ValidatorEditpart<YMinLengthValidator> implements |
| IMinLengthValidatorEditpart { |
| |
| /** The bridge observer. */ |
| private ValidationConfigToValidatorBridge bridgeObserver; |
| |
| /** |
| * Instantiates a new min length validator editpart. |
| */ |
| public MinLengthValidatorEditpart() { |
| super( |
| ValidationPackage.Literals.YMIN_LENGTH_VALIDATION_CONFIG__MIN_LENGTH); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.ecview.core.common.editpart.emf.validation.ValidatorEditpart#createValidator() |
| */ |
| @Override |
| protected IValidator createValidator() { |
| checkDisposed(); |
| |
| MinLengthValidator validator = new MinLengthValidator(getModel()); |
| IViewContext context = getViewContext(getModel()); |
| validator.setI18nService((II18nService) context |
| .getService(II18nService.class.getName())); |
| validator.setLocale(context.getLocale()); |
| return validator; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.ecview.core.common.editpart.validation.IValidatorEditpart#setConfig(org.eclipse.osbp.ecview.core.common.validation.IValidationConfig) |
| */ |
| @Override |
| public void setConfig(IValidationConfig config) { |
| checkDisposed(); |
| |
| YMinLengthValidationConfig validatable = (YMinLengthValidationConfig) config |
| .getValidationSettings(); |
| |
| // create an observer that transfers the changes at the validatable to |
| // the validator |
| bridgeObserver = ValidationConfigToValidatorBridge |
| .createObserver( |
| validatable, |
| ValidationPackage.Literals.YMIN_LENGTH_VALIDATION_CONFIG__MIN_LENGTH, |
| getModel(), |
| ValidationPackage.Literals.YMIN_LENGTH_VALIDATION_CONFIG__MIN_LENGTH); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.ecview.core.common.editpart.emf.validation.ValidatorEditpart#internalDispose() |
| */ |
| @Override |
| protected void internalDispose() { |
| try { |
| if (bridgeObserver != null) { |
| bridgeObserver.dispose(); |
| bridgeObserver = null; |
| } |
| } finally { |
| super.internalDispose(); |
| } |
| } |
| } |