private ISeamProperty findSeamProperty(IFile file, int start, int end) {
    if (file == null) return null;
    IProject project = file.getProject();
    if (project == null) return null;

    ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
    if (seamProject == null) return null;

    Set<ISeamComponent> components = seamProject.getComponentsByPath(file.getFullPath());
    for (ISeamComponent component : components) {
      Set<ISeamXmlComponentDeclaration> declarations = component.getXmlDeclarations();
      for (ISeamXmlComponentDeclaration declaration : declarations) {
        Collection<ISeamProperty> properties = declaration.getProperties();
        for (ISeamProperty property : properties) {
          ITextSourceReference location =
              property.getLocationFor(ISeamXmlComponentDeclaration.NAME);

          if (location.getStartPosition() <= start
              && (location.getStartPosition() + location.getLength()) >= end) return property;
        }
      }
    }

    return null;
  }
コード例 #2
0
        public Map<String, IStatus> validate(Object value, Object context) {
          String name = value.toString();
          if (context != null && context instanceof ISeamProject) {
            ISeamProject seamProject = (ISeamProject) context;
            ISeamComponent component = seamProject.getComponent(name);
            if (component != null)
              return createErrormessage(
                  new Status(
                      IStatus.ERROR,
                      SeamCorePlugin.PLUGIN_ID,
                      NLS.bind(SeamCoreMessages.VALIDATOR_FACTORY_COMPONENT_ALREADY_EXISTS, name)));
          }

          String[] segs = name.split("\\."); // $NON-NLS-1$
          for (String segm : segs) {
            if (!segm.trim().equals(segm))
              return createErrormessage(
                  new Status(
                      IStatus.ERROR,
                      SeamCorePlugin.PLUGIN_ID,
                      SeamCoreMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID));

            IStatus status =
                JavaConventions.validateClassFileName(
                    segm + ".class", DEFAULT_SOURCE_LEVEL, DEFAULT_COMPLIANCE_LEVEL); // $NON-NLS-1$
            if (!status.isOK())
              return createErrormessage(
                  new Status(
                      IStatus.ERROR,
                      SeamCorePlugin.PLUGIN_ID,
                      SeamCoreMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID));
          }
          return NO_ERRORS;
        }
 private boolean checkFactories(ISeamProject seamProject) {
   if (seamProject != null) {
     Set<ISeamFactory> factories = seamProject.getFactoriesByName(getOldName());
     return factories.size() > 0;
   }
   return false;
 }
  private boolean checkDataModels(ISeamProject seamProject) {
    if (seamProject != null) {
      Set<IBijectedAttribute> variables =
          seamProject.getBijectedAttributesByName(getOldName(), BijectedAttributeType.DATA_BINDER);

      return variables.size() > 0;
    }
    return false;
  }
  private ISeamComponent checkComponent(ISeamProject seamProject) {
    if (seamProject != null) {
      ISeamComponent component = seamProject.getComponent(getOldName());
      if (component != null) return component;

      Set<ISeamContextVariable> variables = seamProject.getVariablesByName(getOldName());

      if (variables == null) return null;

      for (ISeamContextVariable variable : variables) {
        if (variable instanceof ISeamContextShortVariable) {
          ISeamContextVariable original = ((ISeamContextShortVariable) variable).getOriginal();
          if (original instanceof ISeamComponent) return (ISeamComponent) original;
        }
      }
    }
    return null;
  }