Project

General

Profile

Download (22.8 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.metadata.CdmPreference;
29
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
30
import eu.etaxonomy.cdm.model.metadata.PublishEnum;
31
import eu.etaxonomy.cdm.model.name.TaxonName;
32
import eu.etaxonomy.cdm.model.reference.Reference;
33
import eu.etaxonomy.cdm.model.taxon.Classification;
34
import eu.etaxonomy.cdm.model.taxon.Taxon;
35
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
36
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
37
import eu.etaxonomy.taxeditor.l10n.Messages;
38
import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
39
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
40
import eu.etaxonomy.taxeditor.store.CdmStore;
41
import eu.etaxonomy.taxeditor.store.StoreUtil;
42
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
43
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
44
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
45
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
46
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
47
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
48
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
49
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
50
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
51
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractSingleSourceElement;
52
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
53
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
54

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

    
61
    private static final String STATUS_NOTES = Messages.TaxonNodeWizardPage_STATUS_NOTES;
62
    private static final String CLASSIFICATION_STR = Messages.TaxonNodeWizardPage_CLASSIFICATION;
63
    private static final String REUSE_EXISTING_TAXON = Messages.TaxonNodeWizardPage_REUSE_EXISTING_TAXON;
64
    private static final String REUSE_EXISTING_NAME = Messages.TaxonNodeWizardPage_REUSE_EXISTING_NAME;
65
    private static final String SECUNDUM_REFERENCE = Messages.TaxonNodeWizardPage_SECUNDUM_REFERENCE;
66

    
67
    private static final Font FONT_BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
68

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

    
77
	private TaxonNodeSelectionElement selection_parentTaxonNode;
78
	private EntitySelectionElement<Taxon> selection_reuseExistingTaxon;
79
	private EntitySelectionElement<TaxonName> selection_reuseExistingName;
80
    private EntitySelectionElement<Reference> selection_SecRef;
81

    
82
//    private OriginalSourceElement singleSourceSection;
83

    
84
    private TextWithLabelElement textTaxonSec;
85
	private TextWithLabelElement microReference;
86
    private TextWithLabelElement textNewTaxonName;
87
	private TaxonNodeAgentRelationCollectionSection selectionNodeAgentRelation;
88
	private EnumComboElement<TaxonNodeStatus> combo_status;
89
	private CheckboxElement checkbox_publish;
90
    private MultilanguageTextElement multiLanguageTextStatusNotes;
91

    
92
	public TaxonNodeDetailElement(CdmFormFactory formFactory,
93
			ICdmFormElement formElement, boolean isCreateNew) {
94
		super(formFactory, formElement);
95
		createNew = isCreateNew;
96
	}
97

    
98
	public Map<Language, LanguageString> getMultiLanguageTextExcludedNotes() {
99
        return multiLanguageTextStatusNotes.getMultilanguageText();
100
    }
101

    
102
	public TaxonNodeStatus getTaxonNodeStatus(){
103
	    return status;
104
	}
105

    
106
    public Reference getRef() {
107
        return getEntity().getCitation();
108
    }
109
    public TaxonName getExistingName() {
110
        return selection_reuseExistingName.getEntity();
111
    }
112
    public String getMicroReference() {
113
        return microReference.getText();
114
    }
115

    
116
	@Override
117
	public void createControls(ICdmFormElement formElement,TaxonNode entity, int style) {
118
//	    taxon = entity.getTaxon();
119

    
120
	    Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
121
	    taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
122
	    taxonTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
123
	    taxonTitle.setFont(FONT_BOLD);
124

    
125

    
126

    
127
	    if (isCreateNew()){
128
	        textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
129
                    Messages.TaxonNodeWizardPage_NEW_TAXON, "", style);
130
            textNewTaxonName.setFocus();
131

    
132
	        selection_reuseExistingTaxon = formFactory
133
                    .createSelectionElement(Taxon.class,//getConversationHolder(),
134
                            formElement,
135
                            REUSE_EXISTING_TAXON, null,
136
                            EntitySelectionElement.DELETABLE, style);
137

    
138
            selection_reuseExistingName = formFactory
139
                    .createSelectionElement(TaxonName.class,//getConversationHolder(),
140
                            formElement,
141
                            REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null,
142
                            EntitySelectionElement.DELETABLE, style);
143
            selection_SecRef = formFactory
144
                    .createSelectionElement(Reference.class,//getConversationHolder(),
145
                            formElement, SECUNDUM_REFERENCE, taxon != null? taxon.getSec(): null,
146
                            EntitySelectionElement.DELETABLE, style, 100);
147

    
148
            microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", style);
149

    
150

    
151
            checkbox_publish = formFactory.createCheckbox(formElement,
152
                    Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
153

    
154
            checkbox_publish.setEnabled(isCreateNew());
155
            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
156
            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
157
            Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
158
            nodeTitle.setText("Taxon Node");
159
            nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
160
            nodeTitle.setFont(FONT_BOLD);
161
//            LabelElement nodeTitle = formFactory.createLabel(formElement, Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
162
//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
163
//            nodeTitle.setBackground(getPersistentBackground());
164
//            nodeTitle.setBold();
165

    
166
            selection_parentTaxonNode = formFactory
167
                    .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
168
                            EntitySelectionElement.DELETABLE, style, 100);
169

    
170

    
171

    
172
	    }else{
173
	        taxon = getEntity().getTaxon();
174
	        selection_reuseExistingTaxon = formFactory
175
                  .createSelectionElement(Taxon.class,//getConversationHolder(),
176
                          formElement,
177
                          Messages.TaxonNodeWizardPage_TAXON, taxon,
178
                          EntitySelectionElement.DELETABLE, SWT.NULL);
179

    
180

    
181
	        textTaxonSec = formFactory.createTextWithLabelElement(formElement,SECUNDUM_REFERENCE, "", SWT.NULL);
182
	        microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", SWT.NULL);
183
            if (entity.getTaxon().getSec() != null){
184
                textTaxonSec.setText(taxon.getSec().getTitleCache());
185
            }
186
            textTaxonSec.setEnabled(false);
187
            microReference.setEnabled(false);
188
            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
189
            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
190

    
191
            Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
192
            nodeTitle.setText("Taxon Node");
193
            nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
194
            nodeTitle.setFont(FONT_BOLD);
195

    
196
//            LabelElement nodeTitle = formFactory.createLabel(formElement, "Taxon Node");
197
//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
198
//            nodeTitle.setBackground(getPersistentBackground());
199
//            nodeTitle.setBold();
200

    
201

    
202
            if (entity.getParent().getTaxon() == null){
203
                TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
204
                        formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), SWT.NULL);
205
                textParent.setEnabled(false);
206
            }else{
207
                TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
208
                        formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), SWT.NULL);
