2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.propertysheet
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.jface
.text
.IDocument
;
14 import org
.eclipse
.jface
.text
.contentassist
.ContentAssistEvent
;
15 import org
.eclipse
.jface
.text
.contentassist
.ContentAssistant
;
16 import org
.eclipse
.jface
.text
.contentassist
.ICompletionListener
;
17 import org
.eclipse
.jface
.text
.contentassist
.ICompletionProposal
;
18 import org
.eclipse
.jface
.text
.contentassist
.IContentAssistant
;
19 import org
.eclipse
.jface
.text
.source
.ISourceViewer
;
20 import org
.eclipse
.jface
.text
.source
.SourceViewerConfiguration
;
21 import org
.eclipse
.swt
.graphics
.Color
;
22 import org
.eclipse
.swt
.graphics
.RGB
;
23 import org
.eclipse
.swt
.widgets
.Display
;
30 public class SourceViewerConfig
extends SourceViewerConfiguration
{
31 private static final Logger logger
= Logger
32 .getLogger(SourceViewerConfig
.class);
34 public IContentAssistant
getContentAssistant(ISourceViewer sourceViewer
) {
36 ContentAssistant assistant
= new ContentAssistant();
37 assistant
.setContentAssistProcessor(
38 new CompletionProcessor(),
39 IDocument
.DEFAULT_CONTENT_TYPE
);
40 assistant
.enableAutoActivation(true);
41 assistant
.setAutoActivationDelay(50);
42 assistant
.setProposalPopupOrientation(
43 IContentAssistant
.PROPOSAL_OVERLAY
);
44 assistant
.setStatusLineVisible(true);
45 // assistant.setStatusMessage("Create a nomenclatural or taxonomic relationship");
46 assistant
.setProposalSelectorBackground(
47 new Color(Display
.getCurrent(), new RGB(255, 255, 255)));
48 assistant
.setInformationControlCreator(
49 getInformationControlCreator(sourceViewer
)); // this is what pops up in the yellow context box
50 assistant
.addCompletionListener(new ICompletionListener() {
53 public void assistSessionEnded(ContentAssistEvent event
) {
54 // TODO Auto-generated method stub
58 public void assistSessionStarted(ContentAssistEvent event
) {
59 // TODO Auto-generated method stub
63 public void selectionChanged(ICompletionProposal proposal
,
64 boolean smartToggle
) {
66 logger
.warn("Inserting " + proposal
.getDisplayString());