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 java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.jface
.text
.ITextViewer
;
17 import org
.eclipse
.jface
.text
.contentassist
.CompletionProposal
;
18 import org
.eclipse
.jface
.text
.contentassist
.ICompletionProposal
;
19 import org
.eclipse
.jface
.text
.contentassist
.IContentAssistProcessor
;
20 import org
.eclipse
.jface
.text
.contentassist
.IContextInformation
;
21 import org
.eclipse
.jface
.text
.contentassist
.IContextInformationValidator
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
26 * FIXME This looks very incomplete
32 public class CompletionProcessor
implements IContentAssistProcessor
{
33 private static final Logger logger
= Logger
34 .getLogger(CompletionProcessor
.class);
37 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
39 public ICompletionProposal
[] computeCompletionProposals(
40 ITextViewer viewer
, int documentOffset
) {
41 String context
= "Describe formatting / parsing of this rel. type.";
42 // Image img = ResourceManager.getPluginImage(Activator.getDefault(), "icons/unknown.gif");
43 // ICompletionProposal[] result =
44 // new ICompletionProposal[myProposals.length];
45 // for (int i = 0; i < myProposals.length; i++) {
46 // IContextInformation contextInfo =
47 // new ContextInformation(null, myProposals[i]+" Style");
48 // result[i] = new CompletionProposal(myProposals[i],documentOffset, 0,
49 // myProposals[i].length(), ResourceManager.getPluginImage(Activator.getDefault(), myIcons[i]),
50 // myProposals[i], contextInfo, context);
54 String searchText
= viewer
.getTextWidget().getText() + "%";
55 // List<TaxonNameBase> names = CdmUtil.getNameByName(searchText);
56 List
<TaxonNameBase
> names
= null;
57 logger
.warn(names
.size() + " names");
58 List
<ICompletionProposal
> proposals
= new ArrayList
<ICompletionProposal
>();
59 // String[] test = new String[] {"suggestion 1", "suggestion 2", "suggestion 3"};
60 for (TaxonNameBase name
: names
) {
61 String proposalText
= name
.getTitleCache();
62 // for (String proposalText : test) {
63 proposals
.add(new CompletionProposal(proposalText
,
66 proposalText
.length(),
73 logger
.warn(proposals
.size() + " proposals.");
74 return proposals
.toArray(new ICompletionProposal
[proposals
.size()]);
78 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
80 public IContextInformation
[] computeContextInformation(ITextViewer viewer
,
86 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
88 public char[] getCompletionProposalAutoActivationCharacters() {
89 return new char[] {'a','b','c','d','e','f','g','H'};
93 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
95 public char[] getContextInformationAutoActivationCharacters() {
100 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
102 public IContextInformationValidator
getContextInformationValidator() {
107 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
109 public String
getErrorMessage() {