svn commit: r17512 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-11-21 05:36:36-0800
New Revision: 17512
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java
Log:
Reduce code needed to redraw of expansion/contraction.
Increase click area when performing expand/collapse
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java?view=diff&pathrev=17512&r1=17511&r2=17512
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java 2009-11-21 05:36:36-0800
@@ -64,6 +64,8 @@
private static Icon collapsedIcon;
static {
+ // Extract the icon that is used by the tree control
+ // for the current look and feel
final JTree dummyTree = new JTree();
final TreeUI tu = dummyTree.getUI();
@@ -104,6 +106,10 @@
*/
private boolean expanded = false;
+ /**
+ * The label that contains the +/- symbol to indicate
+ * expansion feature to user.
+ */
private JLabel expander;
/**
@@ -115,7 +121,7 @@
JPanel buttonPanel = new JPanel();
expander = new JLabel();
- expander.addMouseListener(this);
+ this.addMouseListener(this);
setIcon();
buttonPanel.add(expander, BorderLayout.NORTH);
add(buttonPanel, BorderLayout.WEST);
@@ -171,20 +177,7 @@
@Override
public void mouseClicked(MouseEvent e) {
- expanded = !expanded;
-
- setIcon();
-
- // TODO: This forces a redraw but what is the minimum we really
- // need here?
- getParent().validate();
- getParent().invalidate();
- getParent().repaint();
- getParent().doLayout();
- getParent().validate();
- getParent().invalidate();
- getParent().repaint();
- getParent().doLayout();
+ toggleExpansion();
}
@Override
@@ -211,23 +204,22 @@
}
+ /**
+ * Toggle between expansion and contraction of the control
+ */
private void toggleExpansion() {
expanded = !expanded;
setIcon();
- // TODO: This forces a redraw but what is the minimum we really
- // need here?
- getParent().validate();
+ // Froce the parent to redraw
getParent().invalidate();
- getParent().repaint();
- getParent().doLayout();
getParent().validate();
- getParent().invalidate();
- getParent().repaint();
- getParent().doLayout();
}
+ /**
+ * Set the icon according to the current expansion setting
+ */
private void setIcon() {
if (expanded) {
expander.setIcon(expandedIcon);
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2422780
To unsubscribe from this discussion, e-mail: [[email protected]].