Author: pwang
Date: 2009-12-01 13:53:47 -0800 (Tue, 01 Dec 2009)
New Revision: 18629

Modified:
   
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/BasicNetworkEditEventHandler.java
Log:
Add option for user to specify Edge interaction type

Modified: 
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/BasicNetworkEditEventHandler.java
===================================================================
--- 
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/BasicNetworkEditEventHandler.java
     2009-12-01 21:48:43 UTC (rev 18628)
+++ 
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/BasicNetworkEditEventHandler.java
     2009-12-01 21:53:47 UTC (rev 18629)
@@ -54,6 +54,8 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
+import javax.swing.JOptionPane;
+
 import cytoscape.CyEdge;
 import cytoscape.CyNode;
 import cytoscape.Cytoscape;
@@ -61,6 +63,7 @@
 import cytoscape.editor.CytoscapeEditorManager;
 import cytoscape.editor.editors.BasicCytoscapeEditor;
 import cytoscape.editor.impl.SIF_Interpreter;
+import cytoscape.editor.impl.ShapePalette;
 import cytoscape.view.CyNetworkView;
 import cytoscape.view.CytoscapeDesktop;
 
@@ -491,19 +494,56 @@
 
                Node source_node = source.getNode();
                Node target_node = target.getNode();
+               
+               CyEdge myEdge;
+               if (ShapePalette.specifyIdentifier){
+                       String _edgeAttributeValue = 
getEdgeAttributeValueFromUser(source_node, target_node);
+                       if (_edgeAttributeValue == null){
+                               return null;
+                       }
+                       myEdge = _caller.addEdge(source_node, target_node,
+                cytoscape.data.Semantics.INTERACTION,
+                _edgeAttributeValue, true,
+                _edgeAttributeValue);                                          
+               }
+               else {
+                       myEdge = _caller.addEdge(source_node, target_node,
+                cytoscape.data.Semantics.INTERACTION,
+                (this.getEdgeAttributeValue() != null)
+                ? this.getEdgeAttributeValue()
+                : BasicNetworkEditEventHandler.DEFAULT_EDGE, true,
+                (this.getEdgeAttributeValue() != null)
+                ? this.getEdgeAttributeValue()
+                : BasicNetworkEditEventHandler.DEFAULT_EDGE);                  
+               }
 
-               CyEdge myEdge = _caller.addEdge(source_node, target_node,
-                                               
cytoscape.data.Semantics.INTERACTION,
-                                               (this.getEdgeAttributeValue() 
!= null)
-                                               ? this.getEdgeAttributeValue()
-                                               : 
BasicNetworkEditEventHandler.DEFAULT_EDGE, true,
-                                               (this.getEdgeAttributeValue() 
!= null)
-                                               ? this.getEdgeAttributeValue()
-                                               : 
BasicNetworkEditEventHandler.DEFAULT_EDGE);
                completeFinishEdge();
                return myEdge;
        }
 
+       
+       private String getEdgeAttributeValueFromUser(Node source_node, Node 
target_node) {
+               String _edgeAttributeValue = null;
+
+               while (true){
+                       _edgeAttributeValue = 
JOptionPane.showInputDialog(Cytoscape.getDesktop(),"Please Specify Edge 
Interaction Type", this.getEdgeAttributeValue());
+                       if (_edgeAttributeValue == null){
+                               return null;
+                       }
+                       // Check if the Edge ID already existed                 
        
+                       CyEdge aEdge = Cytoscape.getCyEdge(source_node, 
target_node, cytoscape.data.Semantics.INTERACTION, _edgeAttributeValue, false, 
true);
+       
+                       if (aEdge == null){
+                               break;
+                       }
+                       JOptionPane.showMessageDialog(Cytoscape.getDesktop(), 
_edgeAttributeValue + " already existed!", "Duplicated Edge Identifier", 
+                                       JOptionPane.WARNING_MESSAGE);
+               }
+
+               return _edgeAttributeValue;
+       }
+       
+       
        /**
         * Perform all cleanup and refresh activities to complete
         * finishEdge().

--

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.


Reply via email to