Project

General

Profile

« Previous | Next » 

Revision fb5347e6

Added by Patrick Plitzner almost 10 years ago

  • added conversation/session support to DerivateLabelProvider
    • GUI widgets using the provider need to provide a conversation/session to avoid LazyInitializationException

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchView.java
14 14
import org.eclipse.ui.IMemento;
15 15
import org.eclipse.ui.part.ViewPart;
16 16

  
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
17 18
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
18 19
import eu.etaxonomy.taxeditor.model.IContextListener;
19 20
import eu.etaxonomy.taxeditor.store.CdmStore;
......
26 27

  
27 28
    public static final String ID = "eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView";
28 29
    private DerivateSearchCompositeController derivateSearchCompositeController;
30
    private ConversationHolder conversationHolder;
29 31

  
30 32
    /**
31 33
     * Constructs a new DerivateSearchView and registers it to listen to context changes
......
50 52
    @Override
51 53
    public void setFocus() {
52 54
        derivateSearchCompositeController.setFocus();
55
        //make sure to bind again if maybe in another view the conversation was unbound
56
        if(getConversationHolder()!=null && !getConversationHolder().isBound()){
57
            getConversationHolder().bind();
58
        }
53 59
    }
54 60

  
55 61
    /* (non-Javadoc)
......
81 87
     */
82 88
    @Override
83 89
    public void contextRefresh(IProgressMonitor monitor) {
90
        initConversation();
91
    }
92

  
93
    private void initConversation(){
94
        if(conversationHolder==null){
95
            conversationHolder = CdmStore.createConversation();
96
        }
84 97
    }
85 98

  
86 99
    /* (non-Javadoc)
......
88 101
     */
89 102
    @Override
90 103
    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
104
        if(getConversationHolder()!=null){
105
            getConversationHolder().close();
106
        }
107
    }
108

  
109
    /**
110
     * @return the conversationHolder
111
     */
112
    public ConversationHolder getConversationHolder() {
113
        if(CdmStore.isActive() && conversationHolder==null){
114
            initConversation();
115
        }
116
        return conversationHolder;
91 117
    }
92 118
}

Also available in: Unified diff