[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Dec 6 17:03:48 UTC 2007


gordonp
Thu Dec  6 12:03:48 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv25354/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	MobyContentGUI.java 
Log Message:
Added typechecking for int:tab map
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.13,1.14
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java	2007/07/28 03:38:41	1.13
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java	2007/12/06 17:03:48	1.14
@@ -83,10 +83,8 @@
     private SeahawkOptionsGUI settingsGUI;
 
     private boolean setup;
-    private Map request2tab;
+    private Map<Integer,MobyContentPane> request2tab;
     private int activeTabIndex = -1;
-    private File lastDirOpened = null;
-    private javax.swing.filechooser.FileFilter lastFilterUsed = null;  //not java.io.FileFilter
     
     private static int defaultCloseOperation = JFrame.EXIT_ON_CLOSE;
     private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentGUI.class);
@@ -98,7 +96,7 @@
 	setTitle("Seahawk: MOBY Data Display");
 	setSize(530, 400);
 	servicesGUI = mgui;
-	request2tab = new TreeMap();
+	request2tab = new TreeMap<Integer,MobyContentPane>();
 	setup = false;
 	addComponentListener(this);
 
@@ -390,7 +388,7 @@
     }
 
     public void stop(MobyRequest request, int requestID){
-	MobyContentPane tab = (MobyContentPane) request2tab.get(new Integer(requestID));
+	MobyContentPane tab = request2tab.get(new Integer(requestID));
 	if(tab == null){
 	    logger.warn("Ignoring request to stop response monitoring, because the tab for request " +
 			       requestID + " no longer exists");
@@ -403,7 +401,7 @@
     // Called by MobyRequest when the response is available
     public void processEvent(MobyRequestEvent mre){
 	setVisible(true);
-	MobyContentPane tab = (MobyContentPane) request2tab.get(new Integer(mre.getID()));
+	MobyContentPane tab = request2tab.get(new Integer(mre.getID()));
 	if(tab == null){
 	    logger.warn("Ignoring request to display response, because the tab for request " +
 			       mre.getID() + " no longer exists");
@@ -574,76 +572,6 @@
 	}
     }
 
-    public void showFileDialog(boolean useDefaultHandler){
-	JFileChooser fileChooser = new JFileChooser();
-	fileChooser.setDialogTitle(FILE_CHOOSER_OPEN_TITLE);
-	fileChooser.setName(FILE_CHOOSER_OPEN_TITLE);
-
-	// Remember the last dir explored (if we have one)
-	if(lastDirOpened != null){
-	    fileChooser.setCurrentDirectory(lastDirOpened);
-	}
-
-	fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
-	fileChooser.addChoosableFileFilter(new DescriptiveFileFilter(MobySaveDialog.RTF_EXT, 
-								     MobySaveDialog.RTF_DESC));
-	fileChooser.addChoosableFileFilter(new DescriptiveFileFilter(MobySaveDialog.HTML_EXT, 
-								     MobySaveDialog.HTML_DESC));
-	fileChooser.addChoosableFileFilter(new DescriptiveFileFilter(MobySaveDialog.TXT_EXT, 
-								     MobySaveDialog.TXT_DESC));
-	DescriptiveFileFilter xmlFilter = new DescriptiveFileFilter(MobySaveDialog.XML_EXT, 
-								     MobySaveDialog.XML_DESC);
-	fileChooser.addChoosableFileFilter(xmlFilter);
-	fileChooser.setAcceptAllFileFilterUsed(true);
-	if(lastFilterUsed != null){
-	    fileChooser.setFileFilter(lastFilterUsed); // remember last thing the user did
-	}
-	else{
-	    fileChooser.setFileFilter(xmlFilter);  //show xml only by default
-	}
-
-	for(;;){
-	    int choice = fileChooser.showOpenDialog(this);
-	    if (choice == JFileChooser.APPROVE_OPTION) {
-		if(!fileChooser.getSelectedFile().exists()){
-		    Object[] options = {"Try again", "Cancel"};
-		    int response = JOptionPane.showOptionDialog(this,
-								"Sorry, the specified file does not exist",
-								"Invalid File Name",
-								JOptionPane.OK_CANCEL_OPTION,
-								JOptionPane.QUESTION_MESSAGE,
-								null,
-								options,
-								options[0]);
-		    if(response == 1){  //Cancel
-			return;
-		    }
-		    else{
-			continue;  // Try again
-		    }
-		}
-		
-		try{
-		    // Remember the directory and filter for future reference
-		    lastDirOpened = fileChooser.getCurrentDirectory();
-		    lastFilterUsed = fileChooser.getFileFilter();
-
-		    loadPaneFromURL(fileChooser.getSelectedFile().toURI().toURL(), useDefaultHandler);
-		    return;
-		}
-		catch(Exception e){
-		    JOptionPane.showMessageDialog(this,
-						  "Could not load the data:\n"+e,
-						  "Error Loading Data From File",
-						  JOptionPane.ERROR_MESSAGE);
-		}
-	    }
-	    else{
-		return;  // Cancel
-	    }
-	}  //end infinite for loop
-    }
-
     /**
      * Load a Seahawk browser tab with the data held in the given MobyContentInstance.
      * Note that this methods take a snapshot of the data when it is passed in.  Subsequent
@@ -740,7 +668,8 @@
 
 	String cmd = e.getActionCommand();
 	if(FILE_OPEN_OPTION.equals(cmd)){
-	    showFileDialog((e.getModifiers() & MobyServicesGUI.USE_DEFAULT_HANDLER_MASK) != 0);
+	    MobySaveDialog.showFileOpenDialog(this, 
+					      (e.getModifiers() & MobyServicesGUI.USE_DEFAULT_HANDLER_MASK) != 0);
 	}
 	else if(WEB_OPEN_OPTION.equals(cmd)){
 	    showWebDialog((e.getModifiers() & MobyServicesGUI.USE_DEFAULT_HANDLER_MASK) != 0);




More information about the MOBY-guts mailing list