Author: kono
Date: 2010-02-18 11:07:25 -0800 (Thu, 18 Feb 2010)
New Revision: 19365
Modified:
cytoscape/trunk/src/cytoscape/util/swing/AttributeImportPanel.java
Log:
Fixed bug ID 2184: Attribute Import Panel's Combo box is not synchronized.
Replaced PropertyChangeListener to MultiHashMapDefinitionListener to track
changes in Node Attributes.
Modified: cytoscape/trunk/src/cytoscape/util/swing/AttributeImportPanel.java
===================================================================
--- cytoscape/trunk/src/cytoscape/util/swing/AttributeImportPanel.java
2010-02-18 18:48:20 UTC (rev 19364)
+++ cytoscape/trunk/src/cytoscape/util/swing/AttributeImportPanel.java
2010-02-18 19:07:25 UTC (rev 19365)
@@ -37,11 +37,13 @@
import cytoscape.Cytoscape;
import cytoscape.data.CyAttributes;
+import cytoscape.data.attr.MultiHashMapDefinitionListener;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Arrays;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
@@ -59,7 +61,10 @@
* @version 0.5
*
*/
-public abstract class AttributeImportPanel extends JPanel implements
PropertyChangeListener {
+public abstract class AttributeImportPanel extends JPanel implements
MultiHashMapDefinitionListener {
+
+ private static final long serialVersionUID = 876173290119736978L;
+
/**
* Will be caught by parent object (usually a dialog.)
*/
@@ -92,9 +97,10 @@
this.attributePanelTitle = attrPanelTitle;
initComponents();
- setAttributes();
+ setAttributes(null);
-
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(this);
+ // Listening to the changes in Node Attributes.
+
Cytoscape.getNodeAttributes().getMultiHashMapDefinition().addDataDefinitionListener(this);
}
protected void initComponents() {
@@ -330,9 +336,15 @@
/**
* Set list of attributes currently available for Cytoscape.
*/
- protected void setAttributes() {
+ protected void setAttributes(final String attributeName) {
+ if (attributeName != null) {
+ attributeComboBox.removeItem(attributeName);
+ return;
+ }
+
final CyAttributes nodeAttr = Cytoscape.getNodeAttributes();
final String[] names = nodeAttr.getAttributeNames();
+ Arrays.sort(names);
attributeComboBox.removeAllItems();
attributeComboBox.addItem("ID");
@@ -344,12 +356,15 @@
}
}
- public void propertyChange(PropertyChangeEvent e) {
- if(e.getPropertyName().equals(Cytoscape.ATTRIBUTES_CHANGED)) {
- setAttributes();
- }
+ public void attributeDefined(String attributeName) {
+ setAttributes(null);
}
+
+ public void attributeUndefined(String attributeName) {
+ setAttributes(attributeName);
+ }
+
// Swing components. Maybe accessed from child classes.
protected javax.swing.JComboBox attributeComboBox;
protected javax.swing.JLabel attributeLabel;
--
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.