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