Project

General

Profile

Download (3.4 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.ui.section.name;
12

    
13
import java.util.Collection;
14
import java.util.Collections;
15
import java.util.List;
16
import java.util.Map;
17

    
18
import org.eclipse.jface.wizard.Wizard;
19

    
20
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22
import eu.etaxonomy.cdm.model.common.CdmBase;
23
import eu.etaxonomy.cdm.model.name.NameRelationship;
24
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
25
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
26
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
27
import eu.etaxonomy.taxeditor.store.CdmStore;
28

    
29
/**
30
 * <p>NameRelationshipWizard class.</p>
31
 *
32
 * @author n.hoffmann
33
 * @created Jun 1, 2010
34
 * @version 1.0
35
 */
36
public class NameRelationshipWizard extends Wizard implements IConversationEnabled, ICdmEntitySessionEnabled{
37

    
38
	private static NameRelationshipDetailSection callingSection;
39
	
40
	private ICdmEntitySession cdmEntitySession;
41
    private ICdmEntitySession previousCdmEntitySession;
42
    private CdmBase rootElement;
43
	
44
	/**
45
	 * <p>Constructor for NameRelationshipWizard.</p>
46
	 *
47
	 * @param callingSection a {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection} object.
48
	 */
49
	public NameRelationshipWizard(NameRelationshipDetailSection callingSection) {
50
		NameRelationshipWizard.callingSection = callingSection;
51
		rootElement = callingSection.getEntity();
52
		if (CdmStore.isActive()) {
53
            previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
54
            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
55
            cdmEntitySession.bind();
56
        }
57
	}
58
		
59
	private NameRelationshipWizardPage page;
60

    
61
	/** {@inheritDoc} */
62
	@Override
63
	public void addPages() {
64
		page = new NameRelationshipWizardPage(callingSection); 
65
		
66
		addPage(page);
67
	}
68
	
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
71
	 */
72
	/** {@inheritDoc} */
73
	@Override
74
	public boolean performFinish() {
75
		return page.isPageComplete();
76
	}
77

    
78
	@Override
79
    public void dispose() {
80
        super.dispose();
81
        if(cdmEntitySession != null) {
82
            cdmEntitySession.dispose();
83
        }
84
        if(previousCdmEntitySession!=null){
85
            previousCdmEntitySession.bind();
86
        }
87
    }
88

    
89
	/**
90
	 * <p>getNameRelationship</p>
91
	 *
92
	 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
93
	 */
94
	public NameRelationship getNameRelationship() {
95
		return page.getNameRelationship();
96
	}
97

    
98
	/**
99
	 * <p>getConversationHolder</p>
100
	 *
101
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
102
	 */
103
	public ConversationHolder getConversationHolder() {
104
		return callingSection.getConversationHolder();
105
	}
106

    
107
	/** {@inheritDoc} */
108
	public void update(CdmDataChangeMap changeEvents) {}
109

    
110
	 @Override
111
	    public ICdmEntitySession getCdmEntitySession() {
112
	        return cdmEntitySession;
113
	    }
114

    
115
	    @Override
116
	    public java.util.Collection<CdmBase> getRootEntities() {
117
	        return Collections.singleton(rootElement);
118
	    }
119

    
120
	    @Override
121
	    public Map<Object, List<String>> getPropertyPathsMap() {
122
	        return null;
123
	    }
124
}
(10-10/25)