package eu.etaxonomy.taxeditor.ui.section.classification;
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
import org.apache.commons.lang.StringUtils;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import eu.etaxonomy.cdm.model.common.LanguageString;
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PublishEnum;
import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
* @created Sep 27, 2010
* @version 1.0
*/
-public class TaxonNodeDetailElement extends AbstractCdmDetailElement<ITaxonTreeNode> {
+public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode> {
private boolean createNew = false;
-
- private EntitySelectionElement<Classification> selection_classification;
-
private Classification classification;
+ private TaxonNode parentNode;
+ private Taxon taxon;
private TaxonNodeSelectionElement selection_parentTaxonNode;
-
- private ITaxonTreeNode parentTreeNode;
-
private EntitySelectionElement<Taxon> selection_reuseExistingTaxon;
- private EntitySelectionElement<Reference> selection_SecRef;
+ private EntitySelectionElement<TaxonName> selection_reuseExistingName;
+
+ private EntitySelectionElement<Reference> selection_SecRef;
private EntitySelectionElement<Reference> selection_Ref;
+
+
+ TextWithLabelElement textTaxonSec;
+
private TextWithLabelElement microReference;
- private Taxon taxon;
- private TextWithLabelElement textNewTaxonName;
+ private TextWithLabelElement textNewTaxonName;
private TaxonNodeAgentRelationCollectionSection selectionNodeAgentRelation;
- private CheckboxElement checkbox_openInEditor;
-
private CheckboxElement checkbox_unplaced;
-
private CheckboxElement checkbox_excluded;
private CheckboxElement checkbox_publish;
-
-
+ private CheckboxElement checkbox_placementDoubtful;
private MultilanguageTextElement multiLanguageTextExcludedNotes;
- private boolean openInEditor;
private boolean complete;
private boolean excluded = false;
private boolean unplaced = false;
+ private boolean placementDoubtful = false;
+
- private EntitySelectionElement<TaxonName> selection_reuseExistingName;
public TaxonNodeDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement, boolean isCreateNew) {
}
+ public Map<Language, LanguageString> getMultiLanguageTextExcludedNotes() {
+ return multiLanguageTextExcludedNotes.getMultilanguageText();
+ }
+
+
+
+ public boolean isExcluded() {
+ return excluded;
+ }
+
+
+
+ public boolean isUnplaced() {
+ return unplaced;
+ }
+
+
+
+ public boolean isPlacementDoubtful() {
+ return placementDoubtful;
+ }
+
+ public Reference getRef() {
+ return selection_Ref.getEntity();
+ }
+ public TaxonName getExistingName() {
+ return selection_reuseExistingName.getEntity();
+ }
+ public String getMicroReference() {
+ return microReference.getText();
+ }
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement,
- ITaxonTreeNode entity, int style) {
+ TaxonNode entity, int style) {
+// taxon = entity.getTaxon();
+
if (isCreateNew()){
- selection_classification = formFactory
- .createSelectionElement(Classification.class,//getConversationHolder(),
- formElement, "Classification",
- null, EntitySelectionElement.DELETABLE, style);
+// setParentTreeNode(entity);
selection_parentTaxonNode = formFactory
- .createTaxonNodeSelectionElement(getConversationHolder(), formElement, "Parent", null,
- EntitySelectionElement.DELETABLE, style);
+ .createTaxonNodeSelectionElement(getConversationHolder(), formElement, "Parent", parentNode,
+ EntitySelectionElement.DELETABLE, style, 100);
+
+ selection_Ref = formFactory
+ .createSelectionElement(Reference.class,
+ formElement, "Parent Child Relation Source", null,
+ EntitySelectionElement.DELETABLE, style, 100);
+
+ microReference = formFactory.createTextWithLabelElement(formElement,"Detail", "", style);
+ microReference.setText(parentNode.getMicroReference());
selection_reuseExistingTaxon = formFactory
.createSelectionElement(Taxon.class,//getConversationHolder(),
selection_reuseExistingName = formFactory
.createSelectionElement(TaxonName.class,//getConversationHolder(),
formElement,
- "Reuse existing name", null,
+ "Reuse existing name", taxon != null? taxon.getName(): null,
EntitySelectionElement.DELETABLE, style);
selection_SecRef = formFactory
.createSelectionElement(Reference.class,//getConversationHolder(),
- formElement, "Secundum Reference", null,
- EntitySelectionElement.DELETABLE, style);
+ formElement, "Secundum Reference", taxon != null? taxon.getSec(): null,
+ EntitySelectionElement.DELETABLE, style, 100);
if (isCreateNew()){
textNewTaxonName = formFactory.createTextWithLabelElement(formElement,"New Taxon", "", style);
}
}else{
- TextWithLabelElement textClassification = formFactory.createTextWithLabelElement(formElement,"Classification", ((TaxonNode)entity).getClassification().getTitleCache(), style);
- textClassification.setEnabled(false);
+ taxon = getEntity().getTaxon();
+ if (entity.getParent().getTaxon() == null){
+ TextWithLabelElement textParent = formFactory.createTextWithLabelElement(formElement,"Classification", entity.getClassification().getTitleCache(), style);
+ textParent.setEnabled(false);
+ }else{
+ TextWithLabelElement textParent = formFactory.createTextWithLabelElement(formElement,"Parent", entity.getParent().getTaxon().getTitleCache(), style);
+ textParent.setEnabled(false);
+ }
+
+ selection_Ref = formFactory
+ .createSelectionElement(Reference.class,
+ formElement, "Parent Child Relation Source", null,
+ EntitySelectionElement.DELETABLE, style);
- TextWithLabelElement textTaxon = formFactory.createTextWithLabelElement(formElement,"Taxon", ((TaxonNode)entity).getTaxon().getTitleCache(), style);
- textTaxon.setEnabled(false);
+ selection_reuseExistingTaxon = formFactory
+ .createSelectionElement(Taxon.class,//getConversationHolder(),
+ formElement,
+ "Taxon", taxon,
+ EntitySelectionElement.DELETABLE, style);
- TextWithLabelElement textTaxonSec = formFactory.createTextWithLabelElement(formElement,"Secundum Reference", "", style);
- if (((TaxonNode)entity).getTaxon().getSec() != null){
- textTaxonSec.setText(((TaxonNode)entity).getTaxon().getSec().getTitleCache());
+ textTaxonSec = formFactory.createTextWithLabelElement(formElement,"Secundum Reference", "", style);
+ if (entity.getTaxon().getSec() != null){
+ textTaxonSec.setText(taxon.getSec().getTitleCache());
}
textTaxonSec.setEnabled(false);
}
- selection_Ref = formFactory
- .createSelectionElement(Reference.class,//getConversationHolder(),
- formElement, "Parent Child Relation Source", null,
- EntitySelectionElement.DELETABLE, style);
- microReference = formFactory.createTextWithLabelElement(formElement,"Detail", "", style);
if (!isCreateNew()){
- selection_Ref.setEntity(entity.getReference());
+ if (entity.getReference() != null){
+ selection_Ref.setEntity(entity.getReference());
+ }
+
}
- if (entity instanceof TaxonNode) {
- checkbox_publish = formFactory.createCheckbox(formElement,
- "Taxon is public", ((TaxonNode)entity).getTaxon().isPublish(), style);
- }else{
- checkbox_publish = formFactory.createCheckbox(formElement,
- "Taxon is public", true, style);
- }
- checkbox_publish.setEnabled(isCreateNew());
+
+
+ Taxon tax = null;
+ if (entity.getTaxon() != null){
+ tax = entity.getTaxon();
+ }
+ checkbox_publish = formFactory.createCheckbox(formElement,
+ "Taxon is published", tax != null? tax.isPublish(): true, style);
+
+
+ checkbox_publish.setEnabled(isCreateNew());
+
+ checkbox_placementDoubtful = formFactory.createCheckbox(formElement,
+ "Placement is doubtful", tax!= null? entity.isDoubtful(): false, style);
+
+
+
if(isCreateNew()){
- CdmPreference defaultPublish = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
- if (defaultPublish != null && defaultPublish.getValue().equals(IPreferenceKeys.PUBLISH)){
+
+
+ String defaultPublish = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
+ if (defaultPublish != null && defaultPublish.equals(PublishEnum.Publish.getKey())){
checkbox_publish.setSelection(true);
- } else if (defaultPublish != null && defaultPublish.getValue().equals(IPreferenceKeys.DO_NOT_PUBLISH)){
+ } else if (defaultPublish != null && defaultPublish.equals(PublishEnum.NotPublish.getKey())){
checkbox_publish.setSelection(false);
}else{
- if(this.getParentTreeNode() != null && this.getParentTreeNode().isInstanceOf(TaxonNode.class)){
- checkbox_publish.setSelection(((TaxonNode)this.getParentTreeNode()).getTaxon().isPublish());
+ if(this.getParentTreeNode() != null && this.getParentTreeNode().isInstanceOf(TaxonNode.class) && this.getParentTreeNode().getTaxon() != null){
+ checkbox_publish.setSelection(this.getParentTreeNode().getTaxon().isPublish());
}else{
checkbox_publish.setSelection(true);
}
}
- setParentTreeNode(entity);
+
} else{
setTreeNode(entity);
complete = true;
}
- if (entity instanceof TaxonNode) {
- checkbox_unplaced = formFactory.createCheckbox(formElement,
- "Taxon is unplaced", ((TaxonNode)entity).isUnplaced(), style);
- }else{
- checkbox_unplaced = formFactory.createCheckbox(formElement,
- "Taxon is unplaced", false, style);
- }
+
+ checkbox_unplaced = formFactory.createCheckbox(formElement,
+ "Taxon is unplaced", entity.isUnplaced(), style);
+
if (isCreateNew()){
preFillTaxonName();
}
- if (entity instanceof TaxonNode) {
- checkbox_excluded = formFactory.createCheckbox(formElement,
- "Taxon is excluded", ((TaxonNode)entity).isExcluded(), style);
- multiLanguageTextExcludedNotes = formFactory.createMultiLanguageTextElement(formElement, "Excluded Notes", ((TaxonNode)entity).getExcludedNote(), 50, style);
- multiLanguageTextExcludedNotes.setEnabled(((TaxonNode) entity).isExcluded());
- }else{
- checkbox_excluded = formFactory.createCheckbox(formElement,
- "Taxon is excluded", false, style);
- multiLanguageTextExcludedNotes = formFactory.createMultiLanguageTextElement(formElement, "Excluded Notes", new HashMap<Language, LanguageString>(), 50, style);
- multiLanguageTextExcludedNotes.setEnabled(false);
- }
+ checkbox_excluded = formFactory.createCheckbox(formElement,
+ "Taxon is excluded", entity.isExcluded(), style);
+ multiLanguageTextExcludedNotes = formFactory.createMultiLanguageTextElement(formElement, "Excluded Notes", entity.getExcludedNote(), 50, style);
+ multiLanguageTextExcludedNotes.setEnabled(entity.isExcluded());
+
if (!isCreateNew()){
- selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), style);
- selectionNodeAgentRelation.setEntity((TaxonNode)entity);
+ selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
+ selectionNodeAgentRelation.setEntity(entity);
selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
}
- checkbox_openInEditor = formFactory.createCheckbox(formElement,
- "Open in Editor", true, style);
- setOpenInEditor(true);
+
}
private void preFillTaxonName() {
- if(getEntity() instanceof TaxonNode ){
- TaxonNode node = (TaxonNode)getEntity();
- if(node.getTaxon()!=null){
- Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
- if(taxon.getName()!=null){
- TaxonName name = HibernateProxyHelper.deproxy(node.getTaxon().getName());
- if (!isCreateNew()){
- textNewTaxonName.setText(name.getNameCache());
- } else if( ! name.isSupraGeneric() && name.getRank() != null){
- String taxonName = "";
- if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
- taxonName = name.getGenusOrUninomial();
- }
- else if(name.isSpecies() || name.isInfraSpecific() ){
- taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
- }
- if (StringUtils.isNotBlank(taxonName)){
- textNewTaxonName.setText(taxonName + " ");
- if(textNewTaxonName.getMainControl() instanceof Text){
- Text text = (Text)textNewTaxonName.getMainControl();
- text.setSelection(textNewTaxonName.getText().length());
- }
- }
+ TaxonNode node = parentNode;
+ if(node.getTaxon()!=null){
+ Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
+ if(taxon.getName()!=null){
+ TaxonName name = HibernateProxyHelper.deproxy(node.getTaxon().getName());
+ if (!isCreateNew()){
+ textNewTaxonName.setText(name.getNameCache());
+ } else if( ! name.isSupraGeneric() && name.getRank() != null){
+ String taxonName = "";
+ if(name.isGenus() || name.isInfraGeneric()|| name.isSpeciesAggregate() ){
+ taxonName = name.getGenusOrUninomial();
+ }
+ else if(name.isSpecies() || name.isInfraSpecific() ){
+ taxonName = CdmUtils.concat(" ", name.getGenusOrUninomial(),name.getSpecificEpithet());
+ }
+ if (StringUtils.isNotBlank(taxonName)){
+ textNewTaxonName.setText(taxonName + " ");
+ if(textNewTaxonName.getMainControl() instanceof Text){
+ Text text = (Text)textNewTaxonName.getMainControl();
+ text.setSelection(textNewTaxonName.getText().length());
+ }
}
}
}
}
+
}
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if (eventSource == selection_classification) {
- setClassification(selection_classification.getEntity());
- } else if (eventSource == selection_parentTaxonNode) {
- setParentTreeNode(selection_parentTaxonNode.getEntity());
+ if (eventSource == selection_parentTaxonNode) {
+ setParentTreeNode(selection_parentTaxonNode.getEntity());
} else if (eventSource == selection_reuseExistingTaxon) {
- boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
- selection_reuseExistingName.setEnabled(enabled);
- if (!enabled){
- setTaxon(selection_reuseExistingTaxon.getEntity());
- }else{
- textNewTaxonName.setText(null);
- }
- complete = !textNewTaxonName.getText().isEmpty();
-
-
+ if (selection_reuseExistingTaxon.getEntity() != null){
+ setTaxon(selection_reuseExistingTaxon.getEntity());
+ if (getTaxon().getSec()!= null){
+ if (isCreateNew()){
+ selection_SecRef.setEntity(getTaxon().getSec());
+ }else{
+ textTaxonSec.setText((getTaxon().getSec().getTitleCache()));
+ }
+ }else{
+ if (isCreateNew()){
+ selection_SecRef.setEntity(null);
+ }else{
+ textTaxonSec.setText("");
+ }
+ }
+ checkbox_publish.setSelected(getTaxon().isPublish());
+ }
+ boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
+ if (selection_reuseExistingName != null){
+ selection_reuseExistingName.setEnabled(enabled);
+ }
+ if (textNewTaxonName != null){
+ textNewTaxonName.setEnabled(enabled);
+ }
+ complete = true;
} else if (eventSource == selection_reuseExistingName) {
boolean enabled = selection_reuseExistingName.getEntity() == null;
- setTaxon(selection_reuseExistingName.getEntity());
- selection_reuseExistingTaxon.setEnabled(enabled);
+ setTaxon(HibernateProxyHelper.deproxy(selection_reuseExistingName.getEntity()));
+ if (selection_reuseExistingTaxon != null){
+ selection_reuseExistingTaxon.setEnabled(enabled);
+ }
textNewTaxonName.setEnabled(enabled);
-
complete = !textNewTaxonName.getText().isEmpty();
}
- if (!isCreateNew()){
- if (eventSource == selection_Ref) {
- ((TaxonNode) getEntity()).setReference(selection_Ref.getEntity());
- }else if (eventSource == selection_SecRef) {
- ((TaxonNode) getEntity()).getTaxon().setSec(selection_SecRef.getEntity());
- }else if (eventSource == microReference) {
- ((TaxonNode) getEntity()).setMicroReference(microReference.getText());
- } else if (eventSource == checkbox_publish) {
- ((TaxonNode)getEntity()).getTaxon().setPublish(checkbox_publish.getSelection());
+
+ if (eventSource == selection_Ref) {
+ if(!isCreateNew()){
+ getEntity().setReference(selection_Ref.getEntity());
}
- }
+ }else if (eventSource == selection_SecRef) {
+ if (taxon != null){
+ taxon.setSec(selection_SecRef.getEntity());
+ }
+ }else if (eventSource == microReference) {
+ if(!isCreateNew()){
+ getEntity().setMicroReference(microReference.getText());
+ }
+ } else if (eventSource == checkbox_publish) {
+ if (taxon != null){
+ taxon.setPublish(checkbox_publish.getSelection());
+ }
+ }
+
if (eventSource == checkbox_excluded) {
excluded = checkbox_excluded.getSelection();
if (!isCreateNew()){
- ((TaxonNode)getEntity()).setExcluded(excluded);
+ getEntity().setExcluded(excluded);
}
+
multiLanguageTextExcludedNotes.setEnabled(excluded);
}
if (eventSource == checkbox_unplaced) {
unplaced = checkbox_unplaced.getSelection();
if (!isCreateNew()){
- ((TaxonNode)getEntity()).setUnplaced(unplaced);
+ getEntity().setUnplaced(unplaced);
}
+
+ }
+
+ if (eventSource == checkbox_placementDoubtful) {
+ placementDoubtful = checkbox_placementDoubtful.getSelection();
+ if (!isCreateNew()){
+ getEntity().setDoubtful(placementDoubtful);
+ }
+
}
if (eventSource == textNewTaxonName) {
boolean enabled = CdmUtils.isBlank(textNewTaxonName.getText());
- selection_reuseExistingTaxon.setEnabled(enabled);
+ if (selection_reuseExistingTaxon != null){
+ selection_reuseExistingTaxon.setEnabled(enabled);
+ }
selection_reuseExistingName.setEnabled(enabled);
complete = CdmUtils.isNotBlank(textNewTaxonName.getText());
}
- if (eventSource == checkbox_openInEditor) {
- setOpenInEditor(checkbox_openInEditor.getSelection());
- }
+
if (eventSource == selectionNodeAgentRelation){
boolean allComplete = true;
for (ICdmFormElement element : selectionNodeAgentRelation.getElements()){
return classification;
}
- public boolean isOpenInEditor() {
- return openInEditor;
- }
- public ITaxonTreeNode getParentTreeNode() {
- return parentTreeNode;
- }
- private void setClassification(Classification classification) {
- this.classification = classification;
- setParentTreeNode(classification);
+ public TaxonNode getParentTreeNode() {
+ return parentNode;
}
- private void setParentTreeNode(ITaxonTreeNode parentTreeNode) {
- this.parentTreeNode = parentTreeNode;
-
- if (parentTreeNode instanceof Classification) {
- classification = (Classification) parentTreeNode;
- selection_classification.setEntity(classification);
- selection_parentTaxonNode.setEntity(null);
- selection_parentTaxonNode.setClassification(classification);
- selection_SecRef.setEntity(classification.getReference());
- } else if (parentTreeNode instanceof TaxonNode) {
+ public void setParentTreeNode(TaxonNode parentTreeNode) {
+ this.parentNode = parentTreeNode;
+ updateContent();
+ if (parentTreeNode.getTaxon() == null) {
+ classification = parentTreeNode.getClassification();
+ if (selection_parentTaxonNode != null){
+ selection_parentTaxonNode.setEntity(classification.getRootNode());
+ selection_parentTaxonNode.setClassification(classification);
+ selection_SecRef.setEntity(classification.getReference());
+ }
+ } else {
classification = HibernateProxyHelper
- .deproxy(((TaxonNode) parentTreeNode).getClassification());
- selection_classification.setEntity(classification);
- selection_parentTaxonNode.setEntity(HibernateProxyHelper
- .deproxy((TaxonNode) parentTreeNode));
- selection_parentTaxonNode.setClassification(classification);
- selection_SecRef.setEntity(((TaxonNode)parentTreeNode).getTaxon().getSec());
- } else if(parentTreeNode == null){
- this.parentTreeNode = selection_classification.getEntity();
+ .deproxy(parentTreeNode.getClassification());
+ if (selection_parentTaxonNode != null){
+ selection_parentTaxonNode.setEntity(HibernateProxyHelper.deproxy(parentTreeNode));
+ selection_parentTaxonNode.setClassification(classification);
+ selection_SecRef.setEntity(parentTreeNode.getTaxon().getSec());
+ }
+
+
}
}
+ @Override
+ protected void updateControlStates(){
+ Collection<Object> except = new ArrayList<Object>();
+ for(ICdmFormElement formElement:getElements()){
+ if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
+ except.add(formElement);
+ }
+ }
+ if (isCreateNew() ){
+ enabled = true;
+ }else{
+ enabled = getEntity() != null && CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud);
+ }
+ setEnabled(enabled, except);
+ }
- private void setTreeNode(ITaxonTreeNode treeNode) {
+ private void setTreeNode(TaxonNode treeNode) {
classification = HibernateProxyHelper
- .deproxy(((TaxonNode) treeNode).getClassification());
+ .deproxy(treeNode.getClassification());
if (isCreateNew()){
- selection_classification.setEntity(classification);
- selection_parentTaxonNode.setEntity(((TaxonNode) treeNode).getParent());
- selection_parentTaxonNode.setClassification(((TaxonNode) treeNode).getParent().getClassification());
- selection_SecRef.setEntity(((TaxonNode)treeNode).getTaxon().getSec());
+ selection_parentTaxonNode.setEntity(treeNode.getParent());
+ selection_parentTaxonNode.setClassification(treeNode.getParent().getClassification());
+ selection_SecRef.setEntity(treeNode.getTaxon().getSec());
}
}
private void setTaxon(Taxon taxon) {
this.taxon = taxon;
+ if (!isCreateNew()){
+ getEntity().setTaxon(taxon);
+ }
+ this.set_publish(taxon.isPublish());
if (isCreateNew()){
textNewTaxonName.setText(taxon.getName().getTitleCache());
+ if (taxon.getSec() != null){
+ selection_SecRef.setEntity(taxon.getSec());
+ }
+ }else{
+ if (taxon.getSec() != null) {
+ this.textTaxonSec.setText(taxon.getSec().getTitleCache());
+ }
}
- selection_SecRef.setEntity(taxon.getSec());
+
+
}
private void setTaxon(TaxonName taxonName) {
if (textNewTaxonName.getText() == null || !taxonName.getTitleCache().trim().equals(textNewTaxonName.getText().trim())){
textNewTaxonName.setText(taxonName.getTitleCache());
}
-// if (!taxonName.getTitleCache().trim().equals(textNewTaxonName.getText().trim())){
-// textNewTaxonName.setText(taxonName.getTitleCache());
-// }
+ if (!isCreateNew()){
+ getEntity().setTaxon(taxon);
+ }
+
} else {
textNewTaxonName.setText(null);
}
}
- private void setOpenInEditor(boolean openInEditor) {
- this.openInEditor = openInEditor;
- }
-
public String getTaxonName() {
return textNewTaxonName.getText();
}
return taxon;
}
- public Reference getReference(){
+ public Reference getSecReference(){
return selection_SecRef.getSelection();
}
return createNew;
}
- public boolean isExcluded() {
- return excluded;
- }
-
- public boolean isUnplaced() {
- return unplaced;
- }
-
public boolean is_publish() {
boolean isPublishPreference = true;
- CdmPreference defaultPublish = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
- if (defaultPublish != null && defaultPublish.getValue().equals(IPreferenceKeys.DO_NOT_PUBLISH)){
+ CdmPreference defaultPublish = CdmPreferenceCache.instance().get(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey());
+ if (defaultPublish != null && defaultPublish.getValue()!= null && defaultPublish.getValue().equals(PublishEnum.NotPublish.getKey())){
isPublishPreference = false;
}
return checkbox_publish!=null?checkbox_publish.getSelection():isPublishPreference;
this.checkbox_publish.setSelection(publish);
}
+ /**
+ * Updates all widgets to display the latest data
+ */
+ @Override
+ protected void updateContent() {
+ removeElements();
+ if (isCreateNew()){
+ createControls(this, parentNode, SWT.NONE);
+ }else{
+ createControls(this, getEntity(), SWT.NONE);
+ }
+ updateControlStates();
+ }
+
}