Author: pwang
Date: 2009-12-01 13:46:12 -0800 (Tue, 01 Dec 2009)
New Revision: 18627

Modified:
   
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/PaletteNetworkEditEventHandler.java
Log:
Add option for user to specify Node identifier

Modified: 
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/PaletteNetworkEditEventHandler.java
===================================================================
--- 
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/PaletteNetworkEditEventHandler.java
   2009-12-01 21:44:04 UTC (rev 18626)
+++ 
coreplugins/trunk/CytoscapeEditor2/src/cytoscape/editor/event/PaletteNetworkEditEventHandler.java
   2009-12-01 21:46:12 UTC (rev 18627)
@@ -51,6 +51,7 @@
 import cytoscape.view.CyNetworkView;
 import ding.view.DGraphView;
 import ding.view.InnerCanvas;
+import javax.swing.JOptionPane;
 
 
 /**
@@ -205,10 +206,40 @@
 
        // overwridden by subclasses:
        protected void handleDroppedNode(String attributeName, String 
attributeValue, Point location) {
-               get_caller().addNode("node" + counter, attributeName, 
attributeValue, location);
+               String nodeID = "node" + counter;
+
+               if (ShapePalette.specifyIdentifier){
+                       nodeID = getNodeID(nodeID);
+                       if (nodeID == null){
+                               return;
+                       }
+               }
+
+               get_caller().addNode(nodeID, attributeName, attributeValue, 
location);
                counter++;
        }
 
+       private String getNodeID(String nodeID){
+               String newNodeID = null;
+
+               while (true){
+                       newNodeID = 
JOptionPane.showInputDialog(Cytoscape.getDesktop(),"Please Specify Node 
identifier", nodeID);
+                       if (newNodeID == null){
+                               return null;
+                       }
+
+                       // Check if the nodeID already existed                  
        
+                       CyNode aNode = Cytoscape.getCyNode(newNodeID);
+                       if (aNode == null){
+                               break;
+                       }
+                       JOptionPane.showMessageDialog(Cytoscape.getDesktop(), 
newNodeID + " already existed!", "Duplicated Identifier", 
+                                       JOptionPane.WARNING_MESSAGE);
+               }
+
+               return newNodeID;
+       }
+       
        // overwridden by subclasses:
        protected void handleDroppedEdge(String attributeName, String 
attributeValue, Point location) {
                if (isEdgeStarted()) {
@@ -243,7 +274,16 @@
                NodeView targetNode = 
getCurrentDGraphView().getPickedNodeView(location);
                if (targetNode == null) {
                        // Create a new Node
-                       CyNode newNode = get_caller().addNode("node" + counter, 
attributeName, attributeValue, location);
+                       String nodeID = "node" + counter;
+                       
+                       if (ShapePalette.specifyIdentifier){
+                               nodeID = getNodeID(nodeID);
+                               if (nodeID == null){
+                                       return;
+                               }
+                       }
+                                               
+                       CyNode newNode = get_caller().addNode(nodeID, 
attributeName, attributeValue, location);                         
                        counter++;
                        
                        // Set a nested network for this newly created node

--

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