Revision 04f83f13
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditingSupportE4.java | ||
---|---|---|
32 | 32 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
33 | 33 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
34 | 34 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
35 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
|
36 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
|
35 | 37 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
36 | 38 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
37 | 39 |
|
38 | 40 |
public final class DistributionEditingSupportE4 extends EditingSupport { |
39 | 41 |
|
40 | 42 |
private ComboBoxViewerCellEditor cellEditor = null; |
41 |
private final TableViewer viewer; |
|
43 |
//private final TableViewer viewer;
|
|
42 | 44 |
private final ChecklistEditorE4 editor; |
43 | 45 |
// private final IDescriptionService descriptionService; |
44 | 46 |
private final int columnIndex; |
... | ... | |
51 | 53 |
|
52 | 54 |
public DistributionEditingSupportE4(TableViewer viewer, ChecklistEditorE4 checklistEditor, int columnIndex) { |
53 | 55 |
super(viewer); |
54 |
this.viewer = viewer; |
|
56 |
// this.viewer = viewer;
|
|
55 | 57 |
this.columnIndex = columnIndex; |
56 | 58 |
|
57 | 59 |
// descriptionService = CdmStore.getService(IDescriptionService.class); |
58 | 60 |
editor = checklistEditor; |
59 |
cellEditor = new ComboBoxViewerCellEditor((Composite) viewer.getControl(), SWT.READ_ONLY);
|
|
61 |
cellEditor = new DistributionStatusComboBoxViewerCellEditor((Composite) this.getViewer().getControl(), SWT.READ_ONLY);
|
|
60 | 62 |
cellEditor.setLabelProvider(new LabelProvider(){ |
61 | 63 |
@Override |
62 | 64 |
public String getText(Object element) { |
... | ... | |
91 | 93 |
inputAll.addAll(1, input); |
92 | 94 |
cellEditor.setInput(inputAll); |
93 | 95 |
|
96 |
|
|
94 | 97 |
} |
95 | 98 |
|
96 | 99 |
@Override |
... | ... | |
112 | 115 |
|
113 | 116 |
if (distributionForColumn != null) { |
114 | 117 |
PresenceAbsenceTerm status = distributionForColumn.getStatus(); |
118 |
|
|
115 | 119 |
if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){ |
116 | 120 |
if (status.getIdInVocabulary() != null){ |
117 | 121 |
result = status.getIdInVocabulary(); |
... | ... | |
126 | 130 |
} |
127 | 131 |
} |
128 | 132 |
|
129 |
fireStateChanged(distributionForColumn); |
|
133 |
//fireStateChanged(distributionForColumn);
|
|
130 | 134 |
return result; |
131 | 135 |
} |
132 | 136 |
return null; |
... | ... | |
142 | 146 |
@Override |
143 | 147 |
protected void setValue(Object element, Object value) { |
144 | 148 |
if (element instanceof Taxon && value instanceof PresenceAbsenceTerm) { |
149 |
|
|
145 | 150 |
Taxon taxon = (Taxon) element; |
146 | 151 |
PresenceAbsenceTerm occurenceStatus = (PresenceAbsenceTerm) value; |
147 | 152 |
Distribution distribution = getDistributionForColumn(taxon); |
... | ... | |
163 | 168 |
// viewer.update(element, null); |
164 | 169 |
// viewer.refresh(); |
165 | 170 |
// editor.setDirty(true); |
171 |
|
|
166 | 172 |
editor.changed(element); |
167 |
viewer.refresh(); |
|
173 |
getViewer().refresh(); |
|
174 |
|
|
175 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_TAXON_DETAILS, true); |
|
168 | 176 |
} |
169 | 177 |
} |
170 | 178 |
|
... | ... | |
180 | 188 |
// List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, |
181 | 189 |
// null, null, null, DESC_INIT_STRATEGY); |
182 | 190 |
Set<TaxonDescription> listTaxonDescriptions = taxon.getDescriptions(); |
183 |
TableColumn column = viewer.getTable().getColumn(columnIndex);
|
|
191 |
TableColumn column = ((TableViewer)getViewer()).getTable().getColumn(columnIndex);
|
|
184 | 192 |
for (TaxonDescription td : listTaxonDescriptions) { |
185 | 193 |
for (DescriptionElementBase deb : td.getElements()) { |
186 | 194 |
if (deb instanceof Distribution) { |
... | ... | |
203 | 211 |
} |
204 | 212 |
|
205 | 213 |
private void createDistributionForColumn(Taxon taxon, PresenceAbsenceTerm occurenceStatus) { |
206 |
TableColumn column = viewer.getTable().getColumn(columnIndex);
|
|
214 |
TableColumn column = ((TableViewer)this.getViewer()).getTable().getColumn(columnIndex);
|
|
207 | 215 |
|
208 | 216 |
SortedSet<DefinedTermBase> namedAreas = this.editor.getLabelProvider().getNamedAreas(false); |
209 | 217 |
|
Also available in: Unified diff
ref #7063:fix that the last selection always appears in next field in distribution editor