Revision f18400be
Added by Katja Luther about 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java | ||
---|---|---|
105 | 105 |
IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener, |
106 | 106 |
ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 { |
107 | 107 |
|
108 |
private Taxon taxon;
|
|
108 |
private Taxon taxon;
|
|
109 | 109 |
|
110 |
private ManagedForm managedForm;
|
|
111 |
private ScrolledForm scrolledForm;
|
|
112 |
private Composite parent;
|
|
113 |
private ISelectionProvider simpleSelectionProvider;
|
|
110 |
private ManagedForm managedForm;
|
|
111 |
private ScrolledForm scrolledForm;
|
|
112 |
private Composite parent;
|
|
113 |
private ISelectionProvider simpleSelectionProvider;
|
|
114 | 114 |
|
115 |
private TaxonBase selection;
|
|
115 |
private TaxonBase selection;
|
|
116 | 116 |
|
117 |
private ConversationHolder conversation;
|
|
117 |
private ConversationHolder conversation;
|
|
118 | 118 |
|
119 |
private AcceptedGroupE4 acceptedGroup;
|
|
120 |
private List<HomotypicalSynonymGroupE4> heterotypicSynonymGroups = new ArrayList<>();
|
|
121 |
private MisappliedGroupE4 misappliedGroup;
|
|
119 |
private AcceptedGroupE4 acceptedGroup;
|
|
120 |
private List<HomotypicalSynonymGroupE4> heterotypicSynonymGroups = new ArrayList<>();
|
|
121 |
private MisappliedGroupE4 misappliedGroup;
|
|
122 | 122 |
|
123 |
private DropTarget target;
|
|
123 |
private DropTarget target;
|
|
124 | 124 |
|
125 |
@Inject
|
|
126 |
UISynchronize sync;
|
|
125 |
@Inject
|
|
126 |
UISynchronize sync;
|
|
127 | 127 |
|
128 |
private TaxonBase objectAffectedByLastOperation;
|
|
128 |
private TaxonBase objectAffectedByLastOperation;
|
|
129 | 129 |
|
130 |
@Inject
|
|
131 |
private EMenuService menuService;
|
|
130 |
@Inject
|
|
131 |
private EMenuService menuService;
|
|
132 | 132 |
|
133 |
@Inject
|
|
134 |
private ESelectionService selService;
|
|
133 |
@Inject
|
|
134 |
private ESelectionService selService;
|
|
135 | 135 |
|
136 |
@Inject
|
|
137 |
private IEclipseContext context;
|
|
136 |
@Inject
|
|
137 |
private IEclipseContext context;
|
|
138 | 138 |
|
139 |
@Inject
|
|
140 |
private MDirtyable dirty;
|
|
139 |
@Inject
|
|
140 |
private MDirtyable dirty;
|
|
141 | 141 |
|
142 |
private MPart thisPart;
|
|
142 |
private MPart thisPart;
|
|
143 | 143 |
|
144 | 144 |
private TaxonEditorInputE4 input; |
145 | 145 |
|
... | ... | |
148 | 148 |
@Inject |
149 | 149 |
private IEventBroker eventBroker; |
150 | 150 |
|
151 |
@Inject |
|
152 |
public TaxonNameEditorE4() { |
|
153 |
undoContext = new UndoContext(); |
|
154 |
} |
|
155 |
|
|
151 |
@Inject |
|
152 |
public TaxonNameEditorE4() { |
|
153 |
undoContext = new UndoContext(); |
|
154 |
} |
|
156 | 155 |
|
157 |
@PostConstruct
|
|
156 |
@PostConstruct
|
|
158 | 157 |
public void createPartControl(Composite parent, MPart thisPart) { |
159 |
this.thisPart = thisPart;
|
|
158 |
this.thisPart = thisPart;
|
|
160 | 159 |
|
161 | 160 |
createManagedForm(parent); |
162 | 161 |
|
163 |
TaxeditorPartService.getInstance().addListener( |
|
164 |
TaxeditorPartService.PART_ACTIVATED, this); |
|
162 |
TaxeditorPartService.getInstance().addListener(TaxeditorPartService.PART_ACTIVATED, this); |
|
165 | 163 |
|
166 |
}
|
|
164 |
}
|
|
167 | 165 |
|
168 |
protected void createManagedForm(Composite composite) {
|
|
166 |
protected void createManagedForm(Composite composite) {
|
|
169 | 167 |
|
170 |
managedForm = new ManagedForm(composite) {
|
|
168 |
managedForm = new ManagedForm(composite) {
|
|
171 | 169 |
|
172 |
@Override
|
|
173 |
public void dirtyStateChanged() {
|
|
174 |
dirty.setDirty(true);
|
|
175 |
}
|
|
170 |
@Override
|
|
171 |
public void dirtyStateChanged() {
|
|
172 |
dirty.setDirty(true);
|
|
173 |
}
|
|
176 | 174 |
|
177 |
@Override |
|
178 |
public boolean setInput(Object input) { |
|
179 |
if (input instanceof AbstractGroupedContainerE4) { |
|
180 |
TaxonBase newSelection = ((AbstractGroupedContainerE4) input).getData(); |
|
181 |
if(selection!=newSelection || TaxonNameEditorE4.this.isDirty()){ |
|
182 |
selection = newSelection; |
|
183 |
selService.setSelection(new StructuredSelection(selection)); |
|
184 |
} |
|
185 |
}else if(input == null){ |
|
186 |
selection = null; |
|
175 |
@Override |
|
176 |
public boolean setInput(Object input) { |
|
177 |
if (input instanceof AbstractGroupedContainerE4) { |
|
178 |
TaxonBase newSelection = ((AbstractGroupedContainerE4) input).getData(); |
|
179 |
if (selection != newSelection || TaxonNameEditorE4.this.isDirty()) { |
|
180 |
selection = newSelection; |
|
181 |
selService.setSelection(new StructuredSelection(selection)); |
|
182 |
|
|
183 |
} |
|
184 |
} else if (input == null) { |
|
185 |
selection = null; |
|
187 | 186 |
selService.setSelection(new StructuredSelection()); |
188 |
}
|
|
187 |
}
|
|
189 | 188 |
|
189 |
return super.setInput(input); |
|
190 |
} |
|
191 |
}; |
|
190 | 192 |
|
191 |
return super.setInput(input); |
|
192 |
} |
|
193 |
}; |
|
194 |
|
|
195 |
scrolledForm = managedForm.getForm(); |
|
196 |
parent = scrolledForm.getBody(); |
|
197 |
|
|
198 |
parent.setData(taxon); |
|
193 |
scrolledForm = managedForm.getForm(); |
|
194 |
parent = scrolledForm.getBody(); |
|
199 | 195 |
|
200 |
TableWrapLayout layout = new TableWrapLayout(); |
|
201 |
layout.leftMargin = 0; |
|
202 |
layout.rightMargin = 0; |
|
203 |
layout.topMargin = 0; |
|
204 |
layout.bottomMargin = 0; |
|
196 |
parent.setData(taxon); |
|
205 | 197 |
|
206 |
layout.verticalSpacing = 0; |
|
207 |
layout.horizontalSpacing = 0; |
|
198 |
TableWrapLayout layout = new TableWrapLayout(); |
|
199 |
layout.leftMargin = 0; |
|
200 |
layout.rightMargin = 0; |
|
201 |
layout.topMargin = 0; |
|
202 |
layout.bottomMargin = 0; |
|
208 | 203 |
|
209 |
parent.setLayout(layout); |
|
210 |
parent.setBackground(AbstractUtility |
|
211 |
.getColor(Resources.COLOR_COMPOSITE_BACKGROUND)); |
|
212 |
} |
|
204 |
layout.verticalSpacing = 0; |
|
205 |
layout.horizontalSpacing = 0; |
|
213 | 206 |
|
214 |
public void createOrUpdateNameComposites(boolean accepted, boolean heterotypicGroups, boolean misappliedNames) { |
|
207 |
parent.setLayout(layout); |
|
208 |
parent.setBackground(AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND)); |
|
209 |
} |
|
215 | 210 |
|
211 |
public void createOrUpdateNameComposites(boolean accepted, boolean heterotypicGroups, boolean misappliedNames) { |
|
216 | 212 |
|
217 |
if (accepted){
|
|
213 |
if (accepted) {
|
|
218 | 214 |
ContainerFactoryE4.createOrUpdateAcceptedTaxonsHomotypicGroup(this); |
219 | 215 |
} |
220 |
if (heterotypicGroups){ |
|
216 |
if (heterotypicGroups) {
|
|
221 | 217 |
ContainerFactoryE4.createOrUpdateHeterotypicSynonymyGroups(this); |
222 | 218 |
} |
223 |
if (misappliedNames){ |
|
219 |
if (misappliedNames) {
|
|
224 | 220 |
ContainerFactoryE4.createOrUpdateMisapplicationsGroup(this); |
225 | 221 |
} |
226 | 222 |
ContainerFactoryE4.setMenuToAllContainers(this); |
227 | 223 |
|
224 |
// Redraw composite |
|
225 |
parent.pack(); |
|
226 |
managedForm.refresh(); |
|
227 |
managedForm.reflow(true); |
|
228 | 228 |
|
229 |
} |
|
229 | 230 |
|
230 |
// Redraw composite |
|
231 |
parent.pack(); |
|
232 |
managedForm.refresh(); |
|
233 |
managedForm.reflow(true); |
|
234 |
|
|
235 |
|
|
236 |
} |
|
237 |
|
|
238 |
@Override |
|
231 |
@Override |
|
239 | 232 |
public Taxon getTaxon() { |
240 |
return HibernateProxyHelper.deproxy(taxon);
|
|
241 |
}
|
|
233 |
return HibernateProxyHelper.deproxy(taxon);
|
|
234 |
}
|
|
242 | 235 |
|
243 |
public void setDirty() {
|
|
244 |
managedForm.dirtyStateChanged();
|
|
245 |
}
|
|
236 |
public void setDirty() {
|
|
237 |
managedForm.dirtyStateChanged();
|
|
238 |
}
|
|
246 | 239 |
|
247 |
@Focus |
|
248 |
public void setFocus() { |
|
249 |
//make sure to bind again if maybe in another view the conversation was unbound |
|
250 |
if(conversation!=null && !conversation.isBound()){ |
|
240 |
@Focus |
|
241 |
public void setFocus() { |
|
242 |
// make sure to bind again if maybe in another view the conversation was |
|
243 |
// unbound |
|
244 |
if (conversation != null && !conversation.isBound()) { |
|
251 | 245 |
conversation.bind(); |
252 | 246 |
} |
253 | 247 |
|
254 |
if(input!=null){ |
|
255 |
if (getSelectedContainer() == null) { |
|
256 |
throw new IllegalStateException( |
|
257 |
Messages.TaxonNameEditor_THERE_SHOULD_ALWAYS_BE); |
|
258 |
} |
|
259 |
getSelectedContainer().setSelected(); |
|
260 |
if (!input.getCdmEntitySession().isActive()){ |
|
261 |
input.bind(); |
|
262 |
} |
|
263 |
|
|
264 |
// check permissions |
|
265 |
boolean doEnable = permissionsSatisfied(); |
|
266 |
managedForm.getForm().setEnabled(doEnable); |
|
267 |
} |
|
248 |
if (input != null) { |
|
249 |
if (getSelectedContainer() == null) { |
|
250 |
throw new IllegalStateException(Messages.TaxonNameEditor_THERE_SHOULD_ALWAYS_BE); |
|
251 |
} |
|
252 |
getSelectedContainer().setSelected(); |
|
253 |
if (!input.getCdmEntitySession().isActive()) { |
|
254 |
input.bind(); |
|
255 |
} |
|
256 |
|
|
257 |
// check permissions |
|
258 |
boolean doEnable = permissionsSatisfied(); |
|
259 |
managedForm.getForm().setEnabled(doEnable); |
|
260 |
} |
|
268 | 261 |
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, this); |
269 |
}
|
|
262 |
}
|
|
270 | 263 |
|
271 |
@Override |
|
272 |
public boolean permissionsSatisfied() { |
|
273 |
TaxonNode taxonNode = input.getTaxonNode(); |
|
274 |
boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), RequiredPermissions.TAXON_EDIT); |
|
275 |
return doEnable; |
|
276 |
} |
|
264 |
@Override |
|
265 |
public boolean permissionsSatisfied() { |
|
266 |
TaxonNode taxonNode = input.getTaxonNode(); |
|
267 |
boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), |
|
268 |
RequiredPermissions.TAXON_EDIT); |
|
269 |
return doEnable; |
|
270 |
} |
|
277 | 271 |
|
278 |
@Override
|
|
272 |
@Override
|
|
279 | 273 |
public ConversationHolder getConversationHolder() { |
280 |
return conversation;
|
|
281 |
}
|
|
274 |
return conversation;
|
|
275 |
}
|
|
282 | 276 |
|
283 |
/** {@inheritDoc} */
|
|
284 |
@Override
|
|
277 |
/** {@inheritDoc} */
|
|
278 |
@Override
|
|
285 | 279 |
public void update(CdmDataChangeMap events) { |
286 |
// redraw();
|
|
287 |
}
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Redraws this editor return true on success
|
|
291 |
*
|
|
292 |
* @return a boolean.
|
|
293 |
*/
|
|
280 |
// redraw();
|
|
281 |
}
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Redraws this editor return true on success
|
|
285 |
*
|
|
286 |
* @return a boolean.
|
|
287 |
*/
|
|
294 | 288 |
public boolean redraw() { |
295 |
return redraw(true, true, true, true);
|
|
296 |
}
|
|
297 |
|
|
298 |
/**
|
|
299 |
* {@inheritDoc}
|
|
300 |
*
|
|
301 |
* Redraws the editor controls
|
|
302 |
*/
|
|
289 |
return redraw(true, true, true, true);
|
|
290 |
}
|
|
291 |
|
|
292 |
/**
|
|
293 |
* {@inheritDoc}
|
|
294 |
*
|
|
295 |
* Redraws the editor controls
|
|
296 |
*/
|
|
303 | 297 |
public boolean redraw(boolean focus, boolean accepted, boolean heterotypic, boolean misappliedNames) { |
304 | 298 |
|
305 |
createOrUpdateNameComposites(accepted, heterotypic, misappliedNames);
|
|
299 |
createOrUpdateNameComposites(accepted, heterotypic, misappliedNames);
|
|
306 | 300 |
|
307 |
if (focus) {
|
|
308 |
setFocus();
|
|
309 |
}
|
|
301 |
if (focus) {
|
|
302 |
setFocus();
|
|
303 |
}
|
|
310 | 304 |
|
311 |
return true;
|
|
312 |
}
|
|
305 |
return true;
|
|
306 |
}
|
|
313 | 307 |
|
314 |
@Override
|
|
308 |
@Override
|
|
315 | 309 |
public boolean postOperation(Object objectAffectedByOperation) { |
310 |
if (objectAffectedByOperation instanceof TaxonBase) { |
|
311 |
objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation; |
|
312 |
} |
|
313 |
onComplete(); |
|
314 |
redraw(true, true, true, true); |
|
315 |
changed(objectAffectedByOperation); |
|
316 |
|
|
317 |
|
|
318 |
return true; |
|
319 |
} |
|
320 |
|
|
321 |
public ManagedForm getManagedForm() { |
|
322 |
return managedForm; |
|
323 |
} |
|
324 |
|
|
325 |
/** |
|
326 |
* <p> |
|
327 |
* checkForEmptyNames |
|
328 |
* </p> |
|
329 |
* |
|
330 |
* @return true if there are empty names |
|
331 |
*/ |
|
332 |
public boolean checkForEmptyNames() { |
|
333 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
|
334 |
if (container != null |
|
335 |
&& (container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache()))) { |
|
336 |
return true; |
|
337 |
} |
|
338 |
} |
|
339 |
return false; |
|
340 |
} |
|
341 |
|
|
342 |
public Set<AbstractGroupedContainerE4> getEmptyContainers() { |
|
343 |
Set<AbstractGroupedContainerE4> containersWithEmptyNames = new HashSet<>(); |
|
344 |
|
|
345 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
|
346 |
if (container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())) { |
|
347 |
containersWithEmptyNames.add(container); |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
return containersWithEmptyNames; |
|
352 |
} |
|
316 | 353 |
|
317 |
changed(objectAffectedByOperation); |
|
318 |
|
|
319 |
redraw(true, true,true, true); |
|
320 |
|
|
321 |
if (objectAffectedByOperation instanceof TaxonBase) { |
|
322 |
objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation; |
|
323 |
} |
|
324 |
|
|
325 |
return true; |
|
326 |
} |
|
327 |
|
|
328 |
public ManagedForm getManagedForm() { |
|
329 |
return managedForm; |
|
330 |
} |
|
331 |
|
|
332 |
|
|
333 |
/** |
|
334 |
* <p> |
|
335 |
* checkForEmptyNames |
|
336 |
* </p> |
|
337 |
* |
|
338 |
* @return true if there are empty names |
|
339 |
*/ |
|
340 |
public boolean checkForEmptyNames() { |
|
341 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
|
342 |
if (container != null && (container.getName() == null |
|
343 |
|| StringUtils.isEmpty(container.getName().getTitleCache()))) { |
|
344 |
return true; |
|
345 |
} |
|
346 |
} |
|
347 |
return false; |
|
348 |
} |
|
349 |
|
|
350 |
public Set<AbstractGroupedContainerE4> getEmptyContainers() { |
|
351 |
Set<AbstractGroupedContainerE4> containersWithEmptyNames = new HashSet<>(); |
|
352 |
|
|
353 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
|
354 |
if (container.getName() == null |
|
355 |
|| StringUtils.isEmpty(container.getName().getTitleCache())) { |
|
356 |
containersWithEmptyNames.add(container); |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
return containersWithEmptyNames; |
|
361 |
} |
|
362 |
|
|
363 |
/** {@inheritDoc} */ |
|
364 |
@Override |
|
354 |
/** {@inheritDoc} */ |
|
355 |
@Override |
|
365 | 356 |
@Persist |
366 |
public void save(IProgressMonitor monitor) { |
|
367 |
|
|
368 |
monitor.beginTask(Messages.TaxonNameEditor_SAVING_NAMES, getGroupedContainers().size()); |
|
369 |
if (!conversation.isBound()) { |
|
370 |
conversation.bind(); |
|
371 |
|
|
372 |
} |
|
373 |
conversation.commit(true); |
|
374 |
monitor.worked(1); |
|
375 |
|
|
376 |
// check for empty names |
|
377 |
if (checkForEmptyNames()) { |
|
378 |
MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED, |
|
379 |
Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE); |
|
380 |
return; |
|
381 |
} |
|
382 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
|
383 |
|
|
384 |
monitor.subTask(Messages.TaxonNameEditor_SAVING_COMPOSITES |
|
385 |
+ container.getTaxonBase().getTitleCache()); |
|
386 |
container.persistName(); |
|
387 |
//because of missing cascading the concepts need to be saved separately |
|
388 |
if (container instanceof ConceptContainerE4){ |
|
389 |
input.addToSaveNewConcept((Taxon)container.getData()); |
|
390 |
} |
|
391 |
// In case the progress monitor was canceled throw an exception. |
|
392 |
if (monitor.isCanceled()) { |
|
393 |
throw new OperationCanceledException(); |
|
394 |
} |
|
395 |
|
|
396 |
// Otherwise declare this step as done. |
|
397 |
monitor.worked(1); |
|
398 |
|
|
399 |
} |
|
400 |
input.setSync(sync); |
|
401 |
input.merge(); |
|
402 |
// commit the conversation and start a new transaction immediately |
|
357 |
public void save(IProgressMonitor monitor) { |
|
358 |
|
|
359 |
monitor.beginTask(Messages.TaxonNameEditor_SAVING_NAMES, getGroupedContainers().size()); |
|
360 |
if (!conversation.isBound()) { |
|
361 |
conversation.bind(); |
|
362 |
|
|
363 |
} |
|
403 | 364 |
conversation.commit(true); |
365 |
monitor.worked(1); |
|
366 |
|
|
367 |
// check for empty names |
|
368 |
if (checkForEmptyNames()) { |
|
369 |
MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED, |
|
370 |
Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE); |
|
371 |
return; |
|
372 |
} |
|
373 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
|
374 |
|
|
375 |
monitor.subTask(Messages.TaxonNameEditor_SAVING_COMPOSITES + container.getTaxonBase().getTitleCache()); |
|
376 |
container.persistName(); |
|
377 |
// because of missing cascading the concepts need to be saved |
|
378 |
// separately |
|
379 |
if (container instanceof ConceptContainerE4) { |
|
380 |
input.addToSaveNewConcept((Taxon) container.getData()); |
|
381 |
} |
|
382 |
// In case the progress monitor was canceled throw an exception. |
|
383 |
if (monitor.isCanceled()) { |
|
384 |
throw new OperationCanceledException(); |
|
385 |
} |
|
404 | 386 |
|
387 |
// Otherwise declare this step as done. |
|
388 |
monitor.worked(1); |
|
389 |
|
|
390 |
} |
|
391 |
input.setSync(sync); |
|
392 |
input.merge(); |
|
393 |
// commit the conversation and start a new transaction immediately |
|
394 |
conversation.commit(true); |
|
405 | 395 |
|
406 | 396 |
dirty.setDirty(false); |
407 | 397 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true); |
408 | 398 |
EventUtility.postEvent(WorkbenchEventConstants.SAVE_TAXON, true); |
409 |
// Stop the progress monitor.
|
|
410 |
monitor.done();
|
|
411 |
}
|
|
412 |
|
|
413 |
public void init(TaxonEditorInputE4 input) {
|
|
414 |
if (this.input != null){
|
|
415 |
this.input.dispose();
|
|
416 |
// this.acceptedGroup = null;
|
|
417 |
// this.heterotypicSynonymGroups.clear();
|
|
418 |
// this.misappliedGroup = null;
|
|
419 |
}
|
|
420 |
if (!(input != null)) {
|
|
399 |
// Stop the progress monitor.
|
|
400 |
monitor.done();
|
|
401 |
}
|
|
402 |
|
|
403 |
public void init(TaxonEditorInputE4 input) {
|
|
404 |
if (this.input != null) {
|
|
405 |
this.input.dispose();
|
|
406 |
// this.acceptedGroup = null;
|
|
407 |
// this.heterotypicSynonymGroups.clear();
|
|
408 |
// this.misappliedGroup = null;
|
|
409 |
}
|
|
410 |
if (!(input != null)) {
|
|
421 | 411 |
MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT)); |
422 | 412 |
return; |
423 | 413 |
} |
424 | 414 |
|
425 |
if (input.getAdapter(Taxon.class) != null) {
|
|
426 |
taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
|
|
427 |
} else {
|
|
428 |
MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT_TAXON_NULL));
|
|
429 |
return;
|
|
430 |
}
|
|
415 |
if (input.getAdapter(Taxon.class) != null) {
|
|
416 |
taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
|
|
417 |
} else {
|
|
418 |
MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT_TAXON_NULL));
|
|
419 |
return;
|
|
420 |
}
|
|
431 | 421 |
|
432 |
this.input = input;
|
|
433 |
conversation = input.getConversationHolder();
|
|
422 |
this.input = input;
|
|
423 |
conversation = input.getConversationHolder();
|
|
434 | 424 |
|
435 | 425 |
createOrUpdateNameComposites(true, true, true); |
436 | 426 |
|
... | ... | |
438 | 428 |
|
439 | 429 |
setPartName(); |
440 | 430 |
|
441 |
//set initial selection |
|
431 |
// set initial selection
|
|
442 | 432 |
TaxonBase initiallySelectedTaxonBase = input.getInitiallySelectedTaxonBase(); |
443 |
if(initiallySelectedTaxonBase!=null){
|
|
433 |
if (initiallySelectedTaxonBase != null) {
|
|
444 | 434 |
selService.setSelection(new StructuredSelection(initiallySelectedTaxonBase)); |
445 | 435 |
getContainer(initiallySelectedTaxonBase).setSelected(); |
446 | 436 |
} |
447 |
} |
|
448 |
|
|
449 |
private void createDragSupport() { |
|
450 |
// Listen for names being dragged outside of existing homotypic groups - |
|
451 |
// user wants to create a new group |
|
452 |
Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() }; |
|
453 |
int operations = DND.DROP_MOVE; |
|
454 |
if (target == null) { |
|
455 |
target = new DropTarget(parent, operations); |
|
456 |
target.setTransfer(types); |
|
457 |
target.addDropListener(new NameEditorDropTargetListenerE4(this)); |
|
458 |
} |
|
459 |
} |
|
460 |
|
|
461 |
public AcceptedNameContainerE4 getAcceptedNameContainer() { |
|
462 |
return getAcceptedGroup().getAcceptedNameContainer(); |
|
463 |
} |
|
464 |
|
|
465 |
public HomotypicalSynonymGroupE4 getHomotypicalGroupContainer( |
|
466 |
HomotypicalGroup homotypicalGroup) { |
|
467 |
for (HomotypicalSynonymGroupE4 group : getHeterotypicSynonymGroups()) { |
|
468 |
if (group.getGroup().equals(homotypicalGroup)) { |
|
469 |
return group; |
|
470 |
} |
|
471 |
} |
|
472 |
|
|
473 |
return null; |
|
474 |
} |
|
475 |
|
|
476 |
/** |
|
477 |
* <p> |
|
478 |
* getDirtyNames |
|
479 |
* </p> |
|
480 |
* |
|
481 |
* @return a Set containing all composites that have been edited |
|
482 |
*/ |
|
483 |
public Set<AbstractGroupedContainerE4> getDirtyNames() { |
|
484 |
Set<AbstractGroupedContainerE4> dirtyNames = new HashSet<>(); |
|
485 |
|
|
486 |
for (AbstractGroupedContainerE4 composite : getGroupedContainers()) { |
|
487 |
if (composite.isDirty()) { |
|
488 |
dirtyNames.add(composite); |
|
489 |
} |
|
490 |
} |
|
491 |
|
|
492 |
return dirtyNames; |
|
493 |
} |
|
494 |
|
|
495 |
public List<AbstractGroupedContainerE4> getGroupedContainers() { |
|
496 |
List<AbstractGroupedContainerE4> groupedComposites = new ArrayList<>(); |
|
497 |
|
|
498 |
for (AbstractGroupE4 group : getAllGroups()) { |
|
499 |
if (group!= null){ |
|
500 |
groupedComposites.addAll(group.getGroupedContainers()); |
|
501 |
} |
|
502 |
} |
|
503 |
|
|
504 |
return groupedComposites; |
|
505 |
} |
|
506 |
|
|
507 |
public List<AbstractGroupE4> getAllGroups() { |
|
508 |
List<AbstractGroupE4> allGroups = new ArrayList<>(); |
|
509 |
|
|
510 |
allGroups.add(getAcceptedGroup()); |
|
511 |
|
|
512 |
heterotypicSynonymGroups = getHeterotypicSynonymGroups(); |
|
513 |
|
|
514 |
if (heterotypicSynonymGroups != null) { |
|
515 |
allGroups.addAll(heterotypicSynonymGroups); |
|
516 |
} |
|
517 |
|
|
518 |
if (misappliedGroup != null) { |
|
519 |
allGroups.add(misappliedGroup); |
|
520 |
} |
|
521 |
|
|
522 |
return allGroups; |
|
523 |
} |
|
524 |
|
|
525 |
@Override |
|
526 |
public IEclipseContext getContext() { |
|
527 |
return context; |
|
528 |
} |
|
529 |
|
|
530 |
@Override |
|
437 |
} |
|
438 |
|
|
439 |
private void createDragSupport() { |
|
440 |
// Listen for names being dragged outside of existing homotypic groups - |
|
441 |
// user wants to create a new group |
|
442 |
Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() }; |
|
443 |
int operations = DND.DROP_MOVE; |
|
444 |
if (target == null) { |
|
445 |
target = new DropTarget(parent, operations); |
|
446 |
target.setTransfer(types); |
|
447 |
target.addDropListener(new NameEditorDropTargetListenerE4(this)); |
|
448 |
} |
|
449 |
} |
|
450 |
|
|
451 |
public AcceptedNameContainerE4 getAcceptedNameContainer() { |
|
452 |
return getAcceptedGroup().getAcceptedNameContainer(); |
|
453 |
} |
|
454 |
|
|
455 |
public HomotypicalSynonymGroupE4 getHomotypicalGroupContainer(HomotypicalGroup homotypicalGroup) { |
|
456 |
for (HomotypicalSynonymGroupE4 group : getHeterotypicSynonymGroups()) { |
|
457 |
if (group.getGroup().equals(homotypicalGroup)) { |
|
458 |
return group; |
|
459 |
} |
|
460 |
} |
|
461 |
|
|
462 |
return null; |
|
463 |
} |
|
464 |
|
|
465 |
/** |
|
466 |
* <p> |
|
467 |
* getDirtyNames |
|
468 |
* </p> |
|
469 |
* |
|
470 |
* @return a Set containing all composites that have been edited |
|
471 |
*/ |
|
472 |
public Set<AbstractGroupedContainerE4> getDirtyNames() { |
|
473 |
Set<AbstractGroupedContainerE4> dirtyNames = new HashSet<>(); |
|
474 |
|
|
475 |
for (AbstractGroupedContainerE4 composite : getGroupedContainers()) { |
|
476 |
if (composite.isDirty()) { |
|
477 |
dirtyNames.add(composite); |
|
478 |
} |
|
479 |
} |
|
480 |
|
|
481 |
return dirtyNames; |
|
482 |
} |
|
483 |
|
|
484 |
public List<AbstractGroupedContainerE4> getGroupedContainers() { |
|
485 |
List<AbstractGroupedContainerE4> groupedComposites = new ArrayList<>(); |
|
486 |
|
|
487 |
for (AbstractGroupE4 group : getAllGroups()) { |
|
488 |
if (group != null) { |
|
489 |
groupedComposites.addAll(group.getGroupedContainers()); |
|
490 |
} |
|
491 |
} |
|
492 |
|
|
493 |
return groupedComposites; |
|
494 |
} |
|
495 |
|
|
496 |
public List<AbstractGroupE4> getAllGroups() { |
|
497 |
List<AbstractGroupE4> allGroups = new ArrayList<>(); |
|
498 |
|
|
499 |
allGroups.add(getAcceptedGroup()); |
|
500 |
|
|
501 |
heterotypicSynonymGroups = getHeterotypicSynonymGroups(); |
|
502 |
|
|
503 |
if (heterotypicSynonymGroups != null) { |
|
504 |
allGroups.addAll(heterotypicSynonymGroups); |
|
505 |
} |
|
506 |
|
|
507 |
if (misappliedGroup != null) { |
|
508 |
allGroups.add(misappliedGroup); |
|
509 |
} |
|
510 |
|
|
511 |
return allGroups; |
|
512 |
} |
|
513 |
|
|
514 |
@Override |
|
515 |
public IEclipseContext getContext() { |
|
516 |
return context; |
|
517 |
} |
|
518 |
|
|
519 |
@Override |
|
531 | 520 |
public boolean isDirty() { |
532 |
return dirty.isDirty();
|
|
533 |
}
|
|
521 |
return dirty.isDirty();
|
|
522 |
}
|
|
534 | 523 |
|
535 |
@PreDestroy
|
|
536 |
public void dispose() {
|
|
537 |
if(conversation!=null){
|
|
524 |
@PreDestroy
|
|
525 |
public void dispose() {
|
|
526 |
if (conversation != null) {
|
|
538 | 527 |
conversation.unregisterForDataStoreChanges(this); |
539 | 528 |
conversation.close(); |
540 | 529 |
} |
541 |
if(input!=null){
|
|
530 |
if (input != null) {
|
|
542 | 531 |
input.dispose(); |
543 | 532 |
} |
544 | 533 |
dirty.setDirty(false); |
545 | 534 |
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, null); |
546 |
}
|
|
535 |
}
|
|
547 | 536 |
|
548 |
/** {@inheritDoc} */
|
|
549 |
@Override
|
|
537 |
/** {@inheritDoc} */
|
|
538 |
@Override
|
|
550 | 539 |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
551 |
System.err.println("Bla");
|
|
552 |
}
|
|
540 |
System.err.println("Bla");
|
|
541 |
}
|
|
553 | 542 |
|
554 |
public AbstractGroupedContainerE4 getSelectedContainer() { |
|
555 |
return (selection != null) ? getContainer(selection) |
|
556 |
: getAcceptedNameContainer(); |
|
557 |
} |
|
543 |
public AbstractGroupedContainerE4 getSelectedContainer() { |
|
544 |
return (selection != null) ? getContainer(selection) : getAcceptedNameContainer(); |
|
545 |
} |
|
558 | 546 |
|
559 | 547 |
@Override |
560 | 548 |
public void dragEntered() { |
561 | 549 |
// TODO change this |
562 |
getControl().setBackground( |
|
563 |
AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER)); |
|
550 |
getControl().setBackground(AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER)); |
|
564 | 551 |
} |
565 | 552 |
|
566 | 553 |
@Override |
567 | 554 |
public void dragLeft() { |
568 |
getControl().setBackground( |
|
569 |
AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND)); |
|
555 |
getControl().setBackground(AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND)); |
|
570 | 556 |
} |
571 | 557 |
|
558 |
public void setMisapplicationsGroup(MisappliedGroupE4 misappliedGroup) { |
|
559 |
this.misappliedGroup = misappliedGroup; |
|
560 |
} |
|
572 | 561 |
|
573 |
public void setMisapplicationsGroup(MisappliedGroupE4 misappliedGroup) { |
|
574 |
this.misappliedGroup = misappliedGroup; |
|
575 |
} |
|
576 |
|
|
577 |
public FormToolkit getToolkit() { |
|
578 |
return managedForm.getToolkit(); |
|
579 |
} |
|
562 |
public FormToolkit getToolkit() { |
|
563 |
return managedForm.getToolkit(); |
|
564 |
} |
|
580 | 565 |
|
581 |
public List<HomotypicalSynonymGroupE4> getHeterotypicSynonymGroups() {
|
|
582 |
return heterotypicSynonymGroups;
|
|
583 |
}
|
|
566 |
public List<HomotypicalSynonymGroupE4> getHeterotypicSynonymGroups() {
|
|
567 |
return heterotypicSynonymGroups;
|
|
568 |
}
|
|
584 | 569 |
|
585 |
public void addHeterotypicSynonymGroup(HomotypicalSynonymGroupE4 group) {
|
|
586 |
heterotypicSynonymGroups.add(group);
|
|
587 |
}
|
|
570 |
public void addHeterotypicSynonymGroup(HomotypicalSynonymGroupE4 group) {
|
|
571 |
heterotypicSynonymGroups.add(group);
|
|
572 |
}
|
|
588 | 573 |
|
589 |
public AcceptedGroupE4 getAcceptedGroup() {
|
|
590 |
return acceptedGroup;
|
|
591 |
}
|
|
574 |
public AcceptedGroupE4 getAcceptedGroup() {
|
|
575 |
return acceptedGroup;
|
|
576 |
}
|
|
592 | 577 |
|
593 |
public void setAcceptedGroup(AcceptedGroupE4 acceptedGroup) {
|
|
594 |
this.acceptedGroup = acceptedGroup;
|
|
595 |
}
|
|
578 |
public void setAcceptedGroup(AcceptedGroupE4 acceptedGroup) {
|
|
579 |
this.acceptedGroup = acceptedGroup;
|
|
580 |
}
|
|
596 | 581 |
|
597 |
public MisappliedGroupE4 getMisappliedGroup() {
|
|
598 |
return misappliedGroup;
|
|
599 |
}
|
|
582 |
public MisappliedGroupE4 getMisappliedGroup() {
|
|
583 |
return misappliedGroup;
|
|
584 |
}
|
|
600 | 585 |
|
601 |
public boolean isActive() {
|
|
602 |
return this.equals(AbstractUtility.getActivePart());
|
|
603 |
}
|
|
586 |
public boolean isActive() {
|
|
587 |
return this.equals(AbstractUtility.getActivePart());
|
|
588 |
}
|
|
604 | 589 |
|
605 | 590 |
@Override |
606 | 591 |
public boolean onComplete() { |
607 |
getContainer(objectAffectedByLastOperation).setSelected();
|
|
608 |
return true;
|
|
609 |
}
|
|
592 |
getContainer(objectAffectedByLastOperation).setSelected();
|
|
593 |
return true;
|
|
594 |
}
|
|
610 | 595 |
|
611 |
/** {@inheritDoc} */
|
|
612 |
@Override
|
|
596 |
/** {@inheritDoc} */
|
|
597 |
@Override
|
|
613 | 598 |
public void partChanged(Integer eventType, IWorkbenchPartReference partRef) { |
614 |
if (!partRef.getPart(false).equals(this)) {
|
|
615 |
// getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
|
|
616 |
}
|
|
617 |
}
|
|
618 |
|
|
619 |
public void removeGroup(AbstractGroupE4 group) {
|
|
620 |
if (group != null) {
|
|
621 |
group.dispose();
|
|
622 |
|
|
623 |
//if (heterotypicSynonymGroups != null) {
|
|
624 |
heterotypicSynonymGroups.remove(group);
|
|
625 |
//}
|
|
626 |
}
|
|
627 |
}
|
|
628 |
|
|
629 |
public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
|
|
630 |
@SuppressWarnings("rawtypes")
|
|
599 |
if (!partRef.getPart(false).equals(this)) {
|
|
600 |
// getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
|
|
601 |
}
|
|
602 |
}
|
|
603 |
|
|
604 |
public void removeGroup(AbstractGroupE4 group) {
|
|
605 |
if (group != null) {
|
|
606 |
group.dispose();
|
|
607 |
|
|
608 |
// if (heterotypicSynonymGroups != null) {
|
|
609 |
heterotypicSynonymGroups.remove(group);
|
|
610 |
// }
|
|
611 |
}
|
|
612 |
}
|
|
613 |
|
|
614 |
public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
|
|
615 |
@SuppressWarnings("rawtypes")
|
|
631 | 616 |
List<AbstractGroupedContainerE4> groupedContainers = getGroupedContainers(); |
632 |
for (AbstractGroupedContainerE4 container : groupedContainers) { |
|
633 |
if (container.getData().equals(taxonBase) |
|
634 |
&& container.getNameViewer().getTextWidget() != null) { |
|
635 |
return container; |
|
636 |
} |
|
637 |
} |
|
638 |
return getAcceptedNameContainer(); |
|
639 |
} |
|
617 |
for (AbstractGroupedContainerE4 container : groupedContainers) { |
|
618 |
if (container.getData().equals(taxonBase) && container.getNameViewer().getTextWidget() != null) { |
|
619 |
return container; |
|
620 |
} |
|
621 |
} |
|
622 |
return getAcceptedNameContainer(); |
|
623 |
} |
|
640 | 624 |
|
641 | 625 |
public void setOnError() { |
642 |
Color disabledColor = AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
|
|
643 |
setEnabled(false, disabledColor);
|
|
644 |
}
|
|
626 |
Color disabledColor = AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
|
|
627 |
setEnabled(false, disabledColor);
|
|
628 |
}
|
|
645 | 629 |
|
646 |
public void setDisabled(){
|
|
647 |
Color disabledColor = AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
|
|
648 |
setEnabled(false, disabledColor);
|
|
649 |
}
|
|
630 |
public void setDisabled() {
|
|
631 |
Color disabledColor = AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
|
|
632 |
setEnabled(false, disabledColor);
|
|
633 |
}
|
|
650 | 634 |
|
651 |
protected void setEnabled(boolean enabled, Color background) {
|
|
635 |
protected void setEnabled(boolean enabled, Color background) {
|
|
652 | 636 |
|
653 |
for(AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()){
|
|
654 |
groupedContainer.setEnabled(enabled);
|
|
655 |
}
|
|
637 |
for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
|
|
638 |
groupedContainer.setEnabled(enabled);
|
|
639 |
}
|
|
656 | 640 |
|
657 |
// send an empty selection to the current provider - TODO only on error ??? |
|
658 |
if (!enabled) { |
|
659 |
getManagedForm().setInput(null); |
|
641 |
// send an empty selection to the current provider - TODO only on error |
|
642 |
// ??? |
|
643 |
if (!enabled) { |
|
644 |
getManagedForm().setInput(null); |
|
660 | 645 |
|
661 |
for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
|
|
662 |
groupedContainer.setBackground(background);
|
|
663 |
}
|
|
664 |
}
|
|
665 |
getControl().setBackground(background);
|
|
666 |
}
|
|
646 |
for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
|
|
647 |
groupedContainer.setBackground(background);
|
|
648 |
}
|
|
649 |
}
|
|
650 |
getControl().setBackground(background);
|
|
651 |
}
|
|
667 | 652 |
|
668 | 653 |
@Override |
669 | 654 |
public void changed(Object element) { |
670 | 655 |
// setDirty(true); |
671 |
// if the attribute is null then do not set the dirty flag -> hotfix for the problem that for tasks done in service methods the changes are saved automatically |
|
672 |
if (element != null){ |
|
656 |
// if the attribute is null then do not set the dirty flag -> hotfix for |
|
657 |
// the problem that for tasks done in service methods the changes are |
|
658 |
// saved automatically |
|
659 |
if (element != null) { |
|
673 | 660 |
dirty.setDirty(true); |
674 |
//refresh part title |
|
675 |
//TODO: refresh taxon node in taxon navigator |
|
661 |
// refresh part title
|
|
662 |
// TODO: refresh taxon node in taxon navigator
|
|
676 | 663 |
setPartName(); |
677 | 664 |
} |
678 | 665 |
|
... | ... | |
691 | 678 |
} |
692 | 679 |
} |
693 | 680 |
|
694 |
public void setPartName(){ |
|
695 |
//FIXME: temporary fix for #6437 to avoid outdated title caches |
|
681 |
public void setPartName() {
|
|
682 |
// FIXME: temporary fix for #6437 to avoid outdated title caches
|
|
696 | 683 |
thisPart.setLabel(this.taxon.getName().generateFullTitle()); |
697 |
// thisPart.setLabel(this.taxon.getName().getFullTitleCache());
|
|
684 |
// thisPart.setLabel(this.taxon.getName().getFullTitleCache());
|
|
698 | 685 |
} |
699 | 686 |
|
700 | 687 |
@Override |
... | ... | |
702 | 689 |
setDirty(); |
703 | 690 |
} |
704 | 691 |
|
705 |
|
|
706 | 692 |
public IUndoContext getUndoContext() { |
707 | 693 |
return undoContext; |
708 | 694 |
} |
709 | 695 |
|
710 | 696 |
@Override |
711 |
public Composite getControl(){ |
|
697 |
public Composite getControl() {
|
|
712 | 698 |
return managedForm.getForm().getBody(); |
713 | 699 |
} |
714 | 700 |
|
... | ... | |
720 | 706 |
return selService; |
721 | 707 |
} |
722 | 708 |
|
723 |
|
|
724 | 709 |
/** |
725 | 710 |
* {@inheritDoc} |
726 | 711 |
*/ |
... | ... | |
743 | 728 |
|
744 | 729 |
@Inject |
745 | 730 |
@Optional |
746 |
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)CdmBase cdmbase){
|
|
731 |
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) CdmBase cdmbase) {
|
|
747 | 732 |
|
748 |
if ((EventUtility.getTaxonEditor() != null && EventUtility.getTaxonEditor().equals(this)) || (this.taxon != null && (this.taxon.equals(cdmbase) || (this.taxon.getName() != null && this.taxon.getName().equals(cdmbase))))){ |
|
733 |
if ((EventUtility.getTaxonEditor() != null && EventUtility.getTaxonEditor().equals(this)) |
|
734 |
|| (this.taxon != null && (this.taxon.equals(cdmbase) |
|
735 |
|| (this.taxon.getName() != null && this.taxon.getName().equals(cdmbase))))) { |
|
749 | 736 |
this.redraw(false, true, true, true); |
750 | 737 |
this.setDirty(); |
751 |
if (cdmbase instanceof TaxonBase){ |
|
738 |
if (cdmbase instanceof TaxonBase) {
|
|
752 | 739 |
this.selection = (TaxonBase) cdmbase; |
753 | 740 |
} |
754 | 741 |
|
755 |
|
|
756 | 742 |
} |
757 | 743 |
} |
758 | 744 |
|
759 | 745 |
@Inject |
760 | 746 |
@Optional |
761 |
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)UUID cdmbaseUuid){
|
|
747 |
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) UUID cdmbaseUuid) {
|
|
762 | 748 |
|
763 |
if (this.taxon.getUuid().equals(cdmbaseUuid)){ |
|
749 |
if (this.taxon.getUuid().equals(cdmbaseUuid)) {
|
|
764 | 750 |
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(cdmbaseUuid); |
765 | 751 |
init(input); |
766 | 752 |
} |
... | ... | |
768 | 754 |
|
769 | 755 |
@Inject |
770 | 756 |
@Optional |
771 |
private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.DELETE_DERIVATIVE)DeleteResult result){
|
|
772 |
if(taxon.getName()==null){
|
|
757 |
private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.DELETE_DERIVATIVE) DeleteResult result) {
|
|
758 |
if (taxon.getName() == null) {
|
|
773 | 759 |
return; |
774 | 760 |
} |
775 | 761 |
Set<DerivedUnit> typeDesignationSpecimens = new HashSet<>(); |
776 |
this.taxon.getName().getSpecimenTypeDesignations().forEach(designation->typeDesignationSpecimens.add(designation.getTypeSpecimen())); |
|
777 |
//check if any deleted object was a type specimen |
|
778 |
if(result.getUpdatedObjects().stream() |
|
779 |
//filter only DerivedUnits |
|
780 |
.filter(cdmBase->cdmBase.isInstanceOf(DerivedUnit.class)) |
|
781 |
//deproxy from CdmBase to DerivedUnit |
|
782 |
.map(unit->HibernateProxyHelper.deproxy(unit, DerivedUnit.class)) |
|
783 |
//check for match in type designations |
|
784 |
.anyMatch(unit->typeDesignationSpecimens.contains(unit))){ |
|
785 |
EditorUtil.updateEditor(this.input.getTaxonNode(), this); |
|
762 |
this.taxon.getName().getSpecimenTypeDesignations() |
|
763 |
.forEach(designation -> typeDesignationSpecimens.add(designation.getTypeSpecimen())); |
|
764 |
// check if any deleted object was a type specimen |
|
765 |
if (result.getUpdatedObjects().stream() |
|
766 |
// filter only DerivedUnits |
|
767 |
.filter(cdmBase -> cdmBase.isInstanceOf(DerivedUnit.class)) |
|
768 |
// deproxy from CdmBase to DerivedUnit |
|
769 |
.map(unit -> HibernateProxyHelper.deproxy(unit, DerivedUnit.class)) |
|
770 |
// check for match in type designations |
|
771 |
.anyMatch(unit -> typeDesignationSpecimens.contains(unit))) { |
|
772 |
EditorUtil.updateEditor(this.input.getTaxonNode(), this); |
|
786 | 773 |
|
787 | 774 |
} |
788 | 775 |
|
789 |
|
|
790 |
|
|
791 |
|
|
792 | 776 |
} |
793 | 777 |
|
794 | 778 |
} |
Also available in: Unified diff
fix correct focus and selection after changing from synonym to MAN