Java Code Examples for org.eclipse.jface.text.contentassist.ContentAssistant#setInformationControlCreator()

The following examples show how to use org.eclipse.jface.text.contentassist.ContentAssistant#setInformationControlCreator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BibSourceViewerConfiguration.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    assistant = new ContentAssistant();
    assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    
    assistant.setContentAssistProcessor(new BibCompletionProcessor(this.editor.getDocumentModel()),
            BibPartitionScanner.BIB_ENTRY);
    assistant.setContentAssistProcessor(new BibCompletionProcessor(this.editor.getDocumentModel()),
            IDocument.DEFAULT_CONTENT_TYPE);

    assistant.enableAutoActivation(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.BIB_COMPLETION));
    assistant.enableAutoInsert(true);
    assistant.setAutoActivationDelay(TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.BIB_COMPLETION_DELAY));
    assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
    assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
    return assistant;
}
 
Example 2
Source File: TLASourceViewerConfiguration.java    From tlaplus with MIT License 6 votes vote down vote up
/**
   * Content assistant
   */
  public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
  {
      ContentAssistant assistant = new ContentAssistant();
      assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
      assistant.setContentAssistProcessor(new TLACompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
      assistant.setContentAssistProcessor(new PCalCompletionProcessor(), TLAPartitionScanner.TLA_PCAL);
      assistant.enableColoredLabels(true);
      assistant.enableAutoActivation(true);
      assistant.setAutoActivationDelay(500);
assistant.setInformationControlCreator(new IInformationControlCreator() {
	public IInformationControl createInformationControl(final Shell parent) {
		return new DefaultInformationControl(parent, (DefaultInformationControl.IInformationPresenter) null);
	}
});
assistant.setSorter(new ICompletionProposalSorter() {
	public int compare(ICompletionProposal p1, ICompletionProposal p2) {
		return 0;
	}
});
      assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
      assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
      assistant.setContextInformationPopupBackground(TLAEditorActivator.getDefault().getTLAColorProvider().getColor(
              TLAColorProvider.CONTENT_ASSIST_BACKGROUND_KEY));
      return assistant;
  }
 
Example 3
Source File: JsonSourceViewerConfiguration.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant ca = new ContentAssistant();
    JsonContentAssistProcessor processor = createContentAssistProcessor(ca);

    ca.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    ca.enableAutoInsert(false);
    ca.enablePrefixCompletion(false);
    ca.enableAutoActivation(true);
    ca.setAutoActivationDelay(100);
    ca.enableColoredLabels(true);
    ca.setShowEmptyList(true);
    ca.setRepeatedInvocationMode(true);
    ca.addCompletionListener(processor);
    ca.setStatusLineVisible(true);

    return ca;
}
 
Example 4
Source File: TexSourceViewerConfiguration.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
        
//        ContentAssistant assistant = new ContentAssistant();
        assistant = new ContentAssistant();
        assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
        
        // note that partitioning affects completions
        //TexCompletionProcessor tcp = new TexCompletionProcessor(this.editor.getDocumentModel());
        TexCompletionProcessor tcp = new TexCompletionProcessor(this.editor.getDocumentModel(), sourceViewer);
        TexMathCompletionProcessor tmcp = new TexMathCompletionProcessor(this.editor.getDocumentModel(), sourceViewer);
//        assistant.setContentAssistProcessor(new TexCompletionProcessor(this.editor.getDocumentModel()),
//                IDocument.DEFAULT_CONTENT_TYPE);

        assistant.setContentAssistProcessor(tcp, IDocument.DEFAULT_CONTENT_TYPE);
        //assistant.setContentAssistProcessor(tcp, TexPartitionScanner.TEX_MATH);
        assistant.setContentAssistProcessor(tmcp, FastLaTeXPartitionScanner.TEX_MATH);
        assistant.setContentAssistProcessor(tcp, FastLaTeXPartitionScanner.TEX_CURLY_BRACKETS);
        assistant.setContentAssistProcessor(tcp, FastLaTeXPartitionScanner.TEX_SQUARE_BRACKETS);
        assistant.setContentAssistProcessor(tcp, FastLaTeXPartitionScanner.TEX_TIKZPIC);

        assistant.enableAutoActivation(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.TEX_COMPLETION));
        assistant.enableAutoInsert(true);
        assistant.setAutoActivationDelay(TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.TEX_COMPLETION_DELAY));
        
        assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
        assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
        assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

        return assistant;
    }
 
Example 5
Source File: ImpexSourceViewerConfig.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
	
	ContentAssistant assistant = new ContentAssistant();
	assistant.enableAutoActivation(true);
	assistant.setAutoActivationDelay(300);
	assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
	assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
	assistant.enableAutoInsert(true);
	assistant.enablePrefixCompletion(true);
	
	IContentAssistProcessor pr = new ImpexInstructionContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_INSTRUCTION);
	
	//pr = new ImpexTypeAttributeContentAssistProcessor();
	pr = new ImpexTypeSystemContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_HEADER);
	
	pr = new ImpexDataContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_DATA);
	
	pr = new ImpexCommentContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, ImpexDocumentPartitioner.IMPEX_COMMENT);
	
	pr = new ImpexCommandContentAssistProcessor();
	assistant.setContentAssistProcessor(pr, IDocument.DEFAULT_CONTENT_TYPE);
	
	assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
	return assistant;
}
 
