Changeset 376 for trunk/src/org/expeditee/agents/SearchAgent.java
- Timestamp:
- 11/02/08 13:05:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/agents/SearchAgent.java
r362 r376 1 1 package org.expeditee.agents; 2 3 import java.util.Collection; 2 4 3 5 import org.expeditee.gui.Frame; … … 24 26 25 27 public SearchAgent(String searchText) { 26 _pattern = searchText.toLowerCase(); 28 if (searchText != null) 29 _pattern = searchText.toLowerCase(); 27 30 } 28 31 … … 39 42 false); 40 43 } 41 return initialise(frame, item, frame.getFramesetName(), resultFrameset,44 return initialise(frame, item, getSearchDescription(frame), resultFrameset, 42 45 null, pattern); 46 } 47 48 /** 49 * @param frame 50 * @return 51 */ 52 protected String getSearchDescription(Frame frame) { 53 return frame.getFramesetName(); 43 54 } 44 55 … … 56 67 public boolean initialise(Frame frame, Item item, String startName, 57 68 String resultsFrameset, String replacementString, String pattern) { 58 //TODO: Put the init params in the constructor!! Dont want to be setting _pattern in two places! 59 69 // TODO: Put the init params in the constructor!! Dont want to be 70 // setting _pattern in two places! 71 60 72 if (_pattern == null) 61 73 _pattern = pattern.toLowerCase(); … … 66 78 // and type as the title 67 79 String title = this.getClass().getSimpleName() + " [" + startName 68 + "] [" + _pattern + "]"; 69 _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title, false, true); 80 + "]"+getResultsTitleSuffix(); 81 _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title, 82 false, true); 70 83 // Set the frame to be displayed after running the agent 71 84 _end = _results.getFirstFrame(); 72 85 73 86 return super.initialise(frame, item); 87 } 88 89 protected String getResultsTitleSuffix() { 90 return " [" + _pattern + "]"; 74 91 } 75 92 … … 111 128 return true; 112 129 } 130 131 protected int addResults(String frameName, Collection<String> found) { 132 return addResults(frameName, frameName, found); 133 } 134 135 /** 136 * @param frameNumber 137 * @param frameName 138 * @param found 139 * @return 140 */ 141 protected int addResults(String frameNumber, String frameName, Collection<String> found) { 142 int size = found == null ? 0 : found.size(); 143 // If the frame exists 144 if (found != null) 145 _frameCount++; 146 if (size > 0) { 147 // String repeats = size > 1? ("("+ size+ ")") : ""; 148 for (String s : found) { 149 StringBuffer surrogate = new StringBuffer(); 150 surrogate.append("[").append(frameNumber).append("] "); 151 if (s.length() > SearchAgent.SURROGATE_LENGTH) 152 surrogate.append( 153 s.substring(0, SearchAgent.SURROGATE_LENGTH - 3)) 154 .append("..."); 155 else { 156 surrogate.append(s); 157 } 158 159 _results.addText(surrogate.toString(), null, 160 frameName, null, false); 161 FrameGraphics.requestRefresh(true); 162 } 163 } 164 return size; 165 } 113 166 }
Note:
See TracChangeset
for help on using the changeset viewer.