From 3e0e471b49e1fba03908f8e16ba238d2757f92b7 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 18 Feb 2009 17:35:36 +0000
Subject: [PATCH] Fix for issue 3800 (Monitoring General Information : Resize the Show Operations... window)

---
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java                    |    3 
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java                 |    3 
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java               |    7 
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java      |    5 
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java          |    5 
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/MonitoringAttributesViewPanel.java |  516 ++++++++++++++++++++++++++--------------------
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/event/ScrollPaneBorderListener.java   |   65 ++++-
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java                   |   31 +-
 opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java        |    5 
 9 files changed, 374 insertions(+), 266 deletions(-)

diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/event/ScrollPaneBorderListener.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/event/ScrollPaneBorderListener.java
index bb570ac..2fa24b7 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/event/ScrollPaneBorderListener.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/event/ScrollPaneBorderListener.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.event;
@@ -52,32 +52,61 @@
   private Border etchedBorder = BorderFactory.createMatteBorder(0, 0, 1, 0,
       ColorAndFontConstants.defaultBorderColor);
 
-
   /**
-   * The constructor of the listener.
-   * @param scroll the scroll pane to update.
-   * @param addTopBorder whether we want to add a top border or only a bottom
-   * border when the border must be displayed.
+   * Private constructor.
+   *
    */
-  public ScrollPaneBorderListener(JScrollPane scroll, boolean addTopBorder)
+  private ScrollPaneBorderListener()
   {
-    this.scroll = scroll;
-    scroll.getHorizontalScrollBar().addComponentListener(this);
-    scroll.getVerticalScrollBar().addComponentListener(this);
-    if (addTopBorder)
-    {
-      etchedBorder = BorderFactory.createMatteBorder(1, 0, 1, 0,
-          ColorAndFontConstants.defaultBorderColor);
-    }
   }
 
   /**
-   * The constructor of the listener.
+   * Returns a scroll pane border listener that will apply a border only on the
+   * bottom of the scroll.
    * @param scroll the scroll pane to update.
+   * @return a scroll pane border listener that will apply a border only on the
+   * bottom of the scroll.
    */
