Project

General

Profile

Download (22.7 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.lang.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.preference.CdmPreferenceCache;
40
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
41
import eu.etaxonomy.taxeditor.store.CdmStore;
42
import eu.etaxonomy.taxeditor.store.StoreUtil;
43
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
44
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
45
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
46
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
47
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
48
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
49
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
50
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
51
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
52
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
53
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
54
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
55

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

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

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

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

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

    
83
    private OriginalSourceElement singleSourceSection;
84

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

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

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

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

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

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

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

    
127

    
128

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

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

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

    
150
            microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", style);
151

    
152

    
153
            checkbox_publish = formFactory.createCheckbox(formElement,
154
                    Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
155

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

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

    
172

    
173

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

    
182

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

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

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

    
203

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

    
215

    
216
        combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, style, true);
217
        if (!isCreateNew()){
218
            combo_status.setSelection(entity.getStatus());
219
        }
220

    
221
        if(isCreateNew()){
222

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

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

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

    
250

    
251

    
252
		singleSourceSection = formFactory.createOriginalSourceElement(formElement, entity);
253
		if (isCreateNew() || entity.getSource() == null){
254
		    DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
255
		    entity.setSource(source);
256
		    singleSourceSection.setEntity(source);
257
		}else{
258
		    singleSourceSection.setEntity(entity.getSource());
259

    
260
		}
261

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

    
267
	}
268

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

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

    
339
        if (eventSource == singleSourceSection) {
340
//            getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
341

    
342
        }else if (eventSource == selection_SecRef) {
343
            if (taxon != null){
344
                taxon.setSec(selection_SecRef.getEntity());
345
            }
346
        }else if (eventSource == microReference) {
347
            getEntity().getTaxon().setSecMicroReference(microReference.getText());
348

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

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

    
368
            }else if (multilanguageTextCache != null ){
369

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

    
388
            multiLanguageTextStatusNotes.setEnabled(status != null);
389

    
390
            complete = true;
391
        }
392

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

    
400
            complete = CdmUtils.isNotBlank(textNewTaxonName.getText());
401
        }
402

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

    
412
	public Classification getClassification() {
413
		return classification;
414
	}
415

    
416
	public TaxonNode getParentTreeNode() {
417
		return parentNode;
418
	}
419

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

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

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

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

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

    
501
		} else {
502
		    textNewTaxonName.setText(null);
503
		}
504
	}
505

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

    
513
	public Reference getSecReference(){
514
	    return selection_SecRef.getSelection();
515
	}
516

    
517
	public Control getMainControl(){
518
	    return textNewTaxonName.getMainControl();
519
	}
520

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

    
532
    public boolean isCreateNew() {
533
        return createNew;
534
    }
535

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

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

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