Author: neildhruva
Date: 2012-07-02 12:15:36 -0700 (Mon, 02 Jul 2012)
New Revision: 29736

Modified:
   csplugins/trunk/soc/neildhruva/PrintTable/pom.xml
   
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/CyActivator.java
   
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyCytoPanel.java
   
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyTableModel.java
   
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/PanelComponents.java
   
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableAddedEvent.java
   
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableDestroyedEvent.java
Log:
Made version changes for JFreeChart and JCommon in pom.xml.
Associated a new CyTable to every network. This CyTable stores info regarding 
the columns present in the JTable representing the node table of the network 
and a list of boolean values to keep track of which columns are visible/hidden 
in the JTable.

Modified: csplugins/trunk/soc/neildhruva/PrintTable/pom.xml
===================================================================
--- csplugins/trunk/soc/neildhruva/PrintTable/pom.xml   2012-07-02 19:09:33 UTC 
(rev 29735)
+++ csplugins/trunk/soc/neildhruva/PrintTable/pom.xml   2012-07-02 19:15:36 UTC 
(rev 29736)
@@ -4,7 +4,7 @@
        <properties>
                <bundle.symbolicName>PrintTable</bundle.symbolicName>
                
<bundle.namespace>org.cytoscape.sample.internal</bundle.namespace>
-               
<cytoscape.api.version>3.0.0-alpha8-SNAPSHOT</cytoscape.api.version>
+               
<cytoscape.api.version>3.0.0-beta2-SNAPSHOT</cytoscape.api.version>
                
                <maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version>
                <osgi.api.version>4.2.0</osgi.api.version>
@@ -15,7 +15,7 @@
        <packaging>bundle</packaging>
        <name>${bundle.symbolicName}</name>
 
-       <version>3.0.0-alpha8-SNAPSHOT</version>
+       <version>3.0.0-beta2-SNAPSHOT</version>
 
        <build>
                <plugins>
@@ -87,12 +87,12 @@
                <dependency>
                <groupId>jfree</groupId> 
                <artifactId>jfreechart</artifactId>
-               <version>1.0.14</version> 
+               <version>1.0.13</version> 
        </dependency>
        <dependency>
                <groupId>jfree</groupId> 
                <artifactId>jcommon</artifactId>
-               <version>1.0.17</version> 
+               <version>1.0.16</version> 
        </dependency>
        </dependencies>
   

Modified: 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/CyActivator.java
===================================================================
--- 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/CyActivator.java
      2012-07-02 19:09:33 UTC (rev 29735)
+++ 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/CyActivator.java
      2012-07-02 19:15:36 UTC (rev 29736)
@@ -2,6 +2,7 @@
 
 import org.cytoscape.application.events.SetCurrentNetworkListener;
 import org.cytoscape.application.swing.CytoPanelComponent;
+import org.cytoscape.model.CyNetworkTableManager;
 import org.cytoscape.model.CyTableFactory;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
 import org.cytoscape.service.util.AbstractCyActivator;
@@ -18,10 +19,11 @@
        public void start(BundleContext bc) {
                
                CyTableFactory cyDataTableFactoryServiceRef = 
getService(bc,CyTableFactory.class);
+               CyNetworkTableManager cyNetworkTableManagerServiceRef = 
getService(bc, CyNetworkTableManager.class);
                
                MyCytoPanel myCytoPanel = new MyCytoPanel();
-               TableAddedEvent tableAddedEvent =new 
TableAddedEvent(myCytoPanel, cyDataTableFactoryServiceRef);
-               TableDestroyedEvent tableDestroyedEvent =new 
TableDestroyedEvent(myCytoPanel);
+               TableAddedEvent tableAddedEvent = new 
TableAddedEvent(myCytoPanel, cyDataTableFactoryServiceRef, 
cyNetworkTableManagerServiceRef);
+               TableDestroyedEvent tableDestroyedEvent = new 
TableDestroyedEvent(myCytoPanel);
                
                registerService(bc,myCytoPanel,CytoPanelComponent.class, new 
Properties());
                
registerService(bc,tableAddedEvent,SetCurrentNetworkListener.class, new 
Properties());

Modified: 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyCytoPanel.java
===================================================================
--- 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyCytoPanel.java
      2012-07-02 19:09:33 UTC (rev 29735)
+++ 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyCytoPanel.java
      2012-07-02 19:15:36 UTC (rev 29736)
@@ -19,7 +19,6 @@
        private static final long serialVersionUID = 8292806967891823933L;
 
     private JScrollPane jScrollPane1;
-    private JTable table;
     private JCheckBox[] checkBoxArray;
     private GroupLayout layout;
     private int tableColumnCount;
@@ -27,9 +26,7 @@
     private CytoChart cytoChart;
     
     public MyCytoPanel() {
-       
                this.setVisible(true);
-               
        }
 
        /**
@@ -41,15 +38,12 @@
         */
        public void initComponents(JTable table, JCheckBox[] checkBoxArray, int 
tableColumnCount){
                
-               //if(this.table!=null)
-               //      this.removeAll();
                if(this.getComponents().length>0)
                        this.removeAll();
                
                cytoChart = new CytoChart();
                myChart = cytoChart.createChart();
                
-        this.table = table;
         this.checkBoxArray = checkBoxArray;
         this.tableColumnCount = tableColumnCount;
         
@@ -90,7 +84,7 @@
         checkBoxGroupVert.addContainerGap();
         for(int i=0;i<tableColumnCount;i++){
                checkBoxGroupVert.addComponent(checkBoxArray[i]);
-               if(!(i==(tableColumnCount-1))) {
+               if(i!=(tableColumnCount-1)) {
                        
checkBoxGroupVert.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED);
                }
         }
@@ -105,7 +99,6 @@
                     .addContainerGap())
             );
      }
