@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
-
- String text = getText(element);
+ boolean showIdInVoc = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS, true);
+ String text = getText(element, showIdInVoc);
cell.setText(text);
Styler styler = null;
super.update(cell);
}
- public String getText(Object element) {
+ public String getText(Object element, boolean showIdInVocabulary) {
String label = null;
if(element instanceof AbstractTermDto){
AbstractTermDto termDto = (AbstractTermDto)element;
termDto.localize(new TermRepresentation_L10n());
label = termDto.getRepresentation_L10n();
- if(PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS, true)
- && element instanceof TermDto && ((TermDto) termDto).getIdInVocabulary()!=null){
+ if(showIdInVocabulary && element instanceof TermDto && ((TermDto) termDto).getIdInVocabulary()!=null){
label = CdmUtils.concat(" : ", ((TermDto) termDto).getIdInVocabulary(), label);
}
}
import java.util.ArrayList;
-import org.eclipse.jface.viewers.LabelProvider;
-
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
import eu.etaxonomy.cdm.model.term.Representation;
import eu.etaxonomy.cdm.persistence.dto.TermDto;
import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoLabelProvider;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
/**
* @created Aug 5, 2010
* @version 1.0
*/
-public class FeatureTreeLabelProvider extends LabelProvider {
+public class FeatureTreeLabelProvider extends TermDtoLabelProvider{
/** {@inheritDoc} */
@Override
- public String getText(Object element) {
+ public String getText(Object element, boolean showIdInVoc) {
if(element instanceof TermTreeDto){
return ((TermTreeDto) element).getRepresentation_L10n() != null? ((TermTreeDto) element).getRepresentation_L10n() :((TermTreeDto) element).getTitleCache() ;
}else if(element instanceof TermNodeDto){
TermDto term = ((TermNodeDto) element).getTerm();
if(term!=null){
- String rep = term.getRepresentation_L10n();
-// if (rep == null){
-// rep = term.getPreferredRepresentation(new ArrayList<Language>());
-// }
- return rep != null? rep : term.getTitleCache();
+ showIdInVoc = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS_IN_TREE_EDITOR, true);
+ return super.getText(term, showIdInVoc);
}
}else if(element instanceof TermNode){
}
// commit the conversation and start a new transaction immediately
+ Object[] expandedElements = this.viewer.getExpandedElements();
conversation.commit(true);
if (operationList != null && !operationList.isEmpty()){
for (AbstractPostOperation<TermNode> operation: operationList){
// initializeTrees();
this.setDirty(false);
+ this.viewer.setExpandedElements(expandedElements);
}
private void initializeTrees() {
@Override
public void init() {
configurator = new CdmLightExportConfigurator(null);
-// configurator.setCreateCondensedDistributionString(PreferencesUtil.getBooleanValue(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey()));
-// if (configurator.isCreateCondensedDistributionString()){
String recipeString = PreferencesUtil.getStringValue(PreferencePredicate.CondensedDistributionRecipe.getKey());
if (StringUtils.isNotBlank(recipeString)){
configurator.setCondensedDistributionRecipe(CondensedDistributionRecipe.valueOf(recipeString));
}
-// }
if (selection instanceof TreeSelection && !selection.isEmpty() && selection.getFirstElement() instanceof TaxonNodeDto){
selectedNode = (TaxonNodeDto)selection.getFirstElement();
* Whether to show vocabulary of the term when displaying it's label.
*/
public static final String SHOW_VOCABULARY_ID_FOR_TERM_LABELS = "eu.etaxonomy.taxeditor.showVocabularyIdForTermLabels";
+ /**
+ * Whether to show vocabulary of the term when displaying it's label.
+ */
+ public static final String SHOW_VOCABULARY_ID_FOR_TERM_LABELS_IN_TREE_EDITOR = "eu.etaxonomy.taxeditor.showVocabularyIdForTermLabelsInTreeEditor";
/**
*
--- /dev/null
+/**
+* Copyright (C) 2020 EDIT
+* 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.preference;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
+
+/**
+ * @author k.luther
+ * @since Nov 20, 2020
+ */
+public class TermTreePreference extends FieldEditorPreferencePageE4 {
+
+ @Override
+ protected void createFieldEditors() {
+ addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS_IN_TREE_EDITOR),
+ Messages.DescriptionPreferences_1,
+ getFieldEditorParent()));
+
+ }
+
+}