Merge branch 'release/5.18.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / classification / TaxonNodeDetailElement.java
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
95 public TaxonNodeDetailElement(CdmFormFactory formFactory,
96 ICdmFormElement formElement, boolean isCreateNew) {
97 super(formFactory, formElement);
98 createNew = isCreateNew;
99 }
100
101 public Map<Language, LanguageString> getMultiLanguageTextExcludedNotes() {
102 return multiLanguageTextStatusNotes.getMultilanguageText();
103 }
104
105 public TaxonNodeStatus getTaxonNodeStatus(){
106 return status;
107 }
108
109 public Reference getRef() {
110 return getEntity().getCitation();
111 }
112 public TaxonName getExistingName() {
113 return selection_reuseExistingName.getEntity();
114 }
115 public String getMicroReference() {
116 return microReference.getText();
117 }
118
119 @Override
120 public void createControls(ICdmFormElement formElement,TaxonNode entity, int style) {
121 // taxon = entity.getTaxon();
122
123 Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
124 taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
125 taxonTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
126 taxonTitle.setFont(FONT_BOLD);
127
128
129
130 if (isCreateNew()){
131 textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
132 Messages.TaxonNodeWizardPage_NEW_TAXON, "", style);
133 textNewTaxonName.setFocus();
134 textNewTaxonName.setIndent(10);
135
136 selection_reuseExistingTaxon = formFactory
137 .createSelectionElement(Taxon.class,//getConversationHolder(),
138 formElement,
139 REUSE_EXISTING_TAXON, null,
140 EntitySelectionElement.DELETABLE, style);
141 selection_reuseExistingTaxon.setIndent(10);
142 selection_reuseExistingName = formFactory
143 .createSelectionElement(TaxonName.class,//getConversationHolder(),
144 formElement,
145 REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null,
146 EntitySelectionElement.DELETABLE, style);
147 selection_reuseExistingName.setIndent(10);
148 selection_SecRef = formFactory
149 .createSelectionElement(Reference.class,//getConversationHolder(),
150 formElement, SECUNDUM_REFERENCE, taxon != null? taxon.getSec(): null,
151 EntitySelectionElement.DELETABLE, style, 100);
152 selection_SecRef.setIndent(10);
153 microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", style);
154
155 microReference.setIndent(10);
156 checkbox_publish = formFactory.createCheckbox(formElement,
157 Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
158
159 checkbox_publish.setEnabled(isCreateNew());
160 checkbox_publish.setIndent(10);
161 Label spacer = new Label(getLayoutComposite(), SWT.NULL);
162 spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
163 Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
164 nodeTitle.setText("Taxon Node");
165 nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
166 nodeTitle.setFont(FONT_BOLD);
167 // LabelElement nodeTitle = formFactory.createLabel(formElement, Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
168 // nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
169 // nodeTitle.setBackground(getPersistentBackground());
170 // nodeTitle.setBold();
171
172 selection_parentTaxonNode = formFactory
173 .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
174 EntitySelectionElement.DELETABLE, style, 100);
175 selection_parentTaxonNode.setIndent(10);
176
177
178
179 }else{
180 taxon = getEntity().getTaxon();
181 selection_reuseExistingTaxon = formFactory
182 .createSelectionElement(Taxon.class,//getConversationHolder(),
183 formElement,
184 Messages.TaxonNodeWizardPage_TAXON, taxon,
185 EntitySelectionElement.DELETABLE, SWT.NULL);
186
187 selection_reuseExistingTaxon.setIndent(10);
188 textTaxonSec = formFactory.createTextWithLabelElement(formElement,SECUNDUM_REFERENCE, "", SWT.NULL);
189 textTaxonSec.setIndent(10);
190 microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", SWT.NULL);
191 microReference.setIndent(10);
192
193 if (entity.getTaxon().getSec() != null){
194 textTaxonSec.setText(taxon.getSec().getTitleCache());
195 }
196 textTaxonSec.setEnabled(false);
197 microReference.setEnabled(false);
198 Label spacer = new Label(getLayoutComposite(), SWT.NULL);
199 spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
200
201 Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
202 nodeTitle.setText("Taxon Node");
203 nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
204 nodeTitle.setFont(FONT_BOLD);
205
206 // LabelElement nodeTitle = formFactory.createLabel(formElement, "Taxon Node");
207 // nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
208 // nodeTitle.setBackground(getPersistentBackground());
209 // nodeTitle.setBold();
210
211
212 if (entity.getParent().getTaxon() == null){
213 TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
214 formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), SWT.NULL);
215 textParent.setEnabled(false);
216 textParent.setIndent(10);
217 }else{
218 TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
219 formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), SWT.NULL);
220 textParent.setEnabled(false);
221 textParent.setIndent(10);
222 }
223 }
224
225
226 combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, SWT.NULL, true);
227 if (!isCreateNew()){
228 combo_status.setSelection(entity.getStatus());
229 }
230 combo_status.setIndent(10);
231 if(isCreateNew()){
232
233 String defaultPublish = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
234 if (defaultPublish != null && defaultPublish.equals(PublishEnum.Publish.getKey())){
235 checkbox_publish.setSelection(true);
236 } else if (defaultPublish != null && defaultPublish.equals(PublishEnum.NotPublish.getKey())){
237 checkbox_publish.setSelection(false);
238 }else{
239 if(this.getParentTreeNode() != null && this.getParentTreeNode().isInstanceOf(TaxonNode.class) && this.getParentTreeNode().getTaxon() != null){
240 checkbox_publish.setSelection(this.getParentTreeNode().getTaxon().isPublish());
241 }else{
242 checkbox_publish.setSelection(true);
243 }
244 }
245 } else{
246 setTreeNode(entity);
247 complete = true;
248 }
249
250 if (isCreateNew()){
251 preFillTaxonName();
252 }
253
254 multiLanguageTextStatusNotes = formFactory.createMultiLanguageTextElement(formElement, STATUS_NOTES, null, 50, style);
255 if (!isCreateNew()){
256 multiLanguageTextStatusNotes.setMultilanguageText(entity.getStatusNote());
257 multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
258 }
259 multiLanguageTextStatusNotes.setIndent(10);
260 singleSourceSection = formFactory.createOriginalSourceElement(formElement, entity, "");
261 if (isCreateNew() || entity.getSource() == null){
262 DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
263 entity.setSource(source);
264 singleSourceSection.setEntity(source);
265 }else{
266 singleSourceSection.setEntity(entity.getSource());
267
268 }
269 singleSourceSection.setIndent(10);
270 // singleSourceSection.set
271
272 // super.createControls(formElement, entity, style);
273
274 setSourceLabel(Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE);
275
276
277 selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
278 selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
279 selectionNodeAgentRelation.setEntity(entity);
280 selectionNodeAgentRelation.setIndent(10);
281 selectionNodeAgentRelation.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
282 setBackground(getPersistentBackground());
283
284 }
285
286 private void preFillTaxonName() {
287 TaxonNode node = parentNode;
288 if(node != null && node.getTaxon()!=null){
289 Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
290 if(taxon.getName()!=null){
291 TaxonName name = HibernateProxyHelper.deproxy(node.getTaxon().getName());
292 if (!isCreateNew()){
293 textNewTaxonName.setText(name.getNameCache());
294 } else if( ! name.isSupraGeneric() && name.getRank() != null){
295 String taxonName = "";
296 if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
297 taxonName = name.getGenusOrUninomial();
298 }
299 else if(name.isSpecies() || name.isInfraSpecific() ){
300 taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
301 }
302 if (StringUtils.isNotBlank(taxonName)){
303 textNewTaxonName.setText(taxonName + " ");
304 if(textNewTaxonName.getMainControl() instanceof Text){
305 Text text = (Text)textNewTaxonName.getMainControl();
306 text.setSelection(textNewTaxonName.getText().length());
307 }
308 }
309 }
310 }
311 }
312 }
313
314 @Override
315 public void handleEvent(Object eventSource) {
316 if (eventSource == selection_parentTaxonNode) {
317 setParentTreeNode(selection_parentTaxonNode.getEntity());
318 } else if (eventSource == selection_reuseExistingTaxon) {
319 if (selection_reuseExistingTaxon.getEntity() != null){
320 setTaxon(selection_reuseExistingTaxon.getEntity());
321 if (getTaxon().getSec()!= null){
322 microReference.setText(getTaxon().getSecMicroReference());
323 if (isCreateNew()){
324 selection_SecRef.setEntity(getTaxon().getSec());
325 }else{
326 textTaxonSec.setText((getTaxon().getSec().getTitleCache()));
327 }
328 }else{
329 microReference.setText("");
330 if (isCreateNew()){
331 selection_SecRef.setEntity(null);
332 }else{
333 textTaxonSec.setText("");
334 }
335 }
336 checkbox_publish.setSelected(getTaxon().isPublish());
337 }
338 boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
339 if (selection_reuseExistingName != null){
340 selection_reuseExistingName.setEnabled(enabled);
341 }
342 if (textNewTaxonName != null){
343 textNewTaxonName.setEnabled(enabled);
344 }
345 complete = true;
346 } else if (eventSource == selection_reuseExistingName) {
347 boolean enabled = selection_reuseExistingName.getEntity() == null;
348 setTaxon(HibernateProxyHelper.deproxy(selection_reuseExistingName.getEntity()));
349 if (selection_reuseExistingTaxon != null){
350 selection_reuseExistingTaxon.setEnabled(enabled);
351 }
352 textNewTaxonName.setEnabled(enabled);
353 complete = !textNewTaxonName.getText().isEmpty();
354 } else if (eventSource == selection_SecRef) {
355 if (taxon != null){
356 taxon.setSec(selection_SecRef.getEntity());
357 }
358 } else if (eventSource == microReference) {
359 if (taxon != null){
360 taxon.setSecMicroReference(microReference.getText());
361 }
362
363 } else if (eventSource == checkbox_publish) {
364 if (taxon != null){
365 taxon.setPublish(checkbox_publish.getSelection());
366 }
367 }
368
369 if (eventSource == combo_status) {
370 status = combo_status.getSelection();
371 if (status == null){
372 if (multiLanguageTextStatusNotes.getMultilanguageText() != null && !multiLanguageTextStatusNotes.getMultilanguageText().isEmpty()){
373 multilanguageTextCache = new HashMap<>();
374 for (LanguageString langString: multiLanguageTextStatusNotes.getMultilanguageText().values()){
375 multilanguageTextCache.put(langString.getLanguage(), langString);
376 }
377 // multilanguageTextCache = multiLanguageTextStatusNotes.getMultilanguageText();
378 }
379 multiLanguageTextStatusNotes.setMultilanguageText(new HashMap<>());
380 // multiLanguageTextStatusNotes.refresh();
381
382 }else if (multilanguageTextCache != null ){
383
384 multiLanguageTextStatusNotes.setMultilanguageText(multilanguageTextCache);
385 multilanguageTextCache = null;
386 }
387 if (!isCreateNew()){
388 getEntity().setStatus(status);
389 if (status == null){
390 getEntity().getStatusNote().clear();
391 multiLanguageTextStatusNotes.setMultilanguageText(new HashMap<>());
392 multiLanguageTextStatusNotes.refresh();
393 }else{
394 if (multiLanguageTextStatusNotes.getMultilanguageText() != null){
395 for (LanguageString lang:multiLanguageTextStatusNotes.getMultilanguageText().values()){
396 getEntity().putStatusNote(lang);
397 }
398 }
399 }
400 }
401
402 multiLanguageTextStatusNotes.setEnabled(status != null);
403
404 complete = true;
405 }
406
407 if (eventSource == textNewTaxonName) {
408 boolean enabled = CdmUtils.isBlank(textNewTaxonName.getText());
409 if (selection_reuseExistingTaxon != null){
410 selection_reuseExistingTaxon.setEnabled(enabled);
411 }
412 selection_reuseExistingName.setEnabled(enabled);
413
414 complete = CdmUtils.isNotBlank(textNewTaxonName.getText());
415 }
416
417 if (eventSource == selectionNodeAgentRelation){
418 boolean allComplete = true;
419 for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
420 allComplete &=((TaxonNodeAgentRelationCollectionElement)element).isComplete();
421 }
422 complete = !isCreateNew() && allComplete;
423 }
424 }
425
426 public Classification getClassification() {
427 return classification;
428 }
429
430 public TaxonNode getParentTreeNode() {
431 return parentNode;
432 }
433
434 public void setParentTreeNode(TaxonNode parentTreeNode) {
435 this.parentNode = parentTreeNode;
436 updateContent();
437 if (parentTreeNode.getTaxon() == null) {
438 classification = parentTreeNode.getClassification();
439 if (selection_parentTaxonNode != null){
440 selection_parentTaxonNode.setEntity(classification.getRootNode());
441 selection_parentTaxonNode.setClassification(classification);
442 selection_SecRef.setEntity(classification.getReference());
443 }
444 } else {
445 classification = HibernateProxyHelper
446 .deproxy(parentTreeNode.getClassification());
447 if (selection_parentTaxonNode != null){
448 selection_parentTaxonNode.setEntity(HibernateProxyHelper.deproxy(parentTreeNode));
449 selection_parentTaxonNode.setClassification(classification);
450 selection_SecRef.setEntity(parentTreeNode.getTaxon().getSec());
451 }
452 }
453 }
454
455 @Override
456 protected void updateControlStates(){
457 Collection<Object> except = new ArrayList<Object>();
458 for(ICdmFormElement formElement:getElements()){
459 if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
460 except.add(formElement);
461 }
462 }
463 if (isCreateNew() ){
464 enabled = true;
465 }else{
466 enabled = getEntity() != null && CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud);
467 }
468 setEnabled(enabled, except);
469 }
470
471 private void setTreeNode(TaxonNode treeNode) {
472 classification = HibernateProxyHelper
473 .deproxy(treeNode.getClassification());
474 if (isCreateNew()){
475 selection_parentTaxonNode.setEntity(treeNode.getParent());
476 selection_parentTaxonNode.setClassification(treeNode.getParent().getClassification());
477 selection_SecRef.setEntity(treeNode.getTaxon().getSec());
478 }
479 }
480
481 private void setTaxon(Taxon taxon) {
482 this.taxon = taxon;
483 if (!isCreateNew()){
484 getEntity().setTaxon(taxon);
485 }
486 this.set_publish(taxon.isPublish());
487 if (isCreateNew()){
488 textNewTaxonName.setText(taxon.getName().getTitleCache());
489 if (taxon.getSec() != null){
490 selection_SecRef.setEntity(taxon.getSec());
491 }
492 }else{
493 if (taxon.getSec() != null) {
494 this.textTaxonSec.setText(taxon.getSec().getTitleCache());
495 }
496 }
497 }
498
499 private void setTaxon(TaxonName taxonName) {
500 Reference secundum = null;
501 if (getParentTreeNode() != null) {
502 if (this.selection_SecRef.getEntity() != null){
503 secundum = this.selection_SecRef.getEntity();
504 }
505 }
506 if (taxonName != null){
507 taxon = Taxon.NewInstance(taxonName, secundum);
508 if (textNewTaxonName.getText() == null || !taxonName.getTitleCache().trim().equals(textNewTaxonName.getText().trim())){
509 textNewTaxonName.setText(taxonName.getTitleCache());
510 }
511 if (!isCreateNew()){
512 getEntity().setTaxon(taxon);
513 }
514
515 } else {
516 textNewTaxonName.setText(null);
517 }
518 }
519
520 public String getTaxonName() {
521 return textNewTaxonName.getText();
522 }
523 public Taxon getTaxon() {
524 return taxon;
525 }
526
527 public Reference getSecReference(){
528 return selection_SecRef.getSelection();
529 }
530
531 public Control getMainControl(){
532 return textNewTaxonName.getMainControl();
533 }
534
535 public boolean isComplete() {
536 boolean allComplete = true;
537 if (!isCreateNew()){
538 for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
539 allComplete &=((TaxonNodeAgentRelationCollectionElement)element).isComplete();
540 }
541 complete = allComplete;
542 }
543 return complete;
544 }
545
546 public boolean isCreateNew() {
547 return createNew;
548 }
549
550 public boolean is_publish() {
551 boolean isPublishPreference = true;
552 CdmPreference defaultPublish = CdmPreferenceCache.instance().get(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
553 if (defaultPublish != null && defaultPublish.getValue()!= null && defaultPublish.getValue().equals(PublishEnum.NotPublish.getKey())){
554 isPublishPreference = false;
555 }
556 return checkbox_publish!=null?checkbox_publish.getSelection():isPublishPreference;
557 }
558
559 public void set_publish(boolean publish) {
560 this.checkbox_publish.setSelection(publish);
561 }
562
563 /**
564 * Updates all widgets to display the latest data
565 */
566 @Override
567 protected void updateContent() {
568 removeElements();
569 if (isCreateNew()){
570 createControls(this, parentNode, SWT.NONE);
571 }else{
572 createControls(this, getEntity(), SWT.NONE);
573 }
574 updateControlStates();
575 }
576
577 @Override
578 public SelectionArbitrator getSelectionArbitrator() {
579 // TODO Auto-generated method stub
580 return null;
581 }
582 }