Example 6
Source File: CodeTemplateSourceViewerConfiguration.java    From typescript.java with MIT License 5 votes vote down vote up
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

		IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
		JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
		IColorManager manager= textTools.getColorManager();					
		

		ContentAssistant assistant= new ContentAssistant();
		assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
			// Register the same processor for strings and single line comments to get code completion at the start of those partitions.
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_STRING);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_CHARACTER);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVASCRIPT_TEMPLATE_LITERAL);
		assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_DOC);

		assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
		assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
		assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
		assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
		assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
		assistant.setInformationControlCreator(new IInformationControlCreator() {
			public IInformationControl createInformationControl(Shell parent) {
				return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
			}
		});

		Color background= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);			
		assistant.setContextInformationPopupBackground(background);
		assistant.setContextSelectorBackground(background);
		assistant.setProposalSelectorBackground(background);

		Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
		assistant.setContextInformationPopupForeground(foreground);
		assistant.setContextSelectorForeground(foreground);
		assistant.setProposalSelectorForeground(foreground);
		
		return assistant;
	}
 
Example 7
Source File: JavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

	if (getEditor() != null) {

		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, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
		assistant.setContentAssistProcessor(singleLineProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);

		ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING);
		assistant.setContentAssistProcessor(stringProcessor, IJavaPartitions.JAVA_STRING);

		ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
		assistant.setContentAssistProcessor(multiLineProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);

		ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
		assistant.setContentAssistProcessor(javadocProcessor, IJavaPartitions.JAVA_DOC);

		ContentAssistPreference.configure(assistant, fPreferenceStore);

		assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
		assistant.setInformationControlCreator(new IInformationControlCreator() {
			public IInformationControl createInformationControl(Shell parent) {
				return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
			}
		});

		return assistant;
	}

	return null;
}
 
Example 8
Source File: CodeTemplateSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

	IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
	JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
	IColorManager manager= textTools.getColorManager();


	ContentAssistant assistant= new ContentAssistant();
	assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
		// Register the same processor for strings and single line comments to get code completion at the start of those partitions.
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_STRING);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_CHARACTER);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
	assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_DOC);

	assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
	assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
	assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
	assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
	assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
	assistant.setInformationControlCreator(new IInformationControlCreator() {
		public IInformationControl createInformationControl(Shell parent) {
			return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
		}
	});

	Color background= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, manager);
	assistant.setContextInformationPopupBackground(background);
	assistant.setContextSelectorBackground(background);

	Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, manager);
	assistant.setContextInformationPopupForeground(foreground);
	assistant.setContextSelectorForeground(foreground);

	return assistant;
}
 
Example 9
Source File: DefaultContentAssistantFactory.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private void setInformationControlCreator(ContentAssistant assistant, SourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) {
	if (configuration != null && sourceViewer != null)
		assistant.setInformationControlCreator(configuration.getInformationControlCreator(sourceViewer));
}
 
Example 10
Source File: TypeScriptSourceViewerConfiguration.java    From typescript.java with MIT License 4 votes vote down vote up
@Override
	public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
		if (getEditor() != null) {

			ContentAssistant assistant = new ContentAssistant();
			assistant.enableColoredLabels(true);
			assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

			assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$

			IContentAssistProcessor javaProcessor = new TypeScriptCompletionProcessor(getEditor(), assistant,
					IDocument.DEFAULT_CONTENT_TYPE);
			assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE);

			ContentAssistProcessor singleLineProcessor = new TypeScriptCompletionProcessor(getEditor(), assistant,
					IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
			assistant.setContentAssistProcessor(singleLineProcessor, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);

			ContentAssistProcessor stringProcessor = new TypeScriptCompletionProcessor(getEditor(), assistant,
					IJavaScriptPartitions.JAVA_STRING);
			assistant.setContentAssistProcessor(stringProcessor, IJavaScriptPartitions.JAVA_STRING);
			assistant.setContentAssistProcessor(stringProcessor, IJavaScriptPartitions.JAVA_CHARACTER);

			ContentAssistProcessor multiLineProcessor = new TypeScriptCompletionProcessor(getEditor(), assistant,
					IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
			assistant.setContentAssistProcessor(multiLineProcessor, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);

			ContentAssistProcessor templateLiteralProcessor = new TypeScriptCompletionProcessor(getEditor(), assistant,
					IJavaScriptPartitions.JAVASCRIPT_TEMPLATE_LITERAL);
			assistant.setContentAssistProcessor(templateLiteralProcessor,
					IJavaScriptPartitions.JAVASCRIPT_TEMPLATE_LITERAL);

			ContentAssistProcessor jsxProcessor = new TypeScriptCompletionProcessor(getEditor(), assistant,
					IJSXPartitions.JSX);
			assistant.setContentAssistProcessor(jsxProcessor, IJSXPartitions.JSX);

			ContentAssistProcessor javadocProcessor = new TypeScriptJavadocCompletionProcessor(getEditor(), assistant);
			assistant.setContentAssistProcessor(javadocProcessor, IJavaScriptPartitions.JAVA_DOC);

			ContentAssistPreference.configure(assistant, fPreferenceStore);

			assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
			assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

//			assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW);
//			assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_REMOVE);
//			assistant.setAutoActivationDelay(0);
//			assistant.enableColoredLabels(true);
//			assistant.enableAutoActivation(true);
			
			return assistant;
		}
		return null;
	}