209
                textParent.setEnabled(false);
210
            }
211
	    }
212

    
213

    
214
        combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, SWT.NULL, true);
215
        if (!isCreateNew()){
216
            combo_status.setSelection(entity.getStatus());
217
        }
218

    
219
        if(isCreateNew()){
220

    
221
		   String defaultPublish = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
222
	        if (defaultPublish != null && defaultPublish.equals(PublishEnum.Publish.getKey())){
223
	            checkbox_publish.setSelection(true);
224
	        } else if (defaultPublish != null && defaultPublish.equals(PublishEnum.NotPublish.getKey())){
225
	            checkbox_publish.setSelection(false);
226
	        }else{
227
	            if(this.getParentTreeNode() != null &&  this.getParentTreeNode().isInstanceOf(TaxonNode.class) && this.getParentTreeNode().getTaxon() != null){
228
	                checkbox_publish.setSelection(this.getParentTreeNode().getTaxon().isPublish());
229
	            }else{
230
	                checkbox_publish.setSelection(true);
231
	            }
232
	        }
233
	    } else{
234
            setTreeNode(entity);
235
            complete = true;
236
        }
237

    
238
		if (isCreateNew()){
239
		    preFillTaxonName();
240
		}
241

    
242
	    multiLanguageTextStatusNotes = formFactory.createMultiLanguageTextElement(formElement, STATUS_NOTES, null, 50, style);
243
	    if (!isCreateNew()){
244
	        multiLanguageTextStatusNotes.setMultilanguageText(entity.getStatusNote());
245
	        multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
246
	    }
