From 9a2b7fab9d523ff7867840d43cc6739de7c5ee4d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 03 Nov 2008 10:40:33 +0000
Subject: [PATCH] Modify the MainMenuBar and MainActionsPane so that they can be extended. Fix a problem with the ControlPanelLog class: now when it is extended only one log file is created.

---
 opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java       |   19 ++++++++++++++-----
 opends/src/guitools/org/opends/guitools/controlpanel/util/ControlPanelLog.java |    5 ++---
 opends/src/guitools/org/opends/guitools/controlpanel/ui/MainActionsPane.java   |    6 +++++-
 opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericMenuBar.java    |    6 +++++-
 4 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericMenuBar.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericMenuBar.java
index d4b2bff..069fd59 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericMenuBar.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericMenuBar.java
@@ -103,7 +103,11 @@
     return menu;
   }
 
-  private void displayURL(final String url)
+  /**
+   * Tries to display a URL in the systems default WEB browser.
+   * @param url the URL to be displayed.
+   */
+  protected void displayURL(final String url)
   {
     BackgroundTask<Void> worker = new BackgroundTask<Void>()
     {
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainActionsPane.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainActionsPane.java
index f1f5e6a..9000aa9 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainActionsPane.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainActionsPane.java
@@ -174,7 +174,11 @@
     return null;
   }
 
-  private ArrayList<Category> createCategories()
+  /**
+   * Creates the categories contained by this panel.
+   * @return the categories contained by this panel.
+   */
+  protected ArrayList<Category> createCategories()
   {
     ArrayList<Category> categories = new ArrayList<Category>();
     Message[][] labels;
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
index 74387a1..b7057f0 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
@@ -62,6 +62,20 @@
   {
     super(info);
 
+    addMenus();
+
+    if (Utilities.isMacOS())
+    {
+      setMacOSQuitHandler();
+    }
+  }
+
+  /**
+   * Method that can be overwritten to set specific menus.
+   *
+   */
+  protected void addMenus()
+  {
     JMenu menu;
     JMenuItem menuItem;
 
@@ -86,11 +100,6 @@
       add(menu);
     }
     add(createHelpMenuBar());
-
-    if (Utilities.isMacOS())
-    {
-      setMacOSQuitHandler();
-    }
   }
 
   /**
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/util/ControlPanelLog.java b/opends/src/guitools/org/opends/guitools/controlpanel/util/ControlPanelLog.java
index d25b999..94b9299 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/ControlPanelLog.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/ControlPanelLog.java
@@ -44,6 +44,7 @@
     "org.opends"
   };
   static private File logFile = null;
+  static private FileHandler fileHandler;
 
   /**
    * Creates a new file handler for writing log messages to the file indicated
@@ -55,7 +56,7 @@
     if (!isInitialized())
     {
       logFile = file;
-      FileHandler fileHandler = new FileHandler(logFile.getCanonicalPath());
+      fileHandler = new FileHandler(logFile.getCanonicalPath());
       fileHandler.setFormatter(new SimpleFormatter());
       for (String packageName : packages)
       {
@@ -76,8 +77,6 @@
    * @throws IOException if something goes wrong
    */
   static public void initPackage(String packageName) throws IOException {
-    FileHandler fileHandler = new FileHandler(logFile.getCanonicalPath());
-    fileHandler.setFormatter(new SimpleFormatter());
     Logger logger = Logger.getLogger(packageName);
     logger.setUseParentHandlers(false); // disable logging to console
     logger.addHandler(fileHandler);

--
Gitblit v1.10.0