From abaf062ce64bbe4909651563cb81171e794c37ab Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 14 Sep 2007 11:06:06 +0000
Subject: [PATCH] Add support for indenting the heading separator and use it in menus to emphasis the option numbers.

---
 opends/src/server/org/opends/server/util/table/TextTablePrinter.java |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/util/table/TextTablePrinter.java b/opends/src/server/org/opends/server/util/table/TextTablePrinter.java
index 3cda3b8..15130b3 100644
--- a/opends/src/server/org/opends/server/util/table/TextTablePrinter.java
+++ b/opends/src/server/org/opends/server/util/table/TextTablePrinter.java
@@ -139,10 +139,20 @@
           }
 
           for (int j = 0; j < width; j++) {
-            builder.append(headingSeparator);
+            if (headingSeparatorStartColumn > 0) {
+              if (i < headingSeparatorStartColumn) {
+                builder.append(' ');
+              } else if (i == headingSeparatorStartColumn && j < padding) {
+                builder.append(' ');
+              } else {
+                builder.append(headingSeparator);
+              }
+            } else {
+              builder.append(headingSeparator);
+            }
           }
 
-          if (i < (totalColumns - 1)) {
+          if ((i >= headingSeparatorStartColumn) && i < (totalColumns - 1)) {
             builder.append(columnSeparator);
           }
         }
@@ -362,6 +372,9 @@
   // heading row from the rows beneath.
   private char headingSeparator = DEFAULT_HEADING_SEPARATOR;
 
+  // The column where the heading separator should begin.
+  private int headingSeparatorStartColumn = 0;
+
   // The padding which will be used to separate a cell's
   // contents from its adjacent column separators.
   private int padding = DEFAULT_PADDING;
@@ -479,6 +492,26 @@
 
 
   /**
+   * Sets the heading separator start column. The heading separator
+   * will only be display in the specified column and all subsequent
+   * columns. Usually this should be left at zero (the default) but
+   * sometimes it useful to indent the heading separate in order to
+   * provide additional emphasis (for example in menus).
+   *
+   * @param startColumn
+   *          The heading separator start column.
+   */
+  public void setHeadingSeparatorStartColumn(int startColumn) {
+    if (startColumn < 0) {
+      throw new IllegalArgumentException("Negative start column "
+          + startColumn);
+    }
+    this.headingSeparatorStartColumn = startColumn;
+  }
+
+
+
+  /**
    * Sets the amount of characters that the table should be indented.
    * By default the table is not indented.
    *

--
Gitblit v1.10.0