|
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.panel.swing.smf; |
|
27 |
|
28 import java.awt.Component; |
|
29 import java.io.IOException; |
|
30 import java.util.logging.*; |
|
31 import javax.management.InstanceNotFoundException; |
|
32 import com.oracle.solaris.vp.panel.common.model.PanelDescriptor; |
|
33 import com.oracle.solaris.vp.panel.common.smf.*; |
|
34 import com.oracle.solaris.vp.panel.swing.control.SettingsControl; |
|
35 import com.oracle.solaris.vp.util.misc.finder.Finder; |
|
36 |
|
37 public class SmfStatusControl<P extends PanelDescriptor> |
|
38 extends SettingsControl<P, SmfStatusPanel> { |
|
39 |
|
40 // |
|
41 // Static data |
|
42 // |
|
43 |
|
44 private static final String ID = "status"; |
|
45 |
|
46 private static final String NAME = |
|
47 Finder.getString("service.status.name"); |
|
48 |
|
49 // |
|
50 // Instance data |
|
51 // |
|
52 |
|
53 private HasServiceTracker hasTracker; |
|
54 |
|
55 // |
|
56 // Constructors |
|
57 // |
|
58 |
|
59 public SmfStatusControl(P descriptor, HasServiceTracker hasTracker) { |
|
60 super(ID, NAME, descriptor); |
|
61 this.hasTracker = hasTracker; |
|
62 } |
|
63 |
|
64 // |
|
65 // SwingControl methods |
|
66 // |
|
67 |
|
68 @Override |
|
69 protected SmfStatusPanel createComponent() { |
|
70 return new SmfStatusPanel(); |
|
71 } |
|
72 |
|
73 @Override |
|
74 protected void deinitComponent() { |
|
75 doInit(null); |
|
76 } |
|
77 |
|
78 @Override |
|
79 protected void initComponent() { |
|
80 doInit(hasTracker.getServiceTracker()); |
|
81 } |
|
82 |
|
83 // |
|
84 // Private methods |
|
85 // |
|
86 |
|
87 private void doInit(ServiceTracker tracker) { |
|
88 Exception t = null; |
|
89 |
|
90 try { |
|
91 getComponent().init(tracker); |
|
92 } catch (InstanceNotFoundException e) { |
|
93 t = e; |
|
94 } catch (IOException e) { |
|
95 t = e; |
|
96 } |
|
97 |
|
98 if (t != null) { |
|
99 Logger.getLogger(getClass().getPackage().getName()).log( |
|
100 Level.SEVERE, "error instantiating status component", t); |
|
101 } |
|
102 } |
|
103 } |