package eu.etaxonomy.taxeditor.ui.section.classification;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.TableWrapData;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.LanguageString;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.cdm.model.metadata.PublishEnum;
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
private static final String REUSE_EXISTING_NAME = Messages.TaxonNodeWizardPage_REUSE_EXISTING_NAME;
private static final String SECUNDUM_REFERENCE = Messages.TaxonNodeWizardPage_SECUNDUM_REFERENCE;
+ private static final Font FONT_BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
+
private boolean createNew = false;
private Classification classification;
private TaxonNode parentNode;
private EntitySelectionElement<Taxon> selection_reuseExistingTaxon;
private EntitySelectionElement<TaxonName> selection_reuseExistingName;
private EntitySelectionElement<Reference> selection_SecRef;
- private EntitySelectionElement<Reference> selection_Ref;
+
+ private OriginalSourceElement sourceSection;
+
private TextWithLabelElement textTaxonSec;
private TextWithLabelElement microReference;
private TextWithLabelElement textNewTaxonName;
}
public Reference getRef() {
- return selection_Ref.getEntity();
+ return sourceSection.getEntity().getCitation();
}
public TaxonName getExistingName() {
return selection_reuseExistingName.getEntity();
protected void createControls(ICdmFormElement formElement,
TaxonNode entity, int style) {
// taxon = entity.getTaxon();
+ Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
+ taxonTitle.setText("Taxon Information");
+ TableWrapData tableWrap = LayoutConstants.FILL_HORIZONTALLY(2, 2);
+ tableWrap.valign = SWT.TOP;
+ taxonTitle.setLayoutData(tableWrap);
+ taxonTitle.setFont(FONT_BOLD);
if (isCreateNew()){
-// setParentTreeNode(entity);
- selection_parentTaxonNode = formFactory
- .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
- EntitySelectionElement.DELETABLE, style, 100);
-
- selection_Ref = formFactory
- .createSelectionElement(Reference.class,
- formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null,
- EntitySelectionElement.DELETABLE, style, 100);
+ textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
+ Messages.TaxonNodeWizardPage_NEW_TAXON, "", style);
+ textNewTaxonName.setFocus();
- microReference = formFactory.createTextWithLabelElement(formElement,
- Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE_DETAIL, "", style);
- microReference.setText(parentNode.getMicroReference());
-
- selection_reuseExistingTaxon = formFactory
- .createSelectionElement(Taxon.class,//getConversationHolder(),
- formElement,
- REUSE_EXISTING_TAXON, null,
- EntitySelectionElement.DELETABLE, style);
-
- selection_reuseExistingName = formFactory
- .createSelectionElement(TaxonName.class,//getConversationHolder(),
- formElement,
- REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null,
- EntitySelectionElement.DELETABLE, style);
- selection_SecRef = formFactory
+ selection_reuseExistingTaxon = formFactory
+ .createSelectionElement(Taxon.class,//getConversationHolder(),
+ formElement,
+ REUSE_EXISTING_TAXON, null,
+ EntitySelectionElement.DELETABLE, style);
+
+ selection_reuseExistingName = formFactory
+ .createSelectionElement(TaxonName.class,//getConversationHolder(),
+ formElement,
+ REUSE_EXISTING_NAME, taxon != null? taxon.getName(): null,
+ EntitySelectionElement.DELETABLE, style);
+ selection_SecRef = formFactory
.createSelectionElement(Reference.class,//getConversationHolder(),
formElement, SECUNDUM_REFERENCE, taxon != null? taxon.getSec(): null,
EntitySelectionElement.DELETABLE, style, 100);
- if (isCreateNew()){
- textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
- Messages.TaxonNodeWizardPage_NEW_TAXON, "", style);
- textNewTaxonName.setFocus();
- } else{
- textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
- Messages.TaxonNodeWizardPage_TAXON, "", style);
- }
- }else{
- taxon = getEntity().getTaxon();
- if (entity.getParent().getTaxon() == null){
- TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
- formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), style);
- textParent.setEnabled(false);
- }else{
- TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
- formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), style);
- textParent.setEnabled(false);
- }
+ checkbox_publish = formFactory.createCheckbox(formElement,
+ "Taxon is published", true, style);
+
+ checkbox_publish.setEnabled(isCreateNew());
+ Label seperator = new Label(getLayoutComposite(), SWT.HORIZONTAL | SWT.SEPARATOR);
+ seperator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
+ Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
+ nodeTitle.setText("Taxon Node");
+ nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ nodeTitle.setFont(FONT_BOLD);
- selection_Ref = formFactory
- .createSelectionElement(Reference.class,
- formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null,
- EntitySelectionElement.DELETABLE, style);
+// microReference = formFactory.createTextWithLabelElement(formElement,
+// Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE_DETAIL, "", style);
+// microReference.setText(parentNode.getMicroReference());
+ selection_parentTaxonNode = formFactory
+ .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
+ EntitySelectionElement.DELETABLE, style, 100);
+
+
+
+ }else{
+ taxon = getEntity().getTaxon();
selection_reuseExistingTaxon = formFactory
.createSelectionElement(Taxon.class,//getConversationHolder(),
formElement,
EntitySelectionElement.DELETABLE, style);
textTaxonSec = formFactory.createTextWithLabelElement(formElement,SECUNDUM_REFERENCE, "", style);
+
if (entity.getTaxon().getSec() != null){
textTaxonSec.setText(taxon.getSec().getTitleCache());
}
textTaxonSec.setEnabled(false);
- }
- if (!isCreateNew()){
- if (entity.getReference() != null){
- selection_Ref.setEntity(entity.getReference());
- }
- }
+ Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
+ nodeTitle.setText("Taxon Node");
+ nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ nodeTitle.setFont(FONT_BOLD);
- Taxon tax = null;
- if (entity.getTaxon() != null){
- tax = entity.getTaxon();
- }
- checkbox_publish = formFactory.createCheckbox(formElement,
- "Taxon is published", tax != null? tax.isPublish(): true, style);
+ if (entity.getParent().getTaxon() == null){
+ TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
+ formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), style);
+ textParent.setEnabled(false);
+ }else{
+ TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
+ formElement, Messages.TaxonNodeWizardPage_PARENT, entity.getParent().getTaxon().getTitleCache(), style);
+ textParent.setEnabled(false);
+ }
+// sourceSection = formFactory.createOriginalSourceElement(formElement, entity);
- checkbox_publish.setEnabled(isCreateNew());
+ }
+ Label spacer = new Label(getLayoutComposite(), SWT.NULL);
+ spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, style, true);
if (!isCreateNew()){
combo_status.setSelection(entity.getStatus());
if (!isCreateNew()){
selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
- selectionNodeAgentRelation.setEntity(entity);
+
selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ selectionNodeAgentRelation.setEntity(entity);
+ }
+
+ sourceSection = formFactory.createOriginalSourceElement(formElement, entity);
+ if (isCreateNew()){
+ sourceSection.setEntity(null);
+ }else{
+ sourceSection.setEntity(entity.getSource());
}
+
+
}
private void preFillTaxonName() {
complete = !textNewTaxonName.getText().isEmpty();
}
- if (eventSource == selection_Ref) {
+ if (eventSource == sourceSection) {
if(!isCreateNew()){
- getEntity().setReference(selection_Ref.getEntity());
+ getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
}
}else if (eventSource == selection_SecRef) {
if (taxon != null){
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
-import eu.etaxonomy.cdm.model.media.ExternalLink;
+import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
* @author k.luther
* @since Jul 2, 2020
*/
-public class AdvancedSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> {
+public class AdvancedSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase > {
protected TextWithLabelElement text_idInSource;
protected TextWithLabelElement text_idNamespace;
@Override
- protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
+ protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
Display display = Display.getCurrent();
Color background = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
- text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style);
+
+ text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?((OriginalSourceBase)entity).getIdInSource():null, style);
text_idInSource.setBackground(background);
}
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
- text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
+ text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?((OriginalSourceBase)entity).getIdNamespace():null, style);
text_idNamespace.setBackground(background);
}
text_originaleNameString = formFactory.createTextWithLabelElement(
text_originaleNameString.setBackground(background);
// text_cdmsource = formFactory.createTextWithLabelElement(
// formElement, "CDM Source", entity != null?entity.getCdmSource():null, SWT.NULL);
- externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, ExternalLink.class.getCanonicalName()));
- externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- externalLinks.setEntity(entity);
+ externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
+ externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
+ externalLinks.setEntity( ((OriginalSourceBase)entity));
addControl(externalLinks);
addElement(externalLinks);
}
+ @Override
+ public void setEntity(ReferencedEntityBase entity) {
+ super.setEntity(entity);
+ externalLinks.setEntity((OriginalSourceBase)entity);
+ }
+
@Override
public void handleEvent(Object eventSource) {
if (eventSource.equals(text_idInSource)){
- getEntity().setIdInSource(text_idInSource.getText());
+ ((OriginalSourceBase)getEntity()).setIdInSource(text_idInSource.getText());
}else if (eventSource.equals(text_idNamespace)){
- getEntity().setIdNamespace(text_idNamespace.getText());
+ ((OriginalSourceBase)getEntity()).setIdNamespace(text_idNamespace.getText());
}else if (eventSource.equals(text_originaleNameString)){
- getEntity().setOriginalNameString(text_originaleNameString.getText());
+ ((OriginalSourceBase)getEntity()).setOriginalNameString(text_originaleNameString.getText());
}
}
import org.eclipse.jface.util.IPropertyChangeListener;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
-import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
* @author k.luther
* @since Jul 1, 2020
*/
-public class OriginalSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> implements IPropertyChangeListener{
+public class OriginalSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase> implements IPropertyChangeListener{
// protected EnumComboElement<OriginalSourceType> combo_origsourcetype;
private EntitySelectionElement<Reference> selection_Ref;
private OriginalSourceAdvancedSection advancedSection;
+ private CdmBase cdmEntity;
+
// protected EntitySelectionElement<Reference> selection_reference;
// protected TextWithLabelElement text_referenceDetail;
- public OriginalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
+ public OriginalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement, CdmBase cdmEntity) {
super(formFactory, formElement);
+ this.cdmEntity = cdmEntity;
// selectionArbitrator = formFactory.createSelectionArbitrator(this);
}
@Override
- protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
+ protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
selection_Ref = formFactory.createSelectionElement(Reference.class,
formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null,
@Override
public void handleEvent(Object eventSource) {
if (eventSource.equals(selection_Ref)){
+
+ if (getEntity() == null){
+ Reference ref = selection_Ref.getEntity();
+ DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
+ setEntity(source);
+ selection_Ref.setEntity(ref);
+ if (cdmEntity != null && cdmEntity instanceof TaxonNode){
+ ((TaxonNode)cdmEntity).setSource(source);
+ }
+ }
+ //TODO: why is this null????ß
getEntity().setCitation(selection_Ref.getEntity());
+
}
}
+ /**
+ * @param cdmEntity2
+ */
+ public void setCdmEntity(CdmBase cdmEntity) {
+ this.cdmEntity = cdmEntity;
+
+ }
+
}