*/
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
-import eu.etaxonomy.cdm.model.common.TermType;
-import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.cdm.api.service.l10n.TermRepresentation_L10n;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.term.TermTree;
+import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
+import eu.etaxonomy.taxeditor.featuretree.e4.TermTreeEditorComposite;
import eu.etaxonomy.taxeditor.model.ImageResources;
-import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
+import eu.etaxonomy.taxeditor.ui.combo.term.TermUuidComboViewer;
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
private Text txtDescriptiveDataSet;
private TermUuidComboViewer comboRankMin;
private TermUuidComboViewer comboRankMax;
- private FeatureTreeEditorComposite featureTreeEditorComposite;
+ private TermTreeEditorComposite<Feature> TermTreeEditorComposite;
private TreeViewer taxonNodeTree;
- private NamedArea area;
+ private List<TermDto> areas = new ArrayList<>();
private Text textAreaText;
private Button btnChooseArea;
- private Button btnRemoveArea;
+ private Button btnRemoveRankMin;
+ private Button btnRemoveRankMax;
public DescriptiveDataSetComposite(Composite parent, int style) {
super(parent, style);
lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblNewLabel_2.setText(Messages.DescriptiveDataSetComposite_RANK_MIN);
- comboRankMin = new TermUuidComboViewer(this, SWT.NONE);
+ Composite composite_1 = new Composite(this, SWT.NONE);
+ composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ GridLayout gl_composite_1 = new GridLayout(2, false);
+ gl_composite_1.horizontalSpacing = 0;
+ gl_composite_1.verticalSpacing = 0;
+ gl_composite_1.marginWidth = 0;
+ gl_composite_1.marginHeight = 0;
+ composite_1.setLayout(gl_composite_1);
+
+ comboRankMin = new TermUuidComboViewer(composite_1, SWT.NONE);
+ comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
comboRankMin.setInput(TermType.Rank);
- comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+
+ btnRemoveRankMin = new Button(composite_1, SWT.NONE);
+ btnRemoveRankMin.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
+
Tree tree = new Tree(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
taxonNodeTree = new TreeViewer(tree);
lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblNewLabel_3.setText(Messages.DescriptiveDataSetComposite_RANK_MAX);
- comboRankMax = new TermUuidComboViewer(this, SWT.NONE);
+ Composite composite_2 = new Composite(this, SWT.NONE);
+ composite_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ GridLayout gl_composite_2 = new GridLayout(2, false);
+ gl_composite_2.horizontalSpacing = 0;
+ gl_composite_2.verticalSpacing = 0;
+ gl_composite_2.marginWidth = 0;
+ gl_composite_2.marginHeight = 0;
+ composite_2.setLayout(gl_composite_2);
+
+ comboRankMax = new TermUuidComboViewer(composite_2, SWT.NONE);
+ comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
comboRankMax.setInput(TermType.Rank);
- comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+
+ btnRemoveRankMax = new Button(composite_2, SWT.NONE);
+ btnRemoveRankMax.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
Label lblNewLabel_4 = new Label(this, SWT.NONE);
lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
Composite composite = new Composite(this, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
- GridLayout gl_composite = new GridLayout(3, false);
+ GridLayout gl_composite = new GridLayout(2, false);
gl_composite.horizontalSpacing = 0;
gl_composite.verticalSpacing = 0;
gl_composite.marginHeight = 0;
btnChooseArea = new Button(composite, SWT.NONE);
btnChooseArea.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
- btnRemoveArea = new Button(composite, SWT.NONE);
- btnRemoveArea.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
-
- featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
- featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));
- new Label(this, SWT.NONE);
+ TermTreeEditorComposite = new TermTreeEditorComposite<>(this, SWT.NONE);
+ TermTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
}
@Override
comboRankMax.setElement(max);
}
- public FeatureTreeEditorComposite getFeatureTreeEditorComposite() {
- return featureTreeEditorComposite;
+ public TermTreeEditorComposite<Feature> getTermTreeEditorComposite() {
+ return TermTreeEditorComposite;
}
- public FeatureTree getCharacters(){
- return featureTreeEditorComposite.getFeatureTree();
+ public TermTree<Feature> getCharacters(){
+ return TermTreeEditorComposite.getFeatureTree();
}
- public void setCharacters(FeatureTree characters) {
- featureTreeEditorComposite.setSelectedTree(characters);
+ public void setCharacters(TermTree<Feature> characters) {
+ TermTreeEditorComposite.setSelectedTree(characters);
}
public TreeViewer getTaxonNodeTree() {
return taxonNodeTree;
}
-
- public NamedArea getArea(){
- return area;
- }
- public void setArea(NamedArea area) {
- this.area = area;
- textAreaText.setText(area.getLabel());
+ public List<TermDto> getAreas() {
+ return areas;
}
- public void removeArea() {
- this.area = null;
- textAreaText.setText(""); //$NON-NLS-1$
+ public void setAreas(List<TermDto> areas) {
+ this.areas = areas;
+ textAreaText.setText(areas.stream().map(area->{
+ area.localize(new TermRepresentation_L10n());
+ return area.getRepresentation_L10n();
+ }).collect(Collectors.joining(", ")));
}
public Button getBtnChooseArea() {
return btnChooseArea;
}
- public Button getBtnRemoveArea() {
- return btnRemoveArea;
+ public Button getBtnRemoveRankMin() {
+ return btnRemoveRankMin;
+ }
+ public Button getBtnRemoveRankMax() {
+ return btnRemoveRankMax;
}
}