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.Container; |
24 |
|
import java.io.File; |
25 |
|
import java.util.ArrayList; |
26 |
|
import java.util.List; |
27 |
|
import java.util.Map; |
28 |
|
|
29 |
|
import javax.swing.JComponent; |
30 |
|
|
31 |
|
import org.jmol.api.JmolAppConsoleInterface; |
32 |
|
import org.openscience.jmol.app.jmolpanel.console.AppConsole; |
33 |
|
|
34 |
|
import jalview.api.AlignmentViewPanel; |
35 |
|
import jalview.api.structures.JalviewStructureDisplayI; |
36 |
|
import jalview.bin.Console; |
37 |
|
import jalview.bin.Jalview; |
38 |
|
import jalview.datamodel.PDBEntry; |
39 |
|
import jalview.datamodel.SequenceI; |
40 |
|
import jalview.ext.jmol.JalviewJmolBinding; |
41 |
|
import jalview.io.DataSourceType; |
42 |
|
import jalview.structure.StructureSelectionManager; |
43 |
|
import jalview.util.MessageManager; |
44 |
|
import jalview.util.Platform; |
45 |
|
import javajs.util.BS; |
46 |
|
|
|
|
| 60.7% |
Uncovered Elements: 42 (107) |
Complexity: 40 |
Complexity Density: 0.66 |
|
47 |
|
public class AppJmolBinding extends JalviewJmolBinding |
48 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
45 |
public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,... |
50 |
|
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, |
51 |
|
DataSourceType protocol) |
52 |
|
{ |
53 |
45 |
super(sSm, pdbentry, sequenceIs, protocol); |
54 |
45 |
setViewer(appJmol); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
276 |
@Override... |
58 |
|
public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment) |
59 |
|
{ |
60 |
276 |
return new SequenceRenderer(((AlignmentPanel) alignment).av); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
63 |
32 |
@Override... |
64 |
|
public void sendConsoleEcho(String strEcho) |
65 |
|
{ |
66 |
32 |
if (console != null) |
67 |
|
{ |
68 |
18 |
console.sendConsoleEcho(strEcho); |
69 |
|
} |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
72 |
0 |
@Override... |
73 |
|
public void sendConsoleMessage(String strStatus) |
74 |
|
{ |
75 |
0 |
if (console != null && strStatus != null) |
76 |
|
|
77 |
|
|
78 |
|
{ |
79 |
0 |
console.sendConsoleMessage(strStatus); |
80 |
|
} |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
83 |
0 |
@Override... |
84 |
|
public void showUrl(String url, String target) |
85 |
|
{ |
86 |
0 |
try |
87 |
|
{ |
88 |
0 |
jalview.util.BrowserLauncher.openURL(url); |
89 |
|
} catch (Exception e) |
90 |
|
{ |
91 |
0 |
Console.error("Failed to launch Jmol-associated url " + url, e); |
92 |
|
|
93 |
|
} |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
96 |
102 |
@Override... |
97 |
|
public void refreshGUI() |
98 |
|
{ |
99 |
102 |
if (getMappedStructureCount() == 0) |
100 |
|
{ |
101 |
|
|
102 |
50 |
return; |
103 |
|
} |
104 |
|
|
105 |
52 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
106 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
107 |
52 |
@Override... |
108 |
|
public void run() |
109 |
|
{ |
110 |
52 |
JalviewStructureDisplayI theViewer = getViewer(); |
111 |
|
|
112 |
52 |
theViewer.updateTitleAndMenus(); |
113 |
46 |
((JComponent) theViewer).revalidate(); |
114 |
|
} |
115 |
|
}); |
116 |
|
} |
117 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
118 |
8 |
@Override... |
119 |
|
public void notifyScriptTermination(String strStatus, int msWalltime) |
120 |
|
{ |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
} |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
0 |
@Override... |
128 |
|
public void showUrl(String url) |
129 |
|
{ |
130 |
0 |
showUrl(url, "jmol"); |
131 |
|
} |
132 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
133 |
0 |
public void newJmolPopup(String menuName)... |
134 |
|
{ |
135 |
|
|
136 |
|
|
137 |
|
} |
138 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
139 |
0 |
@Override... |
140 |
|
public void selectionChanged(BS arg0) |
141 |
|
{ |
142 |
|
} |
143 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
144 |
0 |
@Override... |
145 |
|
public void showConsole(boolean b) |
146 |
|
{ |
147 |
0 |
getViewer().showConsole(b); |
148 |
|
} |
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
150 |
45 |
@Override... |
151 |
|
protected JmolAppConsoleInterface createJmolConsole( |
152 |
|
Container consolePanel, String buttonsToShow) |
153 |
|
{ |
154 |
45 |
jmolViewer.setJmolCallbackListener(this); |
155 |
|
|
156 |
45 |
return Platform.isJS() || Jalview.isHeadlessMode() ? null |
157 |
|
: new AppConsole(jmolViewer, consolePanel, buttonsToShow); |
158 |
|
} |
159 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
160 |
22 |
@Override... |
161 |
|
protected void releaseUIResources() |
162 |
|
{ |
163 |
22 |
setViewer(null); |
164 |
22 |
closeConsole(); |
165 |
|
} |
166 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
167 |
42 |
@Override... |
168 |
|
public void releaseReferences(Object svl) |
169 |
|
{ |
170 |
42 |
if (svl instanceof SeqPanel) |
171 |
|
{ |
172 |
42 |
getViewer().removeAlignmentPanel(((SeqPanel) svl).ap); |
173 |
|
} |
174 |
|
} |
175 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
176 |
0 |
@Override... |
177 |
|
public Map<String, Object> getJSpecViewProperty(String arg0) |
178 |
|
{ |
179 |
|
|
180 |
0 |
return null; |
181 |
|
} |
182 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
183 |
0 |
@SuppressWarnings("unused")... |
184 |
|
public void cacheFiles(List<File> files) |
185 |
|
{ |
186 |
0 |
if (files == null) |
187 |
|
{ |
188 |
0 |
return; |
189 |
|
} |
190 |
0 |
for (File f : files) |
191 |
|
{ |
192 |
0 |
Platform.cacheFileData(f); |
193 |
|
} |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
@param |
206 |
|
|
207 |
|
@return |
208 |
|
|
209 |
|
|
|
|
| 64.6% |
Uncovered Elements: 17 (48) |
Complexity: 14 |
Complexity Density: 0.44 |
|
210 |
39 |
public List<String> fetchPdbFiles(StructureViewerBase structureViewer)... |
211 |
|
{ |
212 |
|
|
213 |
39 |
StringBuilder errormsgs = new StringBuilder(); |
214 |
|
|
215 |
39 |
List<String> files = new ArrayList<>(); |
216 |
39 |
String pdbid = ""; |
217 |
39 |
try |
218 |
|
{ |
219 |
39 |
String[] filesInViewer = getStructureFiles(); |
220 |
|
|
221 |
|
|
222 |
|
|
223 |
79 |
for (int pi = 0; pi < getPdbCount(); pi++) |
224 |
|
{ |
225 |
40 |
PDBEntry strucEntry = getPdbEntry(pi); |
226 |
|
|
227 |
40 |
String file = strucEntry.getFile(); |
228 |
40 |
if (file == null) |
229 |
|
{ |
230 |
0 |
pdbid = strucEntry.getId(); |
231 |
0 |
try |
232 |
|
{ |
233 |
0 |
file = structureViewer.fetchPdbFile(strucEntry); |
234 |
|
} catch (OutOfMemoryError oomerror) |
235 |
|
{ |
236 |
0 |
new OOMWarning("Retrieving PDB id " + pdbid, oomerror); |
237 |
|
} catch (Exception ex) |
238 |
|
{ |
239 |
0 |
ex.printStackTrace(); |
240 |
0 |
errormsgs.append("'").append(pdbid).append("'"); |
241 |
|
} |
242 |
0 |
if (file != null) |
243 |
|
{ |
244 |
|
|
245 |
0 |
files.add(file); |
246 |
|
} |
247 |
|
else |
248 |
|
{ |
249 |
0 |
errormsgs.append("'").append(pdbid).append("' "); |
250 |
|
} |
251 |
|
} |
252 |
|
else |
253 |
|
{ |
254 |
40 |
if (filesInViewer != null && filesInViewer.length > 0) |
255 |
|
{ |
256 |
2 |
structureViewer.setAddingStructures(true); |
257 |
3 |
for (int c = 0; c < filesInViewer.length; c++) |
258 |
|
{ |
259 |
2 |
if (Platform.pathEquals(filesInViewer[c], file)) |
260 |
|
{ |
261 |
1 |
file = null; |
262 |
1 |
break; |
263 |
|
} |
264 |
|
} |
265 |
|
} |
266 |
40 |
if (file != null) |
267 |
|
{ |
268 |
39 |
files.add(file); |
269 |
|
} |
270 |
|
} |
271 |
|
} |
272 |
|
} catch (OutOfMemoryError oomerror) |
273 |
|
{ |
274 |
0 |
new OOMWarning("Retrieving PDB files: " + pdbid, oomerror); |
275 |
|
} catch (Exception ex) |
276 |
|
{ |
277 |
0 |
ex.printStackTrace(); |
278 |
0 |
errormsgs.append("When retrieving pdbfiles : current was: '") |
279 |
|
.append(pdbid).append("'"); |
280 |
|
} |
281 |
39 |
if (errormsgs.length() > 0) |
282 |
|
{ |
283 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
284 |
|
MessageManager.formatMessage( |
285 |
|
"label.pdb_entries_couldnt_be_retrieved", new String[] |
286 |
|
{ errormsgs.toString() }), |
287 |
|
MessageManager.getString("label.couldnt_load_file"), |
288 |
|
JvOptionPane.ERROR_MESSAGE); |
289 |
|
} |
290 |
39 |
return files; |
291 |
|
} |
292 |
|
|
293 |
|
} |