Project

General

Profile

Revision 2dd8037f

ID2dd8037fa340a85b010fb6769eb767f5199e6734
Parent c6b1be20
Child 5098693b

Added by Patrick Plitzner over 1 year ago

ref #7268 Fix stateful behavior of OpenPreferenceHandler

  • Convert class variables to local variables

View differences:

eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/handler/OpenPreferencesHandler.java
41 41

  
42 42
    private Logger logger = Logger.getLogger(OpenPreferencesHandler.class);
43 43

  
44
    private List<PageWrapper> pagesYetToBeAdded = new ArrayList<>();
45

  
46
    private Map<String, PreferenceNode> idToNodeMap = new HashMap<>();
47

  
48 44
    @Execute
49 45
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
46
        List<PageWrapper> pagesYetToBeAdded = new ArrayList<>();
47
        Map<String, PreferenceNode> idToNodeMap = new HashMap<>();
48

  
50 49
        PreferenceManager manager = new PreferenceManager('/');
51 50

  
52 51
        IExtensionRegistry reg = Platform.getExtensionRegistry();
......
81 80
            }
82 81
        }
83 82

  
84
//        pagesYetToBeAdded.entrySet().stream().
85
//        //filter stream to only contain parent nodes
86
//        filter(entry->{
87
//            PageWrapper pageWrapper = entry.getValue();
88
//            PreferenceNode node = new PreferenceNode(pageWrapper.getId(), pageWrapper.getPage());
89
//            if(StringUtils.isEmpty(pageWrapper.getCategory())){
90
//                manager.addToRoot(node);
91
//                return true;
92
//            }
93
//            return false;
94
//        })
95
//        .map(parent->addPage(parent.getValue(), manager));
96

  
97

  
98 83
        Collections.sort(pagesYetToBeAdded, new PreferenceNodeComparator());
99 84

  
100 85
        int size = pagesYetToBeAdded.size();
......
103 88
            Iterator<PageWrapper> iterator = pagesYetToBeAdded.iterator();
104 89
            while(iterator.hasNext()){
105 90
                PageWrapper pageWrapper = iterator.next();
106
                if(addPage(pageWrapper)){
91
                if(addPage(pageWrapper, idToNodeMap)){
107 92
                    iterator.remove();
108 93
                }
109 94
            }
......
119 104
        dialog.open();
120 105
    }
121 106

  
122
    private boolean addPage(PageWrapper pageWrapper){
107
    private boolean addPage(PageWrapper pageWrapper, Map<String, PreferenceNode> idToNodeMap){
123 108
        PreferenceNode node = new PreferenceNode(pageWrapper.getId(), pageWrapper.getPage());
124
        idToNodeMap.put(pageWrapper.getId(), node);
125 109
        PreferenceNode parent = idToNodeMap.get(pageWrapper.getCategory());
126 110
        if(parent!=null){
111
            idToNodeMap.put(pageWrapper.getId(), node);
127 112
            parent.add(node);
128 113
            return true;
129 114
        }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)