usr/src/java/vpanels/app/usermgr/com/oracle/solaris/vp/panels/usermgr/client/swing/UserMgrUtils.java
changeset 847 a8e124b894b8
parent 811 c65c58b7a1f0
--- a/usr/src/java/vpanels/app/usermgr/com/oracle/solaris/vp/panels/usermgr/client/swing/UserMgrUtils.java	Thu Apr 26 00:14:30 2012 -0400
+++ b/usr/src/java/vpanels/app/usermgr/com/oracle/solaris/vp/panels/usermgr/client/swing/UserMgrUtils.java	Fri Apr 27 00:52:26 2012 -0400
@@ -25,7 +25,9 @@
 
 package com.oracle.solaris.vp.panels.usermgr.client.swing;
 
+import java.awt.*;
 import java.util.Arrays;
+import javax.swing.*;
 import com.oracle.solaris.vp.panel.common.action.ActionFailedException;
 import com.oracle.solaris.vp.util.misc.finder.Finder;
 
@@ -53,19 +55,19 @@
 	// User name must be specified
 	if (username.length() == 0) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.basic.error.username.none"));
+		Finder.getString("usermgr.error.username.none"));
 	}
 
 	// Ensure that the username is valid
 	if (!isValidLogin(username)) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.basic.error.username.bad"));
+		Finder.getString("usermgr.error.username.bad"));
 	}
 
 	// Ensure that username does not already exist
 	if (descriptor.getUserManagedObject(username) != null) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.basic.error.username.exists",
+		Finder.getString("usermgr.error.username.exists",
 		    username));
 	}
     }
@@ -75,21 +77,17 @@
 	// Ensure that the user description, if specified, is valid.
 	if (!isValidUserDesc(userdesc)) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.basic.error.userdesc.bad"));
+		Finder.getString("usermgr.error.userdesc.bad"));
 	}
     }
 
     public static void validatePassword(boolean bNewUser,
 	char[] pass1, char[] pass2) throws ActionFailedException {
-	// Password must be specified for a new user
-	if (pass1.length == 0 && bNewUser)
-	    throw new ActionFailedException(
-		Finder.getString("usermgr.basic.error.pass.none"));
 
 	// Ensure that the passwords match
 	if (!Arrays.equals(pass1, pass2)) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.basic.error.pass.nomatch"));
+		Finder.getString("usermgr.error.pass.nomatch"));
 	}
     }
 
@@ -98,7 +96,7 @@
 	// Ensure that the UID is valid
 	if (uid < VALID_UID) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.advanced.error.uid.bad"));
+		Finder.getString("usermgr.error.uid.bad"));
 	}
     }
 
@@ -107,7 +105,7 @@
 	// Ensure that the homedir is valid
 	if (!isValidHomeDir(homedir)) {
 	    throw new ActionFailedException(
-		Finder.getString("usermgr.advanced.error.homedir.bad"));
+		Finder.getString("usermgr.error.homedir.bad"));
 	}
     }
 
@@ -162,4 +160,20 @@
 	return (homedir.length() >= VALID_HOMEDIRLEN &&
 	    homedir.matches("^\\/[\\-\\p{Alnum}\\._\\/]+$"));
     }
+
+    public static void removeIcons(JOptionPane pane) {
+        Component[] comps = pane.getComponents();
+
+	for (int i = 0; i < comps.length; i++) {
+	    Component comp = comps[i];
+	    if (comp instanceof JPanel) {
+        	Component[] buttons = ((JPanel)comp).getComponents();
+		for (int j = 0; j < buttons.length; j++) {
+		    if (buttons[j] instanceof JButton) {
+			((JButton)buttons[j]).setIcon(null);
+		    }
+		}
+	    }
+	}
+    }
 }