247

    
248
/*
249
 * singleSourceSection = formFactory.createOriginalSourceElement(formElement, entity);
250
        if (isCreateNew() || entity.getSource() == null){
251
            DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
252
            entity.setSource(source);
253
            singleSourceSection.setEntity(source);
254
        }else{
255
            singleSourceSection.setEntity(entity.getSource());
256

    
257
        }
258
 */
259
	    super.createControls(formElement, entity, style);
260
	    setSourceLabel(Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE);
261

    
262

    
263
		selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
264
		selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
265
        selectionNodeAgentRelation.setEntity(entity);
266
        setBackground(getPersistentBackground());
267

    
268
	}
269

    
270
	private void preFillTaxonName() {
271
        TaxonNode node = parentNode;
272
        if(node != null && node.getTaxon()!=null){
273
            Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
274
            if(taxon.getName()!=null){
275
                TaxonName name = HibernateProxyHelper.deproxy(node.getTaxon().getName());
276
                if (!isCreateNew()){
277
                    textNewTaxonName.setText(name.getNameCache());
278
                } else if( ! name.isSupraGeneric() && name.getRank() != null){
279
                    String taxonName = "";
280
                    if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
281
                        taxonName = name.getGenusOrUninomial();
282
                    }
283
                    else if(name.isSpecies() || name.isInfraSpecific() ){
284
                        taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
285
                    }
286
                    if (StringUtils.isNotBlank(taxonName)){
287
                    	textNewTaxonName.setText(taxonName + " ");
288
                    	if(textNewTaxonName.getMainControl() instanceof Text){
289
                    		Text text = (Text)textNewTaxonName.getMainControl();
290
                    		text.setSelection(textNewTaxonName.getText().length());
291
                    	}
292
                    }
293
                }
294
            }
295
        }
296
    }
297

    
298
	@Override
