List of usage examples for org.springframework.ide.eclipse.core.java Introspector getReadableProperty
public static IMethod getReadableProperty(IType type, String propertyName) throws JavaModelException
From source file:org.dozer.eclipse.plugin.sourcepage.hyperlink.DozerClassHyperlinkDetector.java
public IHyperlink createHyperlink(String attrName, String target, Node node, Node parentNode, IDocument document, ITextViewer textViewer, IRegion hyperlinkRegion, IRegion cursor) { String nodeName = parentNode.getNodeName(); IFile file = BeansEditorUtils.getFile(document); IType type = JdtUtils.getJavaType(file.getProject(), target); if ("class-a".equals(nodeName) || "class-b".equals(nodeName) || "a-hint".equals(attrName) || "b-hint".equals(attrName) || "a-deep-index-hint".equals(attrName) || "b-deep-index-hint".equals(attrName)) { //make a simple hyperlink to the class if (type != null) { return new JavaElementHyperlink(hyperlinkRegion, type); }/*w w w. j a va 2 s . com*/ } else if ("set-method".equals(attrName) || "get-method".equals(attrName) || "map-set-method".equals(attrName) || "map-get-method".equals(attrName)) { if ("field".equals(nodeName)) { String targetClassName = DozerPluginUtils.getMappingClassName(node); //get the first method that matches and make a hyperlink to that if (targetClassName != null) { IType targetClass = JdtUtils.getJavaType(file.getProject(), targetClassName); IMethod method = getMethodFromType(targetClass, target); if (method != null) { return new JavaElementHyperlink(hyperlinkRegion, method); } } } } else if ("a-hint".equals(attrName) || "b-hint".equals(attrName)) { //make a simple hyperlink to the class if (parentNode.getParentNode() != null && "mapping".equals(parentNode.getParentNode().getNodeName())) { if (type != null) { return new JavaElementHyperlink(hyperlinkRegion, type); } } } else if ("custom-converter".equals(attrName)) { //make a simple hyperlink to the class if (type != null) { return new JavaElementHyperlink(hyperlinkRegion, type); } } else if ("custom-converter-id".equals(attrName)) { //search spring-bean that uses our mapping file and return the mapping //for the customconverter-id map-property ISourceModelElement modelElement = getModelElementForCustomConverter(BeansEditorUtils.getFile(document), target); if (modelElement != null) { return new SourceModelHyperlink(modelElement, hyperlinkRegion); } } else if ("a".equals(nodeName) || "b".equals(nodeName)) { String targetClassName = DozerPluginUtils.getMappingClassName(node.getParentNode()); String property = node.getNodeValue(); if (targetClassName != null) { IType targetClass = JdtUtils.getJavaType(file.getProject(), targetClassName); try { //if we are doing indexed property mapping, we remove the [] property = property.replaceAll("\\[\\]", ""); IMethod method = Introspector.getReadableProperty(targetClass, property); if (method != null) return new JavaElementHyperlink(hyperlinkRegion, method); } catch (Throwable e) { Logger.logException(e); } } } else if ("bean-factory".equals(attrName)) { //make a simple hyperlink to the class if (type != null) { return new JavaElementHyperlink(hyperlinkRegion, type); } } return null; }