Author: Srinivasarao
Date: 2009-07-30 07:54:02 -0700 (Thu, 30 Jul 2009)
New Revision: 17624

Modified:
   
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/MainPanel.java
   
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/RootPanel.java
   
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPanelImpl.java
   
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPlugin.java
   
csplugins/trunk/soc/srinivasarao/search-ui/src/test/java/org/cytoscape/search/internal/TestSearchPanel.java
Log:


Modified: 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/MainPanel.java
===================================================================
--- 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/MainPanel.java
       2009-07-30 05:06:54 UTC (rev 17623)
+++ 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/MainPanel.java
       2009-07-30 14:54:02 UTC (rev 17624)
@@ -49,7 +49,13 @@
        private static final String REINDEX_TOOLTIP = "<html>"
                        + "Refresh the network index and perform search." + 
"<br>"
                        + "This option is useful after changes to attributes." 
+ "</html>";
+       
+       private static final String ESP_ENABLED_TOOLTIP = "<html>"
+        + "Enter search query and press return. " + "<br>"
+        + "Right click for more options." + "</html>";
 
+    private static final String ESP_DISABLED_TOOLTIP = "Please select or load 
a network to activate search functionality";
+
        /**
         * This is the default constructor
         */
@@ -57,9 +63,23 @@
                super();
                initialize();
                this.netmgr = nm;
+               if(netmgr.getCurrentNetwork()==null)
+                       disableSearch();
+       }
 
+       public void disableSearch(){
+               searchField.setText("");
+               searchField.setEnabled(false);
+               searchField.setToolTipText(ESP_DISABLED_TOOLTIP);
+               searchButton.setEnabled(false);
        }
-
+       
+       public void enableSearch(){
+               searchField.setEnabled(true);
+               searchButton.setEnabled(true);
+               searchField.setToolTipText(ESP_ENABLED_TOOLTIP);
+       }
+       
        /**
         * This method initializes this
         * 

Modified: 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/RootPanel.java
===================================================================
--- 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/RootPanel.java
       2009-07-30 05:06:54 UTC (rev 17623)
+++ 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/RootPanel.java
       2009-07-30 14:54:02 UTC (rev 17624)
@@ -21,21 +21,25 @@
 import javax.swing.Box;
 import javax.swing.JPanel;
 
+import org.cytoscape.session.CyNetworkManager;
+
 public class RootPanel extends JPanel {
 
        private static final long serialVersionUID = 1L;
        ArrayList<BasicDraggablePanel> list;
+       CyNetworkManager netmgr = null;
 
        /**
         * This is the default constructor
         */
