Project

General

Profile

Revision 2a6e2626

ID2a6e2626fddd5f6637955f7f7479468c03767929
Parent 8da50b71
Child 79052a88

Added by Patrick Plitzner about 3 years ago

fix #7792 Cache global language for rendering speed up

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenuE4.java
24 24
import org.eclipse.jface.viewers.IStructuredSelection;
25 25

  
26 26
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
27
import eu.etaxonomy.cdm.model.common.Language;
27 28
import eu.etaxonomy.cdm.model.description.DescriptionBase;
28 29
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
29 30
import eu.etaxonomy.cdm.model.description.Feature;
......
46 47
    /** {@inheritDoc} */
47 48
    @AboutToShow
48 49
    public void aboutToShow(List<MMenuElement> items, @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection) {
50
        Language globalLanguage = PreferencesUtil.getGlobalLanguage();
49 51

  
50 52
        MMenu menu = MMenuFactory.INSTANCE.createMenu();
51 53
        menu.setLabel(Messages.DynamicFeatureMenuE4_new);
52 54
        items.add(menu);
53 55

  
54
            Object selectedElement = selection.getFirstElement();
56
        Object selectedElement = selection.getFirstElement();
55 57

  
56 58
        if (selectedElement instanceof DescriptionBase<?>) {
57 59
            FeatureTree featureTree = getFeatureTree((DescriptionBase<?>) selectedElement);
58 60

  
59 61
            for (FeatureNode childNode : featureTree.getRootChildren()) {
60
                createMenuItem(menu, childNode.getFeature());
61

  
62
                createMenuItem(menu, childNode.getFeature(), globalLanguage);
62 63
            }
63 64
        } else if (selectedElement instanceof FeatureNodeContainer) {
64 65
            FeatureNode featureNode = ((FeatureNodeContainer) selectedElement)
65 66
                    .getFeatureNode();
66 67

  
67 68
            // add the feature to the menu
68
            createMenuItem(menu, featureNode.getFeature());
69
            createMenuItem(menu, featureNode.getFeature(), globalLanguage);
69 70

  
70 71
            // add possible children to the menu
71 72
            for (FeatureNode childNode : featureNode.getChildNodes()) {
72
                createMenuItem(menu, childNode.getFeature());
73
                createMenuItem(menu, childNode.getFeature(), globalLanguage);
73 74
            }
74 75
        } else if (selectedElement instanceof DescriptionElementBase) {
75 76
            Feature feature = ((DescriptionElementBase) selectedElement)
76 77
                    .getFeature();
77
            createMenuItem(menu, feature);
78
            createMenuItem(menu, feature, globalLanguage);
78 79
        }
79 80
    }
80 81

  
81
    private void createMenuItem(MMenu menu, final Feature feature) {
82
    private void createMenuItem(MMenu menu, final Feature feature, Language globalLanguage) {
82 83
        final Feature deproxiedFeature = HibernateProxyHelper.deproxy(feature, Feature.class);
83 84

  
84
        String label = deproxiedFeature.getLabel(PreferencesUtil.getGlobalLanguage());
85
        String label = deproxiedFeature.getLabel(globalLanguage);
85 86
        if (label == null){
86 87
            label = deproxiedFeature.getLabel();
87 88
        }
......
102 103
        //	            e.printStackTrace();
103 104
        //	        }
104 105
        //set params
105
        menuItem.getTransientData().put(CreateDescriptionElementOperation.ID+".feature.uuid", feature.getUuid());
106
        menuItem.getTransientData().put(CreateDescriptionElementOperation.ID+".feature.uuid", deproxiedFeature.getUuid());
106 107

  
107 108
        menuItem.setCommand(mCommand);
108 109
        menu.getChildren().add(menuItem);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)