-  public ScrollPaneBorderListener(JScrollPane scroll)
+  public static ScrollPaneBorderListener createBottomBorderListener(
+      JScrollPane scroll)
   {
-    this(scroll, false);
+    ScrollPaneBorderListener listener = new ScrollPaneBorderListener();
+    listener.scroll = scroll;
+    scroll.getHorizontalScrollBar().addComponentListener(listener);
+    scroll.getVerticalScrollBar().addComponentListener(listener);
+    return listener;
+  }
+
+  /**
+   * Returns a scroll pane border listener that will apply a border on the
+   * bottom and on the top of the scroll.
+   * @param scroll the scroll pane to update.
+   * @return a scroll pane border listener that will apply a border on the
+   * bottom and on the top of the scroll.
+   */
+  public static ScrollPaneBorderListener createBottomAndTopBorderListener(
+      JScrollPane scroll)
+  {
+    ScrollPaneBorderListener listener = createBottomBorderListener(scroll);
+    listener.etchedBorder = BorderFactory.createMatteBorder(1, 0, 1, 0,
+        ColorAndFontConstants.defaultBorderColor);
+    return listener;
+  }
+
+  /**
+   * Returns a scroll pane border listener that will apply a full border to the
+   * scroll.
+   * @param scroll the scroll pane to update.
+   * @return a scroll pane border listener that will apply a full border to the
+   * scroll.
+   */
+  public static ScrollPaneBorderListener createFullBorderListener(
+      JScrollPane scroll)
+  {
+    ScrollPaneBorderListener listener = createBottomBorderListener(scroll);
+    listener.etchedBorder = BorderFactory.createMatteBorder(1, 1, 1, 1,
+        ColorAndFontConstants.defaultBorderColor);
+    return listener;
   }
 
   /**
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
index 11a5c19..37b8d9a 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -254,11 +254,10 @@
       TableColumn col = backupList.getColumn(model.getColumnName(i));
       col.setCellRenderer(renderer);
     }
-    backupList.getTableHeader().setVisible(false);
-    backupList.getTableHeader().setPreferredSize(new Dimension(0, 0));
-    backupList.getTableHeader().setMinimumSize(new Dimension(0, 0));
+    backupList.setTableHeader(null);
     Utilities.updateTableSizes(backupList);
     tableScroll = Utilities.createScrollPane(backupList);
+    tableScroll.setColumnHeaderView(null);
     tableScroll.setPreferredSize(backupList.getPreferredSize());
     gbc.anchor = GridBagConstraints.NORTHWEST;
     add(tableScroll, gbc);
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
index 2bc2dc5..7b1e713 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -88,7 +88,8 @@
     gbc.gridx = 0;
     gbc.gridy = 0;
     JScrollPane scroll = Utilities.createBorderLessScrollBar(p);
-    scrollListener = new ScrollPaneBorderListener(scroll);
+    scrollListener =
+      ScrollPaneBorderListener.createBottomBorderListener(scroll);
     add(scroll, gbc);
 
     gbc.gridy ++;
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
index d2fee03..18f7298 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -88,7 +88,8 @@
     gbc.gridx = 0;
     gbc.gridy = 0;
     JScrollPane scroll = Utilities.createBorderLessScrollBar(p);
-    scrollListener = new ScrollPaneBorderListener(scroll);
+    scrollListener =
+      ScrollPaneBorderListener.createBottomBorderListener(scroll);
     add(scroll, gbc);
 
     gbc.gridy ++;
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
index 2e735f1..b3d86b7 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
@@ -128,7 +128,8 @@
     gbc.gridx = 0;
     gbc.gridy = 0;
     JScrollPane scroll = Utilities.createBorderLessScrollBar(p);
-    scrollListener = new ScrollPaneBorderListener(scroll);
+    scrollListener =
+      ScrollPaneBorderListener.createBottomBorderListener(scroll);
     add(scroll, gbc);
 
     gbc.gridy ++;
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/MonitoringAttributesViewPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/MonitoringAttributesViewPanel.java
index 6b52caa..c92272b 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/MonitoringAttributesViewPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/MonitoringAttributesViewPanel.java
@@ -29,265 +29,335 @@
 import static org.opends.messages.AdminToolMessages.*;
 
 import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 
 import javax.swing.Box;
+import javax.swing.JButton;
 import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
 
 import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
+import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.messages.Message;
 
 /**
- *
- * The panel that allows the user to select which attributes must be displayed
- * in the traffic monitoring tables.
- *
- * @param <T> the type of the objects that this panel manages.  For now it only
- * manages String and MonitoringAttribute objects.
- */
+*
+* The panel that allows the user to select which attributes must be displayed
+* in the traffic monitoring tables.
+*
+* @param <T> the type of the objects that this panel manages.  For now it only
+* manages String and MonitoringAttribute objects.
+*/
 public class MonitoringAttributesViewPanel<T> extends StatusGenericPanel
 {
-  private static final long serialVersionUID = 6462932163745559L;
+ private static final long serialVersionUID = 6462932163745559L;
 
-  private LinkedHashSet<T> selectedAttributes = new LinkedHashSet<T>();
+ private LinkedHashSet<T> selectedAttributes = new LinkedHashSet<T>();
 
-  private LinkedHashSet<T> monitoringAttributes;
+ private LinkedHashSet<T> monitoringAttributes;
 
-  private boolean isCancelled = true;
+ private boolean isCancelled = true;
 
-  // Note: the order of the checkboxes and the elements in the Attributes
-  // enumeration will be the same.
-  private JCheckBox[] checkboxes = {};
+ // Note: the order of the checkboxes and the elements in the Attributes
+ // enumeration will be the same.
+ private JCheckBox[] checkboxes = {};
 
-  /**
-   * Creates an instance of this panel that uses String as attributes.
-   * @param attributes the list of possible attributes.
-   * @return an instance of this panel that uses String as attributes.
-   */
-  public static MonitoringAttributesViewPanel<String>
-  createStringInstance(LinkedHashSet<String> attributes)
-  {
-    return new MonitoringAttributesViewPanel<String>(attributes);
-  }
+ private JButton selectAll;
+ private JButton selectNone;
 
-  /**
-   * Creates an instance of this panel that uses MonitoringAttributes as
-   * attributes.
-   * @param attributes the list of possible attributes.
-   * @return an instance of this panel that uses String as attributes.
-   */
-  public static MonitoringAttributesViewPanel<MonitoringAttributes>
-  createMonitoringAttributesInstance(
-      LinkedHashSet<MonitoringAttributes> attributes)
-  {
-    return new MonitoringAttributesViewPanel<MonitoringAttributes>(attributes);
-  }
+ /**
+  * Creates an instance of this panel that uses String as attributes.
+  * @param attributes the list of possible attributes.
+  * @return an instance of this panel that uses String as attributes.
+  */
+ public static MonitoringAttributesViewPanel<String>
+ createStringInstance(LinkedHashSet<String> attributes)
+ {
+   return new MonitoringAttributesViewPanel<String>(attributes);
+ }
 
-  /**
-   * Default constructor.
-   * @param attributes the attributes that will be proposed to the user.
-   *
-   */
-  protected MonitoringAttributesViewPanel(
-      LinkedHashSet<T> attributes)
-  {
-    super();
-    monitoringAttributes = new LinkedHashSet<T>();
-    monitoringAttributes.addAll(attributes);
-    createLayout();
-  }
+ /**
+  * Creates an instance of this panel that uses MonitoringAttributes as
+  * attributes.
+  * @param attributes the list of possible attributes.
+  * @return an instance of this panel that uses String as attributes.
+  */
+ public static MonitoringAttributesViewPanel<MonitoringAttributes>
+ createMonitoringAttributesInstance(
+     LinkedHashSet<MonitoringAttributes> attributes)
+ {
+   return new MonitoringAttributesViewPanel<MonitoringAttributes>(attributes);
+ }
 
-  /**
-   * Sets the attributes that must be selected in this dialog.
-   * @param selectedAttributes the selected attributes.
-   */
-  public void setSelectedAttributes(
-      Collection<T> selectedAttributes)
-  {
-    int i = 0;
-    for (T attribute : monitoringAttributes)
-    {
-      checkboxes[i].setSelected(selectedAttributes.contains(attribute));
-      i++;
-    }
-  }
+ /**
+  * {@inheritDoc}
+  */
+ @Override
+ public boolean requiresScroll()
+ {
+   return false;
+ }
 
-  /**
-   * Creates the layout of the panel (but the contents are not populated here).
-   */
-  private void createLayout()
-  {
-    GridBagConstraints gbc = new GridBagConstraints();
-    gbc.fill = GridBagConstraints.HORIZONTAL;
-    gbc.gridy = 0;
-    int nCols = monitoringAttributes.size() > 30 ? 3 : 2;
+ /**
+  * Default constructor.
+  * @param attributes the attributes that will be proposed to the user.
+  *
+  */
+ protected MonitoringAttributesViewPanel(
+     LinkedHashSet<T> attributes)
+ {
+   super();
+   monitoringAttributes = new LinkedHashSet<T>();
+   monitoringAttributes.addAll(attributes);
+   createLayout();
+ }
 
-    gbc.gridwidth = nCols;
-    gbc.gridx = 0;
-    add(Utilities.createPrimaryLabel(
-        INFO_CTRL_PANEL_OPERATION_VIEW_LABEL.get()), gbc);
-    gbc.gridy ++;
-    gbc.gridwidth = 1;
-    gbc.insets.top = 10;
+ /**
+  * Sets the attributes that must be selected in this dialog.
+  * @param selectedAttributes the selected attributes.
+  */
+ public void setSelectedAttributes(
+     Collection<T> selectedAttributes)
+ {
+   int i = 0;
+   for (T attribute : monitoringAttributes)
+   {
+     checkboxes[i].setSelected(selectedAttributes.contains(attribute));
+     i++;
+   }
+ }
 
-    checkboxes = new JCheckBox[monitoringAttributes.size()];
+ /**
+  * Creates the layout of the panel (but the contents are not populated here).
+  */
+ private void createLayout()
+ {
+   GridBagConstraints gbc = new GridBagConstraints();
+   gbc.fill = GridBagConstraints.HORIZONTAL;
+   gbc.gridy = 0;
 
-    int i = 0;
-    Iterator<T> ops = monitoringAttributes.iterator();
-    while (ops.hasNext())
-    {
-      T operation = ops.next();
-      Message m = getMessage(operation);
+   gbc.gridwidth = 2;
+   gbc.gridx = 0;
+   add(Utilities.createPrimaryLabel(
+       INFO_CTRL_PANEL_OPERATION_VIEW_LABEL.get()), gbc);
+   gbc.gridy ++;
+   gbc.gridwidth = 1;
+   gbc.insets.top = 10;
 
-      JCheckBox cb = Utilities.createCheckBox(m);
-      gbc.gridx = 0;
-      gbc.weightx = 0.0;
-      gbc.insets.left = 0;
-      checkboxes[i] = cb;
-      add(checkboxes[i], gbc);
-      gbc.weightx = 1.0;
-      gbc.insets.left = 40;
-      while (gbc.gridx + 1 < nCols)
-      {
-        gbc.gridx ++;
-        if (i + 1 >= checkboxes.length)
-        {
-          add(Box.createHorizontalGlue(), gbc);
-        }
-        else
-        {
-          operation = ops.next();
-          m = getMessage(operation);
-          cb = Utilities.createCheckBox(m);
-          checkboxes[i+1] = cb;
-          add(checkboxes[i+1], gbc);
-          i ++;
-          checkboxes[i].setSelected(true);
-        }
-      }
-      gbc.gridy ++;
-      i++;
-    }
-    gbc.gridx = 0;
-    gbc.gridwidth = nCols;
-    gbc.weighty = 1.0;
-    gbc.fill = GridBagConstraints.VERTICAL;
-    add(Box.createVerticalGlue(), gbc);
-  }
+   JPanel checkBoxPanel = new JPanel(new GridBagLayout());
+   checkBoxPanel.setOpaque(false);
+   JScrollPane scroll = Utilities.createBorderLessScrollBar(checkBoxPanel);
+   ScrollPaneBorderListener scrollListener =
+     ScrollPaneBorderListener.createFullBorderListener(scroll);
 
-  /**
-   * {@inheritDoc}
-   */
-  public Message getTitle()
-  {
-    return INFO_CTRL_PANEL_ATTRIBUTE_VIEW_OPTIONS_TITLE.get();
-  }
+   checkboxes = new JCheckBox[monitoringAttributes.size()];
 
-  /**
-   * {@inheritDoc}
-   */
-  public void configurationChanged(ConfigurationChangeEvent ev)
-  {
-  }
+   int i = 0;
+   for (T attribute : monitoringAttributes)
+   {
+     Message m = getMessage(attribute);
+     checkboxes[i] = Utilities.createCheckBox(m);
+     i++;
+   }
+   selectAll = Utilities.createButton(INFO_CTRL_PANEL_SELECT_ALL_BUTTON.get());
+   selectAll.addActionListener(new ActionListener()
+   {
+     public void actionPerformed(ActionEvent ev)
+     {
+       for (JCheckBox cb : checkboxes)
+       {
+         cb.setSelected(true);
+       }
+     }
+   });
 
-  /**
-   * {@inheritDoc}
-   */
-  public Component getPreferredFocusComponent()
-  {
-    return checkboxes[0];
-  }
+   selectNone = Utilities.createButton(
+       INFO_CTRL_PANEL_CLEAR_SELECTION_BUTTON.get());
+   selectNone.addActionListener(new ActionListener()
+   {
+     public void actionPerformed(ActionEvent ev)
+     {
+       for (JCheckBox cb : checkboxes)
+       {
+         cb.setSelected(false);
+       }
+     }
+   });
 
-  /**
-   * {@inheritDoc}
-   */
-  public void toBeDisplayed(boolean visible)
-  {
-    if (visible)
-    {
-      isCancelled = true;
-    }
-  }
+   gbc.weightx = 1.0;
+   gbc.weighty = 1.0;
+   gbc.gridheight = 3;
+   gbc.fill = GridBagConstraints.BOTH;
+   add(scroll, gbc);
 
-  /**
-   * {@inheritDoc}
-   */
-  public void okClicked()
-  {
-    // Check that at least one checkbox is selected.
-    selectedAttributes.clear();
-    int i = 0;
-    for (T operation : monitoringAttributes)
-    {
-      if (checkboxes[i].isSelected())
-      {
-        selectedAttributes.add(operation);
-      }
-      i++;
-    }
-    if (selectedAttributes.isEmpty())
-    {
-      ArrayList<Message> errors = new ArrayList<Message>();
-      errors.add(INFO_CTRL_PANEL_NO_OPERATION_SELECTED.get());
-      super.displayErrorDialog(errors);
-    }
-    else
-    {
-      isCancelled = false;
-      super.closeClicked();
-    }
-  }
+   gbc.gridx = 1;
+   gbc.weightx = 0.0;
+   gbc.weighty = 0.0;
+   gbc.insets.left = 10;
+   gbc.gridheight = 1;
+   add(selectAll, gbc);
+   gbc.gridy ++;
+   gbc.insets.top = 10;
+   add(selectNone, gbc);
+   gbc.gridy ++;
+   gbc.weighty = 1.0;
+   add(Box.createVerticalGlue(), gbc);
 
-  /**
-   * {@inheritDoc}
-   */
-  public GenericDialog.ButtonType getButtonType()
-  {
-    return GenericDialog.ButtonType.OK_CANCEL;
-  }
+   gbc = new GridBagConstraints();
+   gbc.gridy = 0;
+   gbc.gridwidth = 1;
+   int preferredViewHeight = -1;
+   for (JCheckBox cb : checkboxes)
+   {
+     gbc.gridx = 0;
+     gbc.weightx = 0.0;
+     gbc.anchor = GridBagConstraints.WEST;
+     gbc.fill = GridBagConstraints.NONE;
+     checkBoxPanel.add(cb, gbc);
+     gbc.gridx = 1;
+     gbc.weightx = 1.0;
+     gbc.fill = GridBagConstraints.HORIZONTAL;
+     checkBoxPanel.add(Box.createHorizontalGlue(), gbc);
+     gbc.insets.top = 10;
+     gbc.gridy ++;
+     if (gbc.gridy == 15)
+     {
+       preferredViewHeight = checkBoxPanel.getPreferredSize().height;
+     }
+   }
+   if (preferredViewHeight < 0)
+   {
+     preferredViewHeight = checkBoxPanel.getPreferredSize().height;
+   }
+   gbc.insets = new Insets(0, 0, 0, 0);
+   gbc.gridx = 0;
+   gbc.gridwidth = 2;
+   gbc.fill = GridBagConstraints.VERTICAL;
+   gbc.weighty = 1.0;
+   checkBoxPanel.add(Box.createVerticalGlue(), gbc);
+   scroll.getViewport().setPreferredSize(
+       new Dimension(checkBoxPanel.getPreferredSize().width + 15,
+           preferredViewHeight));
+ }
 
-  /**
-   * Returns <CODE>true</CODE> if the user closed the dialog by cancelling it
-   * and <CODE>false</CODE> otherwise.
-   * @return <CODE>true</CODE> if the user closed the dialog by cancelling it
-   * and <CODE>false</CODE> otherwise.
-   */
-  public boolean isCancelled()
-  {
-    return isCancelled;
-  }
+ /**
+  * {@inheritDoc}
+  */
+ public Message getTitle()
+ {
+   return INFO_CTRL_PANEL_ATTRIBUTE_VIEW_OPTIONS_TITLE.get();
+ }
 
-  /**
-   * Returns the list of attributes that the user selected.
-   * @return the list of attributes that the user selected.
-   */
-  public LinkedHashSet<T> getAttributes()
-  {
-    return selectedAttributes;
-  }
+ /**
+  * {@inheritDoc}
+  */
+ public void configurationChanged(ConfigurationChangeEvent ev)
+ {
+ }
 
-  /**
-   * Returns the message for the provided operation.
-   * @param operation the operation.
-   * @return the message for the provided operation.
-   */
-  protected Message getMessage(T operation)
-  {
-    Message m;
-    if (operation instanceof MonitoringAttributes)
-    {
-      m = ((MonitoringAttributes)operation).getMessage();
-    }
-    else
-    {
-      m = Message.raw(operation.toString());
-    }
-    return m;
-  }
+ /**
+  * {@inheritDoc}
+  */
+ public Component getPreferredFocusComponent()
+ {
+   return checkboxes[0];
+ }
+
+ /**
+  * {@inheritDoc}
+  */
+ public void toBeDisplayed(boolean visible)
+ {
+   if (visible)
+   {
+     isCancelled = true;
+   }
+ }
+
+ /**
+  * {@inheritDoc}
+  */
+ public void okClicked()
+ {
+   // Check that at least one checkbox is selected.
+   selectedAttributes.clear();
+   int i = 0;
+   for (T operation : monitoringAttributes)
+   {
+     if (checkboxes[i].isSelected())
+     {
+       selectedAttributes.add(operation);
+     }
+     i++;
+   }
+   if (selectedAttributes.isEmpty())
+   {
+     ArrayList<Message> errors = new ArrayList<Message>();
+     errors.add(INFO_CTRL_PANEL_NO_OPERATION_SELECTED.get());
+     super.displayErrorDialog(errors);
+   }
+   else
+   {
+     isCancelled = false;
+     super.closeClicked();
+   }
+ }
+
+ /**
+  * {@inheritDoc}
+  */
+ public GenericDialog.ButtonType getButtonType()
+ {
+   return GenericDialog.ButtonType.OK_CANCEL;
+ }
+
+ /**
+  * Returns <CODE>true</CODE> if the user closed the dialog by cancelling it
+  * and <CODE>false</CODE> otherwise.
+  * @return <CODE>true</CODE> if the user closed the dialog by cancelling it
+  * and <CODE>false</CODE> otherwise.
+  */
+ public boolean isCancelled()
+ {
+   return isCancelled;
+ }
+
+ /**
+  * Returns the list of attributes that the user selected.
+  * @return the list of attributes that the user selected.
+  */
+ public LinkedHashSet<T> getAttributes()
+ {
+   return selectedAttributes;
+ }
+
+ /**
+  * Returns the message for the provided operation.
+  * @param operation the operation.
+  * @return the message for the provided operation.
+  */
+ protected Message getMessage(T operation)
+ {
+   Message m;
+   if (operation instanceof MonitoringAttributes)
+   {
+     m = ((MonitoringAttributes)operation).getMessage();
+   }
+   else
+   {
+     m = Message.raw(operation.toString());
+   }
+   return m;
+ }
 }
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index a76b807..dac07c2 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -421,7 +421,8 @@
     gbc.gridy ++;
     gbc.fill = GridBagConstraints.BOTH;
     scrollAttributes = Utilities.createBorderLessScrollBar(attributesPanel);