-
        
        public Component getComponent() {
                return this;

Modified: 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyTableModel.java
===================================================================
--- 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyTableModel.java
     2012-07-02 19:09:33 UTC (rev 29735)
+++ 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/MyTableModel.java
     2012-07-02 19:15:36 UTC (rev 29736)
@@ -100,5 +100,4 @@
                }
                return v;       
        }
-       
-}
+}
\ No newline at end of file

Modified: 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/PanelComponents.java
===================================================================
--- 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/PanelComponents.java
  2012-07-02 19:09:33 UTC (rev 29735)
+++ 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/PanelComponents.java
  2012-07-02 19:15:36 UTC (rev 29736)
@@ -2,10 +2,8 @@
 
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
-import java.io.Serializable;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import javax.swing.JCheckBox;
 import javax.swing.JTable;
@@ -13,38 +11,34 @@
 import javax.swing.table.TableColumnModel;
 
 import org.cytoscape.model.CyTable;
-import org.cytoscape.model.CyTableFactory;
 
 public class PanelComponents {
 
     private JTable table;
        private TableColumnModel tableColumnModel;
-       public static Map<String, Serializable> hiddenColumnsColumn;
-    public static Map<String, Serializable> hiddenColumnsIndex;
        private JCheckBox[] checkBoxArray;
        private int columnCount;
-       public static CyTable myCyTable;
+       private CyTable myCyTable;
        private List<Boolean> checkBoxState;
+       private List<String> columnNamesList;
        private Long networkSUID;
+       private CyTable cytable;
+       private MyCytoPanel myCytoPanel;
     
-    public PanelComponents() {
-       
+    public PanelComponents(MyCytoPanel myCytoPanel) {
+       this.myCytoPanel = myCytoPanel;
     }
     
-    static {
-       hiddenColumnsColumn = new HashMap<String, Serializable>();
-        hiddenColumnsIndex = new HashMap<String, Serializable>();
-    }
-
-    public void initCyTable(CyTableFactory tableFactory) {
+    /*public void initCyTable(CyTableFactory tableFactory) {
        //myCyTable stores a network's SUID and a Boolean List that suggests 
whether a particular column of
        //the JTable is visible or hidden based on its true/false value. Each 
element in the list corresponds 
        //to a particular column in a network
                if(myCyTable==null) {
                        myCyTable = tableFactory.createTable("MyCyTable", 
"SUID", Long.class, true, true);
+                       myCyTable.createListColumn("Names", String.class, true);
                        myCyTable.createListColumn("States", Boolean.class, 
true);
                }
-    }
+    }*/
     
     /**
      * Initializes an array of checkboxes with column names of the table as 
titles and
@@ -53,15 +47,21 @@
      * 
      * @return JCheckBox[] Array of checkboxes initialized with column names 
as titles
      */
-    public JCheckBox[] initCheckBoxArray(List<Boolean> checkBoxState, Long 
networkSUID, JTable table){
+    public JCheckBox[] initCheckBoxArray(CyTable myCyTable, Long networkSUID, 
CyTable cytable){
                
-       this.table = table;
+       this.myCyTable = myCyTable;
+       this.cytable = cytable;
+       this.table = new JTable(new MyTableModel(cytable));
        this.tableColumnModel = table.getColumnModel();
        this.columnCount = table.getColumnCount();
-       this.checkBoxState = checkBoxState;
        this.networkSUID = networkSUID;
        
-        checkBoxArray = new JCheckBox[columnCount];
+       this.columnNamesList = new ArrayList<String>();
+               this.checkBoxState = new ArrayList<Boolean>();
+       checkBoxState = myCyTable.getRow(networkSUID).getList("States", 
Boolean.class);
+       columnNamesList = myCyTable.getRow(networkSUID).getList("Names", 
String.class);
+       
+       checkBoxArray = new JCheckBox[columnCount];
         
         for(int i=0;i<columnCount;i++){
                checkBoxArray[i] = new JCheckBox();
@@ -101,57 +101,43 @@
     
     /**
      * Hides the column from the table view by removing it from the table 
column model.
-     * <code>HashMap</code>s store the index and the column that is removed.
      * 
      * @param columnName Name of the column that has to be hidden
      */
     public void hideColumn(String columnName) {
-        int columnIndex = tableColumnModel.getColumnIndex(columnName);
+        
+       int columnIndex = tableColumnModel.getColumnIndex(columnName);
         TableColumn column = tableColumnModel.getColumn(columnIndex);
-        //appending column name with network SUID to uniquely identify the 
column
-        //of a given network
-        columnName+=networkSUID;
-        //enter the columnName-column combination in the HashMap 
hiddenColumnsColumn
-        hiddenColumnsColumn.put(columnName, column);
-        //enter the columnName-index combination in the HashMap 
hiddenColumnsIndex
-        hiddenColumnsIndex.put(columnName, new Integer(columnIndex));
-        tableColumnModel.removeColumn(column);
         
+        columnIndex = columnNamesList.indexOf(columnName);
         checkBoxState.set(columnIndex, false);
         myCyTable.getRow(networkSUID).set("States", checkBoxState);
         
+        tableColumnModel.removeColumn(column);
+        
     }
 
     /**
-     * Makes a column visible in the table view by adding it to the table 
column model.
-     * The column is then moved to where it was deleted from.
+     * Makes a column visible in the table view by refreshing the CytoPanel.
      * 
      * @param columnName Name of the column that has to be made visible
      */
        public void showColumn(String columnName) {
-               //appending column name with network SUID to uniquely identify 
the column
-        //of a given network
-               columnName+=networkSUID;
-               //o acquires the column corresponding to the column name
-               Object o = hiddenColumnsColumn.remove(columnName);
-        if (o == null) {
-            return;
-        }
-        tableColumnModel.addColumn((TableColumn) o);
-        //o acquires the index corresponding to the column name
-        o = hiddenColumnsIndex.remove(columnName);
-        if (o == null) {
-            return;
-        }
-        int columnIndex = ((Integer) o).intValue();
-        //tableColumnModel recalculates the number of columns
-        int lastColumn = tableColumnModel.getColumnCount() - 1;
-        if(columnIndex < lastColumn){
-               tableColumnModel.moveColumn(lastColumn, columnIndex);
-        }
-        
+               
+               int columnIndex = columnNamesList.indexOf(columnName);
         checkBoxState.set(columnIndex, true);
         myCyTable.getRow(networkSUID).set("States", checkBoxState);
+        table = new JTable(new MyTableModel(cytable));
+        tableColumnModel = table.getColumnModel();
+        for(int i=0;i<columnCount;i++){
+               if(!checkBoxState.get(i)) {
+                       TableColumn column = 
tableColumnModel.getColumn(tableColumnModel.getColumnIndex(checkBoxArray[i].getText()));
+                       tableColumnModel.removeColumn(column);
+               }
+        }
+        
+        //refresh the CytoPanel
+        myCytoPanel.initComponents(table, checkBoxArray, columnCount);
     }
        
        /**

Modified: 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableAddedEvent.java
===================================================================
--- 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableAddedEvent.java
  2012-07-02 19:09:33 UTC (rev 29735)
+++ 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableAddedEvent.java
  2012-07-02 19:15:36 UTC (rev 29736)
@@ -8,6 +8,8 @@
 
 import org.cytoscape.application.events.SetCurrentNetworkEvent;
 import org.cytoscape.application.events.SetCurrentNetworkListener;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkTableManager;
 import org.cytoscape.model.CyRow;
 import org.cytoscape.model.CyTable;
 import org.cytoscape.model.CyTableFactory;
@@ -22,12 +24,15 @@
        private int tableColumnCount;
        public static boolean networkDestroyed = false;
        private List<Boolean> checkBoxState;
+       private List<String> columnNamesList;
+       private CyNetworkTableManager networkTableMgr;
+       private CyTableFactory tableFactory;
        
-       TableAddedEvent(MyCytoPanel myCytoPanel, CyTableFactory tableFactory){
-               
+       TableAddedEvent(MyCytoPanel myCytoPanel, CyTableFactory tableFactory, 
CyNetworkTableManager networkTableMgr){
                this.myCytoPanel = myCytoPanel;
-               this.panelComponents = new PanelComponents();
-               panelComponents.initCyTable(tableFactory);
+               this.networkTableMgr = networkTableMgr;
+               this.tableFactory = tableFactory;
+               this.panelComponents = new PanelComponents(myCytoPanel);
        }
 
        
@@ -51,17 +56,32 @@
                table = new JTable(new MyTableModel(cytable));
                tableColumnCount = table.getColumnCount();
                
-               if(PanelComponents.myCyTable.rowExists(networkSUID)) {  
-                       checkBoxState = 
PanelComponents.myCyTable.getRow(networkSUID).getList("States", Boolean.class);
-                       checkBoxArray = 
panelComponents.initCheckBoxArray(checkBoxState, networkSUID, table);
+               CyTable myCyTable = networkTableMgr.getTable(e.getNetwork(), 
CyNetwork.class, "PrintTable");
+               
+               if(myCyTable!=null) {   
+                       checkBoxArray = 
panelComponents.initCheckBoxArray(myCyTable, networkSUID, cytable);
                } else {
+                       //checkBoxState stores information on whether a given 
column of a network table is
+                       //hidden or visible depending on the associated boolean 
value (true for visible)
                        checkBoxState = new ArrayList<Boolean>();
+                       columnNamesList = new ArrayList<String>();
                        for(int i=0; i<tableColumnCount; i++) {
+                               columnNamesList.add(table.getColumnName(i));
                                checkBoxState.add(true);
                        }
-                       CyRow cyrow = 
PanelComponents.myCyTable.getRow(networkSUID);
+                       
+                       //if myCyTable is null, create a new CyTable and 
associate it with the current network.
+                       myCyTable = tableFactory.createTable("PrintTabl", 
"SUID", Long.class, true, true);
+                       myCyTable.createListColumn("Names", String.class, true);
+                       myCyTable.createListColumn("States", Boolean.class, 
true);
+                       
+                       CyRow cyrow = myCyTable.getRow(networkSUID);
+                       cyrow.set("Names", columnNamesList);
                        cyrow.set("States", checkBoxState);
-                       checkBoxArray = 
panelComponents.initCheckBoxArray(checkBoxState, networkSUID, table);
+                       
+                       networkTableMgr.setTable(e.getNetwork(), 
CyNetwork.class, "PrintTable", myCyTable);
+                       
+                       checkBoxArray = 
panelComponents.initCheckBoxArray(myCyTable, networkSUID, cytable);
                }       
                
                table = panelComponents.getTable();

Modified: 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableDestroyedEvent.java
===================================================================
--- 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableDestroyedEvent.java
      2012-07-02 19:09:33 UTC (rev 29735)
+++ 
csplugins/trunk/soc/neildhruva/PrintTable/src/main/java/org/cytoscape/sample/internal/TableDestroyedEvent.java
      2012-07-02 19:15:36 UTC (rev 29736)
@@ -1,12 +1,9 @@
 package org.cytoscape.sample.internal;
 
 import java.awt.GridLayout;
-import java.util.Collection;
 
 import javax.swing.JLabel;
 
-import org.cytoscape.model.CyColumn;
-import org.cytoscape.model.CyTable;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
 
@@ -24,23 +21,6 @@
        @Override
        public void handleEvent(NetworkAboutToBeDestroyedEvent e) {
                
-               long networkSUID = e.getNetwork().getSUID();
-               
-               //TODO: delete row in cytable 
-               
-               //removing all the entries from hiddenColumnsColumn and 
hiddenColumnsIndex Hashmaps
-               String columnName;
-               CyTable cytable =e.getNetwork().getDefaultNodeTable();
-               Collection<CyColumn> columns = cytable.getColumns();
-               for(CyColumn column: columns) {
-                       columnName =column.getName();
-                       columnName+=networkSUID;
-                       
if(PanelComponents.hiddenColumnsColumn.containsKey(columnName)) {
-                               
PanelComponents.hiddenColumnsColumn.remove(columnName);
-                               
PanelComponents.hiddenColumnsIndex.remove(columnName);
-                       }
-               }
-               
                //Clear the Table View Panel
                myCytoPanel.removeAll();
                JLabel label = new JLabel("Please select/import a network");

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