Project

General

Profile

Download (23.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.taxeditor.ui.section.classification;
10

    
11
import java.util.ArrayList;
12
import java.util.Collection;
13
import java.util.HashMap;
14
import java.util.Map;
15

    
16
import org.apache.commons.lang3.StringUtils;
17
import org.eclipse.jface.resource.JFaceResources;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.graphics.Font;
20
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Label;
22
import org.eclipse.swt.widgets.Text;
23

    
24
import eu.etaxonomy.cdm.common.CdmUtils;
25
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
26
import eu.etaxonomy.cdm.model.common.Language;
27
import eu.etaxonomy.cdm.model.common.LanguageString;
28
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
29
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
30
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
31
import eu.etaxonomy.cdm.model.metadata.PublishEnum;
32
import eu.etaxonomy.cdm.model.name.TaxonName;
33
import eu.etaxonomy.cdm.model.reference.Reference;
34
import eu.etaxonomy.cdm.model.taxon.Classification;
35
import eu.etaxonomy.cdm.model.taxon.Taxon;
36
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
37
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
38
import eu.etaxonomy.taxeditor.l10n.Messages;
39
import eu.etaxonomy.taxeditor.model.AbstractUtility;
40
import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
41
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
42
import eu.etaxonomy.taxeditor.preference.Resources;
43
import eu.etaxonomy.taxeditor.store.CdmStore;
44
import eu.etaxonomy.taxeditor.store.StoreUtil;
45
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
46
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
47
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
48
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
49
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
50
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
51
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
52
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
53
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
54
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractSingleSourceElement;
55
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
56
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
57

    
58
/**
59
 * @author n.hoffmann
60
 * @created Sep 27, 2010
61
 */
62
public class TaxonNodeDetailElement extends AbstractSingleSourceElement<TaxonNode> {
63

    
64
    private static final String STATUS_NOTES = Messages.TaxonNodeWizardPage_STATUS_NOTES;
65
    private static final String CLASSIFICATION_STR = Messages.TaxonNodeWizardPage_CLASSIFICATION;
66
    private static final String REUSE_EXISTING_TAXON = Messages.TaxonNodeWizardPage_REUSE_EXISTING_TAXON;
67
    private static final String REUSE_EXISTING_NAME = Messages.TaxonNodeWizardPage_REUSE_EXISTING_NAME;
68
    private static final String SECUNDUM_REFERENCE = Messages.TaxonNodeWizardPage_SECUNDUM_REFERENCE;
69

    
70
    private static final Font FONT_BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
71

    
72
    private boolean createNew = false;
73
	private Classification classification;
74
	private TaxonNode parentNode;
75
	private Taxon taxon;
76
    private boolean complete;
77
    private TaxonNodeStatus status = null;
78
    private Map<Language, LanguageString> multilanguageTextCache;
79

    
80
	private TaxonNodeSelectionElement selection_parentTaxonNode;
81
	private EntitySelectionElement<Taxon> selection_reuseExistingTaxon;
82
	private EntitySelectionElement<TaxonName> selection_reuseExistingName;
83
    private EntitySelectionElement<Reference> selection_SecRef;
84

    
85
//    private OriginalSourceElement singleSourceSection;
86

    
87
    private TextWithLabelElement textTaxonSec;
88
	private TextWithLabelElement microReference;
89
    private TextWithLabelElement textNewTaxonName;
90
	private TaxonNodeAgentRelationCollectionSection selectionNodeAgentRelation;
91
	private EnumComboElement<TaxonNodeStatus> combo_status;
92
	private CheckboxElement checkbox_publish;
93
    private MultilanguageTextElement multiLanguageTextStatusNotes;
94
    String defaultPublish;
95

    
96
	public TaxonNodeDetailElement(CdmFormFactory formFactory,
97
			ICdmFormElement formElement, boolean isCreateNew) {
98
		super(formFactory, formElement);
99
		createNew = isCreateNew;
100
	}
101

    
102
	public Map<Language, LanguageString> getMultiLanguageTextExcludedNotes() {
103
        return multiLanguageTextStatusNotes.getMultilanguageText();
104
    }
105

    
106
	public TaxonNodeStatus getTaxonNodeStatus(){
107
	    return status;
108
	}
109

    
110
    public Reference getRef() {
111
        return getEntity().getCitation();
112
    }
113
    public TaxonName getExistingName() {
114
        return selection_reuseExistingName.getEntity();
115
    }
116
    public String getMicroReference() {
117
        return microReference.getText();
118
    }
119

    
120
	@Override
121
	public void createControls(ICdmFormElement formElement,TaxonNode entity, int style) {
122
//	    taxon = entity.getTaxon();
123

    
124
	    Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
125
	    taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
126
	    taxonTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
127
	    taxonTitle.setFont(FONT_BOLD);
128

    
129

    
130

    
131
	    if (isCreateNew()){
132
	        textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
133
                    Messages.TaxonNodeWizardPage_NEW_TAXON, "", style);
134
            textNewTaxonName.setFocus();
135
            textNewTaxonName.setIndent(10);
136

    
137
	        selection_reuseExistingTaxon = formFactory
138
                    .createSelectionElement(Taxon.class,//getConversationHolder(),
139
                            formElement,
140
                            REUSE_EXISTING_TAXON, null,
141
                            EntitySelectionElement.SELECTABLE, style);
142
	        selection_reuseExistingTaxon.setIndent(10);
143
            selection_reuseExistingName = formFactory
144
                    .createSelectionElement(TaxonName.class,//getConversationHolder(),
145
                            formElement,
146
                            REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null,
147
                            EntitySelectionElement.DELETABLE, style);
148
            selection_reuseExistingName.setIndent(10);
149
            selection_SecRef = formFactory
150
                    .createSelectionElement(Reference.class,//getConversationHolder(),
151
                            formElement, SECUNDUM_REFERENCE, taxon != null? taxon.getSec(): null,
152
                            EntitySelectionElement.DELETABLE, style, 100);
153
            selection_SecRef.setIndent(10);
154
            microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", style);
155

    
156
            microReference.setIndent(10);
157
            checkbox_publish = formFactory.createCheckbox(formElement,
158
                    Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
159

    
160
            checkbox_publish.setEnabled(isCreateNew());
161
            checkbox_publish.setIndent(10);
162
            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
163
            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
164
            Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
165
            nodeTitle.setText("Taxon Node");
166
            nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
167
            nodeTitle.setFont(FONT_BOLD);
168
//            LabelElement nodeTitle = formFactory.createLabel(formElement, Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
169
//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
170
//            nodeTitle.setBackground(getPersistentBackground());
171
//            nodeTitle.setBold();
172

    
173
            selection_parentTaxonNode = formFactory
174
                    .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
175
                            EntitySelectionElement.SELECTABLE, style, 100);
176
            selection_parentTaxonNode.setIndent(10);
177
            selection_parentTaxonNode.setEnabled(false);
178

    
179

    
180

    
181
	    }else{
182
	        taxon = getEntity().getTaxon();
183
	        selection_reuseExistingTaxon = formFactory
184
                  .createSelectionElement(Taxon.class, formElement,
185
                          Messages.TaxonNodeWizardPage_TAXON, taxon,
186
                          EntitySelectionElement.SELECTABLE, SWT.NULL);
187

    
188
	        selection_reuseExistingTaxon.setIndent(10);
189
	        textTaxonSec = formFactory.createTextWithLabelElement(formElement,SECUNDUM_REFERENCE, "", SWT.NULL);
190
	        textTaxonSec.setIndent(10);
191
	        microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", SWT.NULL);
192
	        microReference.setIndent(10);
193

    
194
	        if (entity.getTaxon().getSec() != null){
195
                textTaxonSec.setText(taxon.getSec().getTitleCache());
196
            }
197
            textTaxonSec.setEnabled(false);
198
            microReference.setEnabled(false);
199
            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
200
            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
201

    
202
            Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
203
            nodeTitle.setText("Taxon Node");
204
            nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
205
            nodeTitle.setFont(FONT_BOLD);
206

    
207
//            LabelElement nodeTitle = formFactory.createLabel(formElement, "Taxon Node");
208
//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
209
//            nodeTitle.setBackground(getPersistentBackground());
210
//            nodeTitle.setBold();
211

    
212

    
213
            if (entity.getParent().getTaxon() == null){
214
                TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
215
                        formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), SWT.NULL);
216
                textParent.setEnabled(false);
217
                textParent.setIndent(10);
218
            }else{
219
                TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
220
                        formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), SWT.NULL);
