1 package eu
.etaxonomy
.taxeditor
.designproposal1
.view
;
3 import org
.eclipse
.jface
.text
.IDocument
;
4 import org
.eclipse
.jface
.text
.TextAttribute
;
5 import org
.eclipse
.jface
.text
.contentassist
.ContentAssistant
;
6 import org
.eclipse
.jface
.text
.contentassist
.IContentAssistant
;
7 import org
.eclipse
.jface
.text
.presentation
.IPresentationReconciler
;
8 import org
.eclipse
.jface
.text
.presentation
.PresentationReconciler
;
9 import org
.eclipse
.jface
.text
.rules
.DefaultDamagerRepairer
;
10 import org
.eclipse
.jface
.text
.rules
.Token
;
11 import org
.eclipse
.jface
.text
.source
.ISourceViewer
;
12 import org
.eclipse
.jface
.text
.source
.SourceViewerConfiguration
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.graphics
.Color
;
15 import org
.eclipse
.swt
.graphics
.RGB
;
16 import org
.eclipse
.swt
.widgets
.Display
;
18 import com
.swtdesigner
.SWTResourceManager
;
20 public class MySourceViewerConfig
extends SourceViewerConfiguration
{
21 private MyRuleScanner scanner
;
22 private static Color DEFAULT_TAG_COLOR
=
23 new Color(Display
.getCurrent(), new RGB(0, 0, 0));
25 public MySourceViewerConfig() {
28 protected MyRuleScanner
getTagScanner() {
29 if (scanner
== null) {
30 scanner
= new MyRuleScanner();
31 scanner
.setDefaultReturnToken(
33 new TextAttribute(DEFAULT_TAG_COLOR
,
36 SWTResourceManager
.getFont("Georgia", 11, SWT
.BOLD
| SWT
.ITALIC
))
43 * Define reconciler for MyEditor
45 public IPresentationReconciler
getPresentationReconciler(ISourceViewer sourceViewer
) {
46 PresentationReconciler reconciler
= new PresentationReconciler();
47 DefaultDamagerRepairer dr
= new DefaultDamagerRepairer(getTagScanner());
48 reconciler
.setDamager(dr
, IDocument
.DEFAULT_CONTENT_TYPE
);
49 reconciler
.setRepairer(dr
, IDocument
.DEFAULT_CONTENT_TYPE
);
53 public IContentAssistant
getContentAssistant(ISourceViewer sourceViewer
) {
55 ContentAssistant assistant
= new ContentAssistant();
56 assistant
.setContentAssistProcessor(
57 new MyCompletionProcessor(),
58 IDocument
.DEFAULT_CONTENT_TYPE
);
59 assistant
.enableAutoActivation(true);
60 assistant
.setAutoActivationDelay(50);
61 assistant
.setProposalPopupOrientation(
62 IContentAssistant
.PROPOSAL_OVERLAY
);
63 assistant
.setStatusLineVisible(true);
64 assistant
.setStatusMessage("Create a nomenclatural or taxonomic relationship");
65 assistant
.setProposalSelectorBackground(
66 new Color(Display
.getCurrent(), new RGB(255, 255, 255)));
67 assistant
.setInformationControlCreator(
68 getInformationControlCreator(sourceViewer
)); // this is what pops up the yellow context box