2 * Copyright (C) 2018 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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.common
;
11 import java
.util
.Collection
;
12 import java
.util
.Comparator
;
14 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
15 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceBase
;
16 import eu
.etaxonomy
.cdm
.model
.media
.ExternalLink
;
17 import eu
.etaxonomy
.cdm
.model
.media
.ExternalLinkType
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
27 public class ExternalLinksSection
extends AbstractEntityCollectionSection
<OriginalSourceBase
, ExternalLink
> {
35 public ExternalLinksSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
, ICdmFormElement parentElement
, int style
) {
36 super(cdmFormFactory
, conversation
, parentElement
, "External Links", style
);
42 public Comparator
<ExternalLink
> getComparator() {
43 return new Comparator
<ExternalLink
>(){
46 public int compare(ExternalLink o1
, ExternalLink o2
) {
57 if (o1
.getUri() == o1
.getUri()){
60 if (o1
.getUri() == null){
63 if (o2
.getUri() == null){
66 return o1
.getUri().toString().compareTo(o2
.getUri().toString());
77 public Collection
<ExternalLink
> getCollection(OriginalSourceBase entity
) {
79 return entity
.getLinks();
87 public ExternalLink
createNewElement() {
88 ExternalLink link
= ExternalLink
.NewInstance(ExternalLinkType
.Unknown
, null);
93 public void addElement(ExternalLink element
) {
94 getEntity().addLink(element
);
99 public ExternalLink
addExisting() {
104 public boolean allowAddExisting() {
109 public void removeElement(ExternalLink element
) {
110 getEntity().removeLink(element
);
115 public String
getEmptyString() {
116 return "No external link yet.";
121 protected String
getTooltipString() {