221
                textParent.setEnabled(false);
222
                textParent.setIndent(10);
223
            }
224
	    }
225

    
226

    
227
        combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, SWT.NULL, true);
228
        if (!isCreateNew()){
229
            combo_status.setSelection(entity.getStatus());
230
        }
231
        combo_status.setIndent(10);
232
        if(isCreateNew()){
233

    
234
            defaultPublish = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
235
	        setDefaultPublish();
236
	    } else{
237
            setTreeNode(entity);
238
            complete = true;
239
        }
240

    
241
		if (isCreateNew()){
242
		    preFillTaxonName();
243
		}
244

    
245
	    multiLanguageTextStatusNotes = formFactory.createMultiLanguageTextElement(formElement, STATUS_NOTES, null, 50, style);
246
	    if (!isCreateNew()){
247
	        multiLanguageTextStatusNotes.setMultilanguageText(entity.getStatusNote());
248
	        multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
249
	    }
250
	    multiLanguageTextStatusNotes.setIndent(10);
251
	    singleSourceSection = formFactory.createOriginalSourceElement(formElement, entity, "");
252
        if (isCreateNew() || entity.getSource() == null){
253
            DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
254
            entity.setSource(source);
255
            singleSourceSection.setEntity(source);
256
        }else{
257
            singleSourceSection.setEntity(entity.getSource());
258

    
259
        }
