18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
23 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Use is subject to license terms. |
|
25 */ |
24 */ |
26 |
25 |
27 package org.opensolaris.os.vp.panel.swing.smf; |
26 package org.opensolaris.os.vp.panel.swing.smf; |
28 |
27 |
29 import java.awt.Component; |
28 import java.awt.Component; |
30 import java.util.*; |
29 import java.util.*; |
31 import javax.swing.*; |
30 import javax.swing.*; |
32 import javax.swing.border.Border; |
31 import javax.swing.border.Border; |
33 import org.opensolaris.os.scf.common.*; |
32 import org.opensolaris.os.scf.common.ScfException; |
34 import org.opensolaris.os.smf.*; |
33 import org.opensolaris.os.smf.*; |
35 import org.opensolaris.os.vp.panel.common.smf.*; |
34 import org.opensolaris.os.vp.panel.common.smf.*; |
36 import org.opensolaris.os.vp.panel.swing.view.*; |
35 import org.opensolaris.os.vp.panel.swing.view.ChangeIndicator; |
37 import org.opensolaris.os.vp.util.misc.*; |
36 import org.opensolaris.os.vp.util.misc.*; |
38 import org.opensolaris.os.vp.util.swing.*; |
37 import org.opensolaris.os.vp.util.swing.*; |
39 import org.opensolaris.os.vp.util.swing.layout.*; |
38 import org.opensolaris.os.vp.util.swing.layout.*; |
40 |
39 |
41 @SuppressWarnings({"serial"}) |
40 @SuppressWarnings({"serial"}) |
60 AUTH_PROPS.add("modify_authorization"); |
59 AUTH_PROPS.add("modify_authorization"); |
61 AUTH_PROPS.add("value_authorization"); |
60 AUTH_PROPS.add("value_authorization"); |
62 AUTH_PROPS.add(AUTH_READ); |
61 AUTH_PROPS.add(AUTH_READ); |
63 } |
62 } |
64 |
63 |
65 private boolean empty_ = true; |
64 private boolean empty = true; |
66 private SmfServiceInfo serviceInfo; |
65 private HasService serviceInfo; |
67 |
66 |
68 // |
67 // |
69 // Constructors |
68 // Constructors |
70 // |
69 // |
71 |
70 |
72 public ServiceSettingsPanel() { |
71 public ServiceSettingsPanel() { |
73 } |
72 } |
74 |
73 |
75 public boolean isEmpty() |
74 public boolean isEmpty() { |
76 { |
75 return empty; |
77 return (empty_); |
76 } |
78 } |
77 |
79 |
78 public void init(HasService serviceInfo) throws ScfException { |
80 public void init(SmfServiceInfo serviceInfo) throws ScfException |
|
81 { |
|
82 this.serviceInfo = serviceInfo; |
79 this.serviceInfo = serviceInfo; |
83 JPanel form = createForm(); |
80 JPanel form = createForm(); |
84 setContent(form); |
81 setContent(form); |
85 } |
82 } |
86 |
83 |
96 tabs.setOpaque(false); |
93 tabs.setOpaque(false); |
97 SleekTabbedPaneUI tabui = new SleekTabbedPaneUI(); |
94 SleekTabbedPaneUI tabui = new SleekTabbedPaneUI(); |
98 tabui.setDrawContentBorder(true); |
95 tabui.setDrawContentBorder(true); |
99 tabs.setUI(tabui); |
96 tabs.setUI(tabui); |
100 |
97 |
101 Border empty = GUIUtil.getEmptyBorder(); |
98 Border emptyBorder = GUIUtil.getEmptyBorder(); |
102 int gap = GUIUtil.getHalfGap(); |
99 int gap = GUIUtil.getHalfGap(); |
103 |
100 |
104 ColumnLayoutConstraint c = new ColumnLayoutConstraint( |
101 ColumnLayoutConstraint c = new ColumnLayoutConstraint( |
105 HorizontalAnchor.FILL, gap); |
102 HorizontalAnchor.FILL, gap); |
106 |
103 |
112 |
109 |
113 List<PropertyGroup> pgs = new ArrayList<PropertyGroup>(); |
110 List<PropertyGroup> pgs = new ArrayList<PropertyGroup>(); |
114 pgs.addAll(service.getPropertyGroups()); |
111 pgs.addAll(service.getPropertyGroups()); |
115 Collections.sort(pgs, new Comparator<PropertyGroup>() { |
112 Collections.sort(pgs, new Comparator<PropertyGroup>() { |
116 public int compare(PropertyGroup o1, PropertyGroup o2) { |
113 public int compare(PropertyGroup o1, PropertyGroup o2) { |
117 return (o1.getName().compareTo(o2.getName())); |
114 return o1.getName().compareTo(o2.getName()); |
118 } |
115 } |
119 }); |
116 }); |
120 |
117 |
121 |
118 |
122 for (PropertyGroup pg : pgs) { |
119 for (PropertyGroup pg : pgs) { |
123 if (!pg.getType().equals("application")) |
120 if (!pg.getType().equals("application")) { |
124 continue; |
121 continue; |
|
122 } |
125 |
123 |
126 String pgName = pg.getName(); |
124 String pgName = pg.getName(); |
127 |
125 |
128 pNames.clear(); |
126 pNames.clear(); |
129 pNames.addAll(service.getPropertyNames(pg.getName())); |
127 pNames.addAll(service.getPropertyNames(pg.getName())); |
131 |
129 |
132 JPanel formPanel = null; |
130 JPanel formPanel = null; |
133 Form form = null; |
131 Form form = null; |
134 |
132 |
135 for (String pName : pNames) { |
133 for (String pName : pNames) { |
136 if (AUTH_PROPS.contains(pName)) |
134 if (AUTH_PROPS.contains(pName)) { |
137 continue; |
135 continue; |
|
136 } |
138 |
137 |
139 // XXX Should be a static final somewhere |
138 // XXX Should be a static final somewhere |
140 if (pName.equals("stability")) { |
139 if (pName.equals("stability")) { |
141 continue; |
140 continue; |
142 } |
141 } |
154 |
153 |
155 /* |
154 /* |
156 * There are a number of different ways to treat unreadable |
155 * There are a number of different ways to treat unreadable |
157 * properties. For now we just won't display them. |
156 * properties. For now we just won't display them. |
158 */ |
157 */ |
159 if (!view.property.isReadable()) |
158 if (!view.property.isReadable()) { |
160 continue; |
159 continue; |
|
160 } |
161 |
161 |
162 if (formPanel == null) { |
162 if (formPanel == null) { |
163 formPanel = new JPanel(); |
163 formPanel = new JPanel(); |
164 formPanel.setOpaque(true); |
164 formPanel.setOpaque(true); |
165 formPanel.setBackground( |
165 formPanel.setBackground( |
166 ColorUtil.darker(getBackground(), .05f)); |
166 ColorUtil.darker(getBackground(), .05f)); |
167 formPanel.setBorder(empty); |
167 formPanel.setBorder(emptyBorder); |
168 |
168 |
169 form = new Form(formPanel, VerticalAnchor.TOP); |
169 form = new Form(formPanel, VerticalAnchor.TOP); |
170 form.addTable(3, gap, gap, HorizontalAnchor.FILL, c); |
170 form.addTable(3, gap, gap, HorizontalAnchor.FILL, c); |
171 } |
171 } |
172 |
172 |
189 |
189 |
190 JPanel panel = new JPanel(new ColumnLayout(VerticalAnchor.TOP)); |
190 JPanel panel = new JPanel(new ColumnLayout(VerticalAnchor.TOP)); |
191 panel.setOpaque(false); |
191 panel.setOpaque(false); |
192 |
192 |
193 // If no properties were found... |
193 // If no properties were found... |
194 if (empty_ = (tabs.getTabCount() == 0)) { |
194 if (empty = (tabs.getTabCount() == 0)) { |
195 JLabel label = new JLabel(Finder.getString( |
195 JLabel label = new JLabel(Finder.getString( |
196 "service.settings.nosettings.label")); |
196 "service.settings.nosettings.label")); |
197 |
197 |
198 panel.add(label, c); |
198 panel.add(label, c); |
199 } else { |
199 } else { |