Author: scooter
Date: 2012-03-16 05:12:32 -0700 (Fri, 16 Mar 2012)
New Revision: 28561

Added:
   
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/GroupDataCollapseHandler.java
Modified:
   
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyActivator.java
   
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
Log:
Oops -- bad Scooter!  Forgot to add GroupDataCollapseHandler.java to my 
check-in.  Also
have some Tunable fixes.  Still trying to figure out how to do Tunables 
right....


Modified: 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyActivator.java
===================================================================
--- 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyActivator.java
   2012-03-16 01:03:14 UTC (rev 28560)
+++ 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyActivator.java
   2012-03-16 12:12:32 UTC (rev 28561)
@@ -33,10 +33,10 @@
 
     Properties settingsProps = new Properties();
     settingsProps.setProperty("id","settingsFactory");
-    settingsProps.setProperty("preferredMenu","Tools");
-    settingsProps.setProperty("title", "Group Settings...");
+    settingsProps.setProperty("preferredMenu","Edit.Preferences");
+    settingsProps.setProperty("title", "Group Preferences...");
     settingsProps.setProperty("menuGravity","1.0");
-    settingsProps.setProperty("toolBarGravity","3.4");
+    settingsProps.setProperty("toolBarGravity","4");
     settingsProps.setProperty("inToolBar","false");
     registerService(bc,settingsFactory,TaskFactory.class, settingsProps);
 

Modified: 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
===================================================================
--- 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
   2012-03-16 01:03:14 UTC (rev 28560)
+++ 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/CyGroupSettingsImpl.java
   2012-03-16 12:12:32 UTC (rev 28561)
@@ -41,6 +41,8 @@
        /**********************************
         * Default aggregation attributes *
         *********************************/
