1) Re-arranged packages:
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / propertysheet / SourceViewerConfig.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.propertysheet;
11
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;
24
25 /**
26 * @author p.ciardelli
27 * @created 19.05.2008
28 * @version 1.0
29 */
30 public class SourceViewerConfig extends SourceViewerConfiguration {
31 private static final Logger logger = Logger
32 .getLogger(SourceViewerConfig.class);
33
34 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
35
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() {
51
52 @Override
53 public void assistSessionEnded(ContentAssistEvent event) {
54 // TODO Auto-generated method stub
55 }
56
57 @Override
58 public void assistSessionStarted(ContentAssistEvent event) {
59 // TODO Auto-generated method stub
60 }
61
62 @Override
63 public void selectionChanged(ICompletionProposal proposal,
64 boolean smartToggle) {
65 if (smartToggle) {
66 logger.warn("Inserting " + proposal.getDisplayString());
67 }
68 }
69 });
70 return assistant;
71 }
72 }