author | Stephen Talley <stephen.talley@oracle.com> |
Thu, 22 Jul 2010 10:10:18 -0400 | |
changeset 547 | e1d8b4ddb166 |
parent 545 | 7a29a25b92e2 |
child 591 | 7c5752b99fd6 |
permissions | -rw-r--r-- |
0 | 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 |
/* |
|
545
7a29a25b92e2
14830 smf: panel doesn't react well to failed server connection
Stephen Talley <stephen.talley@oracle.com>
parents:
493
diff
changeset
|
23 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 24 |
*/ |
25 |
||
219
57841c113efe
6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents:
214
diff
changeset
|
26 |
package org.opensolaris.os.vp.panels.coreadm.client.swing; |
0 | 27 |
|
28 |
import java.awt.Component; |
|
29 |
import java.awt.event.*; |
|
196
4aefd5567f1e
4364 sysid: resolve SysIdUtil.createNPException
Stephen Talley <stephen.talley@sun.com>
parents:
193
diff
changeset
|
30 |
import java.net.URL; |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
31 |
import java.util.Map; |
0 | 32 |
import org.opensolaris.os.scf.common.ScfException; |
40
d1412af1ae5b
3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents:
39
diff
changeset
|
33 |
import org.opensolaris.os.vp.panel.common.action.*; |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
34 |
import org.opensolaris.os.vp.panel.common.control.*; |
545
7a29a25b92e2
14830 smf: panel doesn't react well to failed server connection
Stephen Talley <stephen.talley@oracle.com>
parents:
493
diff
changeset
|
35 |
import org.opensolaris.os.vp.panel.common.smf.SmfUtil; |
40
d1412af1ae5b
3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents:
39
diff
changeset
|
36 |
import org.opensolaris.os.vp.panel.swing.control.*; |
282
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
37 |
import org.opensolaris.os.vp.util.misc.Finder; |
286
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
38 |
import org.opensolaris.os.vp.util.misc.property.MutableProperty; |
219
57841c113efe
6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents:
214
diff
changeset
|
39 |
import org.opensolaris.os.vp.util.swing.ReplacingStackPanel; |
0 | 40 |
|
41 |
public class CoreAdmSettingsTab |
|
547
e1d8b4ddb166
16625 SwingSettingsControl does not follow naming conventions
Stephen Talley <stephen.talley@oracle.com>
parents:
545
diff
changeset
|
42 |
extends SettingsControl<CoreAdmPanelDescriptor, CoreAdmSettingsPanel> |
282
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
43 |
implements HasTabComponent { |
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
44 |
|
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
45 |
// |
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
46 |
// Static data |
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
47 |
// |
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
48 |
|
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
49 |
private static final String ID = "settings"; |
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
50 |
private static final String NAME = Finder.getString("settings.name"); |
0 | 51 |
|
52 |
// |
|
53 |
// Instance data |
|
54 |
// |
|
55 |
||
186
8cfd884301c7
5572 performance: prefer ReplacingStackPanel to OverlappingStackPanel where possible
Stephen Talley <stephen.talley@sun.com>
parents:
171
diff
changeset
|
56 |
private ReplacingStackPanel stack = new ReplacingStackPanel(); |
0 | 57 |
|
58 |
// |
|
59 |
// Constructors |
|
60 |
// |
|
61 |
||
62 |
public CoreAdmSettingsTab(CoreAdmPanelDescriptor descriptor) { |
|
282
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
63 |
super(ID, NAME, descriptor); |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
64 |
|
244
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
65 |
CoreAdmSettingsPanel panel = createComponent(); |
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
66 |
setComponent(panel); |
0 | 67 |
|
259
8ca1bf7a5dd9
7991 DefaultControl.addChild should accept multiple Control arguments
Stephen Talley <stephen.talley@sun.com>
parents:
244
diff
changeset
|
68 |
addChildren(new CustomCoreSchemeEditControl(descriptor, |
286
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
69 |
panel.getConfigProperty())); |
0 | 70 |
} |
71 |
||
72 |
// |
|
282
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
73 |
// HasTabComponent methods |
0 | 74 |
// |
75 |
||
76 |
@Override |
|
77 |
public Component getTabComponent() { |
|
78 |
return stack; |
|
79 |
} |
|
80 |
||
81 |
// |
|
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
82 |
// Control methods |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
83 |
// |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
84 |
|
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
85 |
@Override |
360
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
310
diff
changeset
|
86 |
public URL getHelpURL() { |
454
4810858eb6ad
14809 coreadm: help text should be updated to account for new UI design (source code update)
Stephen Talley <stephen.talley@sun.com>
parents:
407
diff
changeset
|
87 |
return buildHelpURL("help/coreadm-settings.html", null); |
360
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
310
diff
changeset
|
88 |
} |
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
310
diff
changeset
|
89 |
|
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
310
diff
changeset
|
90 |
@Override |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
91 |
protected void save() throws ActionAbortedException, ActionFailedException, |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
92 |
ActionUnauthorizedException { |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
93 |
|
286
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
94 |
MutableProperty<CoreConfig> property = |
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
95 |
getComponent().getConfigProperty(); |
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
96 |
|
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
97 |
CoreConfig value = property.getValue(); |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
98 |
CoreAdmPanelDescriptor descriptor = getPanelDescriptor(); |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
99 |
|
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
100 |
try { |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
101 |
value.write(descriptor.getService()); |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
102 |
} catch (ScfException e) { |
545
7a29a25b92e2
14830 smf: panel doesn't react well to failed server connection
Stephen Talley <stephen.talley@oracle.com>
parents:
493
diff
changeset
|
103 |
SmfUtil.throwActionException(e); |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
104 |
} catch (SecurityException e) { |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
105 |
throw new ActionUnauthorizedException(e); |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
106 |
} |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
107 |
|
286
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
108 |
if (property.isChanged()) |
49d494dc998e
8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents:
282
diff
changeset
|
109 |
property.save(); |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
110 |
super.save(); |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
111 |
|
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
112 |
descriptor.setCoreConfig(value); |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
113 |
} |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
114 |
|
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
115 |
@Override |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
116 |
public void start(Navigator navigator, Map<String, String> parameters) |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
117 |
throws NavigationAbortedException, InvalidParameterException { |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
118 |
|
298
cc0001e49171
8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents:
295
diff
changeset
|
119 |
setPropertyChangeSource(getPanelDescriptor()); |
266
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
120 |
super.start(navigator, parameters); |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
121 |
} |
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
122 |
|
b6e25669b646
7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents:
263
diff
changeset
|
123 |
// |
0 | 124 |
// SwingControl methods |
125 |
// |
|
126 |
||
127 |
@Override |
|
493
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
128 |
protected void configComponent(CoreAdmSettingsPanel panel) { |
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
129 |
super.configComponent(panel); |
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
130 |
addDefaultResetAction(); |
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
131 |
addDefaultApplyAction(); |
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
132 |
addDefaultHelpAction(true); |
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
133 |
} |
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
134 |
|
b722c21cb2c3
15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents:
454
diff
changeset
|
135 |
@Override |
244
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
136 |
protected CoreAdmSettingsPanel createComponent() { |
0 | 137 |
CoreAdmSettingsPanel panel = new CoreAdmSettingsPanel(); |
138 |
panel.getCustomEditButton().addActionListener( |
|
139 |
new ActionListener() { |
|
140 |
@Override |
|
141 |
public void actionPerformed(ActionEvent e) { |
|
275
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
266
diff
changeset
|
142 |
Navigable navigable = new SimpleNavigable( |
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
266
diff
changeset
|
143 |
CustomCoreSchemeEditControl.ID, null); |
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
266
diff
changeset
|
144 |
|
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
298
diff
changeset
|
145 |
getNavigator().goToAsync(false, CoreAdmSettingsTab.this, |
275
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
266
diff
changeset
|
146 |
navigable); |
0 | 147 |
} |
148 |
}); |
|
149 |
||
150 |
stack.push(panel); |
|
151 |
setComponentStack(stack); |
|
152 |
||
244
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
153 |
return panel; |
0 | 154 |
} |
155 |
||
156 |
@Override |
|
80
9256ce8453d7
3497 SwingControl methods are too permissive
Stephen Talley <stephen.talley@sun.com>
parents:
56
diff
changeset
|
157 |
protected void initComponent() { |
223
aa68c366f3d0
6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
158 |
getComponent().init(getPanelDescriptor()); |
26
8a459d117e4a
2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents:
20
diff
changeset
|
159 |
} |
0 | 160 |
} |