Project

General

Profile

« Previous | Next » 

Revision 92d4dbe0

Added by Andreas Kohlbecker almost 7 years ago

fix #6673 implementing the PopupEditorFactory and making all PopEditors and presenters POJOs

View differences:

src/main/java/eu/etaxonomy/vaadin/ui/navigation/NavigationManagerBean.java
1 1
package eu.etaxonomy.vaadin.ui.navigation;
2 2

  
3 3
import java.util.Arrays;
4
import java.util.Collection;
5 4
import java.util.HashMap;
6
import java.util.HashSet;
7 5
import java.util.List;
8 6
import java.util.Map;
9
import java.util.Optional;
10 7

  
11 8
import org.apache.log4j.Logger;
12 9
import org.springframework.beans.factory.annotation.Autowired;
......
30 27
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
31 28
import eu.etaxonomy.vaadin.ui.UIInitializedEvent;
32 29
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent;
30
import eu.etaxonomy.vaadin.ui.view.PopupEditorFactory;
33 31
import eu.etaxonomy.vaadin.ui.view.PopupView;
34 32

  
35 33
@UIScope
......
51 49
	@Autowired
52 50
	private PojoEventListenerManager eventListenerManager;
53 51

  
52
	@Autowired
53
	private PopupEditorFactory popupEditorFactory;
54

  
54 55
	@Autowired
55 56
    private UserHelper userHelper;
56 57

  
......
60 61
		popupMap = new HashMap<>();
61 62
	}
62 63

  
63
    private Collection<PopupView> popupViews = new HashSet<>();
64

  
65
    @Lazy
66
    @Autowired(required=false)
67
	private void popUpViews(Collection<PopupView> popupViews){
68
        this.popupViews = popupViews;
69
        // popupViews.forEach(view -> this.popupViews.put(view.getClass(), view));
70
	}
71 64

  
72
    private <P extends PopupView> Optional<PopupView> findPopupView(Class<P> type){
73
        return popupViews.stream().filter(p -> p.getClass().equals(type)).findFirst();
65
    private <P extends PopupView> PopupView findPopupView(Class<P> popupViewClass){
66
        return popupEditorFactory.newPopupView(popupViewClass);
74 67
    }
75 68

  
76 69
    /*
......
122 115
	@Override
123 116
	public <T extends PopupView> T showInPopup(Class<T> popupType) {
124 117

  
125
	    PopupView popupView =  findPopupView(popupType).get(); // TODO make better use of Optional
118
	    PopupView popupView =  findPopupView(popupType); // TODO make better use of Optional
126 119

  
127 120
	    if(AbstractPopupEditor.class.isAssignableFrom(popupView.getClass())){
128 121
	        AbstractEditorPresenter presenter = ((AbstractPopupEditor)popupView).presenter();

Also available in: Unified diff