Revision 4561dd9c
Added by Alexander Oppermann over 9 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistLabelProvider.java | ||
---|---|---|
20 | 20 |
import org.eclipse.jface.preference.IPreferenceStore; |
21 | 21 |
import org.eclipse.jface.viewers.ITableLabelProvider; |
22 | 22 |
import org.eclipse.jface.viewers.LabelProvider; |
23 |
import org.eclipse.jface.viewers.TableViewer; |
|
23 | 24 |
import org.eclipse.swt.graphics.Image; |
25 |
import org.eclipse.swt.widgets.TableColumn; |
|
24 | 26 |
|
25 | 27 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
26 | 28 |
import eu.etaxonomy.cdm.api.service.ITermService; |
... | ... | |
49 | 51 |
public static final String DEFAULT_ENTRY = ""; |
50 | 52 |
private IDescriptionService descriptionService; |
51 | 53 |
private final List<DefinedTermBase<?>> namedAreas; |
52 |
|
|
53 |
|
|
54 |
TableViewer viewer = null; |
|
54 | 55 |
|
55 | 56 |
/** |
56 | 57 |
* |
... | ... | |
59 | 60 |
namedAreas = loadNamedAreas(); |
60 | 61 |
} |
61 | 62 |
|
63 |
public ChecklistLabelProvider(TableViewer viewer) { |
|
64 |
namedAreas = loadNamedAreas(); |
|
65 |
this.viewer = viewer; |
|
66 |
} |
|
67 |
|
|
62 | 68 |
/* |
63 | 69 |
* (non-Javadoc) |
64 | 70 |
* |
... | ... | |
81 | 87 |
* .Object, int) |
82 | 88 |
*/ |
83 | 89 |
/** {@inheritDoc} */ |
84 |
@Override
|
|
90 |
@Override
|
|
85 | 91 |
public String getColumnText(Object element, int columnIndex) { |
86 | 92 |
descriptionService = CdmStore.getService(IDescriptionService.class); |
87 | 93 |
Taxon taxon = (Taxon) element; |
88 | 94 |
//TODO load areas by this list |
89 |
SortedSet<DefinedTermBase<?>> sortedNamedAreas = (SortedSet<DefinedTermBase<?>>) getTermsOrderedByLabels(namedAreas, CdmStore.getDefaultLanguage()); |
|
90 | 95 |
|
91 | 96 |
List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);; |
92 | 97 |
NonViralName<?> nonVirlaName = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class); |
... | ... | |
124 | 129 |
if (deb instanceof Distribution) { |
125 | 130 |
Distribution distribution = (Distribution) deb; |
126 | 131 |
String area = distribution.toString(); |
127 |
if(sortedNamedAreas != null){ |
|
128 |
Object[] array = sortedNamedAreas.toArray(); |
|
129 |
DefinedTermBase<DefinedTermBase> term = (DefinedTermBase<DefinedTermBase>) array[columnIndex-4]; |
|
130 |
if(term != null){ |
|
131 |
if (area.equalsIgnoreCase(term.getTitleCache())) { |
|
132 |
return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY; |
|
133 |
} |
|
134 |
} |
|
132 |
if(viewer != null){ |
|
133 |
TableColumn column = viewer.getTable().getColumn(columnIndex); |
|
134 |
if (area.equalsIgnoreCase(column.getText())) { |
|
135 |
return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY; |
|
136 |
} |
|
135 | 137 |
} |
136 | 138 |
} |
137 | 139 |
} |
Also available in: Unified diff
Added a reload function so that the checklist editor doesn't need to be relaunched after adding terms.