299
	public void handleEvent(Object eventSource) {
300
		if (eventSource == selection_parentTaxonNode) {
301
		    setParentTreeNode(selection_parentTaxonNode.getEntity());
302
		} else if (eventSource == selection_reuseExistingTaxon) {
303
		    if (selection_reuseExistingTaxon.getEntity() != null){
304
		        setTaxon(selection_reuseExistingTaxon.getEntity());
305
		        if (getTaxon().getSec()!= null){
306
		            microReference.setText(getTaxon().getSecMicroReference());
307
		            if (isCreateNew()){
308
		               selection_SecRef.setEntity(getTaxon().getSec());
309
		            }else{
310
		               textTaxonSec.setText((getTaxon().getSec().getTitleCache()));
311
		            }
312
		        }else{
313
		            microReference.setText("");
314
		            if (isCreateNew()){
315
		                    selection_SecRef.setEntity(null);
316
	                    }else{
317
	                       textTaxonSec.setText("");
318
	                    }
319
		        }
320
		        checkbox_publish.setSelected(getTaxon().isPublish());
321
            }
322
		    boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
323
		    if (selection_reuseExistingName != null){
324
		        selection_reuseExistingName.setEnabled(enabled);
325
            }
326
		    if (textNewTaxonName != null){
327
		        textNewTaxonName.setEnabled(enabled);
328
		    }
329
			complete = true;
330
		} else if (eventSource == selection_reuseExistingName) {
331
		    boolean enabled = selection_reuseExistingName.getEntity() == null;
332
			setTaxon(HibernateProxyHelper.deproxy(selection_reuseExistingName.getEntity()));
333
			if (selection_reuseExistingTaxon != null){
334
			    selection_reuseExistingTaxon.setEnabled(enabled);
335
			}
336
			textNewTaxonName.setEnabled(enabled);
337
			complete = !textNewTaxonName.getText().isEmpty();
338
		} else if (eventSource == selection_SecRef) {
339
            if (taxon != null){
340
                taxon.setSec(selection_SecRef.getEntity());
341
            }
342
        } else if (eventSource == microReference) {
343
            if (taxon != null){
344
                taxon.setSecMicroReference(microReference.getText());
345
            }
346

    
347
        }  else if (eventSource == checkbox_publish) {
348
            if (taxon != null){
349
                taxon.setPublish(checkbox_publish.getSelection());
350
            }
351
        }
352

    
353
		if (eventSource == combo_status) {
354
            status = combo_status.getSelection();
355
            if (status == null){
356
                if (multiLanguageTextStatusNotes.getMultilanguageText() != null && !multiLanguageTextStatusNotes.getMultilanguageText().isEmpty()){
357
                    multilanguageTextCache = new HashMap<>();
358
                    for (LanguageString langString: multiLanguageTextStatusNotes.getMultilanguageText().values()){
359
                        multilanguageTextCache.put(langString.getLanguage(), langString);
360
                    }
361
//                    multilanguageTextCache = multiLanguageTextStatusNotes.getMultilanguageText();
362
                }
363
                multiLanguageTextStatusNotes.setMultilanguageText(new HashMap<>());
364
//                multiLanguageTextStatusNotes.refresh();
365

    
366
            }else if (multilanguageTextCache != null ){
367

    
368
                multiLanguageTextStatusNotes.setMultilanguageText(multilanguageTextCache);
369
                multilanguageTextCache = null;
370
            }
371
            if (!isCreateNew()){
372
                getEntity().setStatus(status);
373
                if (status == null){
374
                    getEntity().getStatusNote().clear();
375
                    multiLanguageTextStatusNotes.setMultilanguageText(new HashMap<>());
376
                    multiLanguageTextStatusNotes.refresh();
377
                }else{
378
                    if (multiLanguageTextStatusNotes.getMultilanguageText() != null){
379
                        for (LanguageString lang:multiLanguageTextStatusNotes.getMultilanguageText().values()){
380
                            getEntity().putStatusNote(lang);
381
                        }
382
                    }
383
                }
384
            }
385

    
386
            multiLanguageTextStatusNotes.setEnabled(status != null);
387

    
388
            complete = true;
389
        }
390

    
391
		if (eventSource == textNewTaxonName) {
392
            boolean enabled = CdmUtils.isBlank(textNewTaxonName.getText());
393
            if (selection_reuseExistingTaxon != null){
394
                selection_reuseExistingTaxon.setEnabled(enabled);
395
            }
396
            selection_reuseExistingName.setEnabled(enabled);
397

    
398
            complete = CdmUtils.isNotBlank(textNewTaxonName.getText());
399
        }
400

    
401
		if (eventSource == selectionNodeAgentRelation){
402
		   boolean allComplete = true;
403
		   for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
404
		       allComplete &=((TaxonNodeAgentRelationCollectionElement)element).isComplete();
405
		   }
406
		    complete = !isCreateNew() && allComplete;
407
		}
408
	}
409

    
410
	public Classification getClassification() {
411
		return classification;
412
	}
413

    
414
	public TaxonNode getParentTreeNode() {
415
		return parentNode;
416
	}
417

    
418
	public void setParentTreeNode(TaxonNode parentTreeNode) {
419
		this.parentNode = parentTreeNode;
420
		updateContent();
421
		if (parentTreeNode.getTaxon() == null) {
422
			classification = parentTreeNode.getClassification();
423
			if (selection_parentTaxonNode != null){
424
    			selection_parentTaxonNode.setEntity(classification.getRootNode());
425
    			selection_parentTaxonNode.setClassification(classification);
426
    			selection_SecRef.setEntity(classification.getReference());
427
			}
428
		} else  {
429
			classification = HibernateProxyHelper
430
					.deproxy(parentTreeNode.getClassification());
431
			if (selection_parentTaxonNode != null){
432
			    selection_parentTaxonNode.setEntity(HibernateProxyHelper.deproxy(parentTreeNode));
433
			    selection_parentTaxonNode.setClassification(classification);
434
	            selection_SecRef.setEntity(parentTreeNode.getTaxon().getSec());
435
			}
436
		}
437
	}
438

    
439
	@Override
440
	protected void updateControlStates(){
441
        Collection<Object> except = new ArrayList<Object>();
442
        for(ICdmFormElement formElement:getElements()){
443
            if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
444
                except.add(formElement);
445
            }
446
        }
