Author: ruschein Date: 2010-07-27 10:31:21 -0700 (Tue, 27 Jul 2010) New Revision: 21033
Added:
coreplugins/trunk/browser/images/select_all.png
coreplugins/trunk/browser/images/unselect_all.png
Modified:
coreplugins/trunk/browser/src/browser/AttributeModel.java
coreplugins/trunk/browser/src/browser/ui/AttributeBrowserToolBar.java
Log:
Added "Select All" and "Unselect All" buttons thanks primarily to code
contributed by Maital Ashkenasi.
Added: coreplugins/trunk/browser/images/select_all.png
===================================================================
(Binary files differ)
Property changes on: coreplugins/trunk/browser/images/select_all.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: coreplugins/trunk/browser/images/unselect_all.png
===================================================================
(Binary files differ)
Property changes on: coreplugins/trunk/browser/images/unselect_all.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: coreplugins/trunk/browser/src/browser/AttributeModel.java
===================================================================
--- coreplugins/trunk/browser/src/browser/AttributeModel.java 2010-07-27
17:19:35 UTC (rev 21032)
+++ coreplugins/trunk/browser/src/browser/AttributeModel.java 2010-07-27
17:31:21 UTC (rev 21033)
@@ -36,6 +36,7 @@
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.Set;
@@ -58,6 +59,7 @@
private List<String> attributeNames;
private Object selection = null;
private Set<Byte> validAttrTypes;
+ private Set<String> newAttributeNames = new HashSet<String>();
/**
* Creates a new AttributeModel object.
@@ -97,16 +99,27 @@
* Sets "attributeNames" to the sorted list of user-visible attribute
names with supported data types.
*/
public void sortAttributes() {
+ final Set<String> oldAttributeNames = (attributeNames == null)
? new HashSet<String>() : new HashSet<String>(attributeNames);
+ newAttributeNames = new HashSet<String>();
+
attributeNames = new ArrayList<String>();
for (final String attrName :
CyAttributesUtils.getVisibleAttributeNames(attributes)) {
- if
(validAttrTypes.contains(attributes.getType(attrName)))
+ if
(validAttrTypes.contains(attributes.getType(attrName))) {
attributeNames.add(attrName);
+ if (!oldAttributeNames.contains(attrName))
+ newAttributeNames.add(attrName);
+ }
}
Collections.sort(attributeNames);
+
notifyListeners(new ListDataEvent(this,
ListDataEvent.CONTENTS_CHANGED, 0,
attributeNames.size()));
}
+ public Set<String> getNewAttributeNames() {
+ return newAttributeNames;
+ }
+
/**
* @return the i-th attribute name
*/
Modified: coreplugins/trunk/browser/src/browser/ui/AttributeBrowserToolBar.java
===================================================================
--- coreplugins/trunk/browser/src/browser/ui/AttributeBrowserToolBar.java
2010-07-27 17:19:35 UTC (rev 21032)
+++ coreplugins/trunk/browser/src/browser/ui/AttributeBrowserToolBar.java
2010-07-27 17:31:21 UTC (rev 21033)
@@ -115,6 +115,8 @@
private JList attrDeletionList = null;
private JButton createNewAttributeButton = null;
private JButton deleteAttributeButton = null;
+ private JButton selectAllAttributesButton = null;
+ private JButton unselectAllAttributesButton = null;
private JButton matrixButton = null;
private JButton importButton = null;
@@ -406,9 +408,13 @@
.addPreferredGap(LayoutStyle.RELATED)
.add(getNewButton())
.addPreferredGap(LayoutStyle.RELATED)
+
.add(getSelectAllButton())
+
.addPreferredGap(LayoutStyle.RELATED)
+
.add(getUnselectAllButton())
+
.addPreferredGap(LayoutStyle.RELATED)
.add(getDeleteButton())
.addPreferredGap(LayoutStyle.RELATED,
-
150,
+
28,
Short.MAX_VALUE)
.add(getAttrModButton(),
GroupLayout.PREFERRED_SIZE,
@@ -438,6 +444,14 @@
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
27, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.CENTER,
+
selectAllAttributesButton,
+
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+
27, Short.MAX_VALUE)
+
.add(org.jdesktop.layout.GroupLayout.CENTER,
+
unselectAllAttributesButton,
+
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+
27, Short.MAX_VALUE)
+
.add(org.jdesktop.layout.GroupLayout.CENTER,
deleteAttributeButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
27, Short.MAX_VALUE)
@@ -468,6 +482,10 @@
.addPreferredGap(LayoutStyle.RELATED)
.add(getNewButton())
.addPreferredGap(LayoutStyle.RELATED)
+
.add(getSelectAllButton())
+
.addPreferredGap(LayoutStyle.RELATED)
+
.add(getUnselectAllButton())
+
.addPreferredGap(LayoutStyle.RELATED)
.add(getDeleteButton())
.addPreferredGap(LayoutStyle.RELATED,
320,
@@ -495,6 +513,14 @@
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
27, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.CENTER,
+
selectAllAttributesButton,
+
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+
27, Short.MAX_VALUE)
+
.add(org.jdesktop.layout.GroupLayout.CENTER,
+
unselectAllAttributesButton,
+
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+
27, Short.MAX_VALUE)
+
.add(org.jdesktop.layout.GroupLayout.CENTER,
deleteAttributeButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
27, Short.MAX_VALUE)
@@ -518,6 +544,10 @@
.addPreferredGap(LayoutStyle.RELATED)
.add(getNewButton())
.addPreferredGap(LayoutStyle.RELATED)
+
.add(getSelectAllButton())
+
.addPreferredGap(LayoutStyle.RELATED)
+
.add(getUnselectAllButton())
+
.addPreferredGap(LayoutStyle.RELATED)
.add(getDeleteButton())
.addPreferredGap(LayoutStyle.RELATED,
150,
@@ -548,6 +578,14 @@
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
27, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.CENTER,
+
selectAllAttributesButton,
+
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+
27, Short.MAX_VALUE)
+
.add(org.jdesktop.layout.GroupLayout.CENTER,
+
unselectAllAttributesButton,
+
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+
27, Short.MAX_VALUE)
+
.add(org.jdesktop.layout.GroupLayout.CENTER,
deleteAttributeButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
27, Short.MAX_VALUE)
@@ -739,6 +777,56 @@
return deleteAttributeButton;
}
+ private JButton getSelectAllButton() {
+ if (selectAllAttributesButton == null) {
+ selectAllAttributesButton = new JButton();
+ selectAllAttributesButton.setBorder(null);
+ selectAllAttributesButton.setMargin(new
java.awt.Insets(0, 0, 0, 0));
+ selectAllAttributesButton.setIcon(new
javax.swing.ImageIcon(AttributeBrowser.class.getResource("images/select_all.png")));
+ selectAllAttributesButton.setToolTipText("Select All
Attributes");
+
+ selectAllAttributesButton.addMouseListener(new
java.awt.event.MouseAdapter() {
+ public void
mouseClicked(java.awt.event.MouseEvent e) {
+ List<String> existingAttrs =
CyAttributesUtils.getVisibleAttributeNames(attributes);
+ updateList(existingAttrs);
+ try {
+
getUpdatedSelectedList();
+
tableModel.setTableData(null, orderedCol);
+ } catch (Exception ex) {
+
attributeList.clearSelection();
+ }
+ }
+ });
+ }
+
+ return selectAllAttributesButton;
+ }
+
+ private JButton getUnselectAllButton() {
+ if (unselectAllAttributesButton == null) {
+ unselectAllAttributesButton = new JButton();
+ unselectAllAttributesButton.setBorder(null);
+ unselectAllAttributesButton.setMargin(new
java.awt.Insets(0, 0, 0, 0));
+ unselectAllAttributesButton.setIcon(new
javax.swing.ImageIcon(AttributeBrowser.class.getResource("images/unselect_all.png")));
+ unselectAllAttributesButton.setToolTipText("Unselect
All Attributes");
+
+ unselectAllAttributesButton.addMouseListener(new
java.awt.event.MouseAdapter() {
+ public void
mouseClicked(java.awt.event.MouseEvent e) {
+ final List<String> emptyList =
new ArrayList<String>();
+ updateList(emptyList);
+ try {
+
getUpdatedSelectedList();
+
tableModel.setTableData(null, orderedCol);
+ } catch (Exception ex) {
+
attributeList.clearSelection();
+ }
+ }
+ });
+ }
+
+ return unselectAllAttributesButton;
+ }
+
private void removeAttribute(final MouseEvent e) {
final String[] attrArray = getAttributeArray();
Arrays.sort(attrArray);
--
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.
