*/
package eu.etaxonomy.taxeditor.ui.section.description;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
+import java.util.List;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
}
return source;
}
-
@Override
- public Collection<OriginalSourceBase> getCollection(DescriptionElementBase entity) {
+ protected void internalUpdateSection(boolean changed){
+ setSectionTitle();
+ destroyDynamicContent();
+ if(isExpanded() || expandSectionWhenContentAvailable()) {
+ renderContent(isExpanded());
+ }
+ if(changed) {
+ firePropertyChangeEvent(this);
+ }
+ }
+
+ private void renderContent(boolean forceExpansion){
+ Collection<OriginalSourceBase> collectionElement = getCollectionElement(getEntity());
+ Collection<OriginalSourceBase> collectionDescription = getCollectionDescription(getEntity());
+
+ if(collectionElement == null || collectionElement.isEmpty()){
+ createEmptyContent();
+ }else{
+ List<OriginalSourceBase> elements = new ArrayList<>(collectionElement);
+ Collections.sort(elements, getComparator());
+ createDynamicContents(elements);
+ forceExpansion = true;
+ }
+
+ this.setExpanded(forceExpansion);
+
+
+
+ if(collectionDescription == null || collectionDescription.isEmpty()){
+ createEmptyContent();
+ }else{
+ List<OriginalSourceBase> elements = new ArrayList<>(collectionDescription);
+ Collections.sort(elements, getComparator());
+ createDynamicContents(elements);
+ getEntityCollectionElement().setEnabled(false);
+ forceExpansion = true;
+ }
+
+ this.setExpanded(forceExpansion);
+
+ reflow();
+ }
+
+
+
+ public Collection<OriginalSourceBase> getCollectionDescription(DescriptionElementBase entity) {
Collection<OriginalSourceBase> sources = new HashSet<>();
- sources.addAll(entity.getSources());
+// sources.addAll(entity.getSources());
sources.addAll(entity.getInDescription().getSources());
return sources;
}
+ public Collection<OriginalSourceBase> getCollectionElement(DescriptionElementBase entity) {
+ Collection<OriginalSourceBase> sources = new HashSet<>();
+ sources.addAll(entity.getSources());
+// sources.addAll(entity.getInDescription().getSources());
+
+ return sources;
+ }
@Override
public Comparator<OriginalSourceBase> getComparator() {
public boolean allowAddExisting() {
return false;
}
+
+ @Override
+ public Collection<OriginalSourceBase> getCollection(DescriptionElementBase entity) {
+ Collection<OriginalSourceBase> sources = new HashSet<>();
+ sources.addAll(entity.getSources());
+ sources.addAll(entity.getInDescription().getSources());
+ return sources;
+
+ }
}
\ No newline at end of file