import org.eclipse.swt.widgets.Label;
+import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.term.Representation;
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
import eu.etaxonomy.taxeditor.event.EventUtility;
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
import eu.etaxonomy.taxeditor.model.ColorResources;
import eu.etaxonomy.taxeditor.preference.Resources;
+import eu.etaxonomy.taxeditor.store.CdmStore;
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.RepresentationElement;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
/**
- *
* @author pplitzner
* @since Dec 21, 2017
- *
*/
public class TermTreeDetailElement extends AbstractCdmDetailElement<TermTreeDto> {
private CheckboxElement orderRelevant;
private CheckboxElement isFlat;
- private TextWithLabelElement titleCacheText;
+ //private TextWithLabelElement titleCacheText;
+ protected RepresentationElement element_Representation;
public TermTreeDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
super(formFactory, formElement);
}
-
@Override
protected void createControls(ICdmFormElement formElement, TermTreeDto entity, int style) {
Label lblTermType = new Label(formElement.getLayoutComposite(), style);
lblStructureText.setText(entity.getTermType().getLabel());
lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK));
- titleCacheText = formFactory.createTextWithLabelElement(
- formElement, "Title Cache", entity.getTitleCache(), style);
-
+// titleCacheText = formFactory.createTextWithLabelElement(
+// formElement, "Title Cache", entity.getTitleCache(), style);
+ element_Representation = formFactory.createTranslatableRepresentationElementDto(formElement, entity.getPreferredRepresentation(CdmStore.getDefaultLanguage()),entity, 100, style, true);
allowDuplicates = formFactory.createCheckbox(formElement, "Allow duplicates", entity.isAllowDuplicate(), style);
if (entity.isContainsDuplicates() && entity.isAllowDuplicate()){
allowDuplicates.setEnabled(false);
if (entity.containsSubtrees()){
isFlat.setEnabled(false);
}
-
-
}
@Override
@Override
public void handleEvent(Object eventSource) {
- if (eventSource == titleCacheText) {
- getEntity().setTitleCache(titleCacheText.getText());
+ if (eventSource == element_Representation) {
+// getEntity().setTitleCache(titleCacheText.getText());
+ Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
+ if(selectedRepresentation!=null){
+ Language representationLanguage = selectedRepresentation.getLanguage();
+ if(representationLanguage==null){
+ representationLanguage = Language.getDefaultLanguage();
+ }
+// getEntity().setLabel(selectedRepresentation.getLabel(), representationLanguage);
+ Representation rep = getEntity().getRepresentation(representationLanguage);
+ if (rep == null){
+ rep = new Representation(selectedRepresentation.getDescription(), selectedRepresentation.getLabel(), selectedRepresentation.getAbbreviatedLabel(), representationLanguage);
+ getEntity().addRepresentation(rep);
+ }else{
+ getEntity().getRepresentation(representationLanguage).setLabel(selectedRepresentation.getLabel());
+ getEntity().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
+ getEntity().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
+ }
+ }
+ getEntity().setTitleCache(null);
}
else
if (eventSource == allowDuplicates) {
getEntity().setFlat(isFlat.getSelection());
}
EventUtility.postEvent(WorkbenchEventConstants.ADD_SAVE_CANDIDATE, getEntity());
-
}
}
\ No newline at end of file