X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Furls%2FUrlLinkDisplay.java;h=39d6b35d15a1172eecb3940a07ef52f889d8fdbc;hb=b4decf54532969f6843c88e5f559e9854e0548b8;hp=5991d76ed84eb01f6dbf893c050e88122699823e;hpb=a1bf90058be8be92554ecbc5868982dcdbed5a80;p=jalview.git diff --git a/src/jalview/urls/UrlLinkDisplay.java b/src/jalview/urls/UrlLinkDisplay.java index 5991d76..39d6b35 100644 --- a/src/jalview/urls/UrlLinkDisplay.java +++ b/src/jalview/urls/UrlLinkDisplay.java @@ -36,19 +36,25 @@ import java.util.List; public class UrlLinkDisplay { - private String id; // id is not supplied to display, but used to identify - // entries when saved + // column positions + public static final int DATABASE = 0; - private boolean isPrimary; + public static final int NAME = 1; - private boolean isSelected; + public static final int URL = 2; - private UrlLink link; + public static final int SELECTED = 3; + + public static final int PRIMARY = 4; + + public static final int ID = 5; // Headers for columns in table - private final static List colNames = new ArrayList() + @SuppressWarnings("serial") + private static final List COLNAMES = new ArrayList() { { + add(MessageManager.formatMessage("label.database")); add(MessageManager.formatMessage("label.name")); add(MessageManager.formatMessage("label.url")); add(MessageManager.formatMessage("label.inmenu")); @@ -57,19 +63,17 @@ public class UrlLinkDisplay } }; - // column positions - public final static int NAME = 0; - - public final static int URL = 1; + private String id; // id is not supplied to display, but used to identify + // entries when saved - public final static int SELECTED = 2; + private boolean isPrimary; - public final static int PRIMARY = 3; + private boolean isSelected; - public final static int ID = 4; + private UrlLink link; - public UrlLinkDisplay(String rowId, UrlLink rowLink, - boolean rowSelected, boolean rowDefault) + public UrlLinkDisplay(String rowId, UrlLink rowLink, boolean rowSelected, + boolean rowDefault) { id = rowId; isPrimary = rowDefault; @@ -84,11 +88,16 @@ public class UrlLinkDisplay return id; } - public String getName() + public String getDescription() { return link.getLabel(); } + public String getDBName() + { + return link.getTarget(); + } + public String getUrl() { return link.getUrlWithToken(); @@ -104,14 +113,19 @@ public class UrlLinkDisplay return isSelected; } - public void setName(String name) + public void setDBName(String name) { - link.setLabel(name); + link.setTarget(name); } public void setUrl(String rowUrl) { - link = new UrlLink(getName(), rowUrl); + link = new UrlLink(getDescription(), rowUrl, getDBName()); + } + + public void setDescription(String desc) + { + link.setLabel(desc); } public void setIsDefault(boolean rowDefault) @@ -137,7 +151,9 @@ public class UrlLinkDisplay case SELECTED: return isSelected; case NAME: - return getName(); + return getDescription(); + case DATABASE: + return getDBName(); default: return null; } @@ -160,7 +176,10 @@ public class UrlLinkDisplay isSelected = (boolean) value; break; case NAME: - setName((String) value); + setDescription((String) value); + // deliberate fall through + case DATABASE: + setDBName((String) value); break; default: // do nothing @@ -182,13 +201,9 @@ public class UrlLinkDisplay // so only allow editing if it is not return (!link.usesDBAccession()); } - else if (index == SELECTED) - { - return true; - } else { - return false; + return index == SELECTED; } } @@ -199,7 +214,7 @@ public class UrlLinkDisplay */ public static List getDisplayColumnNames() { - // Display names between NAME and ID (excludes ID) - return colNames.subList(NAME, ID); + // Display names between DESCRIPTION and ID (excludes ID) + return COLNAMES.subList(DATABASE, ID); } }