From f8f7bf5c46f0e0153c3cb34d40e3acd4a07ca6c7 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 16 Oct 2009 12:47:40 +0000
Subject: [PATCH] Fix for issue 4292 (control panel browse entries should not use the ManageDSAIT control systematically)

---
 opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
index 5c0cb4f..737fa52 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -53,8 +53,10 @@
 import java.util.LinkedHashSet;
 
 import javax.naming.InterruptedNamingException;
+import javax.naming.NamingException;
 import javax.naming.ldap.InitialLdapContext;
 import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComponent;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
@@ -1123,7 +1125,7 @@
         menu.add(menus[i]);
         group.add(menus[i]);
       }
-      ActionListener listener = new ActionListener()
+      ActionListener radioListener = new ActionListener()
       {
         private boolean ignoreEvents;
         private JRadioButtonMenuItem lastSelected = menus[0];
@@ -1166,9 +1168,54 @@
       };
       for (int i=0; i<labels.length; i++)
       {
-        menus[i].addActionListener(listener);
+        menus[i].addActionListener(radioListener);
       }
       menus[0].setSelected(true);
+
+      // Add the view menus
+      menu.add(new JSeparator());
+      final JCheckBoxMenuItem sortUserData =
+        new JCheckBoxMenuItem(INFO_CTRL_PANEL_SORT_USER_DATA.get().toString());
+      final JCheckBoxMenuItem followReferrals = new JCheckBoxMenuItem(
+        INFO_CTRL_PANEL_FOLLOW_REFERRALS.get().toString());
+      menu.add(sortUserData);
+      menu.add(followReferrals);
+      sortUserData.setSelected(entryPane.getController().isSorted());
+      followReferrals.setSelected(
+          entryPane.getController().getFollowReferrals());
+      sortUserData.addActionListener(new ActionListener()
+      {
+        public void actionPerformed(ActionEvent ev)
+        {
+          try
+          {
+            entryPane.getController().setSorted(sortUserData.isSelected());
+          }
+          catch (NamingException ne)
+          {
+            // Bug
+            System.err.println("Unexpected error updating sorting.");
+            ne.printStackTrace();
+          }
+        }
+      });
+      followReferrals.addActionListener(new ActionListener()
+      {
+        public void actionPerformed(ActionEvent ev)
+        {
+          try
+          {
+            entryPane.getController().setFollowReferrals(
+                followReferrals.isSelected());
+          }
+          catch (NamingException ne)
+          {
+            // Bug
+            System.err.println("Unexpected error updating referral state.");
+            ne.printStackTrace();
+          }
+        }
+      });
       return menu;
     }
 

--
Gitblit v1.10.0