[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Fri Apr 9 15:50:09 UTC 2010


gordonp
Fri Apr  9 11:50:09 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv1360/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	FilterSearchWidget.java 
Log Message:
Added case sensitivity
moby-live/Java/src/main/ca/ucalgary/seahawk/gui FilterSearchWidget.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.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/FilterSearchWidget.java	2010/03/17 20:20:47	1.1
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.java	2010/04/09 15:50:09	1.2
@@ -17,9 +17,13 @@
 
     private FilterSearch currentFilterSearch;
     private JLabel closeIcon;
+    private JToggleButton caseButton;
     private JTextField searchField;
     private JComboBox docPartOptions;
     private MobyContentPane contentPane;
+    public static final String CASE_SENSITIVE_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/case_sensitive.png";
+    public static final String CASE_INSENSITIVE_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/case_insensitive.png";
+    private static final String CASE_BUTTON_NAME = "case_sensitivity_button"; 
 
     private static Logger logger = Logger.getLogger(FilterSearchWidget.class.getName());
 
@@ -27,7 +31,8 @@
 	super();
 
 	contentPane = mcp;
-	URL u = Thread.currentThread().getContextClassLoader().getResource(CloseTabIcon.CLOSE_TAB_ICON_RESOURCE);
+	ClassLoader cl = Thread.currentThread().getContextClassLoader();
+	URL u = cl.getResource(CloseTabIcon.CLOSE_TAB_ICON_RESOURCE);
 	if(u == null){
 	    throw new Exception("Could not find icon resource " + CloseTabIcon.CLOSE_TAB_ICON_RESOURCE);
 	}
@@ -37,9 +42,22 @@
 	closeIcon.addMouseListener(new Closer(this));
 	closeIcon.setToolTipText("Remove filter criteria");
 
+	Dimension buttonSize = new Dimension(24,24);
+	caseButton = new JToggleButton(new ImageIcon(cl.getResource(CASE_SENSITIVE_ICON_RESOURCE)));
+	caseButton.setDisabledIcon(new ImageIcon(cl.getResource(CASE_INSENSITIVE_ICON_RESOURCE)));
+	caseButton.setToolTipText("Toggles the case sensitivity of the filter");
+	caseButton.setPreferredSize(buttonSize);
+	caseButton.setEnabled(true);
+	caseButton.setSelected(false);
+	caseButton.addActionListener(this);
+	caseButton.setMargin(new java.awt.Insets(2,2,2,2));
+        caseButton.setName(CASE_BUTTON_NAME); // so test cases can find the component
+
 	setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
 	add(closeIcon);
 	add(Box.createRigidArea(new Dimension(5,0)));
+	add(caseButton);
+	add(Box.createRigidArea(new Dimension(5,0)));
 	add(new JLabel("Show data if "));
 	add(Box.createRigidArea(new Dimension(5,0)));
 	searchField = new JTextField(25);
@@ -62,11 +80,15 @@
     public void setFilter(FilterSearch fs){
 	currentFilterSearch = null;
 	if(fs == null){
+	    caseButton.setEnabled(false);
 	    searchField.setEnabled(false);
 	    docPartOptions.setEnabled(false);
 	    return;
 	}
 
+	caseButton.setEnabled(true);
+	caseButton.setSelected(fs.getCaseSensitivity());
+
 	searchField.setEnabled(true);
 	searchField.setText(fs.getFilterRegex().toString());
 
@@ -79,7 +101,15 @@
      * Called when the user has changed the xpath
      */
     public void actionPerformed(ActionEvent e){
-	if(currentFilterSearch == null || e.getSource() != docPartOptions){
+	if(e.getSource() == caseButton){
+	    if(currentFilterSearch == null){
+	        return;
+            }
+            currentFilterSearch.setCaseSensitivity(caseButton.isSelected());
+	    contentPane.applyFilter(true);
+	    return;
+        }
+	else if(currentFilterSearch == null || e.getSource() != docPartOptions){
 	    return;
 	}
 	currentFilterSearch.setSelectedXPath(docPartOptions.getSelectedIndex());




More information about the MOBY-guts mailing list