| [wtp-dev] JavaScript editing in a SourceViewer within a dialog |
I’m dealing with an issue regarding editing of _javascript_ within a dialog. I have a dialog up and running with an embedded JavaSourceViewer with a _javascript_ configuration setup.
I have syntax highlighting, but cannot get the content assist to work.
I’ve looked at the code for EditTemplateDialog and DetailFormatterDialog with no luck.
Do I need access to a JavaProject or CompilationUnit? If so, how might I do this?
I do not have an IEditorPart to work with, obviously since in a dialog. Below is my code for trying to setup content assist for the _javascript_SourceViewConfiguration. However, I get a JavaNoTypeCompletionProposalComputer error when trying it out…I’m assuming due to not having an IEditorPart passed into the JavaCompletionProcessor constructor.
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant= new ContentAssistant();
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$
IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE);
ContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
assistant.setContentAssistProcessor(singleLineProcessor, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaScriptPartitions.JAVA_STRING);
assistant.setContentAssistProcessor(stringProcessor, IJavaScriptPartitions.JAVA_STRING);
ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
assistant.setContentAssistProcessor(multiLineProcessor, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
assistant.setContentAssistProcessor(javadocProcessor, IJavaScriptPartitions.JAVA_DOC);
ContentAssistPreference.configure(assistant, fPreferenceStore);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
return assistant;
}
Is there some other Eclipse code I should be looking at for an example?
Is this the right forum to post such questions?
I’m using Eclipse: 3.4.1 M20080911-1700
I’ve installed WTP 3.0.5
I know I’m using an older version of Eclipse and WTP, but I’m currently stuck at this level and could use any sort of advice.
Thanks in advance