Revision 29ce4176
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/CharacterEditor.java | ||
---|---|---|
12 | 12 |
import java.util.ArrayList; |
13 | 13 |
import java.util.Arrays; |
14 | 14 |
import java.util.HashMap; |
15 |
import java.util.Iterator; |
|
15 | 16 |
import java.util.List; |
16 | 17 |
import java.util.Map; |
17 | 18 |
|
18 | 19 |
import javax.annotation.PostConstruct; |
19 | 20 |
import javax.annotation.PreDestroy; |
20 | 21 |
import javax.inject.Inject; |
21 |
import javax.inject.Named; |
|
22 | 22 |
|
23 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
24 | 23 |
import org.eclipse.e4.ui.di.Focus; |
25 | 24 |
import org.eclipse.e4.ui.di.Persist; |
26 | 25 |
import org.eclipse.e4.ui.model.application.ui.MDirtyable; |
27 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
28 | 26 |
import org.eclipse.e4.ui.workbench.modeling.ESelectionService; |
29 | 27 |
import org.eclipse.jface.viewers.ISelection; |
30 | 28 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
... | ... | |
42 | 40 |
import org.eclipse.swt.widgets.Button; |
43 | 41 |
import org.eclipse.swt.widgets.Composite; |
44 | 42 |
import org.eclipse.swt.widgets.Display; |
45 |
import org.eclipse.swt.widgets.Shell; |
|
46 | 43 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
47 | 44 |
|
48 | 45 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
49 | 46 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
50 | 47 |
import eu.etaxonomy.cdm.api.service.IFeatureTreeService; |
48 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
49 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
51 | 50 |
import eu.etaxonomy.cdm.model.description.Character; |
52 | 51 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
53 | 52 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
... | ... | |
198 | 197 |
"You have to select a structure, a property and a feature tree to perform this action."); |
199 | 198 |
return; |
200 | 199 |
} |
201 |
//get selected structure and property |
|
202 |
FeatureNode structureNode = (FeatureNode) ((TreeSelection)structureTreeSelection).getFirstElement(); |
|
203 |
FeatureNode propertyNode = (FeatureNode) ((TreeSelection)propertyTreeSelection).getFirstElement(); |
|
204 |
//create new Character |
|
205 |
String label = structureNode.getFeature().toString()+" "+propertyNode.getFeature().toString(); |
|
206 |
Character character = Character.NewInstance(structureNode, propertyNode, null, label, label); |
|
207 |
|
|
208 |
//add new Character to feature tree |
|
209 |
FeatureNode parent = ((FeatureTree) characterTreeEditorComposite.getViewer().getInput()).getRoot(); |
|
210 |
CdmStore.getService(IFeatureNodeService.class).addChildFeaturNode(parent.getUuid(), character.getUuid()); |
|
200 |
//get selected structures and properties |
|
201 |
Iterator<FeatureNode> structureIterator = ((TreeSelection)structureTreeSelection).iterator(); |
|
202 |
|
|
203 |
//create all combinations of structures and properties |
|
204 |
while(structureIterator.hasNext()){ |
|
205 |
FeatureNode structureNode = structureIterator.next(); |
|
206 |
Iterator<FeatureNode> propertiesIterator = ((TreeSelection)propertyTreeSelection).iterator(); |
|
207 |
while(propertiesIterator.hasNext()){ |
|
208 |
FeatureNode propertyNode = propertiesIterator.next(); |
|
209 |
//create new Character |
|
210 |
String label = structureNode.getFeature().generateTitle()+" "+propertyNode.getFeature().generateTitle(); |
|
211 |
Character character = Character.NewInstance(structureNode, propertyNode, "", label, label); |
|
212 |
character = HibernateProxyHelper.deproxy(CdmStore.getService(ITermService.class).merge(character), Character.class); |
|
213 |
|
|
214 |
//add new Character to feature tree |
|
215 |
FeatureNode parent = ((FeatureTree) characterTreeEditorComposite.getViewer().getInput()).getRoot(); |
|
216 |
CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(parent.getUuid(), character.getUuid()); |
|
217 |
} |
|
218 |
} |
|
211 | 219 |
|
212 | 220 |
setDirty(true); |
213 | 221 |
characterTreeEditorComposite.getViewer().refresh(); |
Also available in: Unified diff
ref #6762 Fix session handling when creating new character