From 7164c02689bf2fba4a7b1ec9229d6775d3332adc Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Thu, 27 May 2010 09:03:15 +0000
Subject: [PATCH] GUI L&F enhancements, including accessibility and 508 compliances.

---
 opends/src/guitools/org/opends/guitools/controlpanel/ui/components/LabelWithHelpIcon.java |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/components/LabelWithHelpIcon.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/components/LabelWithHelpIcon.java
index fb885be..4446980 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/components/LabelWithHelpIcon.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/components/LabelWithHelpIcon.java
@@ -22,12 +22,13 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.ui.components;
 
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Font;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
@@ -97,6 +98,18 @@
     add(Box.createHorizontalGlue(), gbc);
 
     Utilities.addClickTooltipListener(iconLabel);
+
+    updateAccessibleContext();
+  }
+
+  /**
+   * Set the component this is labeling. Can be {@code null} if this does not
+   * label a {@code Component}.
+   * @param comp the {@code Component} to be labeled.
+   */
+  public void setLabelFor(Component comp)
+  {
+    label.setLabelFor(comp);
   }
 
   /**
@@ -106,6 +119,7 @@
   public void setText(String text)
   {
     label.setText(text);
+    updateAccessibleContext();
   }
 
   /**
@@ -137,6 +151,7 @@
   public void setHelpTooltip(String tooltip)
   {
     iconLabel.setToolTipText(tooltip);
+    updateAccessibleContext();
   }
 
   /**
@@ -198,4 +213,24 @@
       return null;
     }
   }
+
+  private void updateAccessibleContext()
+  {
+    StringBuilder sb = new StringBuilder();
+    String s = label.getText();
+    if (s != null)
+    {
+      sb.append(s);
+    }
+    if (iconLabel.getIcon() != null)
+    {
+      String toolTip = iconLabel.getToolTipText();
+      toolTip = Utilities.stripHtmlToSingleLine(toolTip);
+      if (toolTip != null)
+      {
+        sb.append(" - "+toolTip);
+      }
+    }
+    getAccessibleContext().setAccessibleName(sb.toString());
+  }
 }

--
Gitblit v1.10.0