X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/2d6180c326e4f581e019aba28fabd837a646067d..d58b8e3f77a8664b300c738c9678edb6024edf17:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java index 66df36da8..4cf0c6f82 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java @@ -1,22 +1,24 @@ -// $Id$ /** * Copyright (C) 2009 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ package eu.etaxonomy.taxeditor.ui.section.vocabulary; -import eu.etaxonomy.cdm.model.common.Representation; -import eu.etaxonomy.cdm.model.common.TermBase; -import eu.etaxonomy.cdm.model.common.TermVocabulary; +import org.eclipse.swt.widgets.Button; + +import eu.etaxonomy.cdm.model.common.Language; +import eu.etaxonomy.cdm.model.term.Representation; +import eu.etaxonomy.cdm.model.term.TermBase; +import eu.etaxonomy.cdm.model.term.TermVocabulary; import eu.etaxonomy.taxeditor.editor.definedterm.TermBasePropertyTester; import eu.etaxonomy.taxeditor.store.CdmStore; -import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; -import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; +import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; +import eu.etaxonomy.taxeditor.ui.element.RepresentationElement; import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; @@ -27,65 +29,49 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; */ public abstract class AbstractTermBaseDetailElement extends AbstractCdmDetailElement { - protected TextWithLabelElement text_label; - protected TextWithLabelElement text_description; protected UriWithLabelElement uri_uri; - protected TextWithLabelElement text_abbreviatedLabel; - - /** - * @param formFactory - * @param formElement - */ + protected RepresentationElement element_Representation; + private Button button; + + public AbstractTermBaseDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) { super(formFactory, formElement); } - - /* (non-Javadoc) - * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, java.lang.Object, int) - */ + @Override protected void createControls(ICdmFormElement formElement, T entity, int style) { - Representation representation = getEntity().getRepresentation(CdmStore.getDefaultLanguage()); - - if(representation == null){ - formFactory.createLabel(formElement, "No represantation for the current default Language"); - return; - } - - text_label = formFactory.createTextWithLabelElement(formElement, "Label", representation.getLabel(), style); - text_abbreviatedLabel = formFactory.createTextWithLabelElement(formElement, "Abbrev. Label", representation.getAbbreviatedLabel(), style); - text_description = formFactory.createMultilineTextWithLabel(formElement, "Description", 100, style); - text_description.setText(representation.getDescription()); + element_Representation = formFactory.createTranslatableRepresentationElement(formElement, getEntity().getPreferredRepresentation(CdmStore.getDefaultLanguage()),getEntity(), 100, style, true); uri_uri = formFactory.createUriWithLabelElement(formElement, "URI", getEntity().getUri(), style); - } - @Override + @Override public void setEntity(T entity) { super.setEntity(entity); setEnabled(TermBasePropertyTester.isModifiable(entity)); } - - protected void handleRepresentation(Object eventSource){ - T entity = getEntity(); - Representation representation = entity.getRepresentation(CdmStore.getDefaultLanguage()); - - if (representation == null){ - return; - } - - if (eventSource == text_label){ - representation.setLabel(text_label.getText()); - entity.setLabel(text_label.getText()); - }else if (eventSource == text_abbreviatedLabel){ - representation.setAbbreviatedLabel(text_abbreviatedLabel.getText()); - }else if (eventSource == text_description){ - representation.setText(text_description.getText()); - } - } + + @Override + public void handleEvent(Object eventSource) { + if (eventSource == uri_uri) { + getEntity().setUri(uri_uri.parseText()); + } + else if (eventSource == element_Representation) { + Representation selectedRepresentation = element_Representation.getSelectedRepresentation(); + if(selectedRepresentation!=null){ + Language representationLanguage = selectedRepresentation.getLanguage(); + if(representationLanguage==null){ + representationLanguage = Language.getDefaultLanguage(); + } + getEntity().setLabel(selectedRepresentation.getLabel(), representationLanguage); + getEntity().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel()); + getEntity().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription()); + } + getEntity().setTitleCache(null); + } + } public abstract TermVocabulary getVocabulary(); - + }