Author: pwang
Date: 2009-12-18 15:53:56 -0800 (Fri, 18 Dec 2009)
New Revision: 18792
Modified:
cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java
Log:
When determine the file extension, use predefined file extensions
Modified: cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java
===================================================================
--- cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java
2009-12-18 23:11:45 UTC (rev 18791)
+++ cytoscape/trunk/src/cytoscape/data/readers/AbstractGraphReader.java
2009-12-18 23:53:56 UTC (rev 18792)
@@ -48,6 +48,8 @@
import cytoscape.task.TaskMonitor;
import cytoscape.util.CyNetworkNaming;
import cytoscape.view.CyNetworkView;
+import cytoscape.Cytoscape;
+import java.util.Set;
/**
@@ -102,12 +104,20 @@
File tempFile = new File(fileName);
t = tempFile.getName();
- // Remove the file extension '.sif' or '.gml' as
network title
- if (Pattern.matches(".+\\.SIF$", t.toUpperCase()) ||
- Pattern.matches(".+\\.GML$",
t.toUpperCase()))
- {
- t = t.substring(0, t.length()-4);
- }
+ // Remove the file extension '.sif' or '.gml' or
'.xgmml' as network title
+ // 1. determine the extension of file
+ String ext = "";
+ int dotIndex = t.lastIndexOf(".");
+ if (dotIndex != -1){
+ ext = t.substring(dotIndex+1);
+ }
+
+ // 2. check if the file ext is one of the pre-defined
exts
+ Set extSets = (Set)
Cytoscape.getImportHandler().getAllExtensions();
+ if (extSets.contains(ext)){
+ // if the file ext is pre-defined, remove it
from network title
+ t = t.substring(0, dotIndex);
+ }
}
return CyNetworkNaming.getSuggestedNetworkTitle(t);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.