Search in sources :

Example 1 with HBMInfoHandler

use of org.hibernate.eclipse.mapper.extractor.HBMInfoHandler in project jbosstools-hibernate by jbosstools.

the class HBMXMLContentAssistProcessor method getAttributeValueProposals.

public List getAttributeValueProposals(String attributeName, String start, int offset, ContentAssistRequest contentAssistRequest) {
    Node node = contentAssistRequest.getNode();
    List proposals = new ArrayList();
    // $NON-NLS-1$
    String path = node.getNodeName() + ">" + attributeName;
    HBMInfoHandler handler = sourceLocator.getAttributeHandler(path);
    if (handler != null) {
        proposals.addAll(Arrays.asList(handler.attributeCompletionProposals(getJavaProject(contentAssistRequest), node, attributeName, start, offset)));
    }
    if (DEBUG) {
        String string = contentAssistRequest.getDocumentRegion().getText();
        string = string.replace('<', '[');
        string = string.replace('>', ']');
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
        CompletionProposal completionProposal = new CompletionProposal("[" + start + "],[" + path + "],[" + offset + "]", offset, 1, 4, null, null, null, string);
        proposals.add(completionProposal);
    }
    return proposals;
}
Also used : CompletionProposal(org.eclipse.jface.text.contentassist.CompletionProposal) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) HBMInfoHandler(org.hibernate.eclipse.mapper.extractor.HBMInfoHandler)

Example 2 with HBMInfoHandler

use of org.hibernate.eclipse.mapper.extractor.HBMInfoHandler in project jbosstools-hibernate by jbosstools.

the class HBMXMLHyperlinkDetector method detectHyperlinks.

public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    if (region == null || textViewer == null) {
        return null;
    }
    IJavaProject jp = StructuredTextViewerConfigurationUtil.findJavaProject(textViewer);
    if (jp == null)
        return new IHyperlink[0];
    IDocument document = textViewer.getDocument();
    Node currentNode = getCurrentNode(document, region.getOffset());
    if (currentNode != null) {
        short nodeType = currentNode.getNodeType();
        if (nodeType == Node.ATTRIBUTE_NODE) {
        } else if (nodeType == Node.ELEMENT_NODE) {
            Attr currentAttrNode = getCurrentAttrNode(currentNode, region.getOffset());
            if (currentAttrNode != null) {
                // $NON-NLS-1$
                String path = currentNode.getNodeName() + ">" + currentAttrNode.getName();
                HBMInfoHandler handler = infoExtractor.getAttributeHandler(path);
                if (handler != null) {
                    IJavaProject project = StructuredTextViewerConfigurationUtil.findJavaProject(document);
                    IJavaElement element = handler.getJavaElement(project, currentNode, currentAttrNode);
                    if (element != null) {
                        return new IHyperlink[] { new HBMXMLHyperlink(getHyperlinkRegion(currentAttrNode), element) };
                    } else {
                        return null;
                    }
                }
            }
        }
    }
    return null;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IJavaProject(org.eclipse.jdt.core.IJavaProject) Node(org.w3c.dom.Node) IDocument(org.eclipse.jface.text.IDocument) Attr(org.w3c.dom.Attr) HBMInfoHandler(org.hibernate.eclipse.mapper.extractor.HBMInfoHandler)

Aggregations

HBMInfoHandler (org.hibernate.eclipse.mapper.extractor.HBMInfoHandler)2 Node (org.w3c.dom.Node)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IDocument (org.eclipse.jface.text.IDocument)1 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)1 Attr (org.w3c.dom.Attr)1