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, 2013, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panels.coreadm.client.swing; |
|
27 |
|
28 import com.oracle.solaris.rad.client.RadPrivilegeException; |
|
29 import com.oracle.solaris.scf.common.ScfException; |
|
30 import com.oracle.solaris.vp.panel.common.action.*; |
|
31 import com.oracle.solaris.vp.panel.common.smf.SmfUtil; |
|
32 import com.oracle.solaris.vp.panel.swing.control.SettingsControl; |
|
33 import com.oracle.solaris.vp.util.misc.finder.Finder; |
|
34 import com.oracle.solaris.vp.util.misc.property.MutableProperty; |
|
35 |
|
36 public class CustomCoreSchemeEditControl extends |
|
37 SettingsControl<CoreAdmPanelDescriptor, CustomCoreSchemeEditPanel> { |
|
38 |
|
39 // |
|
40 // Static data |
|
41 // |
|
42 |
|
43 public static final String ID = "custom"; |
|
44 public static final String NAME = Finder.getString( |
|
45 "settings.scheme.custom.title"); |
|
46 |
|
47 // |
|
48 // Instance data |
|
49 // |
|
50 |
|
51 private MutableProperty<CoreConfig> configProperty; |
|
52 |
|
53 // |
|
54 // Constructors |
|
55 // |
|
56 |
|
57 public CustomCoreSchemeEditControl(CoreAdmPanelDescriptor descriptor, |
|
58 MutableProperty<CoreConfig> configProperty) { |
|
59 |
|
60 super(ID, NAME, descriptor); |
|
61 this.configProperty = configProperty; |
|
62 } |
|
63 |
|
64 // |
|
65 // Control methods |
|
66 // |
|
67 |
|
68 @Override |
|
69 public String getHelpMapID() { |
|
70 return "coreadm-custom"; |
|
71 } |
|
72 |
|
73 @Override |
|
74 protected void save() throws ActionAbortedException, ActionFailedException, |
|
75 ActionUnauthorizedException { |
|
76 |
|
77 CoreConfig value = getComponent().getConfig(); |
|
78 CoreAdmPanelDescriptor descriptor = getPanelDescriptor(); |
|
79 |
|
80 try { |
|
81 value.write(descriptor.getService()); |
|
82 } catch (ScfException e) { |
|
83 SmfUtil.throwActionException(e); |
|
84 } catch (RadPrivilegeException e) { |
|
85 throw new ActionUnauthorizedException(e); |
|
86 } |
|
87 |
|
88 configProperty.setValue(getComponent().getConfig()); |
|
89 if (configProperty.isChanged()) { |
|
90 configProperty.save(); |
|
91 } |
|
92 super.save(); |
|
93 |
|
94 descriptor.setCoreConfig(value); |
|
95 } |
|
96 |
|
97 // |
|
98 // SwingControl methods |
|
99 // |
|
100 |
|
101 @Override |
|
102 protected void configComponent(CustomCoreSchemeEditPanel panel) { |
|
103 super.configComponent(panel); |
|
104 addDefaultCancelAction(false); |
|
105 addDefaultOkayAction(false); |
|
106 addDefaultHelpAction(); |
|
107 } |
|
108 |
|
109 @Override |
|
110 protected CustomCoreSchemeEditPanel createComponent() { |
|
111 return new CustomCoreSchemeEditPanel(); |
|
112 } |
|
113 |
|
114 @Override |
|
115 protected void initComponent() { |
|
116 getComponent().init(configProperty.getSavedValue(), |
|
117 configProperty.getValue()); |
|
118 } |
|
119 } |
|