Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Instrumentation
- Runnable
- ORM
- 자바
- 암호학
- StringUtils
- date
- RSA
- String
- Executors
- DAMO
- sha1
- Postman
- 이클립스 플러그인 개발
- Log4J
- 한글조사
- xlet
- JCE
- PKCS#8
- ACAP
- PKCS
- Executor
- 자바 암호화
- AES
- IPTV
- Callable
- 한글조사처리
- mac
- Java
- Freemaker
Archives
- Today
- Total
오늘은 어디로 갈까...
org.eclipse.ui.workbench.texteditor.hyperlinkDetectors 본문
참고 : http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_workbench_texteditor_hyperlinkDetectors.html
EJB를 사용할 때 ctrl+click해서 구현한 Bean에 바로가기 위해서 만들어 본 것
EJB를 사용할 때 ctrl+click해서 구현한 Bean에 바로가기 위해서 만들어 본 것
public class JavaElementHyperlinkDetector extends AbstractHyperlinkDetector { /* * @see * org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks( * org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, * boolean) */ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { ITextEditor textEditor = (ITextEditor) getAdapter(ITextEditor.class); if (region == null || !(textEditor instanceof JavaEditor)) { return null; } IAction openAction = textEditor.getAction("OpenEditor"); if (!(openAction instanceof SelectionDispatchAction)) { return null; } int offset = region.getOffset(); IJavaElement input = EditorUtility.getEditorInputJavaElement( textEditor, false); if (input == null) { return null; } try { IDocument document = textEditor.getDocumentProvider().getDocument( textEditor.getEditorInput()); IRegion wordRegion = JavaWordFinder.findWord(document, offset); if (wordRegion == null || wordRegion.getLength() == 0) { return null; } IJavaElement[] elements = null; elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength()); elements = selectOpenableElements(elements); if (elements.length == 0) { return null; } IHyperlink[] result = new IHyperlink[elements.length]; for (int i = 0; i < elements.length; i++) { result[i] = new JavaElementHyperlink(wordRegion, (SelectionDispatchAction) openAction, elements[i], elements.length > 1); } return result; } catch (JavaModelException e) { return null; } } private IJavaElement[] selectOpenableElements(IJavaElement[] elements) { List result = new ArrayList(elements.length); for (int i = 0; i < elements.length; i++) { IJavaElement element = elements[i]; switch (element.getElementType()) { case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.PACKAGE_FRAGMENT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: case IJavaElement.JAVA_PROJECT: case IJavaElement.JAVA_MODEL: break; default: IJavaElement ejbElement = getElementToOpen(element); if (ejbElement != element) { result.add(ejbElement); } break; } } return (IJavaElement[]) result.toArray(new IJavaElement[result.size()]); } private IJavaElement getElementToOpen(final IJavaElement element) { IJavaElement target = element; boolean isMethod = false; if (element.getElementType() == IJavaElement.METHOD) { isMethod = true; target = element.getParent(); } if (target.getElementType() == IJavaElement.TYPE) { try { if (target instanceof IType) { IType type = (IType) target; if (JavaEEProjectUtilities.isEJBProject(target .getJavaProject().getProject())) { EnterpriseBean bean = J2EEProjectUtilities .getEnterpriseBean(type.getCompilationUnit()); if (bean != null) { type = target.getJavaProject().findType( bean.getEjbClassName()); if (type != null) { target = type; if (isMethod) { IMethod lMethod = (IMethod) element; IMethod eMethod = null; IJavaElement[] children = type .getChildren(); if (children != null && children.length > 0) { for (IJavaElement c : children) { if (c.getElementType() == element.getElementType() && c.getElementName().equals(element.getElementName())) { eMethod = (IMethod) c; if (ArrayUtils.equals(lMethod.getParameterTypes(), eMethod.getParameterTypes())) { return c; } target = c; // 일단 이름만 비슷한걸로 찾기 위해서 } } } } return target; } } } } } catch (Exception e) { return element; } } return element; } }