[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Tue Apr 3 02:34:09 UTC 2007


gordonp
Mon Apr  2 22:34:08 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv6956/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	MobyContentClipboard.java MobyContentGUI.java 
	MobyContentPane.java MobyServicesGUI.java SplashWindow.java 
Log Message:
Added paste functionality miscellanea, and better tab interaction (close icon, ctrl-T for new)
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.2,1.3 MobyContentGUI.java,1.5,1.6 MobyContentPane.java,1.5,1.6 MobyServicesGUI.java,1.7,1.8 SplashWindow.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.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/MobyContentClipboard.java	2007/02/08 16:59:57	1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java	2007/04/03 02:34:08	1.3
@@ -89,6 +89,10 @@
 	sGUI.setClipboard(this);	
     }
 
+    // By overriding this with a blank method body, we avoid adding a close icon to the tab
+    public void stateChanged(javax.swing.event.ChangeEvent ce){
+    }
+
     /** Sets up temporary files, icons, etc. */
     public void init(){
 	int index = tabbedPane.indexOfComponent(this);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java	2007/03/21 16:24:42	1.5
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java	2007/04/03 02:34:08	1.6
@@ -10,6 +10,7 @@
 import java.util.TreeMap;
 
 import javax.swing.*;
+import javax.swing.event.*;
 
 import javax.xml.transform.stream.*;
 import javax.xml.transform.*;
@@ -28,7 +29,7 @@
  * @author Paul Gordon (gordonp at ucalgary.ca)
  */
 
-public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, MobyRequestEventHandler, MouseListener{
+public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener{
 
     // Variables used to coordinate component finding with the unit test cases
     public final static String BACK_BUTTON_NAME = "MCGbackButton";
@@ -50,6 +51,8 @@
     public final static String DEFAULT_STARTUP_PAGE_RESOURCE = "ca/ucalgary/seahawk/resources/startup.html";
     public final static String DEFAULT_XSLT_CONVERTER_URL = "ca/ucalgary/seahawk/resources/moby2HTML.xsl";
     public final static int MAX_TAB_NAME_LENGTH = 25;
+    public final static String CLIPBOARD_TAB_TOOLTIP = "Right-click for clipboard options";
+    public final static String TAB_TOOLTIP = "Right-click for tab options, or Ctrl-T for new tab";
     public final static String CLOSE_TAB_OPTION = "Close This Tab";
     public final static String CLOSE_OTHERS_OPTION = "Close Other Tabs";
     public final static String FILE_OPEN_OPTION = "Open File";
@@ -176,6 +179,8 @@
 	// See OptionsTabbedPaneUI class definiton at the end of this file (overrides right-click behaviour)
 	tabbedPane.setUI(new OptionsTabbedPaneUI(this));
 	tabbedPane.setSize(getContentSize());
+	tabbedPane.setToolTipText("Hit <Control-T> to display a new tab");
+	tabbedPane.addKeyListener(this);
 	
 	clipboard = new MobyContentClipboard(this,
 					     servicesGUI, 
@@ -185,6 +190,18 @@
 
     }
 
+    public boolean allTabsVisible(){
+	if(tabbedPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT){
+	    return true;
+	}
+	for(int i = 0; i < tabbedPane.getTabCount(); i++){
+	    if(tabbedPane.getBoundsAt(i) == null){
+		return false;  //bounds null if not showing on screen
+	    }
+	}
+	return true;
+    }
+
     public JPanel getToolbar(){
 	return statusPanel;
     }
@@ -205,6 +222,24 @@
     }
     
     /**
+     * Implemented to provide paste functionality (control-v or the paste button on a Sun keyboard),
+     * since the editor panes are not editable and therefore by default do not respond to
+     * paste events.
+     */
+    public void keyPressed(KeyEvent e){
+	// Ctrl-T for new tab, like regular Web browsers
+	if(e.getKeyCode() == KeyEvent.VK_T && e.isControlDown()){
+	    MobyContentPane tab = createTab("New Tab");
+	    tabbedPane.setSelectedComponent(tab);
+	    tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," +
+				     "or drag'n'drop/paste data from your desktop or Web browser.");
+	}
+    }
+
+    public void keyReleased(KeyEvent e){}
+    public void keyTyped(KeyEvent e){}
+
+    /**
      * This method sets the layout, basic GUI elements,
      * initializes conditions, and so on so it'll be ready to go when gotoURL is called 
      * to load a MOBY document for the first time.
@@ -245,6 +280,10 @@
 
 	setVisible(true);
 	tabbedPane.add(clipboard);
+	int clipboardIndex = tabbedPane.indexOfComponent(clipboard);
+	if(clipboardIndex != -1){
+	    tabbedPane.setToolTipTextAt(clipboardIndex, CLIPBOARD_TAB_TOOLTIP);
+	}
 	clipboard.setPreferredSize(getContentSize());
 	clipboard.init();
 	setup = true;
@@ -271,6 +310,10 @@
 	setVisible(true);
 	tab.setPreferredSize(getContentSize());
 	tabbedPane.addTab(title, tab);
+	int tabIndex = tabbedPane.indexOfComponent(tab);
+	if(tabIndex != -1){
+	    tabbedPane.setToolTipTextAt(tabIndex, TAB_TOOLTIP);
+	}
 	return tab;
     }
 	
@@ -792,7 +835,7 @@
 			item.addActionListener(gui);
 			tabOptions.add(item);
 		    }
-		    else{
+		    else if(tabbedPane.getTabCount() > 1){
 			item = new JMenuItem(MobyContentGUI.CLOSE_TAB_OPTION);
 			item.setActionCommand(MobyContentGUI.CLOSE_TAB_OPTION);
 			item.addActionListener(gui);
@@ -861,16 +904,19 @@
 	new Thread(){
 		public void run(){org.biomoby.shared.MobyDataType.getDataType("Object");}
 	    }.start();
-	// And the service definitions
 	new Thread(){
-		public void run(){org.biomoby.shared.MobyService.getService("","");}
+		public void run(){org.biomoby.shared.MobyServiceType.getServiceType("Analysis");}
 	    }.start();
+	// And the service definitions
+	//new Thread(){
+	//	public void run(){org.biomoby.shared.MobyService.getService("","");}
+	//    }.start();
 
 	MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel());
 	gui.setDefaultCloseOperation(defaultCloseOperation);
 
 	gui.setVisible(true);
-	if(argv.length != 0){
+	if(argv.length != 0 && argv[0] != null && argv[0].length() != 0){
 	    try{
 		gui.loadPaneFromURL(new URL(argv[0]), true);
 	    }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java	2007/03/23 20:22:52	1.5
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java	2007/04/03 02:34:08	1.6
@@ -19,9 +19,7 @@
 import org.apache.xpath.*;
 import org.apache.xpath.objects.*;
 
-import ca.ucalgary.seahawk.util.DynamicJPopupMenu;
-import ca.ucalgary.seahawk.util.PrintableJEditorPane;
-import ca.ucalgary.seahawk.util.MobyUtils;
+import ca.ucalgary.seahawk.util.*;
 
 import javax.swing.*;
 import javax.swing.event.*;
@@ -41,15 +39,17 @@
  * Also provides link handling (including service options popup) and drag 'n' drop capabilities.
  */
 
-public class MobyContentPane extends JPanel implements Printable, CaretListener, HyperlinkListener, MouseListener, MobyRequestEventHandler, KeyListener{
+public class MobyContentPane extends JPanel implements Printable, CaretListener, HyperlinkListener, MouseListener, MobyRequestEventHandler, KeyListener, ChangeListener{
     public static final String MOBY_SERVICE_POPUP_NAME = "seahawkServicePopup";
     public static final String WAITING_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/hourglass.gif";
     public static final String FAILED_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/failed.gif";
     public static final String LOADED_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/document.gif";
+    private static final int TAB_ICON_SPACER = 2;
 
     private static ImageIcon hourglassIcon; 
     private static ImageIcon failedIcon; 
     private static ImageIcon loadedIcon; 
+    private static ImageIcon closeIcon; 
 
     /** The name of the param in the stylesheet that will hold the Moby doc URL for XPointer usage */
     public final static String XSL_DOC_SOURCE_PARAM = "sourceURL";
@@ -83,6 +83,8 @@
 	addKeyListener(this);
 	setTransferHandler(new FileAndTextTransferHandler(cGUI));
 
+	tabbedPane.addChangeListener(this);
+
 	// The following is a non-user editable pane for showing HTML
 	editorPane = new PrintableJEditorPane();
 	editorPane.addKeyListener(this);
@@ -131,6 +133,35 @@
 	}
     }
 
+    public void stateChanged(ChangeEvent ce){
+	int tabIndex = tabbedPane.indexOfComponent(this);
+	Icon currentIcon = tabIndex < 0 ? null : tabbedPane.getIconAt(tabIndex);
+	if(tabIndex == tabbedPane.getSelectedIndex() && 
+	   tabbedPane.getTabCount() > 1){
+	    try{
+		if(currentIcon == null){
+		    tabbedPane.setIconAt(tabIndex, new CloseTabIcon());
+		    return;
+		}
+		// If there's a real (non-close-tab) single icon, add the close tab icon
+		if(!(currentIcon instanceof CloseTabIcon)){
+		    try{tabbedPane.setIconAt(tabIndex, new CloseTabIcon(currentIcon, TAB_ICON_SPACER));}
+		    catch(Exception e){e.printStackTrace();}
+		    tabbedPane.setDisabledIconAt(tabIndex, currentIcon);
+		}
+	    }
+	    catch(Exception e){
+		e.printStackTrace();
+	    }
+
+	} else{
+	    if(currentIcon != null && currentIcon instanceof CloseTabIcon){
+		tabbedPane.setIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon());
+		tabbedPane.setDisabledIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon());
+	    }
+	}
+    }
+
     public void setPreferredSize(Dimension dims){
 	super.setPreferredSize(dims);
 	scrollPane.setPreferredSize(dims);
@@ -370,8 +401,19 @@
     }
 
     public void failed(String msg){
-	tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), failedIcon);
-	tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), msg);
+	int tabIndex = tabbedPane.indexOfComponent(this);
+	if(tabIndex > -1){
+	    try{tabbedPane.setIconAt(tabIndex, 
+				     new CloseTabIcon(failedIcon, TAB_ICON_SPACER));}
+	    catch(Exception e){e.printStackTrace(); 
+	        tabbedPane.setIconAt(tabIndex, failedIcon);}
+	}
+	else{
+	    tabbedPane.setIconAt(tabIndex, failedIcon);
+	}
+	tabbedPane.setDisabledIconAt(tabIndex, failedIcon);
+
+	tabbedPane.setTitleAt(tabIndex, msg);
 	// Add the ability to back track from the error to the previous document
 	if(historyIndex != -1){
 	    historyIndex++;
@@ -382,8 +424,18 @@
     }
 
     public void succeeded(String msg){
-	tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), loadedIcon);
-	tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), msg);
+	int tabIndex = tabbedPane.indexOfComponent(this);
+	if(tabIndex > -1 && tabbedPane.getTabCount() > 1){
+	    try{tabbedPane.setIconAt(tabIndex, 
+				     new CloseTabIcon(loadedIcon, TAB_ICON_SPACER));}
+            catch(Exception e){e.printStackTrace(); 
+	        tabbedPane.setIconAt(tabIndex, loadedIcon);}
+	}
+	else{
+	    tabbedPane.setIconAt(tabIndex, loadedIcon);
+	}
+	tabbedPane.setDisabledIconAt(tabIndex, loadedIcon);
+	tabbedPane.setTitleAt(tabIndex, msg);
 	// Store the latest title for the URL loaded, in case we revisit
 	historyTabLabels.put(history.elementAt(historyIndex), msg);
 	hasFailed = false;
