components/visual-panels/apache/src/java/vpanels/app/apache/com/oracle/solaris/vp/panels/apache/client/swing/VirtualHostSSLControl.java
changeset 3553 f1d133b09a8c
parent 3552 077ebe3d0d24
child 3554 ef58713bafc4
equal deleted inserted replaced
3552:077ebe3d0d24 3553:f1d133b09a8c
     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) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
       
    24  */
       
    25 
       
    26 package com.oracle.solaris.vp.panels.apache.client.swing;
       
    27 
       
    28 import java.awt.Component;
       
    29 import java.util.Map;
       
    30 import com.oracle.solaris.vp.panel.common.control.*;
       
    31 import com.oracle.solaris.vp.panel.swing.control.SettingsControl;
       
    32 import com.oracle.solaris.vp.util.misc.finder.Finder;
       
    33 import com.oracle.solaris.vp.util.misc.property.MutableProperty;
       
    34 
       
    35 public class VirtualHostSSLControl
       
    36     extends SettingsControl<ApachePanelDescriptor, VirtualHostSSLPanel> {
       
    37 
       
    38     //
       
    39     // Static data
       
    40     //
       
    41 
       
    42     public static final String ID = "ssl";
       
    43     public static final String NAME = Finder.getString("vhost.ssl.name");
       
    44 
       
    45     //
       
    46     // Instance data
       
    47     //
       
    48 
       
    49     private VirtualHostControl parent;
       
    50 
       
    51     //
       
    52     // Constructors
       
    53     //
       
    54 
       
    55     public VirtualHostSSLControl(VirtualHostControl parent) {
       
    56 	super(ID, NAME, parent.getPanelDescriptor());
       
    57 	this.parent = parent;
       
    58     }
       
    59 
       
    60     //
       
    61     // Control methods
       
    62     //
       
    63 
       
    64     @Override
       
    65     public String getHelpMapID() {
       
    66 	return "apache-vhosts-ssl";
       
    67     }
       
    68 
       
    69     @Override
       
    70     protected UnsavedChangesAction getUnsavedChangesAction() {
       
    71 	// Automatically save changes to the VirtualHost -- let MainControl
       
    72 	// prompt the user to save them to the repo
       
    73 	return UnsavedChangesAction.SAVE;
       
    74     }
       
    75 
       
    76     @Override
       
    77     protected boolean isChanged() {
       
    78 	// Save unconditionally, since a property that reports itself as
       
    79 	// unchanged in the panel may still be changed from the corresponding
       
    80 	// property in the VirtualHost.  Alternatively, we could compare each
       
    81 	// panel property to its VirtualHost counterpart and save only if there
       
    82 	// are differences, but this is easier and save() has low overhead.
       
    83 	return true;
       
    84     }
       
    85 
       
    86     @Override
       
    87     protected void save() {
       
    88 	setPropertyChangeIgnore(true);
       
    89 
       
    90 	try {
       
    91 	    VirtualHost vHost = parent.getVirtualHost();
       
    92 	    VirtualHostSSLPanel panel = getComponent();
       
    93 
       
    94 	    vHost.getSslEnabledProperty().setFirstValue(
       
    95 		panel.getEnabledProperty().getValue());
       
    96 
       
    97 	    vHost.getSslIpProperty().setFirstValue(
       
    98 		panel.getIpProperty().getValue());
       
    99 
       
   100 	    vHost.getSslCertProperty().setFirstValue(
       
   101 		panel.getCertProperty().getValue());
       
   102 
       
   103 	    vHost.getSslKeyProperty().setFirstValue(
       
   104 		panel.getKeyProperty().getValue());
       
   105 
       
   106 	    vHost.getSslPortProperty().setFirstValue(
       
   107 		panel.getPortProperty().getValue());
       
   108 	} finally {
       
   109 	    setPropertyChangeIgnore(false);
       
   110 	}
       
   111     }
       
   112 
       
   113     @Override
       
   114     public void start(Navigator navigator, Map<String, String> parameters)
       
   115 	throws NavigationAbortedException, InvalidParameterException,
       
   116 	NavigationFailedException {
       
   117 
       
   118 	setPropertyChangeSource(parent.getVirtualHost(),
       
   119 	    VirtualHost.PROPERTY_SSL_ENABLED,
       
   120 	    VirtualHost.PROPERTY_SSL_IP,
       
   121 	    VirtualHost.PROPERTY_SSL_PORT,
       
   122 	    VirtualHost.PROPERTY_SSL_CERT,
       
   123 	    VirtualHost.PROPERTY_SSL_KEY);
       
   124 
       
   125 	super.start(navigator, parameters);
       
   126     }
       
   127 
       
   128     //
       
   129     // SwingControl methods
       
   130     //
       
   131 
       
   132     @Override
       
   133     protected VirtualHostSSLPanel createComponent() {
       
   134 	VirtualHostSSLPanel panel = new VirtualHostSSLPanel();
       
   135 	return panel;
       
   136     }
       
   137 
       
   138     @Override
       
   139     protected void deinitComponent() {
       
   140 	getComponent().init(null);
       
   141     }
       
   142 
       
   143     @Override
       
   144     protected void initComponent() {
       
   145 	VirtualHost vHost = parent.getVirtualHost();
       
   146 	VirtualHostSSLPanel panel = getComponent();
       
   147 	panel.getChangeableAggregator().reset();
       
   148 	panel.init(vHost);
       
   149     }
       
   150 }