Project

General

Profile

« Previous | Next » 

Revision e36729b8

Added by Patrick Plitzner almost 9 years ago

  • code conventions

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
20 20
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
21 21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22 22
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
23
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23 24
import eu.etaxonomy.taxeditor.store.CdmStore;
24 25
import eu.etaxonomy.taxeditor.store.StoreUtil;
25 26
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
35 36
		INewWizard, IConversationEnabled {
36 37

  
37 38
	private ConversationHolder conversation;
38
	
39

  
39 40
	protected CdmFormFactory formFactory;
40 41

  
41 42
	private T entity;
......
43 44
	private IWorkbench workbench;
44 45

  
45 46
	private IStructuredSelection selection;
46
	
47

  
47 48
	/**
48 49
	 * <p>Constructor for AbstractNewEntityWizard.</p>
49 50
	 *
......
52 53
	public AbstractNewEntityWizard(){
53 54
		setWindowTitle(String.format("New %s", getEntityName()));
54 55
	}
55
	
56

  
56 57
	/**
57 58
	 * FIXME there might be a smarter way to do this,
58
	 * 
59
	 *
59 60
	 * @return
60 61
	 */
61 62
	protected abstract String getEntityName();
......
67 68
	@Override
68 69
	public boolean performFinish() {
69 70
		saveEntity();
70
		
71

  
71 72
		conversation.commit();
72 73
		conversation.close();
73 74
		return true;
74 75
	}
75
	
76

  
76 77
	/**
77 78
	 * <p>Getter for the field <code>entity</code>.</p>
78 79
	 *
......
81 82
	public T getEntity() {
82 83
		return entity;
83 84
	}
84
	
85

  
85 86
	/**
86 87
	 * <p>Setter for the field <code>entity</code>.</p>
87 88
	 *
......
90 91
	public void setEntity(T entity){
91 92
		this.entity = entity;
92 93
	}
93
	
94

  
94 95
	/**
95 96
	 * Adds the entity to the current persistence context
96 97
	 */
......
102 103
	/** {@inheritDoc} */
103 104
	@Override
104 105
	public void init(IWorkbench workbench, IStructuredSelection selection) {
105
		this.workbench = workbench != null ? workbench : StoreUtil.getWorkbench();
106
		
106
		this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench();
107

  
107 108
		if(selection == null){
108
			ISelectionService service = (ISelectionService) this.workbench.getActiveWorkbenchWindow().getSelectionService();
109
			ISelectionService service = this.workbench.getActiveWorkbenchWindow().getSelectionService();
109 110
			if(service.getSelection() instanceof IStructuredSelection){
110 111
				selection = (IStructuredSelection) service.getSelection();
111 112
			}
112 113
		}
113 114
		this.selection = selection;
114
		
115

  
115 116
		formFactory = new CdmFormFactory(Display.getCurrent(), null);
116 117
	 	conversation = CdmStore.createConversation();
117 118
	 	entity = createNewEntity();
118
	 	
119

  
119 120
	}
120
	
121

  
121 122
	/**
122 123
	 * <p>createNewEntity</p>
123 124
	 *
124 125
	 * @return a T object.
125 126
	 */
126 127
	protected abstract T createNewEntity();
127
	
128

  
128 129
	/**
129 130
	 * <p>getConversationHolder</p>
130 131
	 *
131 132
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
132 133
	 */
133
	public ConversationHolder getConversationHolder() {
134
	@Override
135
    public ConversationHolder getConversationHolder() {
134 136
		return conversation;
135 137
	}
136
	
138

  
137 139
	/** {@inheritDoc} */
138
	public void update(CdmDataChangeMap changeEvents) {}
140
	@Override
141
    public void update(CdmDataChangeMap changeEvents) {}
139 142

  
140 143
	/**
141 144
	 * @return the workbench

Also available in: Unified diff