Revision e1055895
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/AbstractComboElement.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.combo; |
10 | 10 |
|
11 |
import org.eclipse.jface.viewers.ComboViewer; |
|
12 | 11 |
import org.eclipse.swt.SWT; |
12 |
import org.eclipse.swt.custom.CCombo; |
|
13 | 13 |
import org.eclipse.swt.events.DisposeEvent; |
14 | 14 |
import org.eclipse.swt.events.DisposeListener; |
15 | 15 |
import org.eclipse.swt.events.SelectionEvent; |
16 | 16 |
import org.eclipse.swt.events.SelectionListener; |
17 | 17 |
import org.eclipse.swt.graphics.Color; |
18 |
import org.eclipse.swt.widgets.Combo; |
|
19 | 18 |
import org.eclipse.swt.widgets.Label; |
20 | 19 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
21 | 20 |
|
... | ... | |
45 | 44 |
|
46 | 45 |
protected Label label; |
47 | 46 |
|
48 |
protected final Combo combo; |
|
47 |
protected final CCombo combo;
|
|
49 | 48 |
|
50 | 49 |
|
51 | 50 |
public AbstractComboElement(CdmFormFactory formFactory, ICdmFormElement formElement) { |
... | ... | |
55 | 54 |
addControl(label); |
56 | 55 |
|
57 | 56 |
// create combo |
58 |
ComboViewer viewer = new ComboViewer(getLayoutComposite(), SWT.BORDER | SWT.READ_ONLY ); |
|
59 |
combo = viewer.getCombo(); |
|
57 |
combo = new CCombo(getLayoutComposite(), SWT.READ_ONLY); |
|
60 | 58 |
addControl(combo); |
61 | 59 |
TableWrapData fill_HORIZONTALLY = LayoutConstants.FILL_HORIZONTALLY(); |
62 | 60 |
combo.setLayoutData(fill_HORIZONTALLY); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java | ||
---|---|---|
49 | 49 |
public void setTermComparator(Comparator<T> termComparator) { |
50 | 50 |
this.termComparator = termComparator; |
51 | 51 |
List<T> termsWithoutNull = terms.subList(1, terms.size()); |
52 |
|
|
52 |
|
|
53 | 53 |
populateTerms(termsWithoutNull); |
54 |
|
|
54 |
|
|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
private final TermType termType; |
... | ... | |
181 | 181 |
if (termComparator != null) { |
182 | 182 |
Collections.sort(preferredTerms, termComparator); |
183 | 183 |
} |
184 |
terms.addAll(preferredTerms); |
|
185 |
|
|
186 |
List<String> labels = new ArrayList<>(); |
|
184 | 187 |
for (T term : preferredTerms) { |
185 | 188 |
String label = getLabel(term); |
186 | 189 |
if (label == null) { |
... | ... | |
198 | 201 |
|
199 | 202 |
} |
200 | 203 |
|
201 |
combo.add(label); |
|
202 |
terms.add(term); |
|
204 |
labels.add(label); |
|
203 | 205 |
|
204 | 206 |
i++; |
205 | 207 |
if (selection != null) { |
... | ... | |
209 | 211 |
} |
210 | 212 |
} |
211 | 213 |
|
212 |
if (selection != null && index == 0) { |
|
214 |
String[] items = labels.toArray(new String[0]); |
|
215 |
combo.setItems(items); |
|
216 |
|
|
217 |
if (selection != null && index == 0) { |
|
213 | 218 |
createTermNotInPreferredTerms(selection); |
214 | 219 |
} |
215 | 220 |
|
216 | 221 |
combo.select(index); |
222 |
|
|
217 | 223 |
} |
218 | 224 |
|
219 | 225 |
protected List<T> getPreferredTerms(){ |
Also available in: Unified diff
ref #7040 Replace Combo with CCombo which renders faster