1 Clazz.declarePackage ("jalview.appletgui");
\r
2 Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "awt2swing.Button", "$.Checkbox", "$.Label", "$.TextField", "java.awt.GridLayout"], "jalview.appletgui.Finder", ["awt2swing.Frame", "jalview.analysis.Finder", "jalview.bin.JalviewLite", "jalview.datamodel.SequenceFeature", "jalview.util.MessageManager", "java.awt.Font", "$.Rectangle", "java.awt.event.KeyAdapter", "$.WindowAdapter"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
7 this.searchResults = null;
\r
10 this.jLabel1 = null;
\r
11 this.textfield = null;
\r
12 this.findAll = null;
\r
13 this.findNext = null;
\r
14 this.actionsPanel = null;
\r
15 this.gridLayout1 = null;
\r
16 this.createNewGroup = null;
\r
17 this.caseSensitive = null;
\r
18 this.searchDescription = null;
\r
19 Clazz.instantialize (this, arguments);
\r
20 }, jalview.appletgui, "Finder", awt2swing.Panel, java.awt.event.ActionListener);
\r
21 Clazz.prepareFields (c$, function () {
\r
22 this.jLabel1 = new awt2swing.Label ();
\r
23 this.textfield = new awt2swing.TextField ();
\r
24 this.findAll = new awt2swing.Button ();
\r
25 this.findNext = new awt2swing.Button ();
\r
26 this.actionsPanel = new awt2swing.Panel ();
\r
27 this.gridLayout1 = new java.awt.GridLayout ();
\r
28 this.createNewGroup = new awt2swing.Button ();
\r
29 this.caseSensitive = new awt2swing.Checkbox ();
\r
30 this.searchDescription = new awt2swing.Checkbox ();
\r
32 Clazz.makeConstructor (c$,
\r
34 Clazz.superConstructor (this, jalview.appletgui.Finder, []);
\r
38 if (Clazz.exceptionOf (e, Exception)) {
\r
39 e.printStackTrace ();
\r
46 this.frame = new awt2swing.Frame ();
\r
47 this.frame.add (this);
\r
48 jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("action.find"), 340, 120);
\r
49 this.frame.repaint ();
\r
50 this.frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.Finder$1") ? 0 : jalview.appletgui.Finder.$Finder$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.Finder$1, this, Clazz.cloneFinals ("ap", ap))));
\r
51 this.textfield.requestFocus ();
\r
52 }, "jalview.appletgui.AlignmentPanel");
\r
53 Clazz.overrideMethod (c$, "actionPerformed",
\r
55 if (evt.getSource () === this.textfield) {
\r
56 this.doSearch (false);
\r
57 } else if (evt.getSource () === this.findNext) {
\r
58 this.doSearch (false);
\r
59 } else if (evt.getSource () === this.findAll) {
\r
62 this.doSearch (true);
\r
63 } else if (evt.getSource () === this.createNewGroup) {
\r
64 this.createNewGroup_actionPerformed ();
\r
65 }}, "java.awt.event.ActionEvent");
\r
66 Clazz.defineMethod (c$, "createNewGroup_actionPerformed",
\r
68 var seqs = new Array (this.searchResults.getSize ());
\r
69 var features = new Array (this.searchResults.getSize ());
\r
70 for (var i = 0; i < this.searchResults.getSize (); i++) {
\r
71 seqs[i] = this.searchResults.getResultSequence (i);
\r
72 features[i] = new jalview.datamodel.SequenceFeature (this.textfield.getText ().trim (), "Search Results", null, this.searchResults.getResultStart (i), this.searchResults.getResultEnd (i), "Search Results");
\r
74 if (this.ap.seqPanel.seqCanvas.getFeatureRenderer ().amendFeatures (seqs, features, true, this.ap)) {
\r
75 this.ap.alignFrame.sequenceFeatures.setState (true);
\r
76 this.av.setShowSequenceFeatures (true);
\r
77 this.ap.highlightSearchResults (null);
\r
79 Clazz.defineMethod (c$, "doSearch",
\r
80 function (findAll) {
\r
81 if (this.ap.av.applet.currentAlignFrame != null) {
\r
82 this.ap = this.ap.av.applet.currentAlignFrame.alignPanel;
\r
83 this.av = this.ap.av;
\r
84 }this.createNewGroup.setEnabled (false);
\r
85 var finder = new jalview.analysis.Finder (this.av.getAlignment (), this.av.getSelectionGroup (), this.seqIndex, this.resIndex);
\r
86 finder.setCaseSensitive (this.caseSensitive.getState ());
\r
87 finder.setIncludeDescription (this.searchDescription.getState ());
\r
88 finder.setFindAll (findAll);
\r
89 var searchString = this.textfield.getText ();
\r
90 finder.find (searchString);
\r
91 this.seqIndex = finder.getSeqIndex ();
\r
92 this.resIndex = finder.getResIndex ();
\r
93 this.searchResults = finder.getSearchResults ();
\r
94 var idMatch = finder.getIdMatch ();
\r
95 var haveResults = false;
\r
96 if ((idMatch.size () > 0)) {
\r
98 this.ap.idPanel.highlightSearchResults (idMatch);
\r
100 this.ap.idPanel.highlightSearchResults (null);
\r
101 }if (this.searchResults.getSize () > 0) {
\r
102 haveResults = true;
\r
103 this.createNewGroup.setEnabled (true);
\r
105 this.searchResults = null;
\r
106 }this.ap.highlightSearchResults (this.searchResults);
\r
107 if (!haveResults) {
\r
108 this.ap.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.finished_searching"));
\r
109 this.resIndex = -1;
\r
113 var message = (idMatch.size () > 0) ? "" + idMatch.size () + " IDs" : "";
\r
114 if (idMatch.size () > 0 && this.searchResults != null && this.searchResults.getSize () > 0) {
\r
115 message += " and ";
\r
116 }if (this.searchResults != null) {
\r
117 message += this.searchResults.getSize () + " subsequence matches.";
\r
118 }this.ap.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.search_results", Clazz.newArray (-1, [searchString, message])));
\r
120 this.ap.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.found_match_for", Clazz.newArray (-1, [searchString])));
\r
122 Clazz.defineMethod (c$, "jbInit",
\r
124 this.jLabel1.setFont ( new java.awt.Font ("Verdana", 0, 12));
\r
125 this.jLabel1.setText (jalview.util.MessageManager.getString ("action.find"));
\r
126 this.jLabel1.setBounds ( new java.awt.Rectangle (3, 30, 34, 15));
\r
127 this.setLayout (null);
\r
128 this.textfield.setFont ( new java.awt.Font ("Verdana", 0, 10));
\r
129 this.textfield.setText ("");
\r
130 this.textfield.setBounds ( new java.awt.Rectangle (40, 17, 133, 21));
\r
131 this.textfield.addKeyListener (((Clazz.isClassDefined ("jalview.appletgui.Finder$2") ? 0 : jalview.appletgui.Finder.$Finder$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.Finder$2, this, null)));
\r
132 this.textfield.addActionListener (this);
\r
133 this.findAll.setFont ( new java.awt.Font ("Verdana", 0, 10));
\r
134 this.findAll.setLabel (jalview.util.MessageManager.getString ("action.find_all"));
\r
135 this.findAll.addActionListener (this);
\r
136 this.findNext.setEnabled (false);
\r
137 this.findNext.setFont ( new java.awt.Font ("Verdana", 0, 10));
\r
138 this.findNext.setLabel (jalview.util.MessageManager.getString ("action.find_next"));
\r
139 this.findNext.addActionListener (this);
\r
140 this.actionsPanel.setBounds ( new java.awt.Rectangle (195, 5, 141, 64));
\r
141 this.actionsPanel.setLayout (this.gridLayout1);
\r
142 this.gridLayout1.setHgap (0);
\r
143 this.gridLayout1.setRows (3);
\r
144 this.gridLayout1.setVgap (2);
\r
145 this.createNewGroup.setEnabled (false);
\r
146 this.createNewGroup.setFont ( new java.awt.Font ("Verdana", 0, 10));
\r
147 this.createNewGroup.setLabel (jalview.util.MessageManager.getString ("label.new_feature"));
\r
148 this.createNewGroup.addActionListener (this);
\r
149 this.caseSensitive.setLabel (jalview.util.MessageManager.getString ("label.match_case"));
\r
150 this.caseSensitive.setBounds ( new java.awt.Rectangle (30, 39, 126, 23));
\r
151 this.searchDescription.setLabel (jalview.util.MessageManager.getString ("label.include_description"));
\r
152 this.searchDescription.setBounds ( new java.awt.Rectangle (30, 59, 170, 23));
\r
153 this.actionsPanel.add (this.findNext, null);
\r
154 this.actionsPanel.add (this.findAll, null);
\r
155 this.actionsPanel.add (this.createNewGroup, null);
\r
156 this.add (this.caseSensitive);
\r
157 this.add (this.textfield, null);
\r
158 this.add (this.jLabel1, null);
\r
159 this.add (this.actionsPanel, null);
\r
160 this.add (this.searchDescription);
\r
162 Clazz.defineMethod (c$, "textfield_keyTyped",
\r
164 this.findNext.setEnabled (true);
\r
165 }, "java.awt.event.KeyEvent");
\r
166 c$.$Finder$1$ = function () {
\r
167 Clazz.pu$h(self.c$);
\r
168 c$ = Clazz.declareAnonymous (jalview.appletgui, "Finder$1", java.awt.event.WindowAdapter);
\r
169 Clazz.overrideMethod (c$, "windowClosing",
\r
171 this.f$.ap.highlightSearchResults (null);
\r
172 }, "java.awt.event.WindowEvent");
\r
175 c$.$Finder$2$ = function () {
\r
176 Clazz.pu$h(self.c$);
\r
177 c$ = Clazz.declareAnonymous (jalview.appletgui, "Finder$2", java.awt.event.KeyAdapter);
\r
178 Clazz.overrideMethod (c$, "keyTyped",
\r
180 this.b$["jalview.appletgui.Finder"].textfield_keyTyped (e);
\r
181 }, "java.awt.event.KeyEvent");
\r