Revision 04f83f13
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditorHelper.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.editor.view.checklist.e4; |
11 | 11 |
|
12 |
import java.util.Map; |
|
12 | 13 |
import java.util.Set; |
14 |
import java.util.UUID; |
|
13 | 15 |
|
14 | 16 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
15 | 17 |
import org.eclipse.jface.viewers.TableViewer; |
16 | 18 |
import org.eclipse.jface.viewers.TableViewerEditor; |
17 | 19 |
import org.eclipse.jface.viewers.ViewerCell; |
18 |
import org.eclipse.swt.widgets.TableColumn; |
|
19 | 20 |
|
20 | 21 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
21 | 22 |
import eu.etaxonomy.cdm.model.description.Distribution; |
22 | 23 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
23 | 24 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
24 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
25 | 25 |
|
26 | 26 |
/** |
27 | 27 |
* @author k.luther |
... | ... | |
30 | 30 |
*/ |
31 | 31 |
public class DistributionEditorHelper { |
32 | 32 |
|
33 |
public static Distribution getDistributionForColumn(SelectionChangedEvent event) { |
|
33 |
public static Distribution getDistributionForColumn(SelectionChangedEvent event, Map<UUID, Integer> areaPosition) {
|
|
34 | 34 |
// List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, |
35 | 35 |
// null, null, null, DESC_INIT_STRATEGY); |
36 | 36 |
TableViewer viewer = null; |
... | ... | |
57 | 57 |
return null; |
58 | 58 |
} |
59 | 59 |
columnIndex = cell.getColumnIndex(); |
60 |
UUID areaUuid = null; |
|
61 |
for (Map.Entry<UUID,Integer> entry: areaPosition.entrySet()){ |
|
62 |
if (entry.getValue().intValue()== columnIndex){ |
|
63 |
areaUuid = entry.getKey(); |
|
64 |
break; |
|
65 |
} |
|
66 |
} |
|
67 |
if (areaUuid == null){ |
|
68 |
return null; |
|
69 |
} |
|
60 | 70 |
Set<TaxonDescription> listTaxonDescriptions = taxon.getDescriptions(); |
61 |
TableColumn column = viewer.getTable().getColumn(columnIndex); |
|
71 |
|
|
62 | 72 |
for (TaxonDescription td : listTaxonDescriptions) { |
63 | 73 |
for (DescriptionElementBase deb : td.getElements()) { |
64 | 74 |
if (deb instanceof Distribution) { |
65 | 75 |
Distribution distribution = (Distribution) deb; |
66 |
if (distribution.getArea() != null){ |
|
67 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
|
68 |
if (column.getText().equalsIgnoreCase(distribution.getArea().getIdInVocabulary())) { |
|
69 |
return distribution; |
|
70 |
} |
|
71 |
}else{ |
|
72 |
if (column.getText().equalsIgnoreCase(distribution.getArea().getTitleCache())) { |
|
73 |
return distribution; |
|
74 |
} |
|
75 |
} |
|
76 |
if (distribution.getArea().getUuid() == areaUuid){ |
|
77 |
return distribution; |
|
76 | 78 |
} |
77 | 79 |
} |
78 | 80 |
} |
Also available in: Unified diff
ref #7063:fix that the last selection always appears in next field in distribution editor