Package tool.editors

Source Code of tool.editors.TypeValidator

package tool.editors;

import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;

import tool.model.ToolClass;
import tool.model.ToolType;

public class TypeValidator implements IValidator {
  private IProject project;
  public TypeValidator(){
//    this.project = project;
  }

  @Override
  public IStatus validate(Object object) {
    if (!(object instanceof String))
      return ValidationStatus.error("Value is not a String");
    ToolType foundClass = ToolClass.fetch(project, (String)object);
    if (foundClass == null){
      return ValidationStatus.error("Type not found");
    } else {
      return ValidationStatus.ok();
    }
  }

}
TOP

Related Classes of tool.editors.TypeValidator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.