-       public RootPanel() {
+       public RootPanel(CyNetworkManager nm) {
                super();
                this.setLayout(new GridBagLayout());
                this.setTransferHandler(new DragAndDropTransferHandler());
                this.setDropTarget(new DropTarget(RootPanel.this,
                                new 
BasicDraggablePanelDropTargetListener(RootPanel.this)));
                list = new ArrayList<BasicDraggablePanel>();
+               this.netmgr = nm;
        }
 
        public void addPanel(Component c) {
@@ -50,6 +54,10 @@
                return list;
        }
 
+       public CyNetworkManager getNetworkManager() {
+               return netmgr;
+       }
+
        public void relayout() {
                GridBagConstraints gc = new GridBagConstraints();
                gc.gridx = 0;
@@ -112,6 +120,7 @@
 
        // Could easily find uses for these, like cursor changes, etc.
        public void dragEnter(DropTargetDragEvent dtde) {
+               
        }
 
        public void dragOver(DropTargetDragEvent dtde) {
@@ -129,10 +138,8 @@
 
        @Override
        public void drop(DropTargetDropEvent dtde) {
-               // TODO Auto-generated method stub
                System.out
                                .println("Step 5 of 7: The user dropped the 
panel. The drop(...) method will compare the drops location with other panels 
and reorder the panels accordingly.");
-               // Needs to be implemented by Srinivas
                this.searchPanel.setCursor(Cursor.getDefaultCursor());
                DataFlavor flavor = null;
                Object transferableObj = null;
@@ -178,5 +185,7 @@
                present.clear();
                present.addAll(orderedPanels);
                searchPanel.relayout();
+               
SearchPanelFactory.getGlobalInstance(searchPanel.getNetworkManager())
+                               .updateSearchField();
        }
 }

Modified: 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPanelImpl.java
===================================================================
--- 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPanelImpl.java
 2009-07-30 05:06:54 UTC (rev 17623)
+++ 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPanelImpl.java
 2009-07-30 14:54:02 UTC (rev 17624)
@@ -34,8 +34,7 @@
        public SearchPanelImpl(CyNetworkManager nm) {
                super();
                this.netmgr = nm;
-               if (netmgr.getCurrentNetwork() != null)
-                       initialize();
+               initialize();
        }
 
        /**
@@ -55,55 +54,57 @@
                g1.weighty = 1.0;
                g1.anchor = GridBagConstraints.NORTHWEST;
                mp = new MainPanel(netmgr);
-               attrPanel = new RootPanel();
+               attrPanel = new RootPanel(netmgr);
                CyNetwork net = netmgr.getCurrentNetwork();
-               CyDataTable nodetable = net.getCyDataTables("NODE").get(
-                               CyNetwork.DEFAULT_ATTRS);
-               Map<String, Class<?>> nodetypemap = 
nodetable.getColumnTypeMap();
-               Set<String> keys = nodetypemap.keySet();
-               Object[] arr = keys.toArray();
-               nodeattrList = new String[arr.length];
-               for (int i = 0; i < arr.length; i++) {
-                       nodeattrList[i] = arr[i].toString();
-               }
-               Arrays.sort(nodeattrList);
-               for (int i = 0; i < nodeattrList.length; i++) {
-                       if (!nodeattrList[i].equals("name")) {
-                               if (nodetypemap.get(nodeattrList[i]).getName() 
== AttributeTypes.TYPE_STRING) {
-                                       StringAttributePanel temp = new 
StringAttributePanel(
-                                                       netmgr, 
nodeattrList[i], "NODE");
-                                       attrPanel.addPanel(temp);
-                               } else if 
(nodetypemap.get(nodeattrList[i]).getName() == AttributeTypes.TYPE_INTEGER
-                                               || 
nodetypemap.get(nodeattrList[i]).getName() == AttributeTypes.TYPE_DOUBLE) {
-                                       NumericAttributePanel temp = new 
NumericAttributePanel(
-                                                       netmgr, 
nodeattrList[i], "NODE", nodetypemap.get(
-                                                                       
nodeattrList[i]).getName());
-                                       attrPanel.addPanel(temp);
+               if (net != null) {
+                       CyDataTable nodetable = net.getCyDataTables("NODE").get(
+                                       CyNetwork.DEFAULT_ATTRS);
+                       Map<String, Class<?>> nodetypemap = 
nodetable.getColumnTypeMap();
+                       Set<String> keys = nodetypemap.keySet();
+                       Object[] arr = keys.toArray();
+                       nodeattrList = new String[arr.length];
+                       for (int i = 0; i < arr.length; i++) {
+                               nodeattrList[i] = arr[i].toString();
+                       }
+                       Arrays.sort(nodeattrList);
+                       for (int i = 0; i < nodeattrList.length; i++) {
+                               if (!nodeattrList[i].equals("name")) {
+                                       if 
(nodetypemap.get(nodeattrList[i]).getName() == AttributeTypes.TYPE_STRING) {
+                                               StringAttributePanel temp = new 
StringAttributePanel(
+                                                               netmgr, 
nodeattrList[i], "NODE");
+                                               attrPanel.addPanel(temp);
+                                       } else if 
(nodetypemap.get(nodeattrList[i]).getName() == AttributeTypes.TYPE_INTEGER
+                                                       || 
nodetypemap.get(nodeattrList[i]).getName() == AttributeTypes.TYPE_DOUBLE) {
+                                               NumericAttributePanel temp = 
new NumericAttributePanel(
+                                                               netmgr, 
nodeattrList[i], "NODE", nodetypemap
+                                                                               
.get(nodeattrList[i]).getName());
+                                               attrPanel.addPanel(temp);
+                                       }
                                }
                        }
-               }
-               CyDataTable edgetable = net.getCyDataTables("EDGE").get(
-                               CyNetwork.DEFAULT_ATTRS);
-               Map<String, Class<?>> edgetypemap = 
edgetable.getColumnTypeMap();
-               keys = edgetypemap.keySet();
-               Object[] edgearr = keys.toArray();
-               edgeattrList = new String[edgearr.length];
-               for (int i = 0; i < edgearr.length; i++) {
-                       edgeattrList[i] = edgearr[i].toString();
-               }
-               Arrays.sort(edgeattrList);
-               for (int i = 0; i < edgeattrList.length; i++) {
-                       if (!edgeattrList[i].equals("name")) {
-                               if (edgetypemap.get(edgeattrList[i]).getName() 
== AttributeTypes.TYPE_STRING) {
-                                       StringAttributePanel temp = new 
StringAttributePanel(
-                                                       netmgr, 
edgeattrList[i], "EDGE");
-                                       attrPanel.addPanel(temp);
-                               } else if 
(edgetypemap.get(edgeattrList[i]).getName() == AttributeTypes.TYPE_INTEGER
-                                               || 
edgetypemap.get(edgeattrList[i]).getName() == AttributeTypes.TYPE_DOUBLE) {
-                                       NumericAttributePanel temp = new 
NumericAttributePanel(
-                                                       netmgr, 
edgeattrList[i], "EDGE", edgetypemap.get(
-                                                                       
edgeattrList[i]).getName());
-                                       attrPanel.addPanel(temp);
+                       CyDataTable edgetable = net.getCyDataTables("EDGE").get(
+                                       CyNetwork.DEFAULT_ATTRS);
+                       Map<String, Class<?>> edgetypemap = 
edgetable.getColumnTypeMap();
+                       keys = edgetypemap.keySet();
+                       Object[] edgearr = keys.toArray();
+                       edgeattrList = new String[edgearr.length];
+                       for (int i = 0; i < edgearr.length; i++) {
+                               edgeattrList[i] = edgearr[i].toString();
+                       }
+                       Arrays.sort(edgeattrList);
+                       for (int i = 0; i < edgeattrList.length; i++) {
+                               if (!edgeattrList[i].equals("name")) {
+                                       if 
(edgetypemap.get(edgeattrList[i]).getName() == AttributeTypes.TYPE_STRING) {
+                                               StringAttributePanel temp = new 
StringAttributePanel(
+                                                               netmgr, 
edgeattrList[i], "EDGE");
+                                               attrPanel.addPanel(temp);
+                                       } else if 
(edgetypemap.get(edgeattrList[i]).getName() == AttributeTypes.TYPE_INTEGER
+                                                       || 
edgetypemap.get(edgeattrList[i]).getName() == AttributeTypes.TYPE_DOUBLE) {
+                                               NumericAttributePanel temp = 
new NumericAttributePanel(
+                                                               netmgr, 
edgeattrList[i], "EDGE", edgetypemap
+                                                                               
.get(edgeattrList[i]).getName());
+                                               attrPanel.addPanel(temp);
+                                       }
                                }
                        }
                }
@@ -115,6 +116,7 @@
                split.setBottomComponent(jsp);
                split.setMinimumSize(new Dimension(280, 200));
                this.add(split, g1);
+
        }
 
        public void performSearch(boolean reindex) {
@@ -197,7 +199,7 @@
                                        sp.clearCheckBoxes();
                                }
                        }
-                       
+
                        else if (list.get(i) instanceof NumericAttributePanel) {
                                NumericAttributePanel np = 
(NumericAttributePanel) list.get(i);
                                if (np != null) {

Modified: 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPlugin.java
===================================================================
--- 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPlugin.java
    2009-07-30 05:06:54 UTC (rev 17623)
+++ 
csplugins/trunk/soc/srinivasarao/search-ui/src/main/java/org/cytoscape/search/internal/SearchPlugin.java
    2009-07-30 14:54:02 UTC (rev 17624)
@@ -23,6 +23,6 @@
        public void initPanel() {
                SearchPanel esp = SearchPanelFactory.getGlobalInstance(netmgr);
                desktop.getCytoPanel(SwingConstants.EAST).add(esp);
-
+               
        }
 }

Modified: 
csplugins/trunk/soc/srinivasarao/search-ui/src/test/java/org/cytoscape/search/internal/TestSearchPanel.java
===================================================================
--- 
csplugins/trunk/soc/srinivasarao/search-ui/src/test/java/org/cytoscape/search/internal/TestSearchPanel.java
 2009-07-30 05:06:54 UTC (rev 17623)
+++ 
csplugins/trunk/soc/srinivasarao/search-ui/src/test/java/org/cytoscape/search/internal/TestSearchPanel.java
 2009-07-30 14:54:02 UTC (rev 17624)
@@ -1,6 +1,7 @@
 package org.cytoscape.search.internal;
 
 import javax.swing.JFrame;
+import javax.swing.WindowConstants;
 
 import org.cytoscape.event.DummyCyEventHelper;
 import org.cytoscape.model.CyDataTable;
@@ -35,6 +36,7 @@
                jf.setTitle("Search Panel");
                jf.setLocation(650, 130);
                jf.setSize(300, 600);
+               jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                jf.setVisible(true);
        }
 


--~--~---------~--~----~------------~-------~--~----~
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