كيفية تنفيذ وثائق مساعدة المحتوى المنبثقة في Eclipse RCP

StackOverflow https://stackoverflow.com/questions/887248

سؤال

لقد قمت بتنفيذ المحرر الخاص بي وأضاف وظيفة إكمال التعليمات البرمجية. مسجل مساعد المحتوى الخاص بي في تكوين عارض المصدر مثل هذا:

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;
}

عندما أضغط كنترول + الفضاء داخل القسم المطلوب، يظهر المنبثقة الانتهاء ويعمل كما هو متوقع.

وهنا سؤالي .. كيف يمكنني تطبيق / تسجيل الوثائق المنبثقة التي تظهر بجانب إكمال المنبثقة؟ (على سبيل المثال في محرر Java)

هل كانت مفيدة؟

المحلول

نحن سوف،

سأجيب على السؤال نفسي ؛-)

عليك أن تضيف هذا الخط

assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

إلى التكوين أعلاه. ثم عند إنشاء الإنجازproposals., ، المعلمة الثامنة (الأخيرة) exortproposalinfo. من المنشئ هو النص، والذي سيتم عرضه في الوثائق المنبثقة.

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

مزيد من المعلومات حول يمكن العثور عليها هنا.

سهل، أليس كذلك .. إذا كنت تعرف كيفية القيام بذلك؛)

نصائح أخرى

لمربع معلومات المصمم (تماما مثل في JDT).

Styled additionnal information


  • ال defaultInformationControl. تحتاج المثال إلى استلام 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));
                }
            };
        }
    }
    

  • يمكن أن تستخدم المقترحات بعد ذلك علامات HTML الأساسية في السلسلة من الأسلوب getadditionalproposalinfo ().
  • public class MyProposal implements ICompletionProposal {
        [...]
        @Override
        public String getAdditionalProposalInfo() {
            return "<b>Hello</b> <i>World</i>!";
        }
    }
    
    مرخصة بموجب: CC-BY-SA مع الإسناد
    لا تنتمي إلى StackOverflow
    scroll top