2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.featuretree
;
12 import java
.util
.Arrays
;
13 import java
.util
.HashSet
;
14 import java
.util
.List
;
16 import java
.util
.stream
.Collectors
;
18 import org
.eclipse
.jface
.layout
.GridLayoutFactory
;
19 import org
.eclipse
.jface
.wizard
.WizardPage
;
20 import org
.eclipse
.swt
.SWT
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
23 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
24 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
25 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTermBase
;
26 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
27 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
28 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermVocabularyDto
;
29 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.DefinedTermSorter
;
30 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.TermDtoContentProvider
;
31 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.TermDtoLabelProvider
;
32 import eu
.etaxonomy
.taxeditor
.preference
.wizard
.CheckBoxTreeComposite
;
33 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
37 * @created Aug 5, 2010
40 public class AvailableFeaturesWizardPage
extends WizardPage
{
42 private CheckBoxTreeComposite treeComposite
;
43 private TermType termType
;
45 protected AvailableFeaturesWizardPage(TermType termType
) {
46 super("Available Terms Wizard Page");
47 this.termType
= termType
;
48 setTitle("Available Terms");
49 setDescription("Please select terms you want to add to the tree.");
54 public void createControl(Composite parent
) {
55 treeComposite
= new CheckBoxTreeComposite(parent
, new TermDtoContentProvider(), new TermDtoLabelProvider(), SWT
.NONE
);
56 List
<TermVocabularyDto
> vocabularyDtos
= CdmStore
.getService(IVocabularyService
.class).findVocabularyDtoByTermType(termType
);
57 treeComposite
.getViewer().setComparator(new DefinedTermSorter());
58 treeComposite
.getViewer().setInput(vocabularyDtos
);
59 GridLayoutFactory
.fillDefaults().applyTo(treeComposite
);
61 setControl(treeComposite
);
64 public Set
<DefinedTermBase
> getSelectedFeatures() {
66 List
<Object
> checkedElements
= Arrays
.asList(treeComposite
.getViewer().getCheckedElements());
67 checkedElements
= checkedElements
.stream().filter(element
->element
instanceof TermDto
).collect(Collectors
.toList());
69 Set
<DefinedTermBase
> terms
= new HashSet
<>();
71 for(Object element
: checkedElements
){
72 if(element
instanceof TermDto
){
73 DefinedTermBase term
= CdmStore
.getService(ITermService
.class).load(((TermDto
) element
).getUuid());