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, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panels.firewall.client.swing; |
|
27 |
|
28 import javax.swing.JPanel; |
|
29 import com.oracle.solaris.vp.panel.swing.view.ChangeIndicator; |
|
30 import com.oracle.solaris.vp.panels.firewall.client.swing.AccessPolicy.Type; |
|
31 import com.oracle.solaris.vp.util.misc.ChangeableAggregator; |
|
32 import com.oracle.solaris.vp.util.swing.*; |
|
33 import com.oracle.solaris.vp.util.swing.layout.*; |
|
34 |
|
35 @SuppressWarnings({"serial"}) |
|
36 public class CommonEditPanel extends SettingsPanel { |
|
37 // |
|
38 // Instance data |
|
39 // |
|
40 |
|
41 private AccessProperty accessProperty; |
|
42 |
|
43 // |
|
44 // Constructors |
|
45 // |
|
46 |
|
47 public CommonEditPanel(boolean doDefault, String panelDesc) { |
|
48 getHelpField().setText(panelDesc); |
|
49 if (doDefault) |
|
50 setUpDefaultPanel(); |
|
51 } |
|
52 |
|
53 // |
|
54 // CommonEditPanel methods |
|
55 // |
|
56 |
|
57 protected JPanel createForm() { |
|
58 ChangeableAggregator aggregator = getChangeableAggregator(); |
|
59 |
|
60 ChangeIndicator accessChange = new ChangeIndicator(); |
|
61 accessProperty.addChangeListener(accessChange); |
|
62 aggregator.addChangeables(accessProperty); |
|
63 |
|
64 JPanel formPanel = new JPanel(); |
|
65 formPanel.setOpaque(false); |
|
66 Form form = new Form(formPanel, VerticalAnchor.TOP); |
|
67 |
|
68 int gap = GUIUtil.getHalfGap(); |
|
69 |
|
70 ColumnLayoutConstraint c = new ColumnLayoutConstraint( |
|
71 HorizontalAnchor.FILL, gap); |
|
72 |
|
73 RowLayoutConstraint r = new RowLayoutConstraint( |
|
74 VerticalAnchor.TOP, gap); |
|
75 r.setLayoutIfInvisible(true); |
|
76 |
|
77 form.addRow(HorizontalAnchor.LEFT, c); |
|
78 form.add(accessProperty.getPanel(), r); |
|
79 form.add(accessChange, r); |
|
80 |
|
81 return formPanel; |
|
82 } |
|
83 |
|
84 protected void setUpPanel(Type... types) { |
|
85 accessProperty = new AccessProperty(types); |
|
86 |
|
87 JPanel form = createForm(); |
|
88 setContent(form, false, true); |
|
89 } |
|
90 |
|
91 protected void setUpDefaultPanel() { |
|
92 setUpPanel(Type.USE_GLOBAL, Type.DENY, Type.ALLOW, Type.NONE); |
|
93 } |
|
94 |
|
95 public void setAccessProperty(AccessProperty accessProperty) { |
|
96 this.accessProperty = accessProperty; |
|
97 } |
|
98 |
|
99 public AccessProperty getAccessProperty() { |
|
100 return accessProperty; |
|
101 } |
|
102 |
|
103 public void init(AccessPolicy policy) { |
|
104 accessProperty.update(policy, false); |
|
105 } |
|
106 |
|
107 public void setPanelDescriptor(FirewallPanelDescriptor descriptor) { |
|
108 accessProperty.setPanelDescriptor(descriptor); |
|
109 } |
|
110 } |
|