[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Fri Feb 4 18:36:35 UTC 2011


gordonp
Fri Feb  4 13:36:35 EST 2011
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util
In directory dev.open-bio.org:/tmp/cvs-serv11955/src/main/ca/ucalgary/seahawk/util

Modified Files:
	CloseTabIcon.java 
Added Files:
	CloseTabListener.java 
Log Message:
Implemented 'Undo close tab' for Seahawk
moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabListener.java,NONE,1.1 CloseTabIcon.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.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/util/CloseTabIcon.java	2007/06/16 00:27:44	1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java	2011/02/04 18:36:35	1.3
@@ -9,6 +9,7 @@
 import java.awt.Graphics;
 import java.awt.Component;
 import java.net.URL;
+import java.util.Vector;
 
 public class CloseTabIcon extends CombinedIcon{
     public static final String CLOSE_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/tabclose.gif";
@@ -17,6 +18,7 @@
 
     private JTabbedPane tabbedPane = null;
     private Rectangle closeIconArea;
+    private Vector<CloseTabListener> listeners;
 
     public CloseTabIcon() throws Exception{
 	this(new NullIcon());
@@ -34,6 +36,14 @@
 	super(getIcon(), otherIcon, spacerWidth, orient);
     }
 
+    public CloseTabIcon addCloseTabListener(CloseTabListener listener){
+	if(listeners == null){
+	    listeners = new Vector<CloseTabListener>();
+	}
+	listeners.add(listener);
+	return this;
+    }
+
     public Rectangle getCloseIconArea(){
 	return closeIconArea;
     }
@@ -102,9 +112,18 @@
 		    // Don't respond unless the close tab icon is actually showing
 		    return;
 		}
+		Component tab = tabbedPane.getComponentAt(tabIndex);
+		if(listeners != null){
+		    for(CloseTabListener listener: listeners){
+			listener.tabClosing(tab);
+		    }
+		}
+
 		tabbedPane.remove(tabIndex);
 		e.consume(); // so other tabs aren't closed by mistake
 		tabbedPane.removeMouseListener(this);
+		tabbedPane = null; // so if the tab is added back at some point, the listen is readded in paintIcon()
+
 	    }
 	}
     }




More information about the MOBY-guts mailing list