usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/smf/ServiceSettingsControl.java
author Stephen Talley <stephen.talley@oracle.com>
Thu, 22 Jul 2010 10:10:18 -0400
changeset 547 e1d8b4ddb166
parent 493 b722c21cb2c3
child 552 8782ebc01e1f
permissions -rw-r--r--
16625 SwingSettingsControl does not follow naming conventions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
547
e1d8b4ddb166 16625 SwingSettingsControl does not follow naming conventions
Stephen Talley <stephen.talley@oracle.com>
parents: 493
diff changeset
    23
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
package org.opensolaris.os.vp.panel.swing.smf;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 292
diff changeset
    28
import java.util.List;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    29
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
    30
import org.opensolaris.os.vp.panel.common.action.ActionFailedException;
286
49d494dc998e 8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents: 282
diff changeset
    31
import org.opensolaris.os.vp.panel.common.smf.SmfMutableProperty;
547
e1d8b4ddb166 16625 SwingSettingsControl does not follow naming conventions
Stephen Talley <stephen.talley@oracle.com>
parents: 493
diff changeset
    32
import org.opensolaris.os.vp.panel.swing.control.SettingsControl;
282
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    33
import org.opensolaris.os.vp.util.misc.*;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    34
292
d3c921786c1d 8634 ServiceSettingsTab and ServiceStatusTab aren't tabs, necessarily
Stephen Talley <stephen.talley@sun.com>
parents: 286
diff changeset
    35
public class ServiceSettingsControl extends
547
e1d8b4ddb166 16625 SwingSettingsControl does not follow naming conventions
Stephen Talley <stephen.talley@oracle.com>
parents: 493
diff changeset
    36
    SettingsControl<ServiceSwingPanelDescriptor, ServiceSettingsPanel> {
282
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    37
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    38
    //
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    39
    // Static data
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    40
    //
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    41
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    42
    private static final String ID = "settings";
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    43
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    44
    private static final String NAME =
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    45
	Finder.getString("service.settings.name");
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    46
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    47
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    48
    // Constructors
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    49
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    50
292
d3c921786c1d 8634 ServiceSettingsTab and ServiceStatusTab aren't tabs, necessarily
Stephen Talley <stephen.talley@sun.com>
parents: 286
diff changeset
    51
    public ServiceSettingsControl(ServiceSwingPanelDescriptor descriptor,
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    52
	ServiceSettingsPanel panel) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    53
282
fdae7ad420be 8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
    54
	super(ID, NAME, descriptor);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    55
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    56
	setComponent(panel);
493
b722c21cb2c3 15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents: 310
diff changeset
    57
	addDefaultResetAction();
b722c21cb2c3 15803 SwingSettingsControl.addDefault*Action methods should only apply to that Control's SettingsPanel
Stephen Talley <stephen.talley@oracle.com>
parents: 310
diff changeset
    58
	addDefaultApplyAction();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    59
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    60
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    61
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    62
    // SwingControl methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    63
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    64
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    65
    @Override
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
    66
    protected void save() throws ActionFailedException {
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 292
diff changeset
    67
	List<Changeable> changeables =
286
49d494dc998e 8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents: 282
diff changeset
    68
	    getComponent().getChangeableAggregator().getChangeables();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    69
286
49d494dc998e 8622 DataWrapper classes should be split into MVC components
Stephen Talley <stephen.talley@sun.com>
parents: 282
diff changeset
    70
	for (Changeable changeable : changeables) {
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 292
diff changeset
    71
	    if (changeable instanceof SmfMutableProperty &&
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 292
diff changeset
    72
		changeable.isChanged()) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 292
diff changeset
    73
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    74
		try {
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 292
diff changeset
    75
		    ((SmfMutableProperty)changeable).saveToRepo();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    76
		} catch (ScfException e) {
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
    77
		    throw new ActionFailedException(e);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    78
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    79
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    80
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    81
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    82
}