Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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