260
        singleSourceSection.setIndent(10);
261
//        singleSourceSection.set
262

    
263
//	    super.createControls(formElement, entity, style);
264

    
265
	    setSourceLabel(Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE);
266

    
267

    
268
		selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
269
		selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
270
        selectionNodeAgentRelation.setEntity(entity);
271
        selectionNodeAgentRelation.setIndent(10);
272
        selectionNodeAgentRelation.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
273
        setBackground(getPersistentBackground());
274

    
275
	}
276

    
277
    private void setDefaultPublish() {
278
        if (defaultPublish != null && defaultPublish.equals(PublishEnum.Publish.getKey())){
279
            checkbox_publish.setSelection(true);
280
        } else if (defaultPublish != null && defaultPublish.equals(PublishEnum.NotPublish.getKey())){
281
            checkbox_publish.setSelection(false);
282
        }else{
283
            if(this.getParentTreeNode() != null &&  this.getParentTreeNode().isInstanceOf(TaxonNode.class) && this.getParentTreeNode().getTaxon() != null){
284
                checkbox_publish.setSelection(this.getParentTreeNode().getTaxon().isPublish());
285
            }else{
286
                checkbox_publish.setSelection(true);
287
            }
288
        }
289
    }
290

    
291
	private void preFillTaxonName() {
292
        TaxonNode node = parentNode;
293
        if(node != null && node.getTaxon()!=null){
294
            Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
295
            if(taxon.getName()!=null){
296
                TaxonName name = HibernateProxyHelper.deproxy(node.getTaxon().getName());
297
                if (!isCreateNew()){
298
                    textNewTaxonName.setText(name.getNameCache());
299
                } else if( ! name.isSupraGeneric() && name.getRank() != null){
300
                    String taxonName = "";
301
                    if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
302
                        taxonName = name.getGenusOrUninomial();
303
                    }
304
                    else if(name.isSpecies() || name.isInfraSpecific() ){
305
                        taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
306
                    }
307
                    if (StringUtils.isNotBlank(taxonName)){
308
                    	textNewTaxonName.setText(taxonName + " ");
309
                    	if(textNewTaxonName.getMainControl() instanceof Text){
310
                    		Text text = (Text)textNewTaxonName.getMainControl();
311
                    		text.setSelection(textNewTaxonName.getText().length());
312
                    	}
313
                    }
314
                }
315
            }
316
        }
317
    }
318

    
319
	@Override
