From ba0c82bc1cb8926ca329a4eae78263ee8bbe1094 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 12 Jul 2007 15:47:29 +0000
Subject: [PATCH] moved UI specific utilties to UI specific utility class

---
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java |  213 -----------------------------------------------------
 1 files changed, 0 insertions(+), 213 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 85fab21..913958f 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -26,10 +26,6 @@
  */
 package org.opends.quicksetup.util;
 
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Toolkit;
-import java.awt.Window;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -50,8 +46,6 @@
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.TrustManager;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
 
 import org.opends.admin.ads.util.ConnectionUtils;
 import org.opends.quicksetup.*;
@@ -78,45 +72,6 @@
   }
 
   /**
-   * Center the component location based on its preferred size. The code
-   * considers the particular case of 2 screens and puts the component on the
-   * center of the left screen
-   *
-   * @param comp the component to be centered.
-   */
-  public static void centerOnScreen(Component comp)
-  {
-    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-
-    int width = (int) comp.getPreferredSize().getWidth();
-    int height = (int) comp.getPreferredSize().getHeight();
-
-    boolean multipleScreen = screenSize.width / screenSize.height >= 2;
-
-    if (multipleScreen)
-    {
-      comp.setLocation((screenSize.width / 4) - (width / 2),
-          (screenSize.height - height) / 2);
-    } else
-    {
-      comp.setLocation((screenSize.width - width) / 2,
-          (screenSize.height - height) / 2);
-    }
-  }
-
-  /**
-   * Center the component location of the ref component.
-   *
-   * @param comp the component to be centered.
-   * @param ref the component to be used as reference.
-   *
-   */
-  public static void centerOnComponent(Window comp, Component ref)
-  {
-    comp.setLocationRelativeTo(ref);
-  }
-
-  /**
    * Returns <CODE>true</CODE> if the provided port is free and we can use it,
    * <CODE>false</CODE> otherwise.
    * @param port the port we are analyzing.
@@ -1009,62 +964,6 @@
   }
 
   /**
-   * Displays a confirmation message dialog.
-  *
-  * @param parent
-   *          the parent frame of the confirmation dialog.
-   * @param msg
-  *          the confirmation message.
-  * @param title
-  *          the title of the dialog.
-  * @return <CODE>true</CODE> if the user confirms the message, or
-  * <CODE>false</CODE> if not.
-  */
- public static boolean displayConfirmation(JFrame parent, String msg,
-     String title)
- {
-   return JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(
-       parent, wrapMsg(msg, 100), title, JOptionPane.YES_NO_OPTION,
-       JOptionPane.QUESTION_MESSAGE, null, // don't use a custom
-       // Icon
-       null, // the titles of buttons
-       null); // default button title
- }
-
-  /**
-   * Displays an error message dialog.
-   *
-   * @param parent
-   *          the parent component of the error dialog.
-   * @param msg
-   *          the error message.
-   * @param title
-   *          the title for the dialog.
-   */
-  public static void displayError(Component parent, String msg, String title)
-  {
-    JOptionPane.showMessageDialog(parent, wrapMsg(msg, 100), title,
-        JOptionPane.ERROR_MESSAGE);
-  }
-
-  /**
-   * Displays an information message dialog.
-   *
-   * @param parent
-   *          the parent frame of the information dialog.
-   * @param msg
-   *          the error message.
-   * @param title
-   *          the title for the dialog.
-   */
-  public static void displayInformationMessage(JFrame parent, String msg,
-      String title)
-  {
-    JOptionPane.showMessageDialog(parent, wrapMsg(msg, 100), title,
-        JOptionPane.INFORMATION_MESSAGE);
-  }
-
-  /**
 
    * Returns the max size in character of a line to be displayed in the command
    * line.
@@ -1294,118 +1193,6 @@
   }
 
   /**
-   * Private method used to wrap the messages that are displayed in dialogs
-   * of type JOptionPane.
-   * @param msg the message.
-   * @param width the maximum width of the column.
-   * @return the wrapped message.
-   */
-  private static String wrapMsg(String msg, int width)
-  {
-    StringBuilder   buffer        = new StringBuilder();
-    StringTokenizer lineTokenizer = new StringTokenizer(msg, "\n", true);
-    while (lineTokenizer.hasMoreTokens())
-    {
-      String line = lineTokenizer.nextToken();
-      if (line.equals("\n"))
-      {
-        // It's an end-of-line character, so append it as-is.
-        buffer.append(line);
-      }
-      else if (line.length() < width)
-      {
-        // The line fits in the specified width, so append it as-is.
-        buffer.append(line);
-      }
-      else
-      {
-        // The line doesn't fit in the specified width, so it needs to be
-        // wrapped.  Do so at space boundaries.
-        StringBuilder   lineBuffer    = new StringBuilder();
-        StringBuilder   delimBuffer   = new StringBuilder();
-        StringTokenizer wordTokenizer = new StringTokenizer(line, " ", true);
-        while (wordTokenizer.hasMoreTokens())
-        {
-          String word = wordTokenizer.nextToken();
-          if (word.equals(" "))
-          {
-            // It's a space, so add it to the delim buffer only if the line
-            // buffer is not empty.
-            if (lineBuffer.length() > 0)
-            {
-              delimBuffer.append(word);
-            }
-          }
-          else if (word.length() > width)
-          {
-            // This is a long word that can't be wrapped, so we'll just have to
-            // make do.
-            if (lineBuffer.length() > 0)
-            {
-              buffer.append(lineBuffer);
-              buffer.append("\n");
-              lineBuffer = new StringBuilder();
-            }
-            buffer.append(word);
-
-            if (wordTokenizer.hasMoreTokens())
-            {
-              // The next token must be a space, so remove it.  If there are
-              // still more tokens after that, then append an EOL.
-              wordTokenizer.nextToken();
-              if (wordTokenizer.hasMoreTokens())
-              {
-                buffer.append("\n");
-              }
-            }
-
-            if (delimBuffer.length() > 0)
-            {
-              delimBuffer = new StringBuilder();
-            }
-          }
-          else
-          {
-            // It's not a space, so see if we can fit it on the current line.
-            int newLineLength = lineBuffer.length() + delimBuffer.length() +
-            word.length();
-            if (newLineLength < width)
-            {
-              // It does fit on the line, so add it.
-              lineBuffer.append(delimBuffer).append(word);
-
-              if (delimBuffer.length() > 0)
-              {
-                delimBuffer = new StringBuilder();
-              }
-            }
-            else
-            {
-              // It doesn't fit on the line, so end the current line and start
-              // a new one.
-              buffer.append(lineBuffer);
-              buffer.append("\n");
-
-              lineBuffer = new StringBuilder();
-              lineBuffer.append(word);
-
-              if (delimBuffer.length() > 0)
-              {
-                delimBuffer = new StringBuilder();
-              }
-            }
-          }
-        }
-
-        // If there's anything left in the line buffer, then add it to the
-        // final buffer.
-        buffer.append(lineBuffer);
-      }
-    }
-    return buffer.toString();
-  }
-
-  /**
    * Inserts HTML break tags into <code>d</code> breaking it up
    * so that no line is longer than <code>maxll</code>.
    * @param d String to break

--
Gitblit v1.10.0