1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import java.awt.FlowLayout; |
24 |
|
import java.awt.event.ActionEvent; |
25 |
|
import java.awt.event.ActionListener; |
26 |
|
import java.util.concurrent.atomic.AtomicBoolean; |
27 |
|
|
28 |
|
import javax.swing.BorderFactory; |
29 |
|
import javax.swing.ButtonGroup; |
30 |
|
import javax.swing.JCheckBox; |
31 |
|
import javax.swing.JLabel; |
32 |
|
import javax.swing.JPanel; |
33 |
|
import javax.swing.JRadioButton; |
34 |
|
|
35 |
|
import jalview.bin.Cache; |
36 |
|
import jalview.util.MessageManager; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
|
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 11 |
Complexity Density: 0.29 |
|
42 |
|
public class LineartOptions extends JPanel |
43 |
|
{ |
44 |
|
public static final String PROMPT_EACH_TIME = "Prompt each time"; |
45 |
|
|
46 |
|
JvOptionPane dialog; |
47 |
|
|
48 |
|
public boolean cancelled = false; |
49 |
|
|
50 |
|
String value; |
51 |
|
|
52 |
|
JRadioButton lineartRB; |
53 |
|
|
54 |
|
JCheckBox askAgainCB = new JCheckBox(); |
55 |
|
|
56 |
|
AtomicBoolean asText; |
57 |
|
|
58 |
|
private String dialogTitle; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@param |
71 |
|
|
72 |
|
@param |
73 |
|
|
74 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
75 |
0 |
public LineartOptions(String formatType, AtomicBoolean textOption)... |
76 |
|
{ |
77 |
0 |
this.asText = textOption; |
78 |
0 |
dialogTitle = MessageManager.formatMessage( |
79 |
|
"label.select_character_style_title", formatType); |
80 |
0 |
String preferencesKey = formatType + "_RENDERING"; |
81 |
0 |
try |
82 |
|
{ |
83 |
0 |
jbInit(preferencesKey, formatType); |
84 |
|
} catch (Exception ex) |
85 |
|
{ |
86 |
0 |
ex.printStackTrace(); |
87 |
|
} |
88 |
|
|
89 |
0 |
dialog = JvOptionPane.newOptionDialog(Desktop.desktop); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@param |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0 |
public void setResponseAction(Object response, Runnable action)... |
99 |
|
{ |
100 |
0 |
dialog.setResponseHandler(response, action); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
107 |
0 |
public void showDialog()... |
108 |
|
{ |
109 |
0 |
Object[] options = new Object[] { MessageManager.getString("action.ok"), |
110 |
|
MessageManager.getString("action.cancel") }; |
111 |
0 |
dialog.showInternalDialog(this, dialogTitle, |
112 |
|
JvOptionPane.OK_CANCEL_OPTION, JvOptionPane.PLAIN_MESSAGE, null, |
113 |
|
options, MessageManager.getString("action.ok")); |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
@param |
121 |
|
@throws |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
|
123 |
0 |
private void jbInit(String preferencesKey, String formatType)... |
124 |
|
throws Exception |
125 |
|
{ |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
0 |
lineartRB = new JRadioButton(MessageManager.getString("label.lineart")); |
131 |
0 |
lineartRB.setFont(JvSwingUtils.getLabelFont()); |
132 |
0 |
lineartRB.setSelected(!asText.get()); |
133 |
0 |
lineartRB.addActionListener(new ActionListener() |
134 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
@Override... |
136 |
|
public void actionPerformed(ActionEvent e) |
137 |
|
{ |
138 |
0 |
asText.set(!lineartRB.isSelected()); |
139 |
|
} |
140 |
|
}); |
141 |
|
|
142 |
0 |
JRadioButton textRB = new JRadioButton( |
143 |
|
MessageManager.getString("action.text")); |
144 |
0 |
textRB.setFont(JvSwingUtils.getLabelFont()); |
145 |
0 |
textRB.setSelected(asText.get()); |
146 |
0 |
textRB.addActionListener(new ActionListener() |
147 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
148 |
0 |
@Override... |
149 |
|
public void actionPerformed(ActionEvent e) |
150 |
|
{ |
151 |
0 |
asText.set(textRB.isSelected()); |
152 |
|
} |
153 |
|
}); |
154 |
|
|
155 |
0 |
ButtonGroup bg = new ButtonGroup(); |
156 |
0 |
bg.add(lineartRB); |
157 |
0 |
bg.add(textRB); |
158 |
|
|
159 |
0 |
askAgainCB.setFont(JvSwingUtils.getLabelFont()); |
160 |
0 |
askAgainCB.setText(MessageManager.getString("label.dont_ask_me_again")); |
161 |
|
|
162 |
0 |
JLabel prompt = new JLabel(MessageManager.formatMessage( |
163 |
|
"label.select_character_rendering_style", formatType)); |
164 |
0 |
prompt.setFont(JvSwingUtils.getLabelFont()); |
165 |
|
|
166 |
0 |
this.setLayout(new FlowLayout(FlowLayout.LEFT)); |
167 |
0 |
setBorder(BorderFactory.createEtchedBorder()); |
168 |
0 |
add(prompt); |
169 |
0 |
add(textRB); |
170 |
0 |
add(lineartRB); |
171 |
0 |
add(askAgainCB); |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
@param |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
181 |
0 |
protected void updatePreference(String preferencesKey)... |
182 |
|
{ |
183 |
0 |
value = lineartRB.isSelected() ? "Lineart" : "Text"; |
184 |
|
|
185 |
0 |
if (askAgainCB.isSelected()) |
186 |
|
{ |
187 |
0 |
Cache.setProperty(preferencesKey, value); |
188 |
|
} |
189 |
|
else |
190 |
|
{ |
191 |
0 |
Cache.applicationProperties.remove(preferencesKey); |
192 |
|
} |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
@return |
199 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
0 |
public String getValue()... |
201 |
|
{ |
202 |
|
|
203 |
0 |
return value; |
204 |
|
} |
205 |
|
} |