320
	public void handleEvent(Object eventSource) {
321
		if (eventSource == selection_parentTaxonNode) {
322
		    setParentTreeNode(selection_parentTaxonNode.getEntity());
323
		} else if (eventSource == selection_reuseExistingTaxon) {
324
		    if (selection_reuseExistingTaxon.getEntity() != null){
325
		        setTaxon(selection_reuseExistingTaxon.getEntity());
326
		        if (getTaxon().getSec()!= null){
327
		            microReference.setText(getTaxon().getSecMicroReference());
328
		            if (isCreateNew()){
329
		               selection_SecRef.setEntity(getTaxon().getSec());
330

    
331
		            }else{
332
		               textTaxonSec.setText((getTaxon().getSec().getTitleCache()));
333
		            }
334
		        }else{
335
		            microReference.setText("");
336
		            if (isCreateNew()){
337
		                    selection_SecRef.setEntity(null);
338

    
339
	                    }else{
340
	                       textTaxonSec.setText("");
341
	                    }
342
		        }
343
		        if (checkbox_publish != null){
344
		            checkbox_publish.setSelected(getTaxon().isPublish());
345
		        }
346
            }else{
347
                if (isCreateNew()){
348
                    selection_SecRef.setEntity(null);
349
                }else{
350
                    textTaxonSec.setText(null);
351
                }
352
                setDefaultPublish();
353
            }
354
		    boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
355
		    if (selection_reuseExistingName != null){
356
		        selection_reuseExistingName.setEnabled(enabled);
357
            }
358
		    if (selection_SecRef != null){
359
		        selection_SecRef.setEnabled(enabled);
360
            }
361
		    if (textNewTaxonName != null){
362
		        textNewTaxonName.setEnabled(enabled);
363
		    }
364
			complete = true;
365
		} else if (eventSource == selection_reuseExistingName) {
366
		    boolean enabled = selection_reuseExistingName.getEntity() == null;
367
			setTaxon(HibernateProxyHelper.deproxy(selection_reuseExistingName.getEntity()));
368
			if (selection_reuseExistingTaxon != null){
369
			    selection_reuseExistingTaxon.setEnabled(enabled);
370
			}
371
			textNewTaxonName.setEnabled(enabled);
372
			complete = !textNewTaxonName.getText().isEmpty();
373
        }
374

    
375
		if (eventSource == combo_status) {
376
            status = combo_status.getSelection();
377
            if (status == null){
378
                if (multiLanguageTextStatusNotes.getMultilanguageText() != null && !multiLanguageTextStatusNotes.getMultilanguageText().isEmpty()){
379
                    multilanguageTextCache = new HashMap<>();
380
                    for (LanguageString langString: multiLanguageTextStatusNotes.getMultilanguageText().values()){
381
                        multilanguageTextCache.put(langString.getLanguage(), langString);
382
                    }
383
//                    multilanguageTextCache = multiLanguageTextStatusNotes.getMultilanguageText();
384
                }
385
                multiLanguageTextStatusNotes.setMultilanguageText(new HashMap<>());
386
//                multiLanguageTextStatusNotes.refresh();
387

    
388
            }else if (multilanguageTextCache != null ){
389

    
390
                multiLanguageTextStatusNotes.setMultilanguageText(multilanguageTextCache);
391
                multilanguageTextCache = null;
392
            }
393
            if (!isCreateNew()){
394
                getEntity().setStatus(status);
395
                if (status == null){
396
                    getEntity().getStatusNote().clear();
397
                    multiLanguageTextStatusNotes.setMultilanguageText(new HashMap<>());
398
                    multiLanguageTextStatusNotes.refresh();
399
                }else{
400
                    if (multiLanguageTextStatusNotes.getMultilanguageText() != null){
401
                        for (LanguageString lang:multiLanguageTextStatusNotes.getMultilanguageText().values()){
402
                            getEntity().putStatusNote(lang);
403
                        }
404
                    }
405
                }
406
            }
407

    
408
            multiLanguageTextStatusNotes.setEnabled(status != null);
409

    
410
            complete = true;
411
        }
412

    
413
		if (eventSource == textNewTaxonName) {
414
            boolean enabled = CdmUtils.isBlank(textNewTaxonName.getText());
415
            if (selection_reuseExistingTaxon != null){
416
                selection_reuseExistingTaxon.setEnabled(enabled);
417
            }
418
            selection_reuseExistingName.setEnabled(enabled);
419

    
420
            complete = CdmUtils.isNotBlank(textNewTaxonName.getText());
421
        }
422

    
423
		if (eventSource == selectionNodeAgentRelation){
424
		   boolean allComplete = true;
425
		   for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
426
		       allComplete &=((TaxonNodeAgentRelationCollectionElement)element).isComplete();
427
		   }
428
		    complete = !isCreateNew() && allComplete;
429
		}
430
	}
431

    
432
	public Classification getClassification() {
433
		return classification;
434
	}
435

    
436
	public TaxonNode getParentTreeNode() {
437
		return parentNode;
438
	}
439

    
440
	public void setParentTreeNode(TaxonNode parentTreeNode) {
441
		this.parentNode = parentTreeNode;
442
		updateContent();
443
		if (parentTreeNode.getTaxon() == null) {
444
			classification = parentTreeNode.getClassification();
445
			if (selection_parentTaxonNode != null){
446
    			selection_parentTaxonNode.setEntity(classification.getRootNode());
447
    			selection_parentTaxonNode.setClassification(classification);
448
    			selection_SecRef.setEntity(classification.getReference());
449
			}
450
		} else  {
451
			classification = HibernateProxyHelper
452
					.deproxy(parentTreeNode.getClassification());
453
			if (selection_parentTaxonNode != null){
454
			    selection_parentTaxonNode.setEntity(HibernateProxyHelper.deproxy(parentTreeNode));
455
			    selection_parentTaxonNode.setClassification(classification);
456
	            selection_SecRef.setEntity(parentTreeNode.getTaxon().getSec());
457
			}
458
		}
459
	}
