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.name"));
53 add(MessageManager.formatMessage("label.url"));
54 add(MessageManager.formatMessage("label.inmenu"));
55 add(MessageManager.formatMessage("label.primary"));
56 add(MessageManager.formatMessage("label.id"));
61 public final static int NAME = 0;
63 public final static int URL = 1;
65 public final static int SELECTED = 2;
67 public final static int PRIMARY = 3;
69 public final static int ID = 4;
71 public UrlLinkDisplay(String rowId, UrlLink rowLink,
72 boolean rowSelected, boolean rowDefault)
75 isPrimary = rowDefault;
76 isSelected = rowSelected;
87 public String getName()
89 return link.getLabel();
92 public String getUrl()
94 return link.getUrlWithToken();
97 public boolean getIsPrimary()
102 public boolean getIsSelected()
107 public void setName(String name)
112 public void setUrl(String rowUrl)
114 link = new UrlLink(getName(), rowUrl);
117 public void setIsDefault(boolean rowDefault)
119 isPrimary = rowDefault;
122 public void setIsSelected(boolean rowSelected)
124 isSelected = rowSelected;
127 public Object getValue(int index)
146 public void setValue(int index, Object value)
154 setUrl((String) value);
157 isPrimary = (boolean) value;
160 isSelected = (boolean) value;
163 setName((String) value);
171 * Identify editable columns
175 * @return whether column can be edited in table
177 public boolean isEditable(int index)
179 if (index == PRIMARY)
181 // primary link must not be a $DB_ACCESSION$ link
182 // so only allow editing if it is not
183 return (!link.usesDBAccession());
185 else if (index == SELECTED)
196 * Get list of column names to display in UI
198 * @return column names
200 public static List<String> getDisplayColumnNames()
202 // Display names between NAME and ID (excludes ID)
203 return colNames.subList(NAME, ID);