1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.reference;
|
12
|
|
13
|
|
14
|
import java.util.ArrayList;
|
15
|
import java.util.Arrays;
|
16
|
import java.util.List;
|
17
|
|
18
|
import org.eclipse.jface.wizard.WizardPage;
|
19
|
import org.eclipse.swt.SWT;
|
20
|
import org.eclipse.swt.widgets.Display;
|
21
|
import org.eclipse.swt.widgets.Label;
|
22
|
import org.eclipse.swt.graphics.Color;
|
23
|
import org.eclipse.swt.graphics.FontData;
|
24
|
|
25
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
26
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
27
|
import eu.etaxonomy.cdm.model.agent.Institution;
|
28
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
29
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
30
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
31
|
import eu.etaxonomy.cdm.model.reference.ReferenceType;
|
32
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
33
|
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
|
34
|
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
|
35
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
36
|
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
|
37
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
38
|
import eu.etaxonomy.taxeditor.ui.element.IErrorIntolerableElement;
|
39
|
import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler;
|
40
|
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
|
41
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
42
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
43
|
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
|
44
|
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
|
45
|
import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
|
46
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
47
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
48
|
|
49
|
/**
|
50
|
* <p>
|
51
|
* ReferenceBaseDetailElement class.
|
52
|
* </p>
|
53
|
*
|
54
|
* @author n.hoffmann
|
55
|
* @created Mar 2, 2010
|
56
|
* @version 1.0
|
57
|
*/
|
58
|
public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElement<Reference>
|
59
|
implements IErrorIntolerableElement, IExceptionHandler {
|
60
|
|
61
|
private LabelElement warnForReferencedObjects;
|
62
|
|
63
|
private ToggleableTextElement toggleableAbbrevCache;
|
64
|
|
65
|
private TextWithLabelElement text_edition;
|
66
|
private TextWithLabelElement text_editor;
|
67
|
private TextWithLabelElement text_isbn;
|
68
|
private TextWithLabelElement text_issn;
|
69
|
private TextWithLabelElement text_organisation;
|
70
|
private TextWithLabelElement text_pages;
|
71
|
private TextWithLabelElement text_placePublished;
|
72
|
private TextWithLabelElement text_publisher;
|
73
|
private TextWithLabelElement text_referenceAbstract;
|
74
|
private TextWithLabelElement text_series;
|
75
|
// private TextWithLabelElement text_seriesPart;
|
76
|
private TextWithLabelElement text_volume;
|
77
|
private TextWithLabelElement text_abbrevTitle;
|
78
|
private TextWithLabelElement text_title;
|
79
|
private UriWithLabelElement text_uri;
|
80
|
private EntitySelectionElement<AgentBase> selection_authorTeam;
|
81
|
private TimePeriodElement element_timePeriod;
|
82
|
private EntitySelectionElement<Reference> selection_inReference;
|
83
|
private EntitySelectionElement<Institution> selection_institution;
|
84
|
private EnumComboElement<ReferenceType> combo_referenceType;
|
85
|
|
86
|
private EntitySelectionElement<Reference> selection_inSeries;
|
87
|
|
88
|
/**
|
89
|
* <p>
|
90
|
* Constructor for ReferenceBaseDetailElement.
|
91
|
* </p>
|
92
|
*
|
93
|
* @param cdmFormFactory
|
94
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
95
|
* object.
|
96
|
* @param formElement
|
97
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
98
|
* object.
|
99
|
* @param style
|
100
|
* a int.
|
101
|
*/
|
102
|
public ReferenceDetailElement(CdmFormFactory cdmFormFactory,
|
103
|
ICdmFormElement formElement, int style) {
|
104
|
super(cdmFormFactory, formElement);
|
105
|
}
|
106
|
|
107
|
/*
|
108
|
* (non-Javadoc)
|
109
|
*
|
110
|
* @see
|
111
|
* eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractCdmDetailComposite
|
112
|
* #createControl(org.eclipse.swt.widgets.Composite, int)
|
113
|
*/
|
114
|
/** {@inheritDoc} */
|
115
|
@Override
|
116
|
protected void createControls(ICdmFormElement formElement,
|
117
|
Reference entity, int style) {
|
118
|
ICdmFormElement o = this.getParentElement();
|
119
|
Class clazz=o.getClass();
|
120
|
setWarnForReferencingObjects(formElement);
|
121
|
|
122
|
|
123
|
toggleable_cache = formFactory.createToggleableTextField(formElement,
|
124
|
"Reference Cache", entity.getTitleCache(),
|
125
|
entity.isProtectedTitleCache(), style);
|
126
|
|
127
|
toggleableAbbrevCache = formFactory.createToggleableTextField(formElement,
|
128
|
"Abbrev. Cache", entity.getAbbrevTitleCache(),
|
129
|
entity.isProtectedAbbrevTitleCache(), style);
|
130
|
|
131
|
combo_referenceType = formFactory.createEnumComboElement(ReferenceType.class,
|
132
|
formElement, style);
|
133
|
|
134
|
combo_referenceType.setSelection(entity.getType());
|
135
|
|
136
|
// title
|
137
|
text_title = formFactory.createTextWithLabelElement(formElement,
|
138
|
"Title", entity.getTitle(), style);
|
139
|
// abbreviated title
|
140
|
text_abbrevTitle = formFactory.createTextWithLabelElement(formElement,
|
141
|
"Nomenclatural Title", entity.getAbbrevTitle(), style);
|
142
|
|
143
|
// author team
|
144
|
selection_authorTeam = formFactory
|
145
|
.createSelectionElement(AgentBase.class,
|
146
|
getConversationHolder(), formElement, "Author",
|
147
|
entity.getAuthorship(),
|
148
|
EntitySelectionElement.ALL, style);
|
149
|
|
150
|
ReferenceType referenceType = entity.getType();
|
151
|
|
152
|
if (referenceType != null) {
|
153
|
|
154
|
createInReferenceByType(this, referenceType, entity, SWT.NULL);
|
155
|
|
156
|
if (referenceType.equals(ReferenceType.Generic)) {
|
157
|
createGenericControls(this, entity, SWT.NULL);
|
158
|
createPublicationControls(this, referenceType, entity, SWT.NULL);
|
159
|
} else {
|
160
|
if (referenceType.isPrintedUnit()) {
|
161
|
createPrintedUnitControls(this, referenceType, entity,
|
162
|
SWT.NULL);
|
163
|
}
|
164
|
if (referenceType.isPublication()) {
|
165
|
createPublicationControls(this, referenceType, entity,
|
166
|
SWT.NULL);
|
167
|
}
|
168
|
if (referenceType.isVolumeReference()) {
|
169
|
createVolumeControls(this, entity, SWT.NULL);
|
170
|
}
|
171
|
if (referenceType.isSection()) {
|
172
|
createSectionControls(this, entity, SWT.NULL);
|
173
|
}
|
174
|
}
|
175
|
}
|
176
|
|
177
|
// date published
|
178
|
element_timePeriod = formFactory.createTimePeriodElement(formElement,
|
179
|
"Date Published", entity.getDatePublished(), style);
|
180
|
|
181
|
createUriAndAbstract(this, entity, SWT.NULL);
|
182
|
handleToggleableAbbrevTitleField();
|
183
|
handleToggleableCacheField();
|
184
|
}
|
185
|
|
186
|
/*
|
187
|
* (non-Javadoc)
|
188
|
*
|
189
|
* @see
|
190
|
* eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractCdmDetailComposite
|
191
|
* #updateContent()
|
192
|
*/
|
193
|
/** {@inheritDoc} */
|
194
|
@Override
|
195
|
protected void updateContent() {
|
196
|
if (getEntity() == null) {
|
197
|
setEntity(ReferenceFactory.newGeneric());
|
198
|
}
|
199
|
|
200
|
super.updateContent();
|
201
|
|
202
|
// enable elements according to state of cache protection
|
203
|
// setEnabled(getEntity().isProtectedTitleCache(), Arrays.asList(new
|
204
|
// Object[]{text_cache}));
|
205
|
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
|
206
|
toggleableAbbrevCache.setEnabled(getEntity().isProtectedAbbrevTitleCache());
|
207
|
setIrrelevantReferenceDetail(false);
|
208
|
setIrrelevantReferenceDetail(true);
|
209
|
}
|
210
|
|
211
|
/**
|
212
|
* Creates an in reference for reference types that do hav this.
|
213
|
*
|
214
|
* @param element
|
215
|
* @param referenceType
|
216
|
* @param reference
|
217
|
* @param style
|
218
|
*/
|
219
|
private void createInReferenceByType(ICdmFormElement element,
|
220
|
ReferenceType referenceType, Reference reference, int style) {
|
221
|
boolean createInReferenceWidget = true;
|
222
|
String label = "In Reference";
|
223
|
|
224
|
switch (referenceType) {
|
225
|
case Generic:
|
226
|
break;
|
227
|
case Section:
|
228
|
break;
|
229
|
case BookSection:
|
230
|
label = "Book";
|
231
|
break;
|
232
|
case InProceedings:
|
233
|
label = "Print Series";
|
234
|
break;
|
235
|
case Article:
|
236
|
label = "Journal";
|
237
|
break;
|
238
|
case WebPage:
|
239
|
break;
|
240
|
default:
|
241
|
createInReferenceWidget = false;
|
242
|
}
|
243
|
|
244
|
if (createInReferenceWidget) {
|
245
|
selection_inReference = formFactory
|
246
|
.createSelectionElement(Reference.class,
|
247
|
getConversationHolder(), element, label,
|
248
|
reference.getInReference(),
|
249
|
EntitySelectionElement.ALL, style);
|
250
|
}
|
251
|
}
|
252
|
|
253
|
/**
|
254
|
* Creates additional controls to edit a generic reference
|
255
|
*
|
256
|
* @param element
|
257
|
* @param reference
|
258
|
* @param listener
|
259
|
* @param style
|
260
|
*/
|
261
|
private void createGenericControls(ICdmFormElement element,
|
262
|
Reference reference, int style) {
|
263
|
|
264
|
// editor
|
265
|
text_editor = formFactory.createTextWithLabelElement(element, "Editor",
|
266
|
reference.getEditor(), style);
|
267
|
|
268
|
// series
|
269
|
text_series = formFactory.createTextWithLabelElement(element, "Series",
|
270
|
reference.getSeriesPart(), style);
|
271
|
|
272
|
// volume
|
273
|
text_volume = formFactory.createTextWithLabelElement(element, "Volume",
|
274
|
reference.getVolume(), style);
|
275
|
|
276
|
// pages
|
277
|
text_pages = formFactory.createTextWithLabelElement(element, "Pages",
|
278
|
reference.getPages(), style);
|
279
|
}
|
280
|
|
281
|
/**
|
282
|
* Creates additional controls to edit a publication
|
283
|
*
|
284
|
* @param element
|
285
|
* @param reference
|
286
|
* @param listener
|
287
|
* @param style
|
288
|
*/
|
289
|
private void createPublicationControls(ICdmFormElement element,
|
290
|
ReferenceType referenceType, Reference reference, int style) {
|
291
|
|
292
|
// placePublished
|
293
|
text_placePublished = formFactory.createTextWithLabelElement(element,
|
294
|
"Place Published", reference.getPlacePublished(), style);
|
295
|
|
296
|
// publisher
|
297
|
text_publisher = formFactory.createTextWithLabelElement(element,
|
298
|
"Publisher", reference.getPublisher(), style);
|
299
|
|
300
|
if (referenceType.equals(ReferenceType.Journal)) {
|
301
|
// issn
|
302
|
text_issn = formFactory.createTextWithLabelElement(element, "ISSN",
|
303
|
reference.getIssn(), style);
|
304
|
}
|
305
|
|
306
|
if (referenceType.equals(ReferenceType.Report)) {
|
307
|
// institution
|
308
|
selection_institution = formFactory
|
309
|
.createSelectionElement(Institution.class,
|
310
|
getConversationHolder(), element, "Institution",
|
311
|
reference.getInstitution(),
|
312
|
EntitySelectionElement.ALL, style);
|
313
|
}
|
314
|
|
315
|
if (referenceType.equals(ReferenceType.Thesis)) {
|
316
|
// school
|
317
|
selection_institution = formFactory
|
318
|
.createSelectionElement(Institution.class,
|
319
|
getConversationHolder(), element, "School",
|
320
|
reference.getSchool(),
|
321
|
EntitySelectionElement.ALL, style);
|
322
|
}
|
323
|
|
324
|
if (referenceType.equals(ReferenceType.Proceedings)) {
|
325
|
// organization
|
326
|
text_organisation = formFactory.createTextWithLabelElement(element,
|
327
|
"Organisation", reference.getOrganization(), style);
|
328
|
}
|
329
|
}
|
330
|
|
331
|
/**
|
332
|
* Creates additional controls to edit a section
|
333
|
*
|
334
|
* @param element
|
335
|
* @param reference
|
336
|
* @param style
|
337
|
*/
|
338
|
private void createSectionControls(ICdmFormElement element,
|
339
|
Reference reference, int style) {
|
340
|
// pages
|
341
|
text_pages = formFactory.createTextWithLabelElement(element, "Pages",
|
342
|
reference.getPages(), style);
|
343
|
}
|
344
|
|
345
|
/**
|
346
|
* Creates additional controls to edit a volume
|
347
|
*
|
348
|
* @param element
|
349
|
* @param reference
|
350
|
* @param style
|
351
|
*/
|
352
|
private void createVolumeControls(ICdmFormElement element,
|
353
|
Reference reference, int style) {
|
354
|
|
355
|
text_volume = formFactory.createTextWithLabelElement(element, "Volume",
|
356
|
reference.getVolume(), style);
|
357
|
|
358
|
text_series = formFactory.createTextWithLabelElement(element, "Series",
|
359
|
reference.getSeriesPart(), style);
|
360
|
}
|
361
|
|
362
|
/**
|
363
|
*
|
364
|
* @param element
|
365
|
* @param referenceType
|
366
|
* @param reference
|
367
|
* @param style
|
368
|
*/
|
369
|
private void createPrintedUnitControls(ICdmFormElement element,
|
370
|
ReferenceType referenceType, Reference reference, int style) {
|
371
|
// in series
|
372
|
selection_inSeries = formFactory
|
373
|
.createSelectionElement(Reference.class,
|
374
|
getConversationHolder(), element, "In Series",
|
375
|
(Reference) reference.getInSeries(),
|
376
|
EntitySelectionElement.ALL, style);
|
377
|
|
378
|
// editor
|
379
|
text_editor = formFactory.createTextWithLabelElement(element, "Editor",
|
380
|
reference.getEditor(), style);
|
381
|
|
382
|
/* series part
|
383
|
text_seriesPart = formFactory.createTextWithLabelElement(element,
|
384
|
"Series", reference.getSeriesPart(), style);
|
385
|
*/
|
386
|
if (referenceType.equals(ReferenceType.Book)) {
|
387
|
// edition
|
388
|
text_edition = formFactory.createTextWithLabelElement(element,
|
389
|
"Edition", reference.getEdition(), style);
|
390
|
|
391
|
// isbn
|
392
|
text_isbn = formFactory.createTextWithLabelElement(element, "ISBN",
|
393
|
reference.getIsbn(), style);
|
394
|
}
|
395
|
}
|
396
|
|
397
|
private void createUriAndAbstract(ICdmFormElement element,
|
398
|
Reference reference, int style) {
|
399
|
// uri
|
400
|
text_uri = formFactory.createUriWithLabelElement(element, "URI",
|
401
|
reference.getUri(), style);
|
402
|
// abstract
|
403
|
text_referenceAbstract = formFactory.createMultiLineTextWithLabel(
|
404
|
element, "Reference Abstract", 100, style);
|
405
|
text_referenceAbstract.setText(reference.getReferenceAbstract());
|
406
|
}
|
407
|
|
408
|
/** {@inheritDoc} */
|
409
|
@Override
|
410
|
public void handleEvent(Object eventSource) {
|
411
|
if (eventSource == combo_referenceType) {
|
412
|
getEntity().setType(combo_referenceType.getSelection());
|
413
|
updateContent();
|
414
|
} else if (eventSource == element_timePeriod) {
|
415
|
getEntity().setDatePublished(element_timePeriod.getTimePeriod());
|
416
|
clearException();
|
417
|
}
|
418
|
// selections
|
419
|
else if (eventSource == selection_authorTeam) {
|
420
|
getEntity().setAuthorship(
|
421
|
(TeamOrPersonBase) selection_authorTeam.getSelection());
|
422
|
} else if (eventSource == selection_inReference) {
|
423
|
getEntity().setInReference(selection_inReference.getSelection());
|
424
|
} else if (eventSource == selection_inSeries) {
|
425
|
getEntity().setInReference(selection_inSeries.getSelection());
|
426
|
} else if (eventSource == selection_institution) {
|
427
|
getEntity().setInstitution(selection_institution.getSelection());
|
428
|
}
|
429
|
|
430
|
// textfields
|
431
|
else if (eventSource == toggleable_cache) {
|
432
|
handleToggleableCacheField();
|
433
|
}
|
434
|
else if (eventSource == toggleableAbbrevCache) {
|
435
|
handleToggleableAbbrevTitleField();
|
436
|
} else if (eventSource == text_edition) {
|
437
|
getEntity().setEdition(text_edition.getText());
|
438
|
} else if (eventSource == text_editor) {
|
439
|
getEntity().setEditor(text_editor.getText());
|
440
|
} else if (eventSource == text_isbn) {
|
441
|
getEntity().setIsbn(text_isbn.getText());
|
442
|
} else if (eventSource == text_issn) {
|
443
|
getEntity().setIssn(text_issn.getText());
|
444
|
} else if (eventSource == text_organisation) {
|
445
|
getEntity().setOrganization(text_organisation.getText());
|
446
|
} else if (eventSource == text_pages) {
|
447
|
getEntity().setPages(text_pages.getText());
|
448
|
} else if (eventSource == text_placePublished) {
|
449
|
getEntity().setPlacePublished(text_placePublished.getText());
|
450
|
} else if (eventSource == text_publisher) {
|
451
|
getEntity().setPublisher(text_publisher.getText());
|
452
|
} else if (eventSource == text_referenceAbstract) {
|
453
|
getEntity().setReferenceAbstract(text_referenceAbstract.getText());
|
454
|
} else if (eventSource == text_series) {
|
455
|
getEntity().setSeriesPart(text_series.getText());
|
456
|
} else if (eventSource == text_title ) {
|
457
|
getEntity().setTitle(text_title.getText());
|
458
|
if (!toggleable_cache.isEnabled()){
|
459
|
toggleable_cache.setText(getEntity().generateTitle());
|
460
|
}
|
461
|
} else if (eventSource == text_abbrevTitle ) {
|
462
|
getEntity().setAbbrevTitle(text_abbrevTitle.getText());
|
463
|
if (!toggleableAbbrevCache.isEnabled()){
|
464
|
toggleableAbbrevCache.setText(getEntity().generateAbbrevTitle());
|
465
|
}
|
466
|
} else if (eventSource == text_uri) {
|
467
|
getEntity().setUri(text_uri.parseText());
|
468
|
} else if (eventSource == text_volume) {
|
469
|
getEntity().setVolume(text_volume.getText());
|
470
|
}
|
471
|
|
472
|
if (eventSource != text_title && eventSource != text_abbrevTitle) {
|
473
|
// set abbrev title cache to null to force new generation
|
474
|
// for the standard title cache this is done by a PropertyChangeListener registered
|
475
|
// in IdentifiableEntity.initListeners()
|
476
|
if(!getEntity().isProtectedAbbrevTitleCache()){
|
477
|
getEntity().setAbbrevTitleCache(null, getEntity().isProtectedAbbrevTitleCache());
|
478
|
}
|
479
|
toggleable_cache.setText(getEntity().getTitleCache());
|
480
|
toggleableAbbrevCache.setText(getEntity().getAbbrevTitleCache());
|
481
|
}
|
482
|
|
483
|
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
|
484
|
}
|
485
|
|
486
|
|
487
|
@Override
|
488
|
public void updateToggleableCacheField() {
|
489
|
if (!getEntity().isProtectedTitleCache()) {
|
490
|
toggleable_cache.setText(getEntity().generateTitle());
|
491
|
}
|
492
|
if (!getEntity().isProtectedAbbrevTitleCache()) {
|
493
|
toggleableAbbrevCache.setText(getEntity().generateAbbrevTitle());
|
494
|
}
|
495
|
}
|
496
|
|
497
|
protected void handleToggleableAbbrevTitleField() {
|
498
|
boolean pushedAbbrevState = toggleableAbbrevCache.getState();
|
499
|
getEntity().setAbbrevTitleCache(toggleableAbbrevCache.getText(), pushedAbbrevState);
|
500
|
setIrrelevantReferenceDetail(true);
|
501
|
updateToggleableCacheField();
|
502
|
}
|
503
|
|
504
|
/*
|
505
|
* (non-Javadoc)
|
506
|
*
|
507
|
* @see
|
508
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleException
|
509
|
* (eu.etaxonomy.taxeditor.forms.CdmPropertyChangeEvent)
|
510
|
*/
|
511
|
/** {@inheritDoc} */
|
512
|
@Override
|
513
|
public void handleException(CdmPropertyChangeEvent event) {
|
514
|
exceptionOccurred(event);
|
515
|
}
|
516
|
|
517
|
/*
|
518
|
* (non-Javadoc)
|
519
|
*
|
520
|
* @see eu.etaxonomy.taxeditor.forms.IExceptionHandler#clearException()
|
521
|
*/
|
522
|
/** {@inheritDoc} */
|
523
|
@Override
|
524
|
public void clearException() {
|
525
|
exceptionOccurred(null);
|
526
|
}
|
527
|
|
528
|
private final List<IExceptionHandler> exceptionHandlers = new ArrayList<IExceptionHandler>();
|
529
|
|
530
|
/*
|
531
|
* (non-Javadoc)
|
532
|
*
|
533
|
* @see
|
534
|
* eu.etaxonomy.taxeditor.forms.IErrorIntolerableElement#addExceptionHandler
|
535
|
* (eu.etaxonomy.taxeditor.forms.IExceptionHandler)
|
536
|
*/
|
537
|
/** {@inheritDoc} */
|
538
|
@Override
|
539
|
public void addExceptionHandler(IExceptionHandler handler) {
|
540
|
exceptionHandlers.add(handler);
|
541
|
}
|
542
|
|
543
|
/*
|
544
|
* (non-Javadoc)
|
545
|
*
|
546
|
* @see
|
547
|
* eu.etaxonomy.taxeditor.forms.IErrorIntolerableElement#removeExceptionHandler
|
548
|
* (eu.etaxonomy.taxeditor.forms.IExceptionHandler)
|
549
|
*/
|
550
|
/** {@inheritDoc} */
|
551
|
@Override
|
552
|
public void removeExceptionHandler(IExceptionHandler handler) {
|
553
|
exceptionHandlers.remove(handler);
|
554
|
}
|
555
|
|
556
|
/*
|
557
|
* (non-Javadoc)
|
558
|
*
|
559
|
* @see
|
560
|
* eu.etaxonomy.taxeditor.forms.IErrorIntolerableElement#exceptionOccurred
|
561
|
* (eu.etaxonomy.taxeditor.forms.CdmPropertyChangeEvent)
|
562
|
*/
|
563
|
/** {@inheritDoc} */
|
564
|
@Override
|
565
|
public void exceptionOccurred(CdmPropertyChangeEvent event) {
|
566
|
for (IExceptionHandler handler : exceptionHandlers) {
|
567
|
if (event == null) {
|
568
|
handler.clearException();
|
569
|
} else {
|
570
|
handler.handleException(event);
|
571
|
}
|
572
|
}
|
573
|
}
|
574
|
|
575
|
@Override
|
576
|
protected void handleToggleableCacheField() {
|
577
|
|
578
|
boolean pushedState = toggleable_cache.getState();
|
579
|
getEntity().setTitleCache(toggleable_cache.getText(), pushedState);
|
580
|
setIrrelevantReferenceDetail(false);
|
581
|
updateToggleableCacheField();
|
582
|
}
|
583
|
|
584
|
protected void setIrrelevantReferenceDetail(boolean abbrev){
|
585
|
|
586
|
List<Object> except = new ArrayList();
|
587
|
except.addAll( Arrays.asList(new Object[] { toggleable_cache, toggleableAbbrevCache, text_editor, text_isbn, text_issn, text_organisation, text_pages, text_placePublished, text_publisher, text_referenceAbstract, text_uri, selection_institution}));
|
588
|
boolean pushedState;
|
589
|
if (abbrev){
|
590
|
except.add(text_title);
|
591
|
pushedState = toggleableAbbrevCache.getState();
|
592
|
} else{
|
593
|
except.add(text_abbrevTitle);
|
594
|
pushedState = toggleable_cache.getState();
|
595
|
}
|
596
|
switch( getEntity().getType()){
|
597
|
case Journal:
|
598
|
except.add(element_timePeriod);
|
599
|
break;
|
600
|
case Book:
|
601
|
except.remove(text_series);
|
602
|
except.remove(text_edition);
|
603
|
break;
|
604
|
default:
|
605
|
break;
|
606
|
}
|
607
|
setIrrelevant(pushedState, except);
|
608
|
}
|
609
|
|
610
|
public void setWarnForReferencingObjects(ICdmFormElement formElement){
|
611
|
Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(getEntity());
|
612
|
if (referencingObjectsCount > 1){
|
613
|
if (warnForReferencedObjects == null){
|
614
|
warnForReferencedObjects = formFactory.createLabel(formElement, CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"));
|
615
|
warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
|
616
|
warnForReferencedObjects.setLayout(LayoutConstants.FILL(2, 2));
|
617
|
warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor(
|
618
|
SWT.COLOR_RED));
|
619
|
|
620
|
}else{
|
621
|
warnForReferencedObjects.setText(CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"));
|
622
|
}
|
623
|
warnForReferencedObjects.setVisible(false);
|
624
|
}
|
625
|
}
|
626
|
|
627
|
public void setWarnForReferencingObjectsVisible(boolean isVisible){
|
628
|
if (warnForReferencedObjects != null){
|
629
|
warnForReferencedObjects.setVisible(isVisible);
|
630
|
}
|
631
|
}
|
632
|
|
633
|
|
634
|
}
|