[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Sat Apr 10 00:40:17 UTC 2010


gordonp
Fri Apr  9 20:40:17 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv14854/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	FilterSearchWidget.java MobyContentPane.java 
Log Message:
Added support for filter inversion (boolean negation)
moby-live/Java/src/main/ca/ucalgary/seahawk/gui FilterSearchWidget.java,1.2,1.3 MobyContentPane.java,1.24,1.25
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.java	2010/04/09 15:50:09	1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.java	2010/04/10 00:40:17	1.3
@@ -18,12 +18,18 @@
     private FilterSearch currentFilterSearch;
     private JLabel closeIcon;
     private JToggleButton caseButton;
+    private JButton inverseButton; // decides whether filter is "if" or "unless"
     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 IF_TEXT = "<html><u>if</u></html>";
+    private static final String UNLESS_TEXT = "<html><u>unless</u></html>";
+    private static final String CASE_INSENSITIVE_MSG = "<html>The filter is case insensitive,<br>click to make case sensitive</html>";
+    private static final String CASE_SENSITIVE_MSG = "<html>The filter is case sensitive,<br>click to make case insensitive</html>";
     private static final String CASE_BUTTON_NAME = "case_sensitivity_button"; 
+    private static final String INVERSE_BUTTON_NAME = "boolean_button"; 
 
     private static Logger logger = Logger.getLogger(FilterSearchWidget.class.getName());
 
@@ -45,7 +51,7 @@
 	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.setToolTipText(CASE_INSENSITIVE_MSG);
 	caseButton.setPreferredSize(buttonSize);
 	caseButton.setEnabled(true);
 	caseButton.setSelected(false);
@@ -53,12 +59,20 @@
 	caseButton.setMargin(new java.awt.Insets(2,2,2,2));
         caseButton.setName(CASE_BUTTON_NAME); // so test cases can find the component
 
+	inverseButton = new JButton(IF_TEXT);
+	inverseButton.setToolTipText("<html>Click to invert the selection between \"if\" and \"unless\"</html>");
+	inverseButton.setEnabled(true);
+	inverseButton.addActionListener(this);
+	inverseButton.setBorderPainted(false); // underline is hint enough that we can press it...looks cleaner
+        inverseButton.setName(INVERSE_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(new JLabel("Show data "));
+	add(inverseButton);
 	add(Box.createRigidArea(new Dimension(5,0)));
 	searchField = new JTextField(25);
 	searchField.setToolTipText("A literal string, or a regular expression");
@@ -81,11 +95,15 @@
 	currentFilterSearch = null;
 	if(fs == null){
 	    caseButton.setEnabled(false);
+	    inverseButton.setEnabled(false);
 	    searchField.setEnabled(false);
 	    docPartOptions.setEnabled(false);
 	    return;
 	}
 
+	inverseButton.setEnabled(true);
+	inverseButton.setText(fs.getSelectionInversed() ? UNLESS_TEXT : IF_TEXT);
+
 	caseButton.setEnabled(true);
 	caseButton.setSelected(fs.getCaseSensitivity());
 
@@ -101,11 +119,30 @@
      * Called when the user has changed the xpath
      */
     public void actionPerformed(ActionEvent e){
-	if(e.getSource() == caseButton){
+	if(e.getSource() == inverseButton){
+	    // Toggle the label for the if/unless button
+	    if(inverseButton.getText().equals(IF_TEXT)){
+		inverseButton.setText(UNLESS_TEXT);
+		currentFilterSearch.setSelectionInversed(true);
+	    }
+	    else{
+		inverseButton.setText(IF_TEXT);
+		currentFilterSearch.setSelectionInversed(false);
+	    }
+	    contentPane.applyFilter(true);
+	    return;
+        }
+	else if(e.getSource() == caseButton){
 	    if(currentFilterSearch == null){
 	        return;
             }
             currentFilterSearch.setCaseSensitivity(caseButton.isSelected());
+	    if(caseButton.isSelected()){
+		caseButton.setToolTipText(CASE_SENSITIVE_MSG);
+	    }
+	    else{
+		caseButton.setToolTipText(CASE_INSENSITIVE_MSG);
+	    }
 	    contentPane.applyFilter(true);
 	    return;
         }
@@ -127,6 +164,7 @@
 	sb.replace(0, sb.length(), searchField.getText());
 	contentPane.applyFilter(true);
     }
+
     public void insertUpdate(DocumentEvent e){
 	if(currentFilterSearch == null){
 	    return;

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java	2010/04/09 15:54:16	1.24
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java	2010/04/10 00:40:17	1.25
@@ -1239,7 +1239,6 @@
 	    popup.add(createServicePopupItem);
 	    popup.setVisible(true);	    
 	}
-	// todo: 
 	// The item below is mainly to allow X to be used in service Y if running service Z on X meets some filter criteria.
 	// This is a common task in bioinformatics workflows.
 	// Backtrack from data to input used for service that generated the data.
@@ -1510,12 +1509,15 @@
 	    }
 	}
 	
+	boolean inversed = fs.getSelectionInversed();
 	Map<String,Boolean> parentMatchingXPtrs = new LinkedHashMap<String,Boolean>();
 	for(String currXPtr: filterableNodes){
 	    for(Map.Entry<String,Boolean> matchingXPtr: matchingXPtrs.entrySet()){
 		if(matchingXPtr.getKey().startsWith(currXPtr+"/")){ // a parent of the matching data
 		    // No positive example yet?
-		    if(!parentMatchingXPtrs.containsKey(currXPtr) || !parentMatchingXPtrs.get(currXPtr).booleanValue()){
+		    if(!parentMatchingXPtrs.containsKey(currXPtr) || 
+		       !inversed && !parentMatchingXPtrs.get(currXPtr).booleanValue() ||
+		       inversed && parentMatchingXPtrs.get(currXPtr).booleanValue()){
 			System.err.println("Adding "+ matchingXPtr.getValue() + " for " + currXPtr);
 			parentMatchingXPtrs.put(currXPtr, matchingXPtr.getValue());
 		    }
@@ -1526,11 +1528,16 @@
 	matchingXPtrs.putAll(parentMatchingXPtrs);
 	for(String currXPtr: matchingXPtrs.keySet()){
 	    // Is part of the selection criteria, but doesn't match the regex
+	    boolean shouldFilter = false;
 	    if(!matchingXPtrs.get(currXPtr).booleanValue() &&
-	       // special condition: if "entire document" xpath is given, filter only at the job level
+	       // special condition: if "entire response" xpath is given, filter only at the job level
 	       (!currentSelectionXPath.equals(FilterSearch.SELECT_ALL_XPATH) || jobXPtrs.containsKey(currXPtr))){
-		filteredData.put(currXPtr, "todo");
+		shouldFilter = true;
 	    }
+	    if(!inversed && shouldFilter ||
+	       inversed && !shouldFilter){ 
+		filteredData.put(currXPtr, "todo");
+	    }	    
 	}
 
 	//todo: filter objects without the HAS field at all...




More information about the MOBY-guts mailing list