fix doubled title in DefinedTerm Details and fix filling of menu items for multilangu...
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / descriptive / handler / DynamicFeatureMenu.java
index 0c10b9ad7df145bd2f37f166c3d583d5a79120d6..d34eee5ce87df80eb3640d7c86a33a982ab1f032 100644 (file)
@@ -29,11 +29,11 @@ import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureNode;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -48,9 +48,9 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class DynamicFeatureMenu extends CompoundContributionItem {
 
-       private ISelectionService selectionService = EditorUtil.getActivePart()
+       private final ISelectionService selectionService = EditorUtil.getActivePart()
                        .getSite().getWorkbenchWindow().getSelectionService();
-       private IHandlerService handlerService = (IHandlerService) EditorUtil
+       private final IHandlerService handlerService = (IHandlerService) EditorUtil
                        .getService(IHandlerService.class);
 
        /*
@@ -75,8 +75,8 @@ public class DynamicFeatureMenu extends CompoundContributionItem {
                                        Object selectedElement = structuredSelection
                                                        .getFirstElement();
 
-                                       if (selectedElement instanceof TaxonDescription) {
-                                               FeatureTree featureTree = getFeatureTree((TaxonDescription) selectedElement);
+                                       if (selectedElement instanceof DescriptionBase<?>) {
+                                               FeatureTree featureTree = getFeatureTree((DescriptionBase<?>) selectedElement);
 
                                                for (FeatureNode childNode : featureTree.getRootChildren()) {
                                                        createMenuItem(menu, childNode.getFeature());
@@ -105,10 +105,14 @@ public class DynamicFeatureMenu extends CompoundContributionItem {
 
        private void createMenuItem(Menu menu, final Feature feature) {
                MenuItem menuItem = new MenuItem(menu, -1);
-               final Feature deproxiedFeature = (Feature) HibernateProxyHelper
-                               .deproxy(feature);
-
-               menuItem.setText(deproxiedFeature.getLabel());
+               final Feature deproxiedFeature = HibernateProxyHelper.deproxy(feature, Feature.class);
+                               
+               String label = deproxiedFeature.getLabel(PreferencesUtil.getGlobalLanguage());
+               if (label == null){
+                       menuItem.setText(deproxiedFeature.getLabel());
+               }else{
+                       menuItem.setText(label);
+               }
                menuItem.addSelectionListener(new SelectionListener() {
 
                        @Override
@@ -123,7 +127,7 @@ public class DynamicFeatureMenu extends CompoundContributionItem {
                                        handlerService.executeCommand(
                                                        CreateDescriptionElementOperation.ID, event);
                                } catch (Exception e) {
-                                       EditorUtil.error(getClass(), e);
+                                       MessagingUtils.error(getClass(), e);
                                }
                        }
                });