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

The following examples show how to use org.eclipse.jface.text.contentassist.ContentAssistant#enableColoredLabels() . 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: 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 2
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 3
Source File: DefaultContentAssistantFactory.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void setColoredLabels(ContentAssistant assistant) {
	assistant.enableColoredLabels(enableStyledLabels);
}
 
Example 4
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;
	}
 
Example 5
Source File: ContentAssistPreference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Configure the given content assistant from the given store.
 *
 * @param assistant the content assistant
 * @param store the preference store
 */
public static void configure(ContentAssistant assistant, IPreferenceStore store) {

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


	boolean enabled= store.getBoolean(AUTOACTIVATION);
	assistant.enableAutoActivation(enabled);

	int delay= store.getInt(AUTOACTIVATION_DELAY);
	assistant.setAutoActivationDelay(delay);

	Color c= getColor(store, PARAMETERS_FOREGROUND, manager);
	assistant.setContextInformationPopupForeground(c);
	assistant.setContextSelectorForeground(c);

	c= getColor(store, PARAMETERS_BACKGROUND, manager);
	assistant.setContextInformationPopupBackground(c);
	assistant.setContextSelectorBackground(c);

	enabled= store.getBoolean(AUTOINSERT);
	assistant.enableAutoInsert(enabled);

	enabled= store.getBoolean(PREFIX_COMPLETION);
	assistant.enablePrefixCompletion(enabled);

	enabled= store.getBoolean(USE_COLORED_LABELS);
	assistant.enableColoredLabels(enabled);


	configureJavaProcessor(assistant, store);
	configureJavaDocProcessor(assistant, store);
}