JAL-1807 test
[jalviewjs.git] / bin / jalview / appletgui / APopupMenu.js
1 Clazz.declarePackage ("jalview.appletgui");
2 Clazz.load (["awt2swing.PopupMenu", "java.awt.event.ActionListener", "$.ItemListener", "awt2swing.CheckboxMenuItem", "$.Menu", "$.MenuItem", "jalview.util.MessageManager"], "jalview.appletgui.APopupMenu", ["awt2swing.Frame", "jalview.analysis.AAFrequency", "$.AlignmentAnnotationUtils", "$.AlignmentUtils", "$.Conservation", "jalview.appletgui.AppletJmol", "$.CutAndPasteTransfer", "$.EditNameDialog", "$.SliderPanel", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.commands.ChangeCaseCommand", "$.EditCommand", "jalview.datamodel.SequenceFeature", "jalview.io.AppletFormatAdapter", "$.SequenceAnnotationReport", "jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.ResidueProperties", "$.StrandColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.ZappoColourScheme", "jalview.util.DBRefUtils", "$.UrlLink", "java.lang.StringBuffer", "$.StringBuilder", "java.util.Arrays", "$.Collections", "$.LinkedHashMap", "$.TreeMap"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.groupMenu = null;
5 this.editGroupName = null;
6 this.clustalColour = null;
7 this.zappoColour = null;
8 this.taylorColour = null;
9 this.hydrophobicityColour = null;
10 this.helixColour = null;
11 this.strandColour = null;
12 this.turnColour = null;
13 this.buriedColour = null;
14 this.abovePIDColour = null;
15 this.userDefinedColour = null;
16 this.PIDColour = null;
17 this.BLOSUM62Colour = null;
18 this.noColourmenuItem = null;
19 this.conservationMenuItem = null;
20 this.ap = null;
21 this.unGroupMenuItem = null;
22 this.createGroupMenuItem = null;
23 this.nucleotideMenuItem = null;
24 this.colourMenu = null;
25 this.showBoxes = null;
26 this.showText = null;
27 this.showColourText = null;
28 this.displayNonconserved = null;
29 this.seqShowAnnotationsMenu = null;
30 this.seqHideAnnotationsMenu = null;
31 this.seqAddReferenceAnnotations = null;
32 this.groupShowAnnotationsMenu = null;
33 this.groupHideAnnotationsMenu = null;
34 this.groupAddReferenceAnnotations = null;
35 this.editMenu = null;
36 this.copy = null;
37 this.cut = null;
38 this.toUpper = null;
39 this.toLower = null;
40 this.toggleCase = null;
41 this.outputmenu = null;
42 this.seqMenu = null;
43 this.pdb = null;
44 this.hideSeqs = null;
45 this.repGroup = null;
46 this.sequenceName = null;
47 this.sequenceFeature = null;
48 this.editSequence = null;
49 this.sequenceDetails = null;
50 this.selSeqDetails = null;
51 this.makeReferenceSeq = null;
52 this.seq = null;
53 this.revealAll = null;
54 this.revealSeq = null;
55 this.revealSeq_index = -1;
56 this.menu1 = null;
57 Clazz.instantialize (this, arguments);
58 }, jalview.appletgui, "APopupMenu", awt2swing.PopupMenu, [java.awt.event.ActionListener, java.awt.event.ItemListener]);
59 Clazz.prepareFields (c$, function () {
60 this.groupMenu =  new awt2swing.Menu ();
61 this.editGroupName =  new awt2swing.MenuItem ();
62 this.clustalColour =  new awt2swing.MenuItem ();
63 this.zappoColour =  new awt2swing.MenuItem ();
64 this.taylorColour =  new awt2swing.MenuItem ();
65 this.hydrophobicityColour =  new awt2swing.MenuItem ();
66 this.helixColour =  new awt2swing.MenuItem ();
67 this.strandColour =  new awt2swing.MenuItem ();
68 this.turnColour =  new awt2swing.MenuItem ();
69 this.buriedColour =  new awt2swing.MenuItem ();
70 this.abovePIDColour =  new awt2swing.CheckboxMenuItem ();
71 this.userDefinedColour =  new awt2swing.MenuItem ();
72 this.PIDColour =  new awt2swing.MenuItem ();
73 this.BLOSUM62Colour =  new awt2swing.MenuItem ();
74 this.noColourmenuItem =  new awt2swing.MenuItem ();
75 this.conservationMenuItem =  new awt2swing.CheckboxMenuItem ();
76 this.unGroupMenuItem =  new awt2swing.MenuItem ();
77 this.createGroupMenuItem =  new awt2swing.MenuItem ();
78 this.nucleotideMenuItem =  new awt2swing.MenuItem ();
79 this.colourMenu =  new awt2swing.Menu ();
80 this.showBoxes =  new awt2swing.CheckboxMenuItem ();
81 this.showText =  new awt2swing.CheckboxMenuItem ();
82 this.showColourText =  new awt2swing.CheckboxMenuItem ();
83 this.displayNonconserved =  new awt2swing.CheckboxMenuItem ();
84 this.seqShowAnnotationsMenu =  new awt2swing.Menu (jalview.util.MessageManager.getString ("label.show_annotations"));
85 this.seqHideAnnotationsMenu =  new awt2swing.Menu (jalview.util.MessageManager.getString ("label.hide_annotations"));
86 this.seqAddReferenceAnnotations =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.add_reference_annotations"));
87 this.groupShowAnnotationsMenu =  new awt2swing.Menu (jalview.util.MessageManager.getString ("label.show_annotations"));
88 this.groupHideAnnotationsMenu =  new awt2swing.Menu (jalview.util.MessageManager.getString ("label.hide_annotations"));
89 this.groupAddReferenceAnnotations =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.add_reference_annotations"));
90 this.editMenu =  new awt2swing.Menu (jalview.util.MessageManager.getString ("action.edit"));
91 this.copy =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.copy"));
92 this.cut =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.cut"));
93 this.toUpper =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.to_upper_case"));
94 this.toLower =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.to_lower_case"));
95 this.toggleCase =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.toggle_case"));
96 this.outputmenu =  new awt2swing.Menu ();
97 this.seqMenu =  new awt2swing.Menu ();
98 this.pdb =  new awt2swing.MenuItem ();
99 this.hideSeqs =  new awt2swing.MenuItem ();
100 this.repGroup =  new awt2swing.MenuItem ();
101 this.sequenceName =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.edit_name_description"));
102 this.sequenceFeature =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.create_sequence_feature"));
103 this.editSequence =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.edit_sequence"));
104 this.sequenceDetails =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sequence_details") + "...");
105 this.selSeqDetails =  new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sequence_details") + "...");
106 this.makeReferenceSeq =  new awt2swing.MenuItem ();
107 this.revealAll =  new awt2swing.MenuItem ();
108 this.revealSeq =  new awt2swing.MenuItem ();
109 this.menu1 =  new awt2swing.Menu ();
110 });
111 Clazz.makeConstructor (c$, 
112 function (apanel, seq, links) {
113 Clazz.superConstructor (this, jalview.appletgui.APopupMenu, []);
114 this.ap = apanel;
115 this.seq = seq;
116 try {
117 this.jbInit ();
118 } catch (e) {
119 if (Clazz.exceptionOf (e, Exception)) {
120 e.printStackTrace ();
121 } else {
122 throw e;
123 }
124 }
125 for (var i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) {
126 var item =  new awt2swing.MenuItem (jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
127 item.addActionListener (this);
128 this.outputmenu.add (item);
129 }
130 this.buildAnnotationSubmenus ();
131 var sg = this.ap.av.getSelectionGroup ();
132 if (sg != null && sg.getSize () > 0) {
133 this.editGroupName.setLabel (jalview.util.MessageManager.formatMessage ("label.name_param",  Clazz.newArray (-1, [sg.getName ()])));
134 this.showText.setState (sg.getDisplayText ());
135 this.showColourText.setState (sg.getColourText ());
136 this.showBoxes.setState (sg.getDisplayBoxes ());
137 this.displayNonconserved.setState (sg.getShowNonconserved ());
138 if (!this.ap.av.getAlignment ().getGroups ().contains (sg)) {
139 this.menu1.setLabel (jalview.util.MessageManager.getString ("action.edit_new_group"));
140 this.groupMenu.remove (this.unGroupMenuItem);
141 } else {
142 this.menu1.setLabel (jalview.util.MessageManager.getString ("action.edit_group"));
143 this.groupMenu.remove (this.createGroupMenuItem);
144 }} else {
145 this.remove (this.hideSeqs);
146 this.remove (this.groupMenu);
147 }if (links != null && links.size () > 0) {
148 var linkMenu =  new awt2swing.Menu (jalview.util.MessageManager.getString ("action.link"));
149 for (var i = 0; i < links.size (); i++) {
150 var link = links.elementAt (i);
151 var urlLink =  new jalview.util.UrlLink (link);
152 if (!urlLink.isValid ()) {
153 System.err.println (urlLink.getInvalidMessage ());
154 continue;
155 }var target = urlLink.getTarget ();
156 var label = urlLink.getLabel ();
157 if (seq != null && urlLink.isDynamic ()) {
158 var dbr = jalview.util.DBRefUtils.selectRefs (seq.getDBRef (),  Clazz.newArray (-1, [target]));
159 var id = seq.getName ();
160 var descr = seq.getDescription ();
161 if (descr != null && descr.length < 1) {
162 descr = null;
163 }if (dbr != null) {
164 for (var r = 0; r < dbr.length; r++) {
165 if (id != null && dbr[r].getAccessionId ().equals (id)) {
166 id = null;
167 }var urls = urlLink.makeUrls (dbr[r].getAccessionId (), true);
168 if (urls != null) {
169 for (var u = 0; u < urls.length; u += 2) {
170 this.addshowLink (linkMenu, label + "|" + urls[u], urls[u + 1]);
171 }
172 }}
173 }if (id != null) {
174 var urls = urlLink.makeUrls (id, true);
175 if (urls != null) {
176 for (var u = 0; u < urls.length; u += 2) {
177 this.addshowLink (linkMenu, label, urls[u + 1]);
178 }
179 }}if (descr != null && urlLink.getRegexReplace () != null) {
180 var urls = urlLink.makeUrls (descr, true);
181 if (urls != null) {
182 for (var u = 0; u < urls.length; u += 2) {
183 this.addshowLink (linkMenu, label, urls[u + 1]);
184 }
185 }}} else {
186 this.addshowLink (linkMenu, target, urlLink.getUrl_prefix ());
187 }}
188 if (linkMenu.getItemCount () > 0) {
189 if (seq != null) {
190 this.seqMenu.add (linkMenu);
191 } else {
192 this.add (linkMenu);
193 }}}if (seq != null) {
194 this.seqMenu.setLabel (seq.getName ());
195 if (seq === this.ap.av.getAlignment ().getSeqrep ()) {
196 this.makeReferenceSeq.setLabel (jalview.util.MessageManager.getString ("action.unmark_as_reference"));
197 } else {
198 this.makeReferenceSeq.setLabel (jalview.util.MessageManager.getString ("action.set_as_reference"));
199 }this.repGroup.setLabel (jalview.util.MessageManager.formatMessage ("label.represent_group_with",  Clazz.newArray (-1, [seq.getName ()])));
200 } else {
201 this.remove (this.seqMenu);
202 }if (!this.ap.av.hasHiddenRows ()) {
203 this.remove (this.revealAll);
204 this.remove (this.revealSeq);
205 } else {
206 var index = this.ap.av.getAlignment ().findIndex (seq);
207 if (this.ap.av.adjustForHiddenSeqs (index) - this.ap.av.adjustForHiddenSeqs (index - 1) > 1) {
208 this.revealSeq_index = index;
209 } else {
210 this.remove (this.revealSeq);
211 }}}, "jalview.appletgui.AlignmentPanel,jalview.datamodel.SequenceI,java.util.Vector");
212 Clazz.defineMethod (c$, "buildAnnotationSubmenus", 
213 ($fz = function () {
214 var selectedSequence = (this.seq == null ? java.util.Collections.emptyList () : java.util.Arrays.asList ([this.seq]));
215 this.buildAnnotationTypesMenus (this.seqShowAnnotationsMenu, this.seqHideAnnotationsMenu, selectedSequence);
216 this.configureReferenceAnnotationsMenu (this.seqAddReferenceAnnotations, selectedSequence);
217 var selectedGroup = (this.ap.av.getSelectionGroup () == null ? java.util.Collections.emptyList () : this.ap.av.getSelectionGroup ().getSequences ());
218 this.buildAnnotationTypesMenus (this.groupShowAnnotationsMenu, this.groupHideAnnotationsMenu, selectedGroup);
219 this.configureReferenceAnnotationsMenu (this.groupAddReferenceAnnotations, selectedGroup);
220 }, $fz.isPrivate = true, $fz));
221 Clazz.defineMethod (c$, "configureReferenceAnnotationsMenu", 
222 ($fz = function (menuItem, forSequences) {
223 menuItem.setEnabled (false);
224 var tipEntries =  new java.util.TreeMap ();
225 var candidates =  new java.util.LinkedHashMap ();
226 var al = this.ap.av.getAlignment ();
227 jalview.analysis.AlignmentUtils.findAddableReferenceAnnotations (forSequences, tipEntries, candidates, al);
228 if (!candidates.isEmpty ()) {
229 var tooltip =  new StringBuilder (64);
230 tooltip.append (jalview.util.MessageManager.getString ("label.add_annotations_for"));
231 menuItem.setEnabled (true);
232 menuItem.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$1") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$1, this, Clazz.cloneFinals ("candidates", candidates))));
233 }}, $fz.isPrivate = true, $fz), "awt2swing.MenuItem,java.util.List");
234 Clazz.defineMethod (c$, "addReferenceAnnotations_actionPerformed", 
235 function (candidates) {
236 var selectionGroup = this.ap.av.getSelectionGroup ();
237 var alignment = this.ap.getAlignment ();
238 jalview.analysis.AlignmentUtils.addReferenceAnnotations (candidates, alignment, selectionGroup);
239 this.refresh ();
240 }, "java.util.Map");
241 Clazz.defineMethod (c$, "addshowLink", 
242 ($fz = function (linkMenu, target, url) {
243 this.addshowLink (linkMenu, target, target, url);
244 }, $fz.isPrivate = true, $fz), "awt2swing.Menu,~S,~S");
245 Clazz.defineMethod (c$, "addshowLink", 
246 ($fz = function (linkMenu, target, label, url) {
247 var item =  new awt2swing.MenuItem (label);
248 item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$2") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$2, this, Clazz.cloneFinals ("url", url, "target", target))));
249 linkMenu.add (item);
250 }, $fz.isPrivate = true, $fz), "awt2swing.Menu,~S,~S,~S");
251 Clazz.overrideMethod (c$, "itemStateChanged", 
252 function (evt) {
253 if (evt.getSource () === this.abovePIDColour) {
254 this.abovePIDColour_itemStateChanged ();
255 } else if (evt.getSource () === this.showColourText) {
256 this.showColourText_itemStateChanged ();
257 } else if (evt.getSource () === this.showText) {
258 this.showText_itemStateChanged ();
259 } else if (evt.getSource () === this.showBoxes) {
260 this.showBoxes_itemStateChanged ();
261 } else if (evt.getSource () === this.displayNonconserved) {
262 this.showNonconserved_itemStateChanged ();
263 }}, "java.awt.event.ItemEvent");
264 Clazz.overrideMethod (c$, "actionPerformed", 
265 function (evt) {
266 var source = evt.getSource ();
267 if (source === this.clustalColour) {
268 this.clustalColour_actionPerformed ();
269 } else if (source === this.zappoColour) {
270 this.zappoColour_actionPerformed ();
271 } else if (source === this.taylorColour) {
272 this.taylorColour_actionPerformed ();
273 } else if (source === this.hydrophobicityColour) {
274 this.hydrophobicityColour_actionPerformed ();
275 } else if (source === this.helixColour) {
276 this.helixColour_actionPerformed ();
277 } else if (source === this.strandColour) {
278 this.strandColour_actionPerformed ();
279 } else if (source === this.turnColour) {
280 this.turnColour_actionPerformed ();
281 } else if (source === this.buriedColour) {
282 this.buriedColour_actionPerformed ();
283 } else if (source === this.nucleotideMenuItem) {
284 this.nucleotideMenuItem_actionPerformed ();
285 } else if (source === this.userDefinedColour) {
286 this.userDefinedColour_actionPerformed ();
287 } else if (source === this.PIDColour) {
288 this.PIDColour_actionPerformed ();
289 } else if (source === this.BLOSUM62Colour) {
290 this.BLOSUM62Colour_actionPerformed ();
291 } else if (source === this.noColourmenuItem) {
292 this.noColourmenuItem_actionPerformed ();
293 } else if (source === this.conservationMenuItem) {
294 this.conservationMenuItem_itemStateChanged ();
295 } else if (source === this.unGroupMenuItem) {
296 this.unGroupMenuItem_actionPerformed ();
297 } else if (source === this.createGroupMenuItem) {
298 this.createGroupMenuItem_actionPerformed ();
299 } else if (source === this.sequenceName) {
300 this.editName ();
301 } else if (source === this.makeReferenceSeq) {
302 this.makeReferenceSeq_actionPerformed ();
303 } else if (source === this.sequenceDetails) {
304 this.showSequenceDetails ();
305 } else if (source === this.selSeqDetails) {
306 this.showSequenceSelectionDetails ();
307 } else if (source === this.pdb) {
308 this.addPDB ();
309 } else if (source === this.hideSeqs) {
310 this.hideSequences (false);
311 } else if (source === this.repGroup) {
312 this.hideSequences (true);
313 } else if (source === this.revealSeq) {
314 this.ap.av.showSequence (this.revealSeq_index);
315 } else if (source === this.revealAll) {
316 this.ap.av.showAllHiddenSeqs ();
317 } else if (source === this.editGroupName) {
318 var dialog =  new jalview.appletgui.EditNameDialog (this.getGroup ().getName (), this.getGroup ().getDescription (), "       Group Name", "Group Description", this.ap.alignFrame, "Edit Group Name / Description", 500, 100, true);
319 if (dialog.accept) {
320 this.getGroup ().setName (dialog.getName ().$replace (' ', '_'));
321 this.getGroup ().setDescription (dialog.getDescription ());
322 }} else if (source === this.copy) {
323 this.ap.alignFrame.copy_actionPerformed ();
324 } else if (source === this.cut) {
325 this.ap.alignFrame.cut_actionPerformed ();
326 } else if (source === this.editSequence) {
327 var sg = this.ap.av.getSelectionGroup ();
328 if (sg != null) {
329 if (this.seq == null) {
330 this.seq = sg.getSequenceAt (0);
331 }var dialog =  new jalview.appletgui.EditNameDialog (this.seq.getSequenceAsString (sg.getStartRes (), sg.getEndRes () + 1), null, "Edit Sequence ", null, this.ap.alignFrame, "Edit Sequence", 500, 100, true);
332 if (dialog.accept) {
333 var editCommand =  new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.edit_sequences"), jalview.commands.EditCommand.Action.REPLACE, dialog.getName ().$replace (' ', this.ap.av.getGapCharacter ()), sg.getSequencesAsArray (this.ap.av.getHiddenRepSequences ()), sg.getStartRes (), sg.getEndRes () + 1, this.ap.av.getAlignment ());
334 this.ap.alignFrame.addHistoryItem (editCommand);
335 this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ());
336 }}} else if (source === this.toUpper || source === this.toLower || source === this.toggleCase) {
337 var sg = this.ap.av.getSelectionGroup ();
338 if (sg != null) {
339 var startEnd = this.ap.av.getVisibleRegionBoundaries (sg.getStartRes (), sg.getEndRes () + 1);
340 var description;
341 var caseChange;
342 if (source === this.toggleCase) {
343 description = "Toggle Case";
344 caseChange = jalview.commands.ChangeCaseCommand.TOGGLE_CASE;
345 } else if (source === this.toUpper) {
346 description = "To Upper Case";
347 caseChange = jalview.commands.ChangeCaseCommand.TO_UPPER;
348 } else {
349 description = "To Lower Case";
350 caseChange = jalview.commands.ChangeCaseCommand.TO_LOWER;
351 }var caseCommand =  new jalview.commands.ChangeCaseCommand (description, sg.getSequencesAsArray (this.ap.av.getHiddenRepSequences ()), startEnd, caseChange);
352 this.ap.alignFrame.addHistoryItem (caseCommand);
353 this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ());
354 }} else if (source === this.sequenceFeature) {
355 var sg = this.ap.av.getSelectionGroup ();
356 if (sg == null) {
357 return;
358 }var rsize = 0;
359 var gSize = sg.getSize ();
360 var rseqs;
361 var seqs =  new Array (gSize);
362 var tfeatures;
363 var features =  new Array (gSize);
364 for (var i = 0; i < gSize; i++) {
365 var start = sg.getSequenceAt (i).findPosition (sg.getStartRes ());
366 var end = sg.findEndRes (sg.getSequenceAt (i));
367 if (start <= end) {
368 seqs[rsize] = sg.getSequenceAt (i);
369 features[rsize] =  new jalview.datamodel.SequenceFeature (null, null, null, start, end, "Jalview");
370 rsize++;
371 }}
372 rseqs =  new Array (rsize);
373 tfeatures =  new Array (rsize);
374 System.arraycopy (seqs, 0, rseqs, 0, rsize);
375 System.arraycopy (features, 0, tfeatures, 0, rsize);
376 features = tfeatures;
377 seqs = rseqs;
378 if (this.ap.seqPanel.seqCanvas.getFeatureRenderer ().amendFeatures (seqs, features, true, this.ap)) {
379 this.ap.alignFrame.sequenceFeatures.setState (true);
380 this.ap.av.setShowSequenceFeatures (true);
381 ;this.ap.highlightSearchResults (null);
382 }} else {
383 this.outputText (evt);
384 }}, "java.awt.event.ActionEvent");
385 Clazz.defineMethod (c$, "outputText", 
386 function (e) {
387 var cap =  new jalview.appletgui.CutAndPasteTransfer (true, this.ap.alignFrame);
388 var frame =  new awt2swing.Frame ();
389 frame.add (cap);
390 jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.selection_output_command",  Clazz.newArray (-1, [e.getActionCommand ()])), 600, 500);
391 cap.setText ( new jalview.io.AppletFormatAdapter ().formatSequences (e.getActionCommand (), this.ap.av.getShowJVSuffix (), this.ap, true));
392 }, "java.awt.event.ActionEvent");
393 Clazz.defineMethod (c$, "showSequenceSelectionDetails", 
394 function () {
395 this.createSequenceDetailsReport (this.ap.av.getSequenceSelection ());
396 });
397 Clazz.defineMethod (c$, "showSequenceDetails", 
398 function () {
399 this.createSequenceDetailsReport ( Clazz.newArray (-1, [this.seq]));
400 });
401 Clazz.defineMethod (c$, "createSequenceDetailsReport", 
402 function (sequences) {
403 var cap =  new jalview.appletgui.CutAndPasteTransfer (false, this.ap.alignFrame);
404 var contents =  new StringBuffer ();
405 for (var seq, $seq = 0, $$seq = sequences; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) {
406 contents.append (jalview.util.MessageManager.formatMessage ("label.annotation_for_displayid",  Clazz.newArray (-1, [seq.getDisplayId (true)])));
407  new jalview.io.SequenceAnnotationReport (null).createSequenceAnnotationReport (contents, seq, true, true, false, (this.ap.seqPanel.seqCanvas.fr != null) ? this.ap.seqPanel.seqCanvas.fr.getMinMax () : null);
408 contents.append ("</p>");
409 }
410 var frame =  new awt2swing.Frame ();
411 frame.add (cap);
412 jalview.bin.JalviewLite.addFrame (frame, "Sequence Details for " + (sequences.length == 1 ? sequences[0].getDisplayId (true) : "Selection"), 600, 500);
413 cap.setText (jalview.util.MessageManager.formatMessage ("label.html_content",  Clazz.newArray (-1, [contents.toString ()])));
414 }, "~A");
415 Clazz.defineMethod (c$, "editName", 
416 function () {
417 var dialog =  new jalview.appletgui.EditNameDialog (this.seq.getName (), this.seq.getDescription (), "       Sequence Name", "Sequence Description", this.ap.alignFrame, "Edit Sequence Name / Description", 500, 100, true);
418 if (dialog.accept) {
419 this.seq.setName (dialog.getName ());
420 this.seq.setDescription (dialog.getDescription ());
421 this.ap.paintAlignment (false);
422 }});
423 Clazz.defineMethod (c$, "addPDB", 
424 function () {
425 if (this.seq.getPDBId () != null) {
426 var entry = this.seq.getPDBId ().firstElement ();
427 if (this.ap.av.applet.jmolAvailable) {
428  new jalview.appletgui.AppletJmol (entry,  Clazz.newArray (-1, [this.seq]), null, this.ap, jalview.io.AppletFormatAdapter.URL);
429 }} else {
430 var cap =  new jalview.appletgui.CutAndPasteTransfer (true, this.ap.alignFrame);
431 cap.setText (jalview.util.MessageManager.getString ("label.paste_pdb_file"));
432 cap.setPDBImport (this.seq);
433 var frame =  new awt2swing.Frame ();
434 frame.add (cap);
435 jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.paste_pdb_file_for_sequence",  Clazz.newArray (-1, [this.seq.getName ()])), 400, 300);
436 }});
437 Clazz.defineMethod (c$, "jbInit", 
438 ($fz = function () {
439 this.groupMenu.setLabel (jalview.util.MessageManager.getString ("label.selection"));
440 this.sequenceFeature.addActionListener (this);
441 this.editGroupName.addActionListener (this);
442 this.unGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_group"));
443 this.unGroupMenuItem.addActionListener (this);
444 this.createGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.create_group"));
445 this.createGroupMenuItem.addActionListener (this);
446 this.nucleotideMenuItem.setLabel (jalview.util.MessageManager.getString ("label.nucleotide"));
447 this.nucleotideMenuItem.addActionListener (this);
448 this.conservationMenuItem.addItemListener (this);
449 this.abovePIDColour.addItemListener (this);
450 this.colourMenu.setLabel (jalview.util.MessageManager.getString ("label.group_colour"));
451 this.showBoxes.setLabel (jalview.util.MessageManager.getString ("action.boxes"));
452 this.showBoxes.setState (true);
453 this.showBoxes.addItemListener (this);
454 this.sequenceName.addActionListener (this);
455 this.sequenceDetails.addActionListener (this);
456 this.selSeqDetails.addActionListener (this);
457 this.displayNonconserved.setLabel (jalview.util.MessageManager.getString ("label.show_non_conversed"));
458 this.displayNonconserved.setState (false);
459 this.displayNonconserved.addItemListener (this);
460 this.showText.setLabel (jalview.util.MessageManager.getString ("action.text"));
461 this.showText.addItemListener (this);
462 this.showColourText.setLabel (jalview.util.MessageManager.getString ("label.colour_text"));
463 this.showColourText.addItemListener (this);
464 this.outputmenu.setLabel (jalview.util.MessageManager.getString ("label.out_to_textbox"));
465 this.seqMenu.setLabel (jalview.util.MessageManager.getString ("label.sequence"));
466 this.pdb.setLabel (jalview.util.MessageManager.getString ("label.view_pdb_structure"));
467 this.hideSeqs.setLabel (jalview.util.MessageManager.getString ("action.hide_sequences"));
468 this.repGroup.setLabel (jalview.util.MessageManager.formatMessage ("label.represent_group_with",  Clazz.newArray (-1, [""])));
469 this.revealAll.setLabel (jalview.util.MessageManager.getString ("action.reveal_all"));
470 this.revealSeq.setLabel (jalview.util.MessageManager.getString ("action.reveal_sequences"));
471 this.menu1.setLabel (jalview.util.MessageManager.getString ("label.group") + ":");
472 this.add (this.groupMenu);
473 this.add (this.seqMenu);
474 this.add (this.hideSeqs);
475 this.add (this.revealSeq);
476 this.add (this.revealAll);
477 this.groupMenu.add (this.groupShowAnnotationsMenu);
478 this.groupMenu.add (this.groupHideAnnotationsMenu);
479 this.groupMenu.add (this.groupAddReferenceAnnotations);
480 this.groupMenu.add (this.editMenu);
481 this.groupMenu.add (this.outputmenu);
482 this.groupMenu.add (this.sequenceFeature);
483 this.groupMenu.add (this.createGroupMenuItem);
484 this.groupMenu.add (this.unGroupMenuItem);
485 this.groupMenu.add (this.menu1);
486 this.colourMenu.add (this.noColourmenuItem);
487 this.colourMenu.add (this.clustalColour);
488 this.colourMenu.add (this.BLOSUM62Colour);
489 this.colourMenu.add (this.PIDColour);
490 this.colourMenu.add (this.zappoColour);
491 this.colourMenu.add (this.taylorColour);
492 this.colourMenu.add (this.hydrophobicityColour);
493 this.colourMenu.add (this.helixColour);
494 this.colourMenu.add (this.strandColour);
495 this.colourMenu.add (this.turnColour);
496 this.colourMenu.add (this.buriedColour);
497 this.colourMenu.add (this.nucleotideMenuItem);
498 this.colourMenu.add (this.userDefinedColour);
499 this.colourMenu.addSeparator ();
500 this.colourMenu.add (this.abovePIDColour);
501 this.colourMenu.add (this.conservationMenuItem);
502 this.noColourmenuItem.setLabel (jalview.util.MessageManager.getString ("label.none"));
503 this.noColourmenuItem.addActionListener (this);
504 this.clustalColour.setLabel (jalview.util.MessageManager.getString ("label.clustalx_colours"));
505 this.clustalColour.addActionListener (this);
506 this.zappoColour.setLabel (jalview.util.MessageManager.getString ("label.zappo"));
507 this.zappoColour.addActionListener (this);
508 this.taylorColour.setLabel (jalview.util.MessageManager.getString ("label.taylor"));
509 this.taylorColour.addActionListener (this);
510 this.hydrophobicityColour.setLabel (jalview.util.MessageManager.getString ("label.hydrophobicity"));
511 this.hydrophobicityColour.addActionListener (this);
512 this.helixColour.setLabel (jalview.util.MessageManager.getString ("label.helix_propensity"));
513 this.helixColour.addActionListener (this);
514 this.strandColour.setLabel (jalview.util.MessageManager.getString ("label.strand_propensity"));
515 this.strandColour.addActionListener (this);
516 this.turnColour.setLabel (jalview.util.MessageManager.getString ("label.turn_propensity"));
517 this.turnColour.addActionListener (this);
518 this.buriedColour.setLabel (jalview.util.MessageManager.getString ("label.buried_index"));
519 this.buriedColour.addActionListener (this);
520 this.abovePIDColour.setLabel (jalview.util.MessageManager.getString ("label.above_identity_percentage"));
521 this.userDefinedColour.setLabel (jalview.util.MessageManager.getString ("action.user_defined"));
522 this.userDefinedColour.addActionListener (this);
523 this.PIDColour.setLabel (jalview.util.MessageManager.getString ("action.percentage_identity"));
524 this.PIDColour.addActionListener (this);
525 this.BLOSUM62Colour.setLabel ("BLOSUM62");
526 this.BLOSUM62Colour.addActionListener (this);
527 this.conservationMenuItem.setLabel (jalview.util.MessageManager.getString ("label.conservation"));
528 this.editMenu.add (this.copy);
529 this.copy.addActionListener (this);
530 this.editMenu.add (this.cut);
531 this.cut.addActionListener (this);
532 this.editMenu.add (this.editSequence);
533 this.editSequence.addActionListener (this);
534 this.editMenu.add (this.toUpper);
535 this.toUpper.addActionListener (this);
536 this.editMenu.add (this.toLower);
537 this.toLower.addActionListener (this);
538 this.editMenu.add (this.toggleCase);
539 this.seqMenu.add (this.seqShowAnnotationsMenu);
540 this.seqMenu.add (this.seqHideAnnotationsMenu);
541 this.seqMenu.add (this.seqAddReferenceAnnotations);
542 this.seqMenu.add (this.sequenceName);
543 this.seqMenu.add (this.makeReferenceSeq);
544 if (!this.ap.av.applet.useXtrnalSviewer) {
545 this.seqMenu.add (this.pdb);
546 }this.seqMenu.add (this.repGroup);
547 this.menu1.add (this.editGroupName);
548 this.menu1.add (this.colourMenu);
549 this.menu1.add (this.showBoxes);
550 this.menu1.add (this.showText);
551 this.menu1.add (this.showColourText);
552 this.menu1.add (this.displayNonconserved);
553 this.toggleCase.addActionListener (this);
554 this.pdb.addActionListener (this);
555 this.hideSeqs.addActionListener (this);
556 this.repGroup.addActionListener (this);
557 this.revealAll.addActionListener (this);
558 this.revealSeq.addActionListener (this);
559 this.makeReferenceSeq.addActionListener (this);
560 }, $fz.isPrivate = true, $fz));
561 Clazz.defineMethod (c$, "refresh", 
562 function () {
563 this.ap.paintAlignment (true);
564 });
565 Clazz.defineMethod (c$, "clustalColour_actionPerformed", 
566 function () {
567 var sg = this.getGroup ();
568 sg.cs =  new jalview.schemes.ClustalxColourScheme (sg, this.ap.av.getHiddenRepSequences ());
569 this.refresh ();
570 });
571 Clazz.defineMethod (c$, "zappoColour_actionPerformed", 
572 function () {
573 this.getGroup ().cs =  new jalview.schemes.ZappoColourScheme ();
574 this.refresh ();
575 });
576 Clazz.defineMethod (c$, "taylorColour_actionPerformed", 
577 function () {
578 this.getGroup ().cs =  new jalview.schemes.TaylorColourScheme ();
579 this.refresh ();
580 });
581 Clazz.defineMethod (c$, "hydrophobicityColour_actionPerformed", 
582 function () {
583 this.getGroup ().cs =  new jalview.schemes.HydrophobicColourScheme ();
584 this.refresh ();
585 });
586 Clazz.defineMethod (c$, "helixColour_actionPerformed", 
587 function () {
588 this.getGroup ().cs =  new jalview.schemes.HelixColourScheme ();
589 this.refresh ();
590 });
591 Clazz.defineMethod (c$, "strandColour_actionPerformed", 
592 function () {
593 this.getGroup ().cs =  new jalview.schemes.StrandColourScheme ();
594 this.refresh ();
595 });
596 Clazz.defineMethod (c$, "turnColour_actionPerformed", 
597 function () {
598 this.getGroup ().cs =  new jalview.schemes.TurnColourScheme ();
599 this.refresh ();
600 });
601 Clazz.defineMethod (c$, "buriedColour_actionPerformed", 
602 function () {
603 this.getGroup ().cs =  new jalview.schemes.BuriedColourScheme ();
604 this.refresh ();
605 });
606 Clazz.defineMethod (c$, "nucleotideMenuItem_actionPerformed", 
607 function () {
608 this.getGroup ().cs =  new jalview.schemes.NucleotideColourScheme ();
609 this.refresh ();
610 });
611 Clazz.defineMethod (c$, "abovePIDColour_itemStateChanged", 
612 function () {
613 var sg = this.getGroup ();
614 if (sg.cs == null) {
615 return;
616 }if (this.abovePIDColour.getState ()) {
617 sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ()));
618 var threshold = jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, sg.cs, this.getGroup ().getName ());
619 sg.cs.setThreshold (threshold, this.ap.av.isIgnoreGapsConsensus ());
620 jalview.appletgui.SliderPanel.showPIDSlider ();
621 } else {
622 sg.cs.setThreshold (0, this.ap.av.isIgnoreGapsConsensus ());
623 }this.refresh ();
624 });
625 Clazz.defineMethod (c$, "userDefinedColour_actionPerformed", 
626 function () {
627  new jalview.appletgui.UserDefinedColours (this.ap, this.getGroup ());
628 });
629 Clazz.defineMethod (c$, "PIDColour_actionPerformed", 
630 function () {
631 var sg = this.getGroup ();
632 sg.cs =  new jalview.schemes.PIDColourScheme ();
633 sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ()));
634 this.refresh ();
635 });
636 Clazz.defineMethod (c$, "BLOSUM62Colour_actionPerformed", 
637 function () {
638 var sg = this.getGroup ();
639 sg.cs =  new jalview.schemes.Blosum62ColourScheme ();
640 sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ()));
641 this.refresh ();
642 });
643 Clazz.defineMethod (c$, "noColourmenuItem_actionPerformed", 
644 function () {
645 this.getGroup ().cs = null;
646 this.refresh ();
647 });
648 Clazz.defineMethod (c$, "conservationMenuItem_itemStateChanged", 
649 function () {
650 var sg = this.getGroup ();
651 if (sg.cs == null) {
652 return;
653 }if (this.conservationMenuItem.getState ()) {
654 sg.cs.setConservation (jalview.analysis.Conservation.calculateConservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth (), false, this.ap.av.getConsPercGaps (), false));
655 jalview.appletgui.SliderPanel.setConservationSlider (this.ap, sg.cs, sg.getName ());
656 jalview.appletgui.SliderPanel.showConservationSlider ();
657 } else {
658 sg.cs.setConservation (null);
659 }this.refresh ();
660 });
661 Clazz.defineMethod (c$, "getGroup", 
662 function () {
663 var sg = this.ap.av.getSelectionGroup ();
664 if (sg != null) {
665 this.ap.av.getAlignment ().addGroup (sg);
666 }return sg;
667 });
668 Clazz.defineMethod (c$, "unGroupMenuItem_actionPerformed", 
669 function () {
670 var sg = this.ap.av.getSelectionGroup ();
671 this.ap.av.getAlignment ().deleteGroup (sg);
672 this.ap.av.setSelectionGroup (null);
673 this.ap.paintAlignment (true);
674 });
675 Clazz.defineMethod (c$, "createGroupMenuItem_actionPerformed", 
676 function () {
677 this.getGroup ();
678 this.refresh ();
679 });
680 Clazz.defineMethod (c$, "showColourText_itemStateChanged", 
681 function () {
682 this.getGroup ().setColourText (this.showColourText.getState ());
683 this.refresh ();
684 });
685 Clazz.defineMethod (c$, "showText_itemStateChanged", 
686 function () {
687 this.getGroup ().setDisplayText (this.showText.getState ());
688 this.refresh ();
689 });
690 Clazz.defineMethod (c$, "makeReferenceSeq_actionPerformed", 
691 function () {
692 if (!this.ap.av.getAlignment ().hasSeqrep ()) {
693 this.ap.av.setDisplayReferenceSeq (true);
694 this.ap.av.setColourByReferenceSeq (true);
695 this.ap.av.getAlignment ().setSeqrep (this.seq);
696 } else {
697 if (this.ap.av.getAlignment ().getSeqrep () === this.seq) {
698 this.ap.av.getAlignment ().setSeqrep (null);
699 } else {
700 this.ap.av.getAlignment ().setSeqrep (this.seq);
701 }}this.refresh ();
702 });
703 Clazz.defineMethod (c$, "showNonconserved_itemStateChanged", 
704 function () {
705 this.getGroup ().setShowNonconserved (this.displayNonconserved.getState ());
706 this.refresh ();
707 });
708 Clazz.defineMethod (c$, "showBoxes_itemStateChanged", 
709 function () {
710 this.getGroup ().setDisplayBoxes (this.showBoxes.getState ());
711 this.refresh ();
712 });
713 Clazz.defineMethod (c$, "hideSequences", 
714 function (representGroup) {
715 var sg = this.ap.av.getSelectionGroup ();
716 if (sg == null || sg.getSize () < 1) {
717 this.ap.av.hideSequence ( Clazz.newArray (-1, [this.seq]));
718 return;
719 }this.ap.av.setSelectionGroup (null);
720 if (representGroup) {
721 this.ap.av.hideRepSequences (this.seq, sg);
722 return;
723 }var gsize = sg.getSize ();
724 var hseqs;
725 hseqs =  new Array (gsize);
726 var index = 0;
727 for (var i = 0; i < gsize; i++) {
728 hseqs[index++] = sg.getSequenceAt (i);
729 }
730 this.ap.av.hideSequence (hseqs);
731 this.ap.av.sendSelection ();
732 }, "~B");
733 Clazz.defineMethod (c$, "buildAnnotationTypesMenus", 
734 function (showMenu, hideMenu, forSequences) {
735 showMenu.removeAll ();
736 hideMenu.removeAll ();
737 var all = java.util.Arrays.asList (["All"]);
738 this.addAnnotationTypeToShowHide (showMenu, forSequences, "", all, true, true);
739 this.addAnnotationTypeToShowHide (hideMenu, forSequences, "", all, true, false);
740 showMenu.addSeparator ();
741 hideMenu.addSeparator ();
742 var annotations = this.ap.getAlignment ().getAlignmentAnnotation ();
743 var shownTypes =  new java.util.LinkedHashMap ();
744 var hiddenTypes =  new java.util.LinkedHashMap ();
745 jalview.analysis.AlignmentAnnotationUtils.getShownHiddenTypes (shownTypes, hiddenTypes, jalview.analysis.AlignmentAnnotationUtils.asList (annotations), forSequences);
746 for (var calcId, $calcId = hiddenTypes.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) {
747 for (var type, $type = hiddenTypes.get (calcId).iterator (); $type.hasNext () && ((type = $type.next ()) || true);) {
748 this.addAnnotationTypeToShowHide (showMenu, forSequences, calcId, type, false, true);
749 }
750 }
751 showMenu.setEnabled (!hiddenTypes.isEmpty ());
752 for (var calcId, $calcId = shownTypes.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) {
753 for (var type, $type = shownTypes.get (calcId).iterator (); $type.hasNext () && ((type = $type.next ()) || true);) {
754 this.addAnnotationTypeToShowHide (hideMenu, forSequences, calcId, type, false, false);
755 }
756 }
757 hideMenu.setEnabled (!shownTypes.isEmpty ());
758 }, "awt2swing.Menu,awt2swing.Menu,java.util.List");
759 Clazz.defineMethod (c$, "addAnnotationTypeToShowHide", 
760 function (showOrHideMenu, forSequences, calcId, types, allTypes, actionIsShow) {
761 var label = types.toString ();
762 label = label.substring (1, label.length - 1);
763 var item =  new awt2swing.MenuItem (label);
764 item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$3") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$3, this, Clazz.cloneFinals ("types", types, "forSequences", forSequences, "allTypes", allTypes, "actionIsShow", actionIsShow))));
765 showOrHideMenu.add (item);
766 }, "awt2swing.Menu,java.util.List,~S,java.util.List,~B,~B");
767 c$.$APopupMenu$1$ = function () {
768 Clazz.pu$h ();
769 c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$1", null, java.awt.event.ActionListener);
770 Clazz.overrideMethod (c$, "actionPerformed", 
771 function (e) {
772 this.b$["jalview.appletgui.APopupMenu"].addReferenceAnnotations_actionPerformed (this.f$.candidates);
773 }, "java.awt.event.ActionEvent");
774 c$ = Clazz.p0p ();
775 };
776 c$.$APopupMenu$2$ = function () {
777 Clazz.pu$h ();
778 c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$2", null, java.awt.event.ActionListener);
779 Clazz.overrideMethod (c$, "actionPerformed", 
780 function (e) {
781 this.b$["jalview.appletgui.APopupMenu"].ap.alignFrame.showURL (this.f$.url, this.f$.target);
782 }, "java.awt.event.ActionEvent");
783 c$ = Clazz.p0p ();
784 };
785 c$.$APopupMenu$3$ = function () {
786 Clazz.pu$h ();
787 c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$3", null, java.awt.event.ActionListener);
788 Clazz.overrideMethod (c$, "actionPerformed", 
789 function (e) {
790 jalview.analysis.AlignmentUtils.showOrHideSequenceAnnotations (this.b$["jalview.appletgui.APopupMenu"].ap.getAlignment (), this.f$.types, this.f$.forSequences, this.f$.allTypes, this.f$.actionIsShow);
791 this.b$["jalview.appletgui.APopupMenu"].refresh ();
792 }, "java.awt.event.ActionEvent");
793 c$ = Clazz.p0p ();
794 };
795 Clazz.defineStatics (c$,
796 "ALL_ANNOTATIONS", "All");
797 });