JAL-2316 GUI updates to Connections tab in Preferences dialog
[jalview.git] / src / jalview / urls / UrlLinkDisplay.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21
22 package jalview.urls;
23
24
25 /**
26  * UrlLink table row definition
27  * 
28  * @author $author$
29  * @version $Revision$
30  */
31
32 public class UrlLinkDisplay
33 {
34   private String id; // id is not supplied to display, but used to identify
35                      // entries when saved
36
37   private String name;
38
39   private String url;
40
41   private boolean isDefault;
42
43   private boolean isSelected;
44
45   public final static int ID = 4;
46
47   public final static int URL = 1;
48
49   public final static int SELECTED = 2;
50
51   public final static int DEFAULT = 3;
52
53   public final static int NAME = 0;
54
55   public UrlLinkDisplay(String rowId, String rowName, String rowUrl,
56           boolean rowSelected, boolean rowDefault)
57   {
58     id = rowId;
59     name = rowName;
60     url = rowUrl;
61     isDefault = rowDefault;
62     isSelected = rowSelected;
63   }
64
65   public String getId()
66   {
67     return id;
68   }
69
70   public String getName()
71   {
72     return name;
73   }
74
75   public String getUrl()
76   {
77     return url;
78   }
79
80   public boolean getIsDefault()
81   {
82     return isDefault;
83   }
84
85   public boolean getIsSelected()
86   {
87     return isSelected;
88   }
89
90   public void setUrl(String rowUrl)
91   {
92     url = rowUrl;
93   }
94
95   public void setIsDefault(boolean rowDefault)
96   {
97     isDefault = rowDefault;
98   }
99
100   public void setIsSelected(boolean rowSelected)
101   {
102     isSelected = rowSelected;
103   }
104
105   public Object getValue(int index)
106   {
107     switch (index)
108     {
109     case ID:
110       return id;
111     case URL:
112       return url;
113     case DEFAULT:
114       return isDefault;
115     case SELECTED:
116       return isSelected;
117     case NAME:
118       return name;
119     default:
120       return null; // TODO
121     }
122   }
123
124   public void setValue(int index, Object value)
125   {
126     switch (index)
127     {
128     case ID:
129       id = (String) value;
130       break;
131     case URL:
132       url = (String) value;
133       break;
134     case DEFAULT:
135       isDefault = (boolean) value;
136       break;
137     case SELECTED:
138       isSelected = (boolean) value;
139       break;
140     case NAME:
141       name = (String) value;
142       break;
143     default:
144       // TODO
145     }
146   }
147
148   public boolean isEditable(int index)
149   {
150     return ((index == DEFAULT) || (index == SELECTED));
151   }
152 }