Package org.springframework.ide.eclipse.beans.core.namespaces.ToolAnnotationUtils

Examples of org.springframework.ide.eclipse.beans.core.namespaces.ToolAnnotationUtils.ToolAnnotationData


  @Override
  public IHyperlink createHyperlink(String name, String target, Node node, Node parentNode, IDocument document,
      ITextViewer textViewer, IRegion hyperlinkRegion, IRegion cursor, Node annotation) {

    IFile file = BeansEditorUtils.getFile(document);
    ToolAnnotationData annotationData = ToolAnnotationUtils.getToolAnnotationData(annotation);

    if (REF_ATTRIBUTE.equals(annotationData.getKind())) {
      Node bean = BeansEditorUtils.getFirstReferenceableNodeById(node.getOwnerDocument(), target, file);
      if (bean != null) {
        IRegion region = getHyperlinkRegion(bean);
        return new NodeElementHyperlink(hyperlinkRegion, region, textViewer);
      }
      else {
        // assume this is an external reference
        Iterator<?> beans = BeansEditorUtils.getBeansFromConfigSets(file).iterator();
        while (beans.hasNext()) {
          IBean modelBean = (IBean) beans.next();
          if (modelBean.getElementName().equals(target)) {
            return new ExternalBeanHyperlink(modelBean, hyperlinkRegion);
          }
        }
      }
    }
    else if (Class.class.getName().equals(annotationData.getExpectedType())) {
      IHyperlink[] detectedHyperlinks = HyperlinkUtils.getXmlJavaHyperlinks(textViewer, hyperlinkRegion);
     
      // only return hyperlink if no xml Java hyperlink will be created to avoid duplicates
      if (detectedHyperlinks == null || detectedHyperlinks.length == 0) {
        if (file != null && file.exists()) {
          IType type = JdtUtils.getJavaType(file.getProject(), target);
          if (type != null) {
            return new JavaElementHyperlink(hyperlinkRegion, type);
          }
        }
      }
    }
    if (annotationData.getExpectedMethodType() != null) {
      String className = evaluateXPathExpression(annotationData.getExpectedMethodType(), node);
      return createMethodHyperlink(target, hyperlinkRegion, file, className);
    }
    else if (annotationData.getExpectedMethodRef() != null) {
      String typeName = evaluateXPathExpression(annotationData.getExpectedMethodRef(), node);
      String className = BeansEditorUtils.getClassNameForBean(file, node.getOwnerDocument(), typeName);
      return createMethodHyperlink(target, hyperlinkRegion, file, className);
    }
    return null;
  }
View Full Code Here


  @Override
  public boolean isLinkableAttr(Attr attr, Node annotation) {
    if (ToolAnnotationUtils.ANNOTATION_ELEMENT.equals(annotation.getLocalName())
        && ToolAnnotationUtils.TOOL_NAMESPACE_URI.equals(annotation.getNamespaceURI())) {
      ToolAnnotationData annotationData = ToolAnnotationUtils.getToolAnnotationData(annotation);
      return annotationData != null
          && (REF_ATTRIBUTE.equals(annotationData.getKind())
              || Class.class.getName().equals(annotationData.getExpectedType())
              || annotationData.getExpectedMethodRef() != null || annotationData.getExpectedMethodType() != null);
    }
    return false;
  }
View Full Code Here

      for (int j = 0; j < children.getLength(); j++) {
        Node annotation = children.item(j);
        if (annotation.getNodeType() == Node.ELEMENT_NODE
            && ToolAnnotationUtils.ANNOTATION_ELEMENT.equals(annotation.getLocalName())
            && ToolAnnotationUtils.TOOL_NAMESPACE_URI.equals(annotation.getNamespaceURI())) {
          ToolAnnotationData annotationData = ToolAnnotationUtils.getToolAnnotationData(annotation);
          if (annotationData != null) {
            annotationDatas.add(annotationData);
          }
        }
      }
View Full Code Here

  public void addAttributeValueProposals(IContentAssistContext context, IContentAssistProposalRecorder recorder,
      Node annotation) {
    if (ToolAnnotationUtils.ANNOTATION_ELEMENT.equals(annotation.getLocalName())
        && ToolAnnotationUtils.TOOL_NAMESPACE_URI.equals(annotation.getNamespaceURI())) {

      ToolAnnotationData annotationData = ToolAnnotationUtils.getToolAnnotationData(annotation);

      if (REF_ATTRIBUTE.equals(annotationData.getKind())) {
        // bean reference content assist
        // TODO CD: add support for typed reference content assist
        BEAN_REFERENCE_CALCULATOR.computeProposals(context, recorder);
      }
      if (Class.class.getName().equals(annotationData.getExpectedType())) {
        // class content assist
        if (annotationData.getAssignableTo() == null) {
          getClassContentAssistCalculator(annotationData).computeProposals(context, recorder);
        }
        else {
          getClassHierachyContentAssistCalculator(annotationData).computeProposals(context, recorder);
        }
      }
      if (annotationData.getExpectedMethodType() != null) {
        String className = evaluateXPathExpression(annotationData.getExpectedMethodType(), context.getNode());
        new NonFilteringMethodContentAssistCalculator(className).computeProposals(context, recorder);
      }
      else if (annotationData.getExpectedMethodRef() != null) {
        String typeName = evaluateXPathExpression(annotationData.getExpectedMethodRef(), context.getNode());
        String className = BeansEditorUtils.getClassNameForBean(context.getFile(), context.getDocument(),
            typeName);
        new NonFilteringMethodContentAssistCalculator(className).computeProposals(context, recorder);
      }
    }
View Full Code Here

  private class BlueprintInterfaceAttributeValidator implements IAttributeValidator {

    private final ToolAnnotationData annotationData;

    public BlueprintInterfaceAttributeValidator() {
      this.annotationData = new ToolAnnotationData();
      this.annotationData.setAssignableToRestriction("interface-only");
    }
View Full Code Here

    if (!appInfo.isEmpty()) {
      for (Element element : appInfo) {
        NodeList children = element.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
          Node annotation = children.item(i);
          ToolAnnotationData data = ToolAnnotationUtils.getToolAnnotationData(annotation);
          if (!widgetCreated) {
            TextAttribute attrWidget = null;
            if (data.getExpectedType() != null
                && data.getExpectedType().equalsIgnoreCase(Class.class.getName())) {
              attrWidget = createClassAttribute(client, attr, true, required);
            }
            else if (data.getKind() != null || data.getExpectedMethodType() != null
                || data.getExpectedMethodRef() != null || data.getExpectedMethodExpression() != null) {
              attrWidget = createToolAnnotationAttribute(client, attr, required);
            }
            if (attrWidget != null) {
              widgets.add(attrWidget);
              adapters.add(new TextAttributeProposalAdapter(attrWidget,
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.beans.core.namespaces.ToolAnnotationUtils.ToolAnnotationData

Copyright © 2018 www.massapicom. 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.