Revision: 1220
Author:   ge0ffrey
Date:     2006-07-07 01:31:11 -0700 (Fri, 07 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1220&view=rev

Log Message:
-----------
RCP-378 Make the use of the edit button in the shuttle list optional

Modified Paths:
--------------
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleList.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinder.java
Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleList.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleList.java
    2006-07-03 14:17:07 UTC (rev 1219)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleList.java
    2006-07-07 08:31:11 UTC (rev 1220)
@@ -49,10 +49,12 @@
  * 
  * @author lstreepy
  * @author Benoit Xhenseval (Small modifications for text + icons config)
- * 
+ * @author Geoffrey De Smet
  */
 public class ShuttleList extends JPanel {
 
+    private boolean showEditButton = false;
+
     private JList _helperList = new JList();
 
     private JList _sourceList = new JList();
@@ -77,7 +79,7 @@
 
     private Comparator _comparator;
 
-    private boolean _panelsShowing = false;
+    private boolean _panelsShowing;
 
     private static final long serialVersionUID = -6038138479095186130L;
 
@@ -85,6 +87,13 @@
      * Simple constructor.
      */
     public ShuttleList() {
+        // The binder actually determines the default
+        this(true);
+    }
+
+    public ShuttleList(boolean showEditButton) {
+        this.showEditButton = showEditButton;
+        this._panelsShowing = !showEditButton;
         buildComponent();
     }
 
@@ -249,14 +258,10 @@
     protected JComponent buildComponent() {
         
_helperList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
 
-        // JPanel buttonPanel = new ControlButtonPanel();
-        JPanel buttonPanel = buildButtonPanel();
-
         GridBagLayout gbl = new GridBagLayout();
         GridBagConstraints gbc = new GridBagConstraints();
 
-        
_sourceList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-        
_chosenList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+        setLayout(gbl);
 
         _editButton = new JButton("Edit...");
         _editButton.setIconTextGap(0);
@@ -268,8 +273,16 @@
             }
         });
 
-        setLayout(gbl);
+        gbc.fill = GridBagConstraints.NONE;
+        gbc.weightx = 0.0;
+        gbc.weighty = 0.0;
+        gbc.insets = new Insets(0, 0, 0, 3);
+        gbc.anchor = GridBagConstraints.NORTHWEST;
+        gbl.setConstraints(_editButton, gbc);
+        add(_editButton);
 
+        
_sourceList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
         gbc.fill = GridBagConstraints.BOTH;
         gbc.weightx = 1.0;
         gbc.weighty = 1.0;
@@ -277,12 +290,17 @@
         JScrollPane sourceScroller = new JScrollPane(_sourceList);
         _sourcePanel.add(BorderLayout.CENTER, sourceScroller);
         gbl.setConstraints(_sourcePanel, gbc);
+        add(_sourcePanel);
 
+        // JPanel buttonPanel = new ControlButtonPanel();
+        JPanel buttonPanel = buildButtonPanel();
         gbc.fill = GridBagConstraints.VERTICAL;
         gbc.weightx = 0;
         gbc.weighty = 1.0;
         gbl.setConstraints(buttonPanel, gbc);
+        add(buttonPanel);
 
+        
_chosenList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         gbc.fill = GridBagConstraints.BOTH;
         gbc.weightx = 1.0;
         gbc.weighty = 1.0;
@@ -290,21 +308,11 @@
         JScrollPane chosenScroller = new JScrollPane(_chosenList);
         _chosenPanel.add(BorderLayout.CENTER, chosenScroller);
         gbl.setConstraints(_chosenPanel, gbc);
-
-        gbc.fill = GridBagConstraints.NONE;
-        gbc.weightx = 0.0;
-        gbc.weighty = 0.0;
-        gbc.insets = new Insets(0, 0, 0, 3);
-        gbc.anchor = GridBagConstraints.NORTHWEST;
-        gbl.setConstraints(_editButton, gbc);
-
-        add(_editButton);
-        add(_sourcePanel);
-        add(buttonPanel);
         add(_chosenPanel);
 
-        _buttonPanel.setVisible(false);
-        _sourcePanel.setVisible(false);
+        _editButton.setVisible(showEditButton);
+        _buttonPanel.setVisible(_panelsShowing);
+        _sourcePanel.setVisible(_panelsShowing);
 
         return this;
     }

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinder.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinder.java
      2006-07-03 14:17:07 UTC (rev 1219)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinder.java
      2006-07-07 08:31:11 UTC (rev 1220)
@@ -104,6 +104,12 @@
 
     public static final String RENDERER_KEY = "renderer";
 
+    private boolean showEditButton = true;
+
+    public void setShowEditButton(boolean showEditButton) {
+        this.showEditButton = showEditButton;
+    }
+
     /**
      * Utility method to construct the context map used to configure instances
      * of [EMAIL PROTECTED] ShutteListBinding} created by this binder.
@@ -218,6 +224,8 @@
      * @inheritDoc
      */
     protected JComponent createControl( Map context ) {
-        return new ShuttleList();
+        ShuttleList shuttleList = new ShuttleList(showEditButton);
+        return shuttleList;
     }
+
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to