svn commit: r17491 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2009-11-19 11:39:18-0800
New Revision: 17491

Modified:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLExpandableRowSelector.java

Log:
Allow lists in the panels to be shrunk and expanded

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java?view=diff&pathrev=17491&r1=17490&r2=17491
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java	2009-11-19 11:39:18-0800
@@ -175,21 +175,21 @@
     }
 
     public void mouseEntered(MouseEvent evt) {
-        if (originalHeight == 0) {
-            originalHeight = getHeight();
-            final int parentHeight = getParent().getHeight();
-            setSize(getWidth(), parentHeight - getY());
-            list.setSize(this.getSize());
-        }
+//        if (originalHeight == 0) {
+//            originalHeight = getHeight();
+//            final int parentHeight = getParent().getHeight();
+//            setSize(getWidth(), parentHeight - getY());
+//            list.setSize(this.getSize());
+//        }
     }
 
     public void mouseExited(MouseEvent evt) {
-        Rectangle rect = new Rectangle(getLocationOnScreen(), getSize());
-        if (!rect.contains(evt.getLocationOnScreen())) {
-            setSize(getWidth(), originalHeight);
-            list.setSize(getWidth(), originalHeight);
-            originalHeight = 0;
-        }
+//        Rectangle rect = new Rectangle(getLocationOnScreen(), getSize());
+//        if (!rect.contains(evt.getLocationOnScreen())) {
+//            setSize(getWidth(), originalHeight);
+//            list.setSize(getWidth(), originalHeight);
+//            originalHeight = 0;
+//        }
     }
 
     public void mousePressed(MouseEvent arg0) {

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java?view=diff&pathrev=17491&r1=17490&r2=17491
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java	2009-11-19 11:39:18-0800
@@ -121,17 +121,16 @@
      * @throws Exception If something goes wrong
      * @see org.argouml.core.propertypanels.panel.UIFactory#createGUI(java.lang.Object)
      */
-    public JPanel createGUI (Object target) throws Exception {
+    public JPanel createGUI (Object target, JPanel panel) throws Exception {
         XMLPropertyPanelsData data = 
             XMLPropPanelFactory.getInstance().getPropertyPanelsData(
                     Model.getMetaTypes().getName(target));
-        JPanel p = buildPanel(data, target);
+        JPanel p = buildPanel(data, target, panel);
         return p;       
     }
     
-    private JPanel buildPanel(XMLPropertyPanelsData data, Object target) {
+    private JPanel buildPanel(XMLPropertyPanelsData data, Object target, JPanel panel) {
         
-        JPanel panel = new JPanel(new LabelledLayout());
         for (XMLPropertyPanelsDataRecord prop : data.getProperties()) {
             if ("text".equals(prop.getType())) {
                 buildTextboxPanel(panel, target, prop);

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=17491&r1=17490&r2=17491
==============================================================================
--- 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-19 11:39:18-0800
@@ -26,10 +26,16 @@
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.ListModel;
 
+import org.tigris.toolbar.toolbutton.ToolButton;
+
 /**
  * A control for displaying the contents of a list model elements in a panel
  * that can be expanded to take maximum possible screen space or shrunk to
@@ -45,7 +51,13 @@
      */
     private JScrollPane scroll;
 
-    private Dimension preferredSize = null;
+    private Dimension shrunkPreferredSize = null;
+    private Dimension shrunkMinimumSize = null;
+    private Dimension expandedPreferredSize = null;
+    private Dimension expandedMinimumSize = null;
+    private Dimension expandedMaximumSize = null;
+    
+    private boolean expanded = false;
     
     /**
      * Constructor
@@ -53,18 +65,21 @@
      */
     public UMLExpandableRowSelector(UMLModelElementListModel model) {
         super(new BorderLayout());
+        add(new ToolButton(new ExpandAction()), BorderLayout.WEST);
         scroll = new ScrollList(model, 1);
         add(scroll);
         
-        preferredSize = scroll.getPreferredSize();
+        shrunkPreferredSize = scroll.getPreferredSize();
+        shrunkMinimumSize = scroll.getMinimumSize();
         
         remove(scroll);
         scroll = new ScrollList(model);
+        
         add(scroll);
+        expandedPreferredSize = scroll.getPreferredSize();
+        expandedMinimumSize = scroll.getMinimumSize();
+        expandedMaximumSize = scroll.getMaximumSize();
         
-        scroll.setVerticalScrollBarPolicy(
-        	JScrollPane.VERTICAL_SCROLLBAR_NEVER);
-
         scroll.setHorizontalScrollBarPolicy(
         	JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     }
@@ -74,9 +89,7 @@
      * @return the minimum size as the height of one row in a JList
      */
     public Dimension getMinimumSize() {
-        Dimension size = super.getMinimumSize();
-        size.height = preferredSize.height;
-        return size;
+        return shrunkPreferredSize;
     }
     
     /**
@@ -84,7 +97,12 @@
      * @return the maximum size as the height of one row in a JList
      */
     public Dimension getMaximumSize() {
-        Dimension size = scroll.getMaximumSize();
+        Dimension size = super.getMaximumSize();
+        if (expanded) {
+            size.height = expandedMaximumSize.height;
+        } else {
+            size.height = shrunkPreferredSize.height;
+        }
         return size;
     }
     
@@ -93,6 +111,31 @@
      * @return the preferred size as the height of one row in a JList
      */
     public Dimension getPreferredSize() {
-        return preferredSize;
+        if (expanded) {
+            return expandedPreferredSize;
+        } else {
+            return shrunkPreferredSize;
+        }
+    }
+    
+    private class ExpandAction extends AbstractAction {
+        ExpandAction() {
+            super();
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent arg0) {
+            expanded = !expanded;
+            // 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();
+        }
     }
 }

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2420199

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.