components/visual-panels/coreadm/src/java/vpanels/app/coreadm/com/oracle/solaris/vp/panels/coreadm/client/swing/CustomCoreSchemeEditControl.java
author devjani.ray@oracle.com <devjani.ray@oracle.com>
Wed, 30 Oct 2013 16:53:48 -0400
branchs11-update
changeset 2805 4888f6212f94
parent 827 0944d8c0158b
permissions -rw-r--r--
17510631 Backport 16984138 to 11.2 - vp components must change to match RAD2 enhancements 17548766 Backport 16808665 to 11.2 - User Manager Panel can assign profiles, but not auth
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     1
/*
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     2
 * CDDL HEADER START
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     3
 *
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     7
 *
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    11
 * and limitations under the License.
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    12
 *
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    18
 *
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    19
 * CDDL HEADER END
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    20
 */
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    21
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    22
/*
2805
4888f6212f94 17510631 Backport 16984138 to 11.2 - vp components must change to match RAD2 enhancements
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 827
diff changeset
    23
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    24
 */
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    25
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    26
package com.oracle.solaris.vp.panels.coreadm.client.swing;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    27
2805
4888f6212f94 17510631 Backport 16984138 to 11.2 - vp components must change to match RAD2 enhancements
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 827
diff changeset
    28
import com.oracle.solaris.rad.client.RadPrivilegeException;
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    29
import com.oracle.solaris.scf.common.ScfException;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    30
import com.oracle.solaris.vp.panel.common.action.*;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    31
import com.oracle.solaris.vp.panel.common.smf.SmfUtil;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    32
import com.oracle.solaris.vp.panel.swing.control.SettingsControl;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    33
import com.oracle.solaris.vp.util.misc.finder.Finder;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    34
import com.oracle.solaris.vp.util.misc.property.MutableProperty;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    35
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    36
public class CustomCoreSchemeEditControl extends
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    37
    SettingsControl<CoreAdmPanelDescriptor, CustomCoreSchemeEditPanel> {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    38
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    39
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    40
    // Static data
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    41
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    42
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    43
    public static final String ID = "custom";
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    44
    public static final String NAME = Finder.getString(
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    45
	"settings.scheme.custom.title");
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    46
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    47
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    48
    // Instance data
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    49
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    50
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    51
    private MutableProperty<CoreConfig> configProperty;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    52
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    53
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    54
    // Constructors
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    55
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    56
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    57
    public CustomCoreSchemeEditControl(CoreAdmPanelDescriptor descriptor,
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    58
        MutableProperty<CoreConfig> configProperty) {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    59
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    60
	super(ID, NAME, descriptor);
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    61
	this.configProperty = configProperty;
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    62
    }
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    63
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    64
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    65
    // Control methods
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    66
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    67
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    68
    @Override
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    69
    public String getHelpMapID() {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    70
	return "coreadm-custom";
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    71
    }
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    72
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    73
    @Override
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    74
    protected void save() throws ActionAbortedException, ActionFailedException,
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    75
	ActionUnauthorizedException {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    76
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    77
	CoreConfig value = getComponent().getConfig();
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    78
	CoreAdmPanelDescriptor descriptor = getPanelDescriptor();
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    79
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    80
	try {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    81
	    value.write(descriptor.getService());
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    82
	} catch (ScfException e) {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    83
	    SmfUtil.throwActionException(e);
2805
4888f6212f94 17510631 Backport 16984138 to 11.2 - vp components must change to match RAD2 enhancements
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 827
diff changeset
    84
	} catch (RadPrivilegeException e) {
827
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    85
	    throw new ActionUnauthorizedException(e);
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    86
	}
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    87
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    88
	configProperty.setValue(getComponent().getConfig());
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    89
	if (configProperty.isChanged()) {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    90
	    configProperty.save();
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    91
	}
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    92
	super.save();
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    93
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    94
	descriptor.setCoreConfig(value);
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    95
    }
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    96
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    97
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    98
    // SwingControl methods
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
    99
    //
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   100
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   101
    @Override
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   102
    protected void configComponent(CustomCoreSchemeEditPanel panel) {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   103
	super.configComponent(panel);
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   104
	addDefaultCancelAction(false);
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   105
	addDefaultOkayAction(false);
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   106
	addDefaultHelpAction();
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   107
    }
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   108
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   109
    @Override
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   110
    protected CustomCoreSchemeEditPanel createComponent() {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   111
	return new CustomCoreSchemeEditPanel();
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   112
    }
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   113
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   114
    @Override
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   115
    protected void initComponent() {
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   116
	getComponent().init(configProperty.getSavedValue(),
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   117
	    configProperty.getValue());
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   118
    }
0944d8c0158b 7169052 Integrate Visual Panels into Userland
Dan Labrecque <dan.labrecque@oracle.com>
parents:
diff changeset
   119
}