@Override
  public void validateFromParams(
      CustomFieldParams cfParams, ErrorCollection errorCollection, FieldConfig fieldConfig) {
    @SuppressWarnings("unchecked")
    final Collection<String> params = cfParams.getAllValues();
    CustomField cf = fieldConfig.getCustomField();
    JiraAuthenticationContext authCtx =
        ComponentManager.getInstance().getJiraAuthenticationContext();
    I18nHelper i18n = authCtx.getI18nHelper();
    UserProjectHistoryManager userProjectHistoryManager =
        ComponentManager.getComponentInstanceOfType(UserProjectHistoryManager.class);
    Project currentProject =
        userProjectHistoryManager.getCurrentProject(Permissions.BROWSE, authCtx.getLoggedInUser());

    boolean isAutocompleteView;
    if (cf.isAllProjects()) {
      isAutocompleteView =
          qfMgr.isAutocompleteView(cf.getIdAsLong(), Consts.PROJECT_ID_FOR_GLOBAL_CF);
    } else {
      isAutocompleteView = qfMgr.isAutocompleteView(cf.getIdAsLong(), currentProject.getId());
    }

    if (isAutocompleteView) {
      if ((params == null) || params.isEmpty()) {
        boolean addNull;
        if (cf.isAllProjects()) {
          addNull = qfMgr.getAddNull(cf.getIdAsLong(), Consts.PROJECT_ID_FOR_GLOBAL_CF);
        } else {
          addNull = qfMgr.getAddNull(cf.getIdAsLong(), currentProject.getId());
        }

        if (!addNull) {
          errorCollection.addError(
              fieldConfig.getFieldId(), i18n.getText("queryfields.error.isnotnull"));
        }
      } else {
        if (params.size() > 1) {
          errorCollection.addError(
              fieldConfig.getFieldId(), i18n.getText("queryfields.error.invalid.params"));
        } else {
          for (String param : params) {
            Issue issue = issueMgr.getIssueObject(param);
            if (issue == null) {
              errorCollection.addError(
                  fieldConfig.getFieldId(), i18n.getText("queryfields.error.notissue", param));
            }
          }
        }
      }
    }
  }
  @Override
  public String doDefault() throws Exception {
    if (isFieldLocked()) {
      return "locked";
    }

    // Set up the context so the view can see it nicely.
    final FieldConfigScheme configScheme = getConfig();
    setGlobal(isGlobalAvailable());
    if (configScheme != null) {
      setName(configScheme.getName());
      setDescription(configScheme.getDescription());

      // Check if this is still editable in "basic" mode
      if (configScheme.isBasicMode()) {
        setBasicMode(true);
        setGlobal(configScheme.isAllProjects());

        final Set issueTypesList = configScheme.getAssociatedIssueTypes();
        setIssuetypes(GenericValueUtils.transformToStrings(issueTypesList, "id"));

        final List projectCategoriesList = configScheme.getAssociatedProjectCategories();
        setProjectCategories(GenericValueUtils.transformToLongIds(projectCategoriesList));

        final List projectsList = configScheme.getAssociatedProjects();
        setProjects(GenericValueUtils.transformToLongIds(projectsList));

        // Set the config
        final MultiMap configMap = configScheme.getConfigsByConfig();
        if (configMap == null) {
          fieldConfigIds = new Long[0];
        } else {
          final Set entries = configScheme.getConfigsByConfig().keySet();
          fieldConfigIds = new Long[entries.size()];
          int i = 0;
          for (final Object entry : entries) {
            final FieldConfig config = (FieldConfig) entry;
            fieldConfigIds[i] = config.getId();
            i++;
          }
        }

      } else {
        // Complex mode
        setBasicMode(false);
        // @TODO
      }
    }

    return super.doDefault();
  }