usr/src/java/vpanels/app/usermgr/com/oracle/solaris/vp/panels/usermgr/client/swing/UserMgrControl.java
changeset 847 a8e124b894b8
parent 846 0a2af4721353
child 848 d7c7737126e9
equal deleted inserted replaced
846:0a2af4721353 847:a8e124b894b8
     1 /*
       
     2  * CDDL HEADER START
       
     3  *
       
     4  * The contents of this file are subject to the terms of the
       
     5  * Common Development and Distribution License (the "License").
       
     6  * You may not use this file except in compliance with the License.
       
     7  *
       
     8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9  * or http://www.opensolaris.org/os/licensing.
       
    10  * See the License for the specific language governing permissions
       
    11  * and limitations under the License.
       
    12  *
       
    13  * When distributing Covered Code, include this CDDL HEADER in each
       
    14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15  * If applicable, add the following below this CDDL HEADER, with the
       
    16  * fields enclosed by brackets "[]" replaced with your own identifying
       
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
       
    18  *
       
    19  * CDDL HEADER END
       
    20  */
       
    21 
       
    22 /*
       
    23  * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
       
    24  */
       
    25 
       
    26 package com.oracle.solaris.vp.panels.usermgr.client.swing;
       
    27 
       
    28 import java.util.Map;
       
    29 import com.oracle.solaris.vp.panel.common.control.*;
       
    30 import com.oracle.solaris.vp.panel.swing.control.TabbedControl;
       
    31 
       
    32 public class UserMgrControl extends TabbedControl<UserMgrPanelDescriptor> {
       
    33 
       
    34     //
       
    35     // Static data
       
    36     //
       
    37     public static final String ID = "usermgr";
       
    38     public static final String PARAM_USER = "user";
       
    39 
       
    40     //
       
    41     // Instance data
       
    42     //
       
    43 
       
    44     private UserManagedObject userMO;
       
    45 
       
    46     //
       
    47     // Constructor
       
    48     //
       
    49 
       
    50     public UserMgrControl(UserMgrPanelDescriptor descriptor) {
       
    51         super(ID, null, descriptor);
       
    52     }
       
    53 
       
    54     //
       
    55     // Control methods
       
    56     //
       
    57 
       
    58     @Override
       
    59     public boolean isBrowsable() {
       
    60 	// This control requires init parameters
       
    61 	return false;
       
    62     }
       
    63 
       
    64     //
       
    65     // DefaultControl Methods
       
    66     //
       
    67 
       
    68     @Override
       
    69     protected void ensureChildrenCreated() {
       
    70 	// Add the basic and advanced tab controls
       
    71 	if (children.size() == 0) {
       
    72 	    addChildren(new UserMgrBasicControl(this));
       
    73 	    addChildren(new UserMgrAdvancedControl(this));
       
    74 	}
       
    75     }
       
    76 
       
    77     //
       
    78     // SwingControl Methods
       
    79     //
       
    80 
       
    81     @Override
       
    82     public void start(Navigator navigator, Map<String, String> parameters)
       
    83 	throws NavigationAbortedException, InvalidParameterException,
       
    84 	NavigationFailedException {
       
    85 
       
    86 	String param = getParameter(parameters, PARAM_USER);
       
    87   	UserManagedObject umo =
       
    88 	    getPanelDescriptor().getUserManagedObject(param);
       
    89 	if (umo == null) {
       
    90 	    throw new InvalidParameterException(getId(), PARAM_USER, param);
       
    91   	}
       
    92 
       
    93   	setUserManagedObject(umo);
       
    94 
       
    95  	super.start(navigator, parameters);
       
    96     }
       
    97 
       
    98     @Override
       
    99     public void stop(boolean isCancel) throws NavigationAbortedException {
       
   100  	super.stop(isCancel);
       
   101  	setUserManagedObject(null);
       
   102     }
       
   103 
       
   104     //
       
   105     // UserMgrControl methods
       
   106     //
       
   107 
       
   108     public UserManagedObject getUserManagedObject() {
       
   109 	return userMO;
       
   110     }
       
   111 
       
   112     //
       
   113     // Private methods
       
   114     //
       
   115 
       
   116     private void setUserManagedObject(UserManagedObject umo) {
       
   117 	this.userMO = umo;
       
   118 	setName(umo == null ? null : umo.getName());
       
   119     }
       
   120 }