From 599261fd1ededbb954a28a2d85eee0e1a062a893 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Wed, 9 Dec 2015 10:50:10 +0100
Subject: [PATCH] Add scope restrictions to PolytomousKey details view #5280
---
.../taxeditor/ui/combo/TermComboElement.java | 24 ++++++++++++-------
.../key/PolytomousKeyDetailElement.java | 5 ++++
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java
index 39993d70a..02243a6cb 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java
@@ -20,7 +20,6 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
-import eu.etaxonomy.cdm.model.common.DefinedTerm;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
@@ -67,6 +66,8 @@ public class TermComboElement
private Comparator termComparator;
+ private final TermType termType;
+ private final TermVocabulary termVocabulary;
private final Class termClass;
private List customPreferredTerms;
@@ -96,12 +97,9 @@ public class TermComboElement
int style) {
super(formFactory, parentElement);
- if(termClass!=null){
- this.termClass = termClass;
- }
- else{
- this.termClass = (Class) DefinedTerm.class;
- }
+ this.termType = termType;
+ this.termVocabulary = termVocabulary;
+ this.termClass = termClass;
this.addEmptyElement = addEmptyElement;
if (labelString != null) {
@@ -265,10 +263,20 @@ public class TermComboElement
* @return a {@link java.util.List} object.
*/
protected List getPreferredTerms(){
+ List preferredTerms = new ArrayList();
if (customPreferredTerms != null){
return customPreferredTerms;
}
- return getTermManager().getPreferredTerms(termClass);
+ else if(termType!=null){
+ preferredTerms = getTermManager().getPreferredTerms(termType);
+ }
+ else if(termVocabulary!=null){
+ preferredTerms = getTermManager().getPreferredTerms(termVocabulary);
+ }
+ if(termClass!=null){
+ preferredTerms = getTermManager().getPreferredTerms(termClass);
+ }
+ return preferredTerms;
}
/**
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java
index de294870e..d6b4286ed 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java
@@ -26,6 +26,7 @@ public class PolytomousKeyDetailElement extends
private NumberWithLabelElement numberStartNumber;
private TaxonomicScopeSection sectionTaxonomicScope;
private GeoScopePolyKeyDetailSection sectionGeoScopes;
+ private ScopeRestrictionSection sectionScopeRestriction;
public PolytomousKeyDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
@@ -46,6 +47,10 @@ public class PolytomousKeyDetailElement extends
sectionGeoScopes = formFactory.createGeoScopePolyKeyDetailSection(getConversationHolder(), formElement, SWT.NULL);
sectionGeoScopes.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
sectionGeoScopes.setEntity(entity);
+
+ sectionScopeRestriction = formFactory.createScopeRestrictionSection(getConversationHolder(), formElement, SWT.NULL);
+ sectionScopeRestriction.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ sectionScopeRestriction.setEntity(entity);
}
public String getText() {
--
2.34.1