447
        if (isCreateNew() ){
448
            enabled = true;
449
        }else{
450
            enabled = getEntity() != null && CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud);
451
        }
452
        setEnabled(enabled, except);
453
    }
454

    
455
	private void setTreeNode(TaxonNode treeNode) {
456
        classification = HibernateProxyHelper
457
                    .deproxy(treeNode.getClassification());
458
        if (isCreateNew()){
459
           selection_parentTaxonNode.setEntity(treeNode.getParent());
460
           selection_parentTaxonNode.setClassification(treeNode.getParent().getClassification());
461
           selection_SecRef.setEntity(treeNode.getTaxon().getSec());
462
        }
463
	}
464

    
465
	private void setTaxon(Taxon taxon) {
466
		this.taxon = taxon;
467
		if (!isCreateNew()){
468
		    getEntity().setTaxon(taxon);
469
		}
470
		this.set_publish(taxon.isPublish());
471
		if (isCreateNew()){
472
		    textNewTaxonName.setText(taxon.getName().getTitleCache());
473
		    if (taxon.getSec() != null){
474
		        selection_SecRef.setEntity(taxon.getSec());
475
		    }
476
		}else{
477
		    if (taxon.getSec() != null) {
478
                this.textTaxonSec.setText(taxon.getSec().getTitleCache());
479
            }
480
		}
481
	}
482

    
483
	private void setTaxon(TaxonName taxonName) {
484
		Reference secundum = null;
485
		if (getParentTreeNode() != null) {
486
			if (this.selection_SecRef.getEntity() != null){
487
				secundum = this.selection_SecRef.getEntity();
488
			}
489
		}
490
		if (taxonName != null){
491
		    taxon = Taxon.NewInstance(taxonName, secundum);
492
		    if (textNewTaxonName.getText() == null || !taxonName.getTitleCache().trim().equals(textNewTaxonName.getText().trim())){
493
		    	 textNewTaxonName.setText(taxonName.getTitleCache());
494
		    }
495
		    if (!isCreateNew()){
496
		        getEntity().setTaxon(taxon);
497
		    }
498

    
499
		} else {
500
		    textNewTaxonName.setText(null);
501
		}
502
	}
503

    
504
	public String getTaxonName() {
505
        return textNewTaxonName.getText();
506
    }
507
	public Taxon getTaxon() {
508
        return taxon;
509
    }
510

    
511
	public Reference getSecReference(){
512
	    return selection_SecRef.getSelection();
513
	}
514

    
515
	public Control getMainControl(){
516
	    return textNewTaxonName.getMainControl();
517
	}
518

    
519
	public boolean isComplete() {
520
	    boolean allComplete = true;
521
	    if (!isCreateNew()){
522
	        for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
523
	            allComplete &=((TaxonNodeAgentRelationCollectionElement)element).isComplete();
524
	        }
525
	        complete = allComplete;
526
	    }
527
		return complete;
528
	}
529

    
530
    public boolean isCreateNew() {
531
        return createNew;
532
    }
533

    
534
    public boolean is_publish() {
535
        boolean isPublishPreference = true;
536
        CdmPreference defaultPublish = CdmPreferenceCache.instance().get(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
537
        if (defaultPublish != null && defaultPublish.getValue()!= null && defaultPublish.getValue().equals(PublishEnum.NotPublish.getKey())){
538
            isPublishPreference = false;
539
        }
540
        return checkbox_publish!=null?checkbox_publish.getSelection():isPublishPreference;
541
    }
542

    
543
    public void set_publish(boolean publish) {
544
        this.checkbox_publish.setSelection(publish);
545
    }
546

    
547
    /**
548
     * Updates all widgets to display the latest data
549
     */
550
    @Override
551
    protected void updateContent() {
552
        removeElements();
553
        if (isCreateNew()){
554
            createControls(this, parentNode, SWT.NONE);
555
        }else{
556
            createControls(this, getEntity(), SWT.NONE);
557
        }
558
        updateControlStates();
559
    }
560

    
561
    @Override
562
    public SelectionArbitrator getSelectionArbitrator() {
563
        // TODO Auto-generated method stub
564
        return null;
565
    }
566
}
(10-10/12)