460

    
461
	@Override
462
	protected void updateControlStates(){
463
        Collection<Object> except = new ArrayList<Object>();
464
        for(ICdmFormElement formElement:getElements()){
465
            if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
466
                except.add(formElement);
467
            }
468
        }
469
        if (isCreateNew() ){
470
            enabled = true;
471
        }else{
472
            enabled = getEntity() != null && CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud);
473
        }
474
        setEnabled(enabled, except);
475
    }
476

    
477
	private void setTreeNode(TaxonNode treeNode) {
478
        classification = HibernateProxyHelper
479
                    .deproxy(treeNode.getClassification());
480
        if (isCreateNew()){
481
           selection_parentTaxonNode.setEntity(treeNode.getParent());
482
           selection_parentTaxonNode.setClassification(treeNode.getParent().getClassification());
483
           selection_SecRef.setEntity(treeNode.getTaxon().getSec());
484
        }
485
	}
486

    
487
	private void setTaxon(Taxon taxon) {
488
		this.taxon = taxon;
489
		if (!isCreateNew()){
490
		    getEntity().setTaxon(taxon);
491
		}
492

    
493
		this.set_publish(taxon.isPublish());
494
		if (isCreateNew()){
495
		    textNewTaxonName.setText(taxon.getName().getTitleCache());
496
		    if (taxon.getSec() != null){
497
		        selection_SecRef.setEntity(taxon.getSec());
498
		    }
499
		}else{
500
		    if (taxon.getSec() != null) {
501
                this.textTaxonSec.setText(taxon.getSec().getTitleCache());
502
            }
503
		}
504
	}
505

    
506
	private void setTaxon(TaxonName taxonName) {
507
		Reference secundum = null;
508
		if (getParentTreeNode() != null) {
509
			if (this.selection_SecRef.getEntity() != null){
510
				secundum = this.selection_SecRef.getEntity();
511
			}
512
		}
513
		textNewTaxonName.setText(taxonName.getTitleCache());
514

    
515
	}
516

    
517
	public String getTaxonName() {
518
        return textNewTaxonName.getText();
519
    }
520
	public Taxon getTaxon() {
521
        return taxon;
522
    }
523

    
524
	public Reference getSecReference(){
525
	    return selection_SecRef.getSelection();
526
	}
527

    
528
	public Control getMainControl(){
529
	    return textNewTaxonName.getMainControl();
530
	}
531

    
532
	public boolean isComplete() {
533
	    boolean allComplete = true;
534
	    if (!isCreateNew()){
535
	        for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
536
	            allComplete &=((TaxonNodeAgentRelationCollectionElement)element).isComplete();
537
	        }
538
	        complete = allComplete;
539
	    }
540
		return complete;
541
	}
542

    
543
    public boolean isCreateNew() {
544
        return createNew;
545
    }
546

    
547
    public boolean is_publish() {
548
        boolean isPublishPreference = true;
549
        CdmPreference defaultPublish = CdmPreferenceCache.instance().get(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
550
        if (defaultPublish != null && defaultPublish.getValue()!= null && defaultPublish.getValue().equals(PublishEnum.NotPublish.getKey())){
551
            isPublishPreference = false;
552
        }
553
        return checkbox_publish!=null?checkbox_publish.getSelection():isPublishPreference;
554
    }
555

    
556
    public void set_publish(boolean publish) {
557
        if (checkbox_publish != null){
558
            this.checkbox_publish.setSelection(publish);
559
        }
560
    }
561

    
562
    /**
563
     * Updates all widgets to display the latest data
564
     */
565
    @Override
566
    protected void updateContent() {
567
        removeElements();
568
        if (isCreateNew()){
569
            createControls(this, parentNode, SWT.NONE);
570
        }else{
571
            createControls(this, getEntity(), SWT.NONE);
572
        }
573
        updateControlStates();
574
    }
575

    
576
    @Override
577
    public SelectionArbitrator getSelectionArbitrator() {
578
        // TODO Auto-generated method stub
579
        return null;
580
    }
581
}
(10-10/12)