1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.javascript; |
22 |
|
|
23 |
|
import jalview.appletgui.AlignFrame; |
24 |
|
import jalview.bin.JalviewLite; |
25 |
|
import jalview.datamodel.ColumnSelection; |
26 |
|
import jalview.datamodel.HiddenColumns; |
27 |
|
import jalview.datamodel.SequenceGroup; |
28 |
|
import jalview.structure.SelectionSource; |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 66 (66) |
Complexity: 22 |
Complexity Density: 0.58 |
|
30 |
|
public class JsSelectionSender extends JSFunctionExec |
31 |
|
implements jalview.structure.SelectionListener, JsCallBack |
32 |
|
{ |
33 |
|
|
34 |
|
AlignFrame _af; |
35 |
|
|
36 |
|
String _listener; |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
38 |
0 |
public JsSelectionSender(JalviewLite jvlite, AlignFrame af,... |
39 |
|
String listener) |
40 |
|
{ |
41 |
0 |
super(jvlite); |
42 |
0 |
_af = af; |
43 |
0 |
_listener = listener; |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 57 (57) |
Complexity: 19 |
Complexity Density: 0.58 |
|
46 |
0 |
@Override... |
47 |
|
public void selection(SequenceGroup seqsel, ColumnSelection colsel, |
48 |
|
HiddenColumns hidden, SelectionSource source) |
49 |
|
{ |
50 |
|
|
51 |
|
|
52 |
0 |
try |
53 |
|
{ |
54 |
0 |
String setid = ""; |
55 |
0 |
AlignFrame src = _af; |
56 |
0 |
if (source != null) |
57 |
|
{ |
58 |
0 |
if (source instanceof jalview.appletgui.AlignViewport |
59 |
|
&& ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source) |
60 |
|
{ |
61 |
|
|
62 |
0 |
src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame; |
63 |
|
|
64 |
|
} |
65 |
|
} |
66 |
0 |
String[] seqs = new String[] {}; |
67 |
0 |
String[] cols = new String[] {}; |
68 |
0 |
int strt = 0, end = (src == null) ? -1 |
69 |
|
: src.alignPanel.av.getAlignment().getWidth(); |
70 |
0 |
if (seqsel != null && seqsel.getSize() > 0) |
71 |
|
{ |
72 |
0 |
seqs = new String[seqsel.getSize()]; |
73 |
0 |
for (int i = 0; i < seqs.length; i++) |
74 |
|
{ |
75 |
0 |
seqs[i] = seqsel.getSequenceAt(i).getName(); |
76 |
|
} |
77 |
0 |
if (strt < seqsel.getStartRes()) |
78 |
|
{ |
79 |
0 |
strt = seqsel.getStartRes(); |
80 |
|
} |
81 |
0 |
if (end == -1 || end > seqsel.getEndRes()) |
82 |
|
{ |
83 |
0 |
end = seqsel.getEndRes(); |
84 |
|
} |
85 |
|
} |
86 |
0 |
if (colsel != null && !colsel.isEmpty()) |
87 |
|
{ |
88 |
0 |
if (end == -1) |
89 |
|
{ |
90 |
0 |
end = colsel.getMax() + 1; |
91 |
|
} |
92 |
0 |
cols = new String[colsel.getSelected().size()]; |
93 |
0 |
for (int i = 0; i < cols.length; i++) |
94 |
|
{ |
95 |
0 |
cols[i] = "" + (1 + colsel.getSelected().get(i).intValue()); |
96 |
|
} |
97 |
|
} |
98 |
|
else |
99 |
|
{ |
100 |
0 |
if (seqsel != null && seqsel.getSize() > 0) |
101 |
|
{ |
102 |
|
|
103 |
0 |
cols = new String[2]; |
104 |
0 |
cols[0] = "" + (1 + strt) + "-" + (1 + end); |
105 |
|
} |
106 |
0 |
; |
107 |
|
|
108 |
|
} |
109 |
0 |
jalview.bin.Console |
110 |
|
.errPrintln("Relaying selection to jsfunction:" + _listener); |
111 |
0 |
executeJavascriptFunction(_listener, |
112 |
|
new Object[] |
113 |
|
{ src, setid, jvlite.arrayToSeparatorList(seqs), |
114 |
|
jvlite.arrayToSeparatorList(cols) }); |
115 |
|
} catch (Exception ex) |
116 |
|
{ |
117 |
0 |
jalview.bin.Console.errPrintln( |
118 |
|
"Jalview Javascript exec error: Couldn't send selection message using function '" |
119 |
|
+ _listener + "'"); |
120 |
0 |
ex.printStackTrace(); |
121 |
0 |
if (ex instanceof netscape.javascript.JSException) |
122 |
|
{ |
123 |
0 |
jalview.bin.Console.errPrintln("Javascript Exception: " |
124 |
|
+ ((netscape.javascript.JSException) ex).getCause() |
125 |
|
.toString()); |
126 |
|
} |
127 |
|
|
128 |
|
} |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0 |
@Override... |
132 |
|
public AlignFrame getAlignFrame() |
133 |
|
{ |
134 |
0 |
return _af; |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0 |
@Override... |
138 |
|
public String getListenerFunction() |
139 |
|
{ |
140 |
0 |
return _listener; |
141 |
|
} |
142 |
|
|
143 |
|
} |