From 013494192c189ce5bd101f198c4d33230374d4b8 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 17 Dec 2009 21:11:04 +0000
Subject: [PATCH] Fix for issue 3601 (Control Panel: unable to modify schema objects or attributes)

---
 opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java |   48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
index 9f5c9cd..8a5a4f5 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -47,6 +47,7 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -55,6 +56,8 @@
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.SearchControls;
@@ -143,6 +146,9 @@
   private static final String MAIN_PANEL = "mainPanel";
   private static final String MESSAGE_PANEL = "messagePanel";
 
+  private static final Logger LOG =
+    Logger.getLogger(StatusGenericPanel.class.getName());
+
   /**
    * The error pane.
    */
@@ -538,7 +544,7 @@
   public void addConfigurationElementCreatedListener(
       ConfigurationElementCreatedListener listener)
   {
-    confListeners.add(listener);
+    getConfigurationElementCreatedListeners().add(listener);
   }
 
   /**
@@ -548,7 +554,7 @@
   public void removeConfigurationElementCreatedListener(
       ConfigurationElementCreatedListener listener)
   {
-    confListeners.remove(listener);
+    getConfigurationElementCreatedListeners().remove(listener);
   }
 
   /**
@@ -558,7 +564,8 @@
    */
   protected void notifyConfigurationElementCreated(Object configObject)
   {
-    for (ConfigurationElementCreatedListener listener : confListeners)
+    for (ConfigurationElementCreatedListener listener :
+      getConfigurationElementCreatedListeners())
     {
       listener.elementCreated(
           new ConfigurationElementCreatedEvent(this, configObject));
@@ -566,6 +573,16 @@
   }
 
   /**
+   * Returns the list of configuration listeners.
+   * @return the list of configuration listeners.
+   */
+  protected List<ConfigurationElementCreatedListener>
+  getConfigurationElementCreatedListeners()
+  {
+    return confListeners;
+  }
+
+  /**
    * Notification that cancel was clicked, the panel is in charge
    * of doing whatever is required (close the dialog, etc.).
    *
@@ -1404,6 +1421,20 @@
   protected void updateComboBoxModel(final Collection<?> newElements,
       final DefaultComboBoxModel model)
   {
+    updateComboBoxModel(newElements, model, null);
+  }
+
+  /**
+   * Updates a combo box model with a number of items.
+   * @param newElements the new items for the combo box model.
+   * @param model the combo box model to be updated.
+   * @param comparator the object that will be used to compare the objects in
+   * the model.  If <CODE>null</CODE>, the equals method will be used.
+   */
+  protected void updateComboBoxModel(final Collection<?> newElements,
+      final DefaultComboBoxModel model,
+      final Comparator<Object> comparator)
+  {
     SwingUtilities.invokeLater(new Runnable()
     {
       public void run()
@@ -1414,7 +1445,15 @@
           int i = 0;
           for (Object newElement : newElements)
           {
-            changed = !newElement.equals(model.getElementAt(i));
+            if (comparator == null)
+            {
+              changed = !newElement.equals(model.getElementAt(i));
+            }
+            else
+            {
+              changed =
+                comparator.compare(newElement, model.getElementAt(i)) != 0;
+            }
             if (changed)
             {
               break;
@@ -1799,6 +1838,7 @@
 
           if (t != null)
           {
+            LOG.log(Level.WARNING, "Error occurred running task: "+t, t);
             if ((task.getReturnCode() != null) &&
                 (errorDetailCode != null))
             {

--
Gitblit v1.10.0