JAL-2446 merged to spike branch
[jalview.git] / src / jalview / urls / api / UrlProviderI.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 package jalview.urls.api;
22
23 import jalview.urls.UrlLinkDisplay;
24
25 import java.util.List;
26
27 /**
28  * Methods for providing consistent access to up-to-date URLs
29  * 
30  * @author $author$
31  * @version $Revision$
32  */
33 public interface UrlProviderI
34 {
35
36   /**
37    * Get names and urls in the UrlProvider as strings for display
38    * 
39    */
40   List<String> getLinksForMenu();
41
42   /**
43    * Get names and urls as strings for display
44    * 
45    */
46   List<UrlLinkDisplay> getLinksForTable();
47
48   /**
49    * Set names and urls from display settings
50    */
51   void setUrlData(List<UrlLinkDisplay> links);
52
53   /**
54    * Get the link for the primary URL
55    * 
56    * @seqid sequence id for which to build link
57    * @return link for the primary URL
58    */
59   String getPrimaryUrl(String seqid);
60
61   /**
62    * Get the primary URL id
63    * 
64    * @return id for primary URL
65    */
66   String getPrimaryUrlId();
67
68   /**
69    * Get the target of the link for the primary URL
70    * 
71    * @seqid sequence id for which to build link
72    * @return target of link for the primary URL
73    */
74   String getPrimaryTarget(String seqid);
75
76   /**
77    * Set the primary URL: if only one URL can be used, this URL is the one which
78    * should be chosen, e.g. provides the URL to be used on double-click of a
79    * sequence id
80    * 
81    * @param id
82    *          the id of the URL to set as primary
83    * @return true if setting is successful
84    * @throws IllegalArgumentException
85    *           if id does not exist as a url in the UrlProvider
86    */
87   boolean setPrimaryUrl(String id) throws IllegalArgumentException;
88
89   /**
90    * Test if UrlProvider contains a url
91    * 
92    * @param id
93    *          to test for
94    * @return true of UrlProvider contains this id, false otherwise
95    */
96   boolean contains(String id);
97
98   /**
99    * Write out all URLs as a string suitable for serialising
100    * 
101    * @return string representation of available URLs
102    */
103   String writeUrlsAsString(boolean selected);
104
105   /**
106    * Choose the primary URL in the event of the selected primary being
107    * unavailable
108    * 
109    * @return id of chosen primary url
110    */
111   String choosePrimaryUrl();
112
113   /**
114    * Determine if id is for a user-defined URL
115    */
116   boolean isUserEntry(String id);
117 }