2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import jalview.util.MessageManager;
25 import jalview.util.UrlLink;
27 import java.util.ArrayList;
28 import java.util.List;
31 * UrlLink table row definition
37 public class UrlLinkDisplay
39 private String id; // id is not supplied to display, but used to identify
42 private boolean isPrimary;
44 private boolean isSelected;
48 // Headers for columns in table
49 private final static List<String> colNames = new ArrayList<String>()
52 add(MessageManager.formatMessage("label.database"));
53 add(MessageManager.formatMessage("label.name"));
54 add(MessageManager.formatMessage("label.url"));
55 add(MessageManager.formatMessage("label.inmenu"));
56 add(MessageManager.formatMessage("label.primary"));
57 add(MessageManager.formatMessage("label.id"));
62 public final static int DATABASE = 0;
64 public final static int NAME = 1;
66 public final static int URL = 2;
68 public final static int SELECTED = 3;
70 public final static int PRIMARY = 4;
72 public final static int ID = 5;
74 public UrlLinkDisplay(String rowId, UrlLink rowLink,
75 boolean rowSelected, boolean rowDefault)
78 isPrimary = rowDefault;
79 isSelected = rowSelected;
90 public String getDescription()
92 return link.getLabel();
95 public String getDBName()
97 return link.getTarget();
100 public String getUrl()
102 return link.getUrlWithToken();
105 public boolean getIsPrimary()
110 public boolean getIsSelected()
115 public void setDBName(String name)
117 link.setTarget(name);
120 public void setUrl(String rowUrl)
122 link = new UrlLink(getDescription(), rowUrl, getDBName());
125 public void setDescription(String desc)
130 public void setIsDefault(boolean rowDefault)
132 isPrimary = rowDefault;
135 public void setIsSelected(boolean rowSelected)
137 isSelected = rowSelected;
140 public Object getValue(int index)
153 return getDescription();
161 public void setValue(int index, Object value)
169 setUrl((String) value);
172 isPrimary = (boolean) value;
175 isSelected = (boolean) value;
178 setDescription((String) value);
180 setDBName((String) value);
188 * Identify editable columns
192 * @return whether column can be edited in table
194 public boolean isEditable(int index)
196 if (index == PRIMARY)
198 // primary link must not be a $DB_ACCESSION$ link
199 // so only allow editing if it is not
200 return (!link.usesDBAccession());
202 else if (index == SELECTED)
213 * Get list of column names to display in UI
215 * @return column names
217 public static List<String> getDisplayColumnNames()
219 // Display names between DESCRIPTION and ID (excludes ID)
220 return colNames.subList(DATABASE, ID);