+       // Default aggregations
+
        @Tunable(description="Enable attribute aggregation", groups={"Attribute 
Aggregation Settings"})
        public boolean enableAttributeAggregation = false;
 
@@ -48,171 +50,56 @@
        @Tunable(description="Integer column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"}, params="displayState=collapsed",
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getIntegerAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(IntegerAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> integerDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
-
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.AVG);
-               return types;
-       }
-
-       public void 
setIntegerAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(Integer.class, new 
IntegerAggregator(input.getSelectedValue()));
-       }
-
        // Long
        @Tunable(description="Long column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"},
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getLongAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(LongAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> longDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
-
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.AVG);
-               return types;
-       }
-
-       public void 
setLongAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(Long.class, new 
LongAggregator(input.getSelectedValue()));
-       }
-
        // Float
        @Tunable(description="Float column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"},
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getFloatAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(FloatAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> floatDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
-
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.AVG);
-               return types;
-       }
-
-       public void 
setFloatAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(Float.class, new 
FloatAggregator(input.getSelectedValue()));
-       }
-
        // Double
        @Tunable(description="Double column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"},
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getDoubleAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(DoubleAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> doubleDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
-
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.AVG);
-               return types;
-       }
-
-       public void 
setDoubleAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(Double.class, new 
DoubleAggregator(input.getSelectedValue()));
-       }
-
-
        // List
        @Tunable(description="List column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"},
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getListAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(ListAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> listDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
-
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.UNIQUE);
-               return types;
-       }
-
-       public void 
setListAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(List.class, new 
ListAggregator(input.getSelectedValue()));
-       }
-
        // String
        @Tunable(description="String column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"},
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getStringAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(StringAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> stringDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
-
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.TSV);
-               return types;
-       }
-
-       public void 
setStringAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(String.class, new 
StringAggregator(input.getSelectedValue()));
-       }
-
        // Boolean
        @Tunable(description="Boolean column aggregation default", 
                 groups={"Attribute Aggregation Settings", "Default 
Aggregation"},
                 dependsOn="enableAttributeAggregation=true")
-  public ListSingleSelection<AttributeHandlingType> 
getBooleanAggregationDefault() {
-               // Get the list of options
-               List<AttributeHandlingType> options = 
Arrays.asList(BooleanAggregator.getSupportedTypes());
+       public ListSingleSelection<AttributeHandlingType> booleanDefault;
 
-               // Create the selection
-               ListSingleSelection<AttributeHandlingType> types = 
-                       new ListSingleSelection<AttributeHandlingType>(options);
 
-               // Initialize it to our default
-               types.setSelectedValue(AttributeHandlingType.OR);
-               return types;
-       }
-
-       public void 
setBooleanAggregationDefault(ListSingleSelection<AttributeHandlingType> input) {
-               allGroupDefaultMap.put(Boolean.class, new 
BooleanAggregator(input.getSelectedValue()));
-       }
-
-
        public CyGroupSettingsImpl(CyGroupManager mgr) {
                this.cyGroupManager = mgr;
                allGroupDefaultMap = new HashMap<Class,Aggregator>();
                allGroupOverrideMap = new HashMap<CyColumn,Aggregator>();
                groupMap = new HashMap<CyGroup,GroupSpecificMaps>();
 
+               initializeDefaults();
+
                // Set some defaults
                
doubleClickAction.setSelectedValue(DoubleClickAction.ExpandContract);
 
-               // Build the options
-               
-
-               // Initialize the defaults
-               allGroupDefaultMap.put(Boolean.class, new 
BooleanAggregator(AttributeHandlingType.NONE));
-               allGroupDefaultMap.put(Double.class, new 
DoubleAggregator(AttributeHandlingType.AVG));
-               allGroupDefaultMap.put(Long.class, new 
LongAggregator(AttributeHandlingType.NONE));
-               allGroupDefaultMap.put(Integer.class, new 
IntegerAggregator(AttributeHandlingType.SUM));
-               allGroupDefaultMap.put(Float.class, new 
FloatAggregator(AttributeHandlingType.SUM));
-               allGroupDefaultMap.put(String.class, new 
StringAggregator(AttributeHandlingType.MCV));
-               allGroupDefaultMap.put(List.class, new 
ListAggregator(AttributeHandlingType.UNIQUE));
        }
 
        // This is a little funky, but we don't really have a task, so we just 
provide the run method
@@ -241,6 +128,7 @@
 
        @Override
        public Aggregator getAggregator(CyGroup group, CyColumn column) {
+               updateDefaults();
                Class type = column.getType();
                Map<Class, Aggregator> defaultMap = allGroupDefaultMap;
                Map<CyColumn, Aggregator> overrideMap = allGroupOverrideMap;
@@ -281,6 +169,7 @@
 
        public void handleEvent(GroupAddedEvent e) {
                CyGroup addedGroup = e.getGroup();
+               updateDefaults();
                Map<Class,Aggregator> defMap = new HashMap<Class, Aggregator>();
                for (Class cKey: allGroupDefaultMap.keySet())
                        defMap.put(cKey, allGroupDefaultMap.get(cKey));
@@ -290,7 +179,52 @@
                groupMap.put(addedGroup, new GroupSpecificMaps(defMap, ovMap));
        }
 
+       private void updateDefaults() {
+               // Update our defaults first
+               allGroupDefaultMap.put(Boolean.class, new 
BooleanAggregator(booleanDefault.getSelectedValue()));
+               allGroupDefaultMap.put(Integer.class, new 
IntegerAggregator(integerDefault.getSelectedValue()));
+               allGroupDefaultMap.put(Float.class, new 
FloatAggregator(floatDefault.getSelectedValue()));
+               allGroupDefaultMap.put(Long.class, new 
LongAggregator(longDefault.getSelectedValue()));
+               allGroupDefaultMap.put(Double.class, new 
DoubleAggregator(doubleDefault.getSelectedValue()));
+               allGroupDefaultMap.put(List.class, new 
ListAggregator(listDefault.getSelectedValue()));
+               allGroupDefaultMap.put(String.class, new 
StringAggregator(stringDefault.getSelectedValue()));
+       }
 
+       private void initializeDefaults() {
+               // Create the selection
+               integerDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(IntegerAggregator.getSupportedTypes()));
+               longDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(LongAggregator.getSupportedTypes()));
+               floatDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(FloatAggregator.getSupportedTypes()));
+               doubleDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(DoubleAggregator.getSupportedTypes()));
+               stringDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(StringAggregator.getSupportedTypes()));
+               listDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(ListAggregator.getSupportedTypes()));
+               booleanDefault = 
+                       new 
ListSingleSelection<AttributeHandlingType>(Arrays.asList(BooleanAggregator.getSupportedTypes()));
+
+               integerDefault.setSelectedValue(AttributeHandlingType.AVG);
+               longDefault.setSelectedValue(AttributeHandlingType.NONE);
+               floatDefault.setSelectedValue(AttributeHandlingType.AVG);
+               doubleDefault.setSelectedValue(AttributeHandlingType.AVG);
+               stringDefault.setSelectedValue(AttributeHandlingType.CSV);
+               listDefault.setSelectedValue(AttributeHandlingType.UNIQUE);
+               booleanDefault.setSelectedValue(AttributeHandlingType.NONE);
+
+               // Initialize the defaults
+               allGroupDefaultMap.put(Integer.class, new 
IntegerAggregator(AttributeHandlingType.AVG));
+               allGroupDefaultMap.put(Long.class, new 
LongAggregator(AttributeHandlingType.NONE));
+               allGroupDefaultMap.put(Float.class, new 
FloatAggregator(AttributeHandlingType.AVG));
+               allGroupDefaultMap.put(Double.class, new 
DoubleAggregator(AttributeHandlingType.AVG));
+               allGroupDefaultMap.put(String.class, new 
StringAggregator(AttributeHandlingType.CSV));
+               allGroupDefaultMap.put(List.class, new 
ListAggregator(AttributeHandlingType.UNIQUE));
+               allGroupDefaultMap.put(Boolean.class, new 
BooleanAggregator(AttributeHandlingType.NONE));
+       }
+
        class GroupSpecificMaps {
                Map<Class, Aggregator> defMap;
                Map<CyColumn, Aggregator> ovMap;

Added: 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/GroupDataCollapseHandler.java
===================================================================
--- 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/GroupDataCollapseHandler.java
                              (rev 0)
+++ 
core3/impl/trunk/group-data-impl/src/main/java/org/cytoscape/group/data/internal/GroupDataCollapseHandler.java
      2012-03-16 12:12:32 UTC (rev 28561)
@@ -0,0 +1,90 @@
+/*
+ File: GroupViewCollapseHandler.java
+
+ Copyright (c) 2006, 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.group.data.internal;
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.data.CyGroupSettings;
+import org.cytoscape.group.data.Aggregator;
+import org.cytoscape.group.events.GroupAboutToCollapseEvent;
+import org.cytoscape.group.events.GroupAboutToCollapseListener;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyColumn;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handle the view portion of group collapse/expand
+ */
+public class GroupDataCollapseHandler implements GroupAboutToCollapseListener
+{
+
+       private final CyGroupManager cyGroupManager;
+       private final CyGroupSettings cyGroupSettings;
+       private static final Logger logger = 
LoggerFactory.getLogger(GroupDataCollapseHandler.class);
+
+       /**
+        * 
+        * @param cyEventHelper
+        */
+       public GroupDataCollapseHandler(final CyGroupManager groupManager, 
final CyGroupSettingsImpl groupSettings) {
+               this.cyGroupManager = groupManager;
+               this.cyGroupSettings = groupSettings;
+       }
+
+       public void handleEvent(GroupAboutToCollapseEvent e) {
+               CyNetwork network = e.getNetwork();
+               CyGroup group = e.getSource();
+               
+               if (e.collapsing()) {
+                       // Are we aggregating
+                       if (!cyGroupSettings.getEnableAttributeAggregation())
+                               return;
+
+                       // Yup -- all of our information is in the settings...
+                       CyTable nodeTable = network.getDefaultNodeTable();
+                       for (CyColumn column: nodeTable.getColumns()) {
+                               Class type = column.getType();
+                               if (column.isPrimaryKey()) continue;
+                               // Do we have an override for this group and 
column?
+                               Aggregator agg = 
cyGroupSettings.getAggregator(group, column);
+                               if (agg == null) continue;
+
+                               // OK, aggregate
+                               agg.aggregate(nodeTable, group, column);
+                       }
+               }
+       }
+}

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