2009-05-20 5 views
3

나는 자체 편집기를 구현하고 코드 완성 기능을 추가했다. 내 콘텐츠를 보조은 다음과 같이 소스 뷰어 구성에 등록 :Eclipse RCP에서 컨텐츠 지원의 문서 팝업 구현 방법

public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { 
    if (assistant == null) { 
     assistant = new ContentAssistant(); 
     assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); 
     assistant.setContentAssistProcessor(getMyAssistProcessor(), 
       MyPartitionScanner.DESIRED_PARTITION_FOR_MY_ASSISTANCE); 
     assistant.enableAutoActivation(true); 
     assistant.setAutoActivationDelay(500); 
     assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); 
     assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); 
    } 
    return assistant; 
} 

내가 Ctrl 키 + 원하는 파티션 내부 공간, 완료 팝업이 나타납니다 예상대로 작동 누르면.

그리고 여기 내 질문이 있습니다. 완성 팝업 옆에 나타나는 문서 팝업을 구현하거나 등록하는 방법은 무엇입니까?

;-) 내가 질문을 자신을 answear 것이다

답변

3

음,

(자바 편집기에서 예를 들어)이 라인 위의 구성에

assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); 

을 추가해야합니다. 그런 다음 CompletionProposals을 만들 때 additionalProposalInfo이라는 생성자 중 8 번째 매개 변수가 텍스트이며 문서 팝업에 표시됩니다.

new CompletionProposal(replacementString, 
          replacementOffset, 
          replacementLength, 
          cursorPosition, 
          image, 
          displayString, 
          contextInformation, 
          additionalProposalInfo); 

자세한 내용은 here을 참조하십시오.) 단지 JDT에서 같은 스타일 정보 상자

3

(); 당신이 그것을 수행하는 방법을 알고있는 경우

쉬운, 그것은 ... 아니다.


  • DefaultInformationControl 예를

    Styled additionnal information

    는에가 HTMLTextPresenter을받은이 필요합니다.
  • import org.eclipse.jface.internal.text.html.HTMLTextPresenter; 
    
    public class MyConfiguration extends SourceViewerConfiguration { 
    
    
        [...] 
        public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { 
         if (assistant == null) { 
          [...] 
          assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); 
         } 
         return assistant; 
        } 
    
        @Override 
        public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) { 
         return new IInformationControlCreator() { 
          public IInformationControl createInformationControl(Shell parent) { 
           return new DefaultInformationControl(parent,new HTMLTextPresenter(false)); 
          } 
         }; 
        } 
    } 
    

  • 제안은 방법 getAdditionalProposalInfo()에서 문자열에 기본 HTML 태그를 사용할 수 있습니다.
  • public class MyProposal implements ICompletionProposal { 
        [...] 
        @Override 
        public String getAdditionalProposalInfo() { 
         return "<b>Hello</b> <i>World</i>!"; 
        } 
    } 
    
    관련 문제