Author: clopes
Date: 2013-01-22 09:08:09 -0800 (Tue, 22 Jan 2013)
New Revision: 31068

Modified:
   
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
   
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeListModel.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
Log:
Fixes #1662 (Attributes in VizMapper are sorted in ASCII/Unicode order, not 
lexicographical order)

Modified: 
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
===================================================================
--- 
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
  2013-01-22 16:43:12 UTC (rev 31067)
+++ 
core3/impl/trunk/filter-impl/src/main/java/org/cytoscape/filter/internal/filters/view/FilterMainPanel.java
  2013-01-22 17:08:09 UTC (rev 31068)
@@ -40,11 +40,13 @@
 import java.awt.event.ComponentEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.text.Collator;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Vector;
 
 import javax.swing.AbstractAction;
@@ -434,46 +436,38 @@
         * prefixed either with "node." or "edge.". Those attributes whose data 
type is neither
         * "String" nor "numeric" will be excluded
         */
-       private List<Object> getCyAttributesList(CyNetwork network, String 
pType) {
-               Vector<String> attributeList = new Vector<String>();
-               CyTable table;
+       private List<String> getCyAttributesList(final CyNetwork network, final 
String pType) {
+               final Vector<String> attributeList = new Vector<String>();
+               CyTable table = null;
                
                if (pType.equalsIgnoreCase("node") && network.getNodeCount() > 
0) {
                        table = network.getDefaultNodeTable();
                } else if (pType.equalsIgnoreCase("edge") && 
network.getEdgeCount() > 0){
                        table = network.getDefaultEdgeTable();
-               } else {
-                       return Collections.emptyList();
                }
                
-               if (table == null) {
-                       return Collections.emptyList();
-               }
-               
-               final Collection<CyColumn> columns = new 
HashSet<CyColumn>(table.getColumns());
-               for (final CyColumn column : columns) {
-                       if(column!= null){
-                               //  Show all attributes, with type of String or 
Number
-                               Class<?> type = column.getType();
-
-                               //  only show user visible attributes,with type 
= Number/String/List
-                               if ((type == Integer.class)||(type == 
Double.class)||(type == Boolean.class)||(type == String.class)||(type == 
List.class)) {
-                                       attributeList.add(pType + "." + 
column.getName());
+               if (table != null) {
+                       final Collection<CyColumn> columns = new 
HashSet<CyColumn>(table.getColumns());
+                       
+                       for (final CyColumn column : columns) {
+                               if (column!= null){
+                                       //  Show all attributes, with type of 
String or Number
+                                       final Class<?> type = column.getType();
+       
+                                       //  only show user visible 
attributes,with type = Number/String/List
+                                       if (type == Integer.class || type == 
Double.class ||
+                                               type == Boolean.class || type 
== String.class || type == List.class) {
+                                               attributeList.add(pType + "." + 
column.getName());
+                                       }
                                }
-
-                               //  Alphabetical sort
-                               Collections.sort(attributeList);
                        }
+                       
+                       // Alphabetical sort
+                       final Collator collator = 
Collator.getInstance(Locale.getDefault());
+                       Collections.sort(attributeList, collator);
                }
-
-               // type conversion
-               Vector<Object> retList = new Vector<Object>();
-
-               for (int i=0; i<attributeList.size(); i++) {
-                       retList.add(attributeList.elementAt(i));
-               }
                
-               return retList;
+               return attributeList;
        }
        
        /*
@@ -644,7 +638,7 @@
                        return;
                }
                
-               List<Object> av;
+               List<String> av;
 
                av = getCyAttributesList(network, "node");
                for (int i = 0; i < av.size(); i++) {

Modified: 
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeListModel.java
===================================================================
--- 
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeListModel.java
    2013-01-22 16:43:12 UTC (rev 31067)
+++ 
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeListModel.java
    2013-01-22 17:08:09 UTC (rev 31068)
@@ -28,13 +28,14 @@
 package org.cytoscape.browser.internal;
 
 
+import java.text.Collator;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
+import java.util.Locale;
 import java.util.Set;
 import java.util.Vector;
 
@@ -51,7 +52,6 @@
 import org.cytoscape.model.events.ColumnDeletedListener;
 import org.cytoscape.model.events.ColumnNameChangedEvent;
 import org.cytoscape.model.events.ColumnNameChangedListener;
-import org.cytoscape.service.util.CyServiceRegistrar;
 
 
 public class AttributeListModel
@@ -103,14 +103,15 @@
                attributeNames = new ArrayList<String>();
                final CyTable attributes = browserTableModel.getAttributes();
                
-               
                for (final CyColumn col : attributes.getColumns()){
                        attributeNames.add(col.getName());
                }
-               Collections.sort(attributeNames);
+               
+               // Locale-specific sorting
+               final Collator collator = 
Collator.getInstance(Locale.getDefault());
+               Collections.sort(attributeNames, collator);
 
-               notifyListeners(new ListDataEvent(this, 
ListDataEvent.CONTENTS_CHANGED, 0,
-                                                 attributeNames.size()));
+               notifyListeners(new ListDataEvent(this, 
ListDataEvent.CONTENTS_CHANGED, 0, attributeNames.size()));
        }
 
        /**

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
    2013-01-22 16:43:12 UTC (rev 31067)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
    2013-01-22 17:08:09 UTC (rev 31068)
@@ -4,8 +4,10 @@
 import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.text.Collator;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -81,10 +83,12 @@
                if (targetSet == null)
                        return;
                
-               final SortedSet<String> sortedName = new TreeSet<String>();
+               final Collator collator = 
Collator.getInstance(Locale.getDefault()); // For locale-specific sorting
+               final SortedSet<String> sortedName = new 
TreeSet<String>(collator);
+               
                final Set<CyNetwork> networks = networkManager.getNetworkSet();
 
-               for (CyNetwork net : networks) {
+               for (final CyNetwork net : networks) {
                        final AttributeSet currentSet = 
this.attrManager.getAttributeSet(net, graphObjectType);
                        
                        for (Entry<String, Class<?>> entry: 
currentSet.getAttrMap().entrySet())
@@ -98,8 +102,7 @@
                // Add new name if not in the list.
                box.setSelectedItem(selected);
 
-               logger.debug(graphObjectType + " Column Name Combobox Updated: 
New Names = "
-                               + targetSet.getAttrMap().keySet());
+               logger.debug(graphObjectType + " Column Name Combobox Updated: 
New Names = " + targetSet.getAttrMap().keySet());
        }
 
        private boolean columnIsAllowed(String name, Class<?> type) {

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