Author: ruschein
Date: 2010-10-12 12:52:34 -0700 (Tue, 12 Oct 2010)
New Revision: 22214
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/CyNode.java
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeBrowser.java
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeModel.java
cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/CyAttributeBrowserTable.java
cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/ModPanel.java
Log:
We now refresh the attribute browser when nested-network-related attributes
(and various others) change.
Modified: cytoscape/trunk/application/src/main/java/cytoscape/CyNode.java
===================================================================
--- cytoscape/trunk/application/src/main/java/cytoscape/CyNode.java
2010-10-12 18:06:33 UTC (rev 22213)
+++ cytoscape/trunk/application/src/main/java/cytoscape/CyNode.java
2010-10-12 19:52:34 UTC (rev 22214)
@@ -1,15 +1,8 @@
/*
File: CyNode.java
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2006, 2010, The Cytoscape Consortium (www.cytoscape.org)
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
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
@@ -36,6 +29,7 @@
*/
package cytoscape;
+
import giny.model.GraphPerspective;
import giny.model.RootGraph;
@@ -47,9 +41,6 @@
import cytoscape.groups.CyGroupManager;
-/**
- *
- */
public class CyNode implements giny.model.Node {
public static final String NESTED_NETWORK_ID_ATTR = "nested_network_id";
public static final String NESTED_NETWORK_IS_VISIBLE_ATTR =
"nested_network_is_visible";
@@ -289,6 +280,7 @@
Cytoscape.getNodeAttributes().deleteAttribute(nodeID,
NESTED_NETWORK_IS_VISIBLE_ATTR);
Cytoscape.getNodeAttributes().deleteAttribute(nodeID,
NESTED_NETWORK_ID_ATTR);
}
+
Cytoscape.getPropertyChangeSupport().firePropertyChange(Cytoscape.ATTRIBUTES_CHANGED,
this, oldNestedNetwork);
// Let listeners know that the previous nested network was
removed
if (oldNestedNetwork != null)
Modified:
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeBrowser.java
===================================================================
---
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeBrowser.java
2010-10-12 18:06:33 UTC (rev 22213)
+++
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeBrowser.java
2010-10-12 19:52:34 UTC (rev 22214)
@@ -179,7 +179,7 @@
// Toolbar for selecting attributes and create new attribute.
attributeBrowserToolBar = new
AttributeBrowserToolBar(tableModel, attributeTable,
- new
AttributeModel(attributes), orderedColumn,
+ new
AttributeModel(attributes, this), orderedColumn,
panelType);
// the attribute table display: CytoPanel 2, horizontal SOUTH
panel.
@@ -230,6 +230,10 @@
}
}
+ void refresh() {
+ tableModel.setTableData(null, null);
+ }
+
/**
* DOCUMENT ME!
*
Modified:
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeModel.java
===================================================================
---
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeModel.java
2010-10-12 18:06:33 UTC (rev 22213)
+++
cytoscape/trunk/coreplugins/browser/src/main/java/browser/AttributeModel.java
2010-10-12 19:52:34 UTC (rev 22214)
@@ -27,6 +27,7 @@
*/
package browser;
+
import cytoscape.Cytoscape;
import cytoscape.data.CyAttributes;
import cytoscape.data.CyAttributesUtils;
@@ -50,10 +51,9 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-/**
- *
- */
+
public class AttributeModel implements ListModel, ComboBoxModel,
MultiHashMapDefinitionListener, PropertyChangeListener {
+ private final AttributeBrowser attribBrowser;
private Vector listeners = new Vector();
private final CyAttributes attributes;
private List<String> attributeNames;
@@ -66,7 +66,8 @@
*
* @param data DOCUMENT ME!
*/
- public AttributeModel(final CyAttributes data, final Set<Byte>
validAttrTypes) {
+ public AttributeModel(final CyAttributes data, final AttributeBrowser
attribBrowser, final Set<Byte> validAttrTypes) {
+ this.attribBrowser = attribBrowser;
this.attributes = data;
this.validAttrTypes = validAttrTypes;
data.getMultiHashMapDefinition().addDataDefinitionListener(this);
@@ -75,8 +76,8 @@
Cytoscape.getPropertyChangeSupport().addPropertyChangeListener(Cytoscape.ATTRIBUTES_CHANGED,
this);
}
- @SuppressWarnings("unchecked") public AttributeModel(final CyAttributes
data) {
- this(data,
+ @SuppressWarnings("unchecked") public AttributeModel(final CyAttributes
data, final AttributeBrowser attribBrowser) {
+ this(data, attribBrowser,
new TreeSet<Byte>((List<Byte>)(Arrays.asList(new Byte[] {
CyAttributes.TYPE_BOOLEAN,
CyAttributes.TYPE_COMPLEX,
@@ -90,8 +91,10 @@
public void propertyChange(PropertyChangeEvent e) {
// This will handle the case for the change of attribute
userVisibility
- if
(e.getPropertyName().equalsIgnoreCase(Cytoscape.ATTRIBUTES_CHANGED)){
+ if (e.getPropertyName() == Cytoscape.ATTRIBUTES_CHANGED) {
sortAttributes();
+ if (attribBrowser != null)
+ attribBrowser.refresh();
}
}
Modified:
cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/CyAttributeBrowserTable.java
===================================================================
---
cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/CyAttributeBrowserTable.java
2010-10-12 18:06:33 UTC (rev 22213)
+++
cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/CyAttributeBrowserTable.java
2010-10-12 19:52:34 UTC (rev 22214)
@@ -1234,34 +1234,30 @@
}
private void adjustColWidth() {
-
final HashMap<String, Integer> widthMap =
ColumnResizer.getColumnPreferredWidths(this);
// Save the width if it does not exist
Iterator<String> it = widthMap.keySet().iterator();
- while (it.hasNext()){
+ while (it.hasNext()) {
String key = it.next();
// make exception for the first column (ID), save it
only when the table is not empty
- if (this.getModel().getRowCount() == 0 &&
key.equalsIgnoreCase("ID")){
+ if (this.getModel().getRowCount() == 0 &&
key.equalsIgnoreCase("ID"))
continue;
- }
- if (!this.columnWidthMap.containsKey(key)){
+ if (!this.columnWidthMap.containsKey(key))
this.columnWidthMap.put(key, widthMap.get(key));
- }
}
// adjust column width
- for (int i=0; i< this.getColumnCount(); i++){
+ for (int i = 0; i < this.getColumnCount(); i++) {
TableColumn col = this.getColumnModel().getColumn(i);
- if
(this.columnWidthMap.containsKey(this.getColumnName(i))){
+ if
(this.columnWidthMap.containsKey(this.getColumnName(i)))
col.setPreferredWidth(this.columnWidthMap.get(this.getColumnName(i)).intValue());
- }
}
}
- public HashMap<String, Integer> getColumnWidthMap(){
+ public HashMap<String, Integer> getColumnWidthMap() {
return this.columnWidthMap;
}
@@ -1271,48 +1267,44 @@
* @param e DOCUMENT ME!
*/
public void propertyChange(PropertyChangeEvent e) {
-
-
if(e.getPropertyName().equals(Integer.toString(Cytoscape.SESSION_OPENED))) {
+ if
(e.getPropertyName().equals(Integer.toString(Cytoscape.SESSION_OPENED)))
ignore = true;
- } else
if(e.getPropertyName().equals(Cytoscape.CYTOSCAPE_INITIALIZED) ||
e.getPropertyName().equals(Cytoscape.SESSION_LOADED) ) {
+ else if
(e.getPropertyName().equals(Cytoscape.CYTOSCAPE_INITIALIZED) ||
e.getPropertyName().equals(Cytoscape.SESSION_LOADED))
ignore = false;
- }
// Ignore all signal if this flag is on.
- if(ignore) return;
+ if (ignore)
+ return;
- if(e.getPropertyName().equals(AttributeBrowser.RESTORE_COLUMN)
&&
- e.getNewValue() != null &&
e.getNewValue().equals(objectType)) {
+ if (e.getPropertyName().equals(AttributeBrowser.RESTORE_COLUMN)
+ && e.getNewValue() != null &&
e.getNewValue().equals(objectType))
+ {
this.adjustColWidth();
return;
}
-
if(e.getPropertyName().equals(AttributeBrowser.CLEAR_INTERNAL_SELECTION)) {
-
- if(e.getNewValue() != null &&
e.getNewValue().equals(objectType)) {
+ if
(e.getPropertyName().equals(AttributeBrowser.CLEAR_INTERNAL_SELECTION)) {
+ if (e.getNewValue() != null &&
e.getNewValue().equals(objectType)) {
getSelectionModel().clearSelection();
Cytoscape.getCurrentNetworkView().redrawGraph(false, true);
}
}
if
(e.getPropertyName().equals(Cytoscape.CYTOSCAPE_INITIALIZED)) {
-
Cytoscape.getDesktop().getSwingPropertyChangeSupport().addPropertyChangeListener(this);
AttributeBrowser.getPropertyChangeSupport().addPropertyChangeListener(this);
}
if (e.getPropertyName().equals(Cytoscape.NETWORK_CREATED)
- || e.getPropertyName().equals(Cytoscape.NETWORK_DESTROYED))
{
+ || e.getPropertyName().equals(Cytoscape.NETWORK_DESTROYED))
tableModel.setTableData();
- }
if ((e.getPropertyName() == CytoscapeDesktop.NETWORK_VIEW_FOCUS)
|| e.getPropertyName().equals(Cytoscape.SESSION_LOADED)
||
e.getPropertyName().equals(Cytoscape.CYTOSCAPE_INITIALIZED)) {
- if (currentNetwork != null) {
+ if (currentNetwork != null)
currentNetwork.removeSelectEventListener(this);
- }
// Change the target network
currentNetwork = Cytoscape.getCurrentNetwork();
Modified:
cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/ModPanel.java
===================================================================
--- cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/ModPanel.java
2010-10-12 18:06:33 UTC (rev 22213)
+++ cytoscape/trunk/coreplugins/browser/src/main/java/browser/ui/ModPanel.java
2010-10-12 19:52:34 UTC (rev 22214)
@@ -104,7 +104,7 @@
this.tableModel = tableModel;
this.objectType = graphObjectType;
- this.defaultAttrModel = new AttributeModel(this.data);
+ this.defaultAttrModel = new AttributeModel(this.data, null);
setLayout(new GridBagLayout());
@@ -386,7 +386,7 @@
attrTypes.add(fromType);
if (fromType ==
CyAttributes.TYPE_INTEGER) // Allow copying from int to float.
attrTypes.add(CyAttributes.TYPE_FLOATING);
- attributeCopyToBox.setModel(new
AttributeModel(data, attrTypes));
+ attributeCopyToBox.setModel(new
AttributeModel(data, null, attrTypes));
}
}
return;
--
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.