[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Mon Apr 26 16:26:18 UTC 2010


gordonp
Mon Apr 26 12:26:18 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv25567/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	ServiceSearchDialog.java 
Log Message:
Case insensitive service name highlighting during search
moby-live/Java/src/main/ca/ucalgary/seahawk/gui ServiceSearchDialog.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/ServiceSearchDialog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/ServiceSearchDialog.java	2010/04/24 17:23:27	1.1
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/ServiceSearchDialog.java	2010/04/26 16:26:18	1.2
@@ -127,6 +127,10 @@
 						Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
 	activeChoices.clear();
 	for(JMenuItem serviceChoice: serviceChoices){
+	    if(serviceChoice.getText() == null){
+		continue;
+	    }
+	    
 	    String label = serviceChoice.getText().replaceAll("<.*?>", "").replaceAll("see description", "");
 	    // get rid of any coloring
 
@@ -134,12 +138,15 @@
 	    if(searchTerm == null || searchTerm.trim().length() == 0){
 		serviceChoice.setText(label);
 		activeChoices.addElement(serviceChoice);
+		continue;
 	    }
+	    Matcher matcher = searchPattern.matcher(label);
 	    // In the label?
-	    else if(serviceChoice.getText() != null &&
-		    searchPattern.matcher(label).find()){
-		label = label.replaceAll("("+searchTerm+")", "<font color='red'>$1</font>");
-		serviceChoice.setText("<html>"+label+"</html>");
+	    if(matcher.find()){
+		label = label.substring(0, matcher.start())+"<font color='red'>" +
+		    matcher.group(0) + "</font>" +
+		    (matcher.end() >= label.length() ? "" : label.substring(matcher.end()));
+		serviceChoice.setText("<html>" + label + "</html>");
 		activeChoices.addElement(serviceChoice);
 	    }
 	    // In the tooltip?




More information about the MOBY-guts mailing list