From a962f63052985ec85f0965a4b5ff2024f6dc0a51 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 24 Nov 2009 14:52:54 +0000
Subject: [PATCH] Cleanup the completed tasks and dispose the progress dialogs once they are closed, since these increases the used memory and today there is no UI to redisplay closed progress dialogs.

---
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index 1962553..b18c8fe 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -169,7 +169,7 @@
   }
 
   /**
-   * Registers a task.  The Control Panel creates a task everytime an operation
+   * Registers a task.  The Control Panel creates a task every time an operation
    * is made and they are stored here.
    * @param task the task to be registered.
    */
@@ -179,6 +179,15 @@
   }
 
   /**
+   * Unregisters a task.
+   * @param task the task to be unregistered.
+   */
+  public void unregisterTask(Task task)
+  {
+    tasks.remove(task);
+  }
+
+  /**
    * Tells whether an index must be reindexed or not.
    * @param index the index.
    * @return <CODE>true</CODE> if the index must be reindexed and
@@ -815,6 +824,7 @@
         {
           while (!stopPooling)
           {
+            cleanupTasks();
             regenerateDescriptor();
             Thread.sleep(poolingPeriod);
           }
@@ -1237,6 +1247,26 @@
   }
 
   /**
+   * Cleans the tasks that are over.
+   */
+  private void cleanupTasks()
+  {
+    Set<Task> toClean = new HashSet<Task>();
+    for (Task task : tasks)
+    {
+      if (task.getState() == Task.State.FINISHED_SUCCESSFULLY ||
+          task.getState() == Task.State.FINISHED_WITH_ERROR)
+      {
+        toClean.add(task);
+      }
+    }
+    for (Task task : toClean)
+    {
+      unregisterTask(task);
+    }
+  }
+
+  /**
    * Returns whether the provided task is running on the provided server or not.
    * The code takes into account that the server object might not be fully
    * initialized (but at least it contains the host name and the instance

--
Gitblit v1.10.0