Mercurial > projects > dwt-addons
comparison dwtx/jface/fieldassist/SimpleContentProposalProvider.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 46a6e0e6ccd4 |
children |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
14 module dwtx.jface.fieldassist.SimpleContentProposalProvider; | 14 module dwtx.jface.fieldassist.SimpleContentProposalProvider; |
15 | 15 |
16 import dwtx.jface.fieldassist.IContentProposalProvider; | 16 import dwtx.jface.fieldassist.IContentProposalProvider; |
17 import dwtx.jface.fieldassist.IContentProposal; | 17 import dwtx.jface.fieldassist.IContentProposal; |
18 | 18 |
19 import tango.util.collection.ArraySeq; | |
20 | 19 |
21 import dwt.dwthelper.utils; | 20 import dwt.dwthelper.utils; |
21 import dwtx.dwtxhelper.Collection; | |
22 | 22 |
23 /** | 23 /** |
24 * SimpleContentProposalProvider is a class designed to map a static list of | 24 * SimpleContentProposalProvider is a class designed to map a static list of |
25 * Strings to content proposals. | 25 * Strings to content proposals. |
26 * | 26 * |
59 this.proposals = proposals; | 59 this.proposals = proposals; |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Return an array of Objects representing the valid content proposals for a | 63 * Return an array of Objects representing the valid content proposals for a |
64 * field. | 64 * field. |
65 * | 65 * |
66 * @param contents | 66 * @param contents |
67 * the current contents of the field (only consulted if filtering | 67 * the current contents of the field (only consulted if filtering |
68 * is set to <code>true</code>) | 68 * is set to <code>true</code>) |
69 * @param position | 69 * @param position |
71 * @return the array of Objects that represent valid proposals for the field | 71 * @return the array of Objects that represent valid proposals for the field |
72 * given its current content. | 72 * given its current content. |
73 */ | 73 */ |
74 public IContentProposal[] getProposals(String contents, int position) { | 74 public IContentProposal[] getProposals(String contents, int position) { |
75 if (filterProposals) { | 75 if (filterProposals) { |
76 auto list = new ArraySeq!(IContentProposal); | 76 ArrayList list = new ArrayList(); |
77 for (int i = 0; i < proposals.length; i++) { | 77 for (int i = 0; i < proposals.length; i++) { |
78 if (proposals[i].length >= contents.length | 78 if (proposals[i].length >= contents.length |
79 && proposals[i].substring(0, contents.length) | 79 && proposals[i].substring(0, contents.length) |
80 .equalsIgnoreCase(contents)) { | 80 .equalsIgnoreCase(contents)) { |
81 list.append(makeContentProposal(proposals[i])); | 81 list.add(cast(Object)makeContentProposal(proposals[i])); |
82 } | 82 } |
83 } | 83 } |
84 return list.toArray(); | 84 return arraycast!(IContentProposal)(list.toArray()); |
85 } | 85 } |
86 if (contentProposals is null) { | 86 if (contentProposals is null) { |
87 contentProposals = new IContentProposal[proposals.length]; | 87 contentProposals = new IContentProposal[proposals.length]; |
88 for (int i = 0; i < proposals.length; i++) { | 88 for (int i = 0; i < proposals.length; i++) { |
89 contentProposals[i] = makeContentProposal(proposals[i]); | 89 contentProposals[i] = makeContentProposal(proposals[i]); |