@@ -685,7 +737,17 @@
 
 	// Set the icon for the tab to an hourglass
 	if(tabbedPane != null){
-	    tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), hourglassIcon);
+	    int tabIndex = tabbedPane.indexOfComponent(this);
+	    if(tabIndex > -1){
+		try{tabbedPane.setIconAt(tabIndex, 
+					 new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER));}
+		catch(Exception e){e.printStackTrace(); 
+	            tabbedPane.setIconAt(tabIndex, hourglassIcon);}
+	    }
+	    else{
+		tabbedPane.setIconAt(tabIndex, hourglassIcon);
+	    }
+	    tabbedPane.setDisabledIconAt(tabIndex, hourglassIcon);
 	}
     }
 
@@ -885,6 +947,15 @@
      * like Control-v to paste.
      */
     public void mouseEntered(MouseEvent e){
+	// There is one situation where we *don't* want to take the focus, when
+	// the secondary parameter dialog has just been displayed.  We get a mouseEntered
+	// callback when the popup menu used to select the service disappears,
+	// and the secondary parameter dialog gets hidden behind the main window where
+	// the user can't see it!
+	if(servicesGUI.isSecondaryParamDialogNew()){
+	    return;
+	}
+
 	if(!requestFocusInWindow()){
 	    requestFocus();
 	}
@@ -1072,17 +1143,22 @@
     }
 
     /**
-     * Implemented to provide paste functonality (control-v or the paste button on a Sun keyboard),
+     * Implemented to provide paste functionality (control-v or the paste button on a Sun keyboard),
      * since the editor panes are not editable and therefore by default do not respond to
      * paste events.
      */
     public void keyPressed(KeyEvent e){
-	System.err.println("Key pressed " + e.getKeyChar());
 	if(e.getKeyCode() == KeyEvent.VK_PASTE ||
 	    e.getKeyCode() == KeyEvent.VK_V && e.isControlDown()){
-	    System.err.println("Paste (pressed)!");
 	    paste();
 	}
+	// Ctrl-T for new tab, like regular Web browsers
+	if(e.getKeyCode() == KeyEvent.VK_T && e.isControlDown()){
+	    MobyContentPane tab = contentGUI.createTab("New Tab");
+	    tabbedPane.setSelectedComponent(tab);
+	    tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," +
+				     "or drag'n'drop/paste data from your desktop or Web browser.");
+	}
     }
 
     public void keyReleased(KeyEvent e){}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java	2007/02/08 16:59:57	1.7
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java	2007/04/03 02:34:08	1.8
@@ -218,6 +218,13 @@
     public void popupMenuWillBecomeVisible(PopupMenuEvent e){
     }
 
+    public boolean isSecondaryParamDialogNew(){
+	if(secondaryGUI == null){
+	    return false;
+	}
+	return secondaryGUI.isNewShowing();
+    }
+
     /**
      * Launches a dialog that the user can configure secondary parameters in,
      * or tries to fill in and use all defaults if valid and useDefaults is specified.
@@ -925,7 +932,7 @@
 
 	    // Visual indicate secondary input usage in the service with an ellipsis at the end of the name
 	    JMenuItem mobyItem = new JMenuItem("Run " + service.getName() + 
-					       (hasSecondaryInput(service) ? "..." : ""));
+					       (hasSecondaryInput(service) ? "..." : "")+(service.isAsynchronous() ? "(async)":""));
 	    mobyItem.setActionCommand("MOBY:"+dataIndex+":"+serviceIndex+(handler == null ? "" : ":"+handler.hashCode()));
 	    mobyItem.addActionListener(this);
 	    String sdesc = "No description provided";

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SplashWindow.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/SplashWindow.java	2006/10/25 13:54:50	1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SplashWindow.java	2007/04/03 02:34:08	1.3
@@ -251,6 +251,7 @@
             
             // Show the window.
             instance.setVisible(true);
+            instance.toFront();
             
             // Note: To make sure the user gets a chance to see the
             // splash window we wait until its paint method has been




More information about the MOBY-guts mailing list