-    scrollListener = new ScrollPaneBorderListener(scrollAttributes, true);
+    scrollListener = ScrollPaneBorderListener.createBottomAndTopBorderListener(
+        scrollAttributes);
     gbc.insets = new Insets(0, 0, 0, 0);
     add(scrollAttributes, gbc);
   }
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
index 55aec1d..87bccfc 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
@@ -250,7 +250,8 @@
     gbc.gridx = 0;
     gbc.gridy = 0;
     JScrollPane scroll = Utilities.createBorderLessScrollBar(p);
-    scrollListener = new ScrollPaneBorderListener(scroll);
+    scrollListener =
+      ScrollPaneBorderListener.createBottomBorderListener(scroll);
     add(scroll, gbc);
 
     gbc.gridy ++;
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
index 94b7a2a..810e04b 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -772,7 +772,7 @@
     int headerMaxWidth = 0;
 
     JTableHeader header = table.getTableHeader();
-    if (header.isVisible())
+    if (header != null && header.isVisible())
     {
       for (int col=0; col<table.getColumnCount(); col++)
       {
@@ -801,14 +801,18 @@
       TableColumn tcol = table.getColumnModel().getColumn(col);
       TableCellRenderer renderer = tcol.getHeaderRenderer();
 
-      if (renderer == null)
+      if ((renderer == null) && (header != null))
       {
-        renderer = table.getTableHeader().getDefaultRenderer();
+        renderer = header.getDefaultRenderer();
       }
 
-      Component comp = renderer.getTableCellRendererComponent(table,
+      if (renderer != null)
+      {
+        Component comp = renderer.getTableCellRendererComponent(table,
             table.getModel().getColumnName(col), false, false, 0, col);
-      colMaxWidth = comp.getPreferredSize().width  + 8;
+        colMaxWidth = comp.getPreferredSize().width  + (2 * horizontalMargin) +
+        8;
+      }
 
       if (colMaxWidth > screenSize.width)
       {
@@ -818,7 +822,7 @@
       for (int row=0; row<table.getRowCount(); row++)
       {
         renderer = table.getCellRenderer(row, col);
-        comp = table.prepareRenderer(renderer, row, col);
+        Component comp = table.prepareRenderer(renderer, row, col);
         int colWidth = comp.getPreferredSize().width + (2 * horizontalMargin);
         colMaxWidth = Math.max(colMaxWidth, colWidth);
       }
@@ -827,7 +831,7 @@
     }
 
 
-    if (header.isVisible())
+    if (header != null && header.isVisible())
     {
       header.setPreferredSize(new Dimension(
           headerMaxWidth,
@@ -835,24 +839,25 @@
     }
 
 
-    int maxRow = 0;
+    int maxRow = table.getRowHeight();
     for (int row=0; row<table.getRowCount(); row++)
     {
-      int rowMaxHeight = table.getRowHeight();
       for (int col=0; col<table.getColumnCount(); col++)
       {
         TableCellRenderer renderer = table.getCellRenderer(row, col);
         Component comp = renderer.getTableCellRendererComponent(table,
             table.getModel().getValueAt(row, col), false, false, row, col);
-        int colHeight = comp.getPreferredSize().height;
+        int colHeight = comp.getPreferredSize().height + (2 * verticalMargin);
         if (colHeight > screenSize.height)
         {
           colHeight = 0;
         }
-        rowMaxHeight = Math.max(rowMaxHeight, colHeight);
+        maxRow = Math.max(maxRow, colHeight);
       }
-      table.setRowHeight(row, rowMaxHeight);
-      maxRow = Math.max(maxRow, rowMaxHeight);
+    }
+    if (maxRow > table.getRowHeight())
+    {
+      table.setRowHeight(maxRow);
     }
     Dimension d1;
     if (rows == -1)

--
Gitblit v1.10.0