Class |
Line # |
Actions |
|||
---|---|---|---|---|---|
JabaOption | 32 | 14 | 13 |
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.ws.jws2.dm; | |
22 | ||
23 | import java.net.MalformedURLException; | |
24 | import java.net.URL; | |
25 | import java.util.List; | |
26 | ||
27 | import compbio.metadata.Option; | |
28 | import jalview.util.MessageManager; | |
29 | import jalview.ws.jws2.ParameterUtils; | |
30 | import jalview.ws.params.OptionI; | |
31 | ||
32 | public class JabaOption implements jalview.ws.params.OptionI | |
33 | { | |
34 | 0 | public JabaOption(Option rg) |
35 | { | |
36 | 0 | opt = rg; |
37 | } | |
38 | ||
39 | Option opt; | |
40 | ||
41 | 0 | @Override |
42 | public String getValue() | |
43 | { | |
44 | 0 | return opt.getDefaultValue(); |
45 | } | |
46 | ||
47 | 0 | @Override |
48 | public String getName() | |
49 | { | |
50 | 0 | return opt.getName(); |
51 | } | |
52 | ||
53 | 0 | @Override |
54 | public URL getFurtherDetails() | |
55 | { | |
56 | 0 | try |
57 | { | |
58 | 0 | return new URL(opt.getBasicURL().toExternalForm() + "/" |
59 | + opt.getFurtherDetails()); | |
60 | } catch (NullPointerException q) | |
61 | { | |
62 | } catch (MalformedURLException q) | |
63 | { | |
64 | ||
65 | } | |
66 | 0 | return null; |
67 | } | |
68 | ||
69 | 0 | @Override |
70 | public boolean isRequired() | |
71 | { | |
72 | 0 | return opt.isRequired(); |
73 | } | |
74 | ||
75 | 0 | @Override |
76 | public String getDescription() | |
77 | { | |
78 | 0 | return opt.getDescription(); |
79 | } | |
80 | ||
81 | 0 | @Override |
82 | public List<String> getPossibleValues() | |
83 | { | |
84 | // TODO: assert typesafety | |
85 | 0 | return opt.getPossibleValues(); |
86 | } | |
87 | ||
88 | 0 | @Override |
89 | public void setValue(String selectedItem) | |
90 | { | |
91 | 0 | try |
92 | { | |
93 | 0 | opt.setDefaultValue(selectedItem); |
94 | } catch (Exception e) | |
95 | { | |
96 | 0 | throw new IllegalArgumentException(MessageManager |
97 | .formatMessage("error.invalid_value_for_option", new String[] | |
98 | { selectedItem, opt.getName() })); | |
99 | } | |
100 | } | |
101 | ||
102 | 0 | @Override |
103 | public OptionI copy() | |
104 | { | |
105 | 0 | return new JabaOption(ParameterUtils.copyOption(opt)); |
106 | } | |
107 | ||
108 | /** | |
109 | * get the underlying Jaba option or parameter object. Note - use copy first | |
110 | * if you want to modify the value of the option. | |
111 | * | |
112 | * @return | |
113 | */ | |
114 | 0 | public Option getOption() |
115 | { | |
116 | 0 | return opt; |
117 | } | |
118 | ||
119 | } |