9ef5fad361631fce5aab412479841515cbff25bf
[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.Map;
14
15 import org.apache.commons.lang3.StringUtils;
16 import org.eclipse.jface.resource.JFaceResources;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.graphics.Font;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Label;
21 import org.eclipse.swt.widgets.Text;
22
23 import eu.etaxonomy.cdm.common.CdmUtils;
24 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
25 import eu.etaxonomy.cdm.model.common.Language;
26 import eu.etaxonomy.cdm.model.common.LanguageString;
27 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
28 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
29 import eu.etaxonomy.cdm.model.metadata.PublishEnum;
30 import eu.etaxonomy.cdm.model.name.TaxonName;
31 import eu.etaxonomy.cdm.model.reference.NamedSource;
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.model.AbstractUtility;
39 import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
40 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
41 import eu.etaxonomy.taxeditor.preference.Resources;
42 import eu.etaxonomy.taxeditor.store.CdmStore;
43 import eu.etaxonomy.taxeditor.store.StoreUtil;
44 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
45 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
46 import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
47 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
48 import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
49 import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
50 import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
51 import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
52 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
53 import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractSingleSourceElement;
54 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
55 import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
56
57 /**
58 * @author n.hoffmann
59 * @created Sep 27, 2010
60 */
61 public class TaxonNodeDetailElement extends AbstractSingleSourceElement<TaxonNode> {
62
63 private static final String STATUS_PLACEMENT = Messages.TaxonNodeWizardPage_PLACEMENT_NOTES;
64 private static final String CLASSIFICATION_STR = Messages.TaxonNodeWizardPage_CLASSIFICATION;
65 private static final String REUSE_EXISTING_TAXON = Messages.TaxonNodeWizardPage_REUSE_EXISTING_TAXON;
66 private static final String REUSE_EXISTING_NAME = Messages.TaxonNodeWizardPage_REUSE_EXISTING_NAME;
67 private static final String SECUNDUM_REFERENCE = Messages.TaxonNodeWizardPage_SECUNDUM_REFERENCE;
68
69 private static final Font FONT_BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
70
71 private boolean createNew = false;
72 private Classification classification;
73 private TaxonNode parentNode;
74 private Taxon taxon;
75 private boolean complete;
76 private TaxonNodeStatus status = null;
77 // private Map<Language, LanguageString> multilanguageTextCache;
78
79 private TaxonNodeSelectionElement selection_parentTaxonNode;
80 private EntitySelectionElement<Taxon> selection_reuseExistingTaxon;
81 private EntitySelectionElement<TaxonName> selection_reuseExistingName;
82 private EntitySelectionElement<Reference> selection_SecRef;
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 multiLanguageTextPlacementNotes;
91 private String defaultPublish;
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 multiLanguageTextPlacementNotes.getMultilanguageText();
101 }
102
103 public TaxonNodeStatus getTaxonNodeStatus(){
104 return status;
105 }
106
107 public Reference getRef() {
108 return 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 public void createControls(ICdmFormElement formElement, TaxonNode entity, int style) {
119 // taxon = entity.getTaxon();
120
121 Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
122 taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
123 taxonTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
124 taxonTitle.setFont(FONT_BOLD);
125
126 if (isCreateNew()){
127 textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
128 Messages.TaxonNodeWizardPage_NEW_TAXON, "", style);
129 textNewTaxonName.setFocus();
130 textNewTaxonName.setIndent(10);
131
132 selection_reuseExistingTaxon = formFactory
133 .createSelectionElement(Taxon.class,
134 formElement,
135 REUSE_EXISTING_TAXON, null,
136 EntitySelectionElement.SELECTABLE, style);
137 selection_reuseExistingTaxon.setIndent(10);
138 selection_reuseExistingName = formFactory
139 .createSelectionElement(TaxonName.class,
140 formElement,
141 REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null,
142 EntitySelectionElement.DELETABLE, style);
143 selection_reuseExistingName.setIndent(10);
144 selection_SecRef = formFactory
145 .createSelectionElement(Reference.class,
146 formElement, SECUNDUM_REFERENCE, taxon != null? taxon.getSec(): null,
147 EntitySelectionElement.DELETABLE, style, 100);
148 selection_SecRef.setIndent(10);
149 microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", style);
150
151 microReference.setIndent(10);
152 checkbox_publish = formFactory.createCheckbox(formElement,
153 Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
154
155 checkbox_publish.setEnabled(isCreateNew());
156 checkbox_publish.setIndent(10);
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(formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
170 EntitySelectionElement.SELECTABLE, style, 100);
171 selection_parentTaxonNode.setIndent(10);
172 selection_parentTaxonNode.setEnabled(false);
173
174
175
176 }else{
177 taxon = getEntity().getTaxon();
178 selection_reuseExistingTaxon = formFactory
179 .createSelectionElement(Taxon.class, formElement,
180 Messages.TaxonNodeWizardPage_TAXON, taxon,
181 EntitySelectionElement.SELECTABLE, SWT.NULL);
182
183 selection_reuseExistingTaxon.setIndent(10);
184 textTaxonSec = formFactory.createTextWithLabelElement(formElement,SECUNDUM_REFERENCE, "", SWT.NULL);
185 textTaxonSec.setIndent(10);
186 microReference = formFactory.createTextWithLabelElement(formElement, "Secundum Details", "", SWT.NULL);
187 microReference.setIndent(10);
188
189 if (entity.getTaxon().getSec() != null){
190 textTaxonSec.setText(taxon.getSec().getTitleCache());
191 }
192 textTaxonSec.setEnabled(false);
193 microReference.setEnabled(false);
194 Label spacer = new Label(getLayoutComposite(), SWT.NULL);
195 spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
196
197 Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
198 nodeTitle.setText("Taxon Node");
199 nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
200 nodeTitle.setFont(FONT_BOLD);
201
202 // LabelElement nodeTitle = formFactory.createLabel(formElement, "Taxon Node");
203 // nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
204 // nodeTitle.setBackground(getPersistentBackground());
205 // nodeTitle.setBold();
206
207
208 if (entity.getParent().getTaxon() == null){
209 TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
210 formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), SWT.NULL);
211 textParent.setEnabled(false);
212 textParent.setIndent(10);
213 }else{
214 TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
215 formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), SWT.NULL);
216 textParent.setEnabled(false);
217 textParent.setIndent(10);
218 }
219 }
220
221
222 combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, SWT.NULL, true);
223 if (!isCreateNew()){
224 combo_status.setSelection(entity.getStatus());
225 }
226 combo_status.setIndent(10);
227 if(isCreateNew()){
228
229 defaultPublish = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
230 setDefaultPublish();
231 } else{
232 setTreeNode(entity);
233 complete = true;
234 }
235
236 if (isCreateNew()){
237 preFillTaxonName();
238 }
239
240 multiLanguageTextPlacementNotes = formFactory.createMultiLanguageTextElement(formElement, STATUS_PLACEMENT, null, 50, style);
241 if (!isCreateNew()){
242 multiLanguageTextPlacementNotes.setMultilanguageText(entity.getStatusNote());
243 // multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
244 }
245 multiLanguageTextPlacementNotes.setIndent(10);
246 singleSourceSection = formFactory.createOriginalSourceElement(formElement, entity, "");
247 if (isCreateNew() || entity.getSource() == null){
248 NamedSource source = NamedSource.NewPrimarySourceInstance(null, null);
249 entity.setSource(source);
250 singleSourceSection.setEntity(source);
251 }else{
252 singleSourceSection.setEntity(entity.getSource());
253
254 }
255 singleSourceSection.setIndent(10);
256
257 setSourceLabel(Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE);
258
259 selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
260 selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
261 selectionNodeAgentRelation.setEntity(entity);
262 selectionNodeAgentRelation.setIndent(10);
263 selectionNodeAgentRelation.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
264 setBackground(getPersistentBackground());
265 }
266
267 private void setDefaultPublish() {
268 if (defaultPublish != null && defaultPublish.equals(PublishEnum.Publish.getKey())){
269 checkbox_publish.setSelection(true);
270 } else if (defaultPublish != null && defaultPublish.equals(PublishEnum.NotPublish.getKey())){
271 checkbox_publish.setSelection(false);
272 }else{
273 if(this.getParentTreeNode() != null && this.getParentTreeNode().isInstanceOf(TaxonNode.class) && this.getParentTreeNode().getTaxon() != null){
274 checkbox_publish.setSelection(this.getParentTreeNode().getTaxon().isPublish());
275 }else{
276 checkbox_publish.setSelection(true);
277 }
278 }
279 }
280
281 private void preFillTaxonName() {
282 TaxonNode node = parentNode;
283 if(node != null && node.getTaxon()!=null){
284 Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
285 if(taxon.getName()!=null){
286 TaxonName name = HibernateProxyHelper.deproxy(node.getTaxon().getName());
287 if (!isCreateNew()){
288 textNewTaxonName.setText(name.getNameCache());
289 } else if( ! name.isSupraGeneric() && name.getRank() != null){
290 String taxonName = "";
291 if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
292 taxonName = name.getGenusOrUninomial();
293 }
294 else if(name.isSpecies() || name.isInfraSpecific() ){
295 taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
296 }
297 if (StringUtils.isNotBlank(taxonName)){
298 textNewTaxonName.setText(taxonName + " ");
299 if(textNewTaxonName.getMainControl() instanceof Text){
300 Text text = (Text)textNewTaxonName.getMainControl();
301 text.setSelection(textNewTaxonName.getText().length());
302 }
303 }
304 }
305 }
306 }
307 }
308
309 @Override
310 public void handleEvent(Object eventSource) {
311 if (eventSource == selection_parentTaxonNode) {
312 setParentTreeNode(selection_parentTaxonNode.getEntity());
313 } else if (eventSource == selection_reuseExistingTaxon) {
314 if (selection_reuseExistingTaxon.getEntity() != null){
315 setTaxon(selection_reuseExistingTaxon.getEntity());
316 if (getTaxon().getSec()!= null){
317 microReference.setText(getTaxon().getSecMicroReference());
318 if (isCreateNew()){
319 selection_SecRef.setEntity(getTaxon().getSec());
320
321 }else{
322 textTaxonSec.setText((getTaxon().getSec().getTitleCache()));
323 }
324 }else{
325 microReference.setText("");
326 if (isCreateNew()){
327 selection_SecRef.setEntity(null);
328
329 }else{
330 textTaxonSec.setText("");
331 }
332 }
333 if (checkbox_publish != null){
334 checkbox_publish.setSelected(getTaxon().isPublish());
335 }
336 }else{
337 if (isCreateNew()){
338 selection_SecRef.setEntity(null);
339 }else{
340 textTaxonSec.setText(null);
341 }
342 setDefaultPublish();
343 }
344 boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
345 if (selection_reuseExistingName != null){
346 selection_reuseExistingName.setEnabled(enabled);
347 }
348 if (selection_SecRef != null){
349 selection_SecRef.setEnabled(enabled);
350 }
351 if (textNewTaxonName != null){
352 textNewTaxonName.setEnabled(enabled);
353 }
354 complete = true;
355 } else if (eventSource == selection_reuseExistingName) {
356 boolean enabled = selection_reuseExistingName.getEntity() == null;
357 setTaxon(HibernateProxyHelper.deproxy(selection_reuseExistingName.getEntity()));
358 if (selection_reuseExistingTaxon != null){
359 selection_reuseExistingTaxon.setEnabled(enabled);
360 }
361 textNewTaxonName.setEnabled(enabled);
362 if (textNewTaxonName.getText() != null){
363 complete = !textNewTaxonName.getText().isEmpty();
364 }else {
365 complete = false;
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
487 this.set_publish(taxon.isPublish());
488 if (isCreateNew()){
489 textNewTaxonName.setText(taxon.getName().getTitleCache());
490 if (taxon.getSec() != null){
491 selection_SecRef.setEntity(taxon.getSec());
492 }
493 }else{
494 if (taxon.getSec() != null) {
495 this.textTaxonSec.setText(taxon.getSec().getTitleCache());
496 }
497 }
498 }
499
500 private void setTaxon(TaxonName taxonName) {
501 Reference secundum = null;
502 if (getParentTreeNode() != null) {
503 if (this.selection_SecRef.getEntity() != null){
504 secundum = this.selection_SecRef.getEntity();
505 }
506 }
507 if (taxonName != null){
508 textNewTaxonName.setText(taxonName.getTitleCache());
509 }else{
510 textNewTaxonName.setText("");
511 if (selection_reuseExistingTaxon != null){
512 selection_reuseExistingTaxon.setEnabled(true);
513 }
514 textNewTaxonName.setEnabled(true);
515
516 }
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 if (checkbox_publish != null){
561 this.checkbox_publish.setSelection(publish);
562 }
563 }
564
565 /**
566 * Updates all widgets to display the latest data
567 */
568 @Override
569 protected void updateContent() {
570 removeElements();
571 if (isCreateNew()){
572 createControls(this, parentNode, SWT.NONE);
573 }else{
574 createControls(this, getEntity(), SWT.NONE);
575 }
576 updateControlStates();
577 }
578
579 @Override
580 public SelectionArbitrator getSelectionArbitrator() {
581 // TODO Auto-generated method stub
582 return null;
583 }
584 }