|
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 SmfLogControl<P extends PanelDescriptor> |
|
38 extends SettingsControl<P, SmfLogPanel> { |
|
39 |
|
40 // |
|
41 // Static data |
|
42 // |
|
43 |
|
44 private static final String ID = "log"; |
|
45 private static final String NAME = Finder.getString("service.log.name"); |
|
46 |
|
47 // |
|
48 // Instance data |
|
49 // |
|
50 |
|
51 private HasServiceTracker tracker; |
|
52 |
|
53 // |
|
54 // Constructors |
|
55 // |
|
56 |
|
57 public SmfLogControl(P descriptor, HasServiceTracker tracker) { |
|
58 super(ID, NAME, descriptor); |
|
59 this.tracker = tracker; |
|
60 } |
|
61 |
|
62 // |
|
63 // SwingControl methods |
|
64 // |
|
65 |
|
66 @Override |
|
67 protected SmfLogPanel createComponent() { |
|
68 return new SmfLogPanel(); |
|
69 } |
|
70 |
|
71 @Override |
|
72 protected void deinitComponent() { |
|
73 doInit(null); |
|
74 } |
|
75 |
|
76 @Override |
|
77 protected void initComponent() { |
|
78 doInit(tracker.getServiceTracker()); |
|
79 } |
|
80 |
|
81 // |
|
82 // Private methods |
|
83 // |
|
84 |
|
85 private void doInit(ServiceTracker tracker) { |
|
86 Exception t = null; |
|
87 |
|
88 try { |
|
89 getComponent().init(tracker); |
|
90 } catch (InstanceNotFoundException e) { |
|
91 t = e; |
|
92 } catch (IOException e) { |
|
93 t = e; |
|
94 } |
|
95 |
|
96 if (t != null) { |
|
97 Logger.getLogger(getClass().getPackage().getName()).log( |
|
98 Level.SEVERE, "error instantiating log component", t); |
|
99 } |
|
100 } |
|
101 } |