Revision 2fe68f38
Added by Patrick Plitzner about 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/character/CharacterEditor.java | ||
---|---|---|
58 | 58 |
import eu.etaxonomy.cdm.api.service.IFeatureTreeService; |
59 | 59 |
import eu.etaxonomy.cdm.api.service.ITermService; |
60 | 60 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
61 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
61 | 62 |
import eu.etaxonomy.cdm.model.common.Representation; |
62 | 63 |
import eu.etaxonomy.cdm.model.common.TermType; |
63 | 64 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
... | ... | |
95 | 96 |
public class CharacterEditor implements IFeatureTreeEditor,IConversationEnabled, ISelectionChangedListener, |
96 | 97 |
ModifyListener, IE4ViewerPart, IPartContentHasDetails, IPartContentHasSupplementalData, IDirtyMarkable { |
97 | 98 |
|
98 |
private FeatureTreeEditorComposite characterTreeEditorComposite; |
|
99 |
private FeatureTreeEditorComposite propertiesTreeEditorComposite; |
|
100 |
private FeatureTreeEditorComposite structuresTreeEditorComposite; |
|
99 |
private FeatureTreeEditorComposite<Character> characterTreeEditorComposite;
|
|
100 |
private FeatureTreeEditorComposite<DefinedTermBase> propertiesTreeEditorComposite;
|
|
101 |
private FeatureTreeEditorComposite<DefinedTermBase> structuresTreeEditorComposite;
|
|
101 | 102 |
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); |
102 | 103 |
|
103 | 104 |
@Inject |
... | ... | |
228 | 229 |
Collection<Character> characters = createCharacters((TreeSelection)structureTreeSelection, (TreeSelection)propertyTreeSelection); |
229 | 230 |
for (Character character : characters) { |
230 | 231 |
//add new Character to feature tree |
231 |
FeatureNode parent = ((FeatureTree) characterTreeEditorComposite.getViewer().getInput()).getRoot();
|
|
232 |
FeatureNode<Character> parent = ((FeatureTree<Character>) characterTreeEditorComposite.getViewer().getInput()).getRoot();
|
|
232 | 233 |
vocabulary.addTerm(character); |
233 | 234 |
CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(parent, character); |
234 | 235 |
} |
... | ... | |
252 | 253 |
|
253 | 254 |
} |
254 | 255 |
|
255 |
private FeatureTreeEditorComposite addFeatureTreeEditor(Composite composite_3) {
|
|
256 |
FeatureTreeEditorComposite featureTreeEditorComposite = new FeatureTreeEditorComposite(composite_3, SWT.NONE);
|
|
256 |
private <T extends DefinedTermBase> FeatureTreeEditorComposite<T> addFeatureTreeEditor(Composite composite_3) {
|
|
257 |
FeatureTreeEditorComposite<T> featureTreeEditorComposite = new FeatureTreeEditorComposite<>(composite_3, SWT.NONE);
|
|
257 | 258 |
featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
258 | 259 |
return featureTreeEditorComposite; |
259 | 260 |
} |
... | ... | |
292 | 293 |
public static Collection<Character> createCharacters(TreeSelection structureTreeSelection, TreeSelection propertyTreeSelection){ |
293 | 294 |
Set<Character> characters = new HashSet<>(); |
294 | 295 |
//get selected structures and properties |
295 |
Iterator<FeatureNode> structureIterator = structureTreeSelection.iterator(); |
|
296 |
Iterator<FeatureNode<DefinedTermBase>> structureIterator = structureTreeSelection.iterator();
|
|
296 | 297 |
|
297 | 298 |
//create all combinations of structures and properties |
298 | 299 |
while(structureIterator.hasNext()){ |
299 |
FeatureNode structureNode = structureIterator.next(); |
|
300 |
Iterator<FeatureNode> propertiesIterator = propertyTreeSelection.iterator(); |
|
300 |
FeatureNode<DefinedTermBase> structureNode = structureIterator.next();
|
|
301 |
Iterator<FeatureNode<DefinedTermBase>> propertiesIterator = propertyTreeSelection.iterator();
|
|
301 | 302 |
while(propertiesIterator.hasNext()){ |
302 |
FeatureNode propertyNode = propertiesIterator.next(); |
|
303 |
FeatureNode<DefinedTermBase> propertyNode = propertiesIterator.next();
|
|
303 | 304 |
Representation structureRepresentation = structureNode.getTerm().getRepresentation(PreferencesUtil.getGlobalLanguage()); |
304 | 305 |
Representation propertyRepresentation = propertyNode.getTerm().getRepresentation(PreferencesUtil.getGlobalLanguage()); |
305 | 306 |
String label = null; |
... | ... | |
328 | 329 |
// commit the conversation and start a new transaction immediately |
329 | 330 |
conversation.commit(true); |
330 | 331 |
|
331 |
FeatureTree featureTree = characterTreeEditorComposite.getFeatureTree(); |
|
332 |
FeatureTree<Character> featureTree = characterTreeEditorComposite.getFeatureTree();
|
|
332 | 333 |
if(featureTree!=null){ |
333 | 334 |
//save characters because they can be modified in this editor |
334 | 335 |
featureTree.getDistinctFeatures().forEach(character->CdmStore.getService(ITermService.class).merge(character,true)); |
... | ... | |
382 | 383 |
} |
383 | 384 |
|
384 | 385 |
@Override |
385 |
public List<FeatureTree> getRootEntities() { |
|
386 |
List<FeatureTree> root = new ArrayList<>(); |
|
386 |
public List<FeatureTree<Character>> getRootEntities() {
|
|
387 |
List<FeatureTree<Character>> root = new ArrayList<>();
|
|
387 | 388 |
root.add(characterTreeEditorComposite.getFeatureTree()); |
388 | 389 |
return root; |
389 | 390 |
} |
... | ... | |
423 | 424 |
return (IStructuredSelection) characterTreeEditorComposite.getViewer().getSelection(); |
424 | 425 |
} |
425 | 426 |
|
426 |
public FeatureTree getCharacterTree(){ |
|
427 |
public FeatureTree<Character> getCharacterTree(){
|
|
427 | 428 |
return characterTreeEditorComposite.getFeatureTree(); |
428 | 429 |
} |
429 | 430 |
|
... | ... | |
435 | 436 |
} |
436 | 437 |
|
437 | 438 |
private class FeatureTreeChooserListener extends SelectionAdapter{ |
438 |
private FeatureTreeEditorComposite featureTreeEditorComposite; |
|
439 |
private FeatureTreeEditorComposite<?> featureTreeEditorComposite;
|
|
439 | 440 |
private TermType termType; |
440 | 441 |
|
441 |
public FeatureTreeChooserListener(FeatureTreeEditorComposite featureTreeEditorComposite, TermType termType) { |
|
442 |
public FeatureTreeChooserListener(FeatureTreeEditorComposite<?> featureTreeEditorComposite, TermType termType) {
|
|
442 | 443 |
super(); |
443 | 444 |
this.featureTreeEditorComposite = featureTreeEditorComposite; |
444 | 445 |
this.termType = termType; |
Also available in: Unified diff
ref #6794 Adapt taxeditor to model changes (feature tree/node generics)