18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
24 */ |
24 */ |
25 |
25 |
26 package com.oracle.solaris.vp.panel.swing.smf; |
26 package com.oracle.solaris.vp.panel.swing.smf; |
27 |
27 |
28 import java.awt.*; |
28 import java.awt.*; |
29 import java.awt.event.*; |
29 import java.awt.event.*; |
30 import java.beans.*; |
30 import java.beans.*; |
31 import java.io.IOException; |
31 import java.io.IOException; |
32 import java.util.*; |
32 import java.util.*; |
33 import java.util.logging.*; |
33 import java.util.logging.*; |
34 import javax.management.*; |
|
35 import javax.swing.*; |
34 import javax.swing.*; |
36 import com.oracle.solaris.rad.jmx.RadNotification; |
|
37 import com.oracle.solaris.scf.common.ScfException; |
35 import com.oracle.solaris.scf.common.ScfException; |
38 import com.oracle.solaris.vp.panel.common.api.smf_old.*; |
36 import com.oracle.solaris.vp.panel.common.api.smf_old.*; |
39 import com.oracle.solaris.vp.panel.common.smf.*; |
37 import com.oracle.solaris.vp.panel.common.smf.*; |
40 import com.oracle.solaris.vp.util.misc.ArrayUtil; |
38 import com.oracle.solaris.vp.util.misc.ArrayUtil; |
41 import com.oracle.solaris.vp.util.misc.finder.Finder; |
39 import com.oracle.solaris.vp.util.misc.finder.Finder; |
96 private PropertyChangeListener serviceListener = |
94 private PropertyChangeListener serviceListener = |
97 new PropertyChangeListener() { |
95 new PropertyChangeListener() { |
98 @Override |
96 @Override |
99 public void propertyChange(PropertyChangeEvent event) { |
97 public void propertyChange(PropertyChangeEvent event) { |
100 serviceChanged(); |
98 serviceChanged(); |
101 } |
|
102 }; |
|
103 |
|
104 private NotificationListener notifyListener = |
|
105 new NotificationListener() { |
|
106 @Override |
|
107 public void handleNotification(Notification n, Object h) { |
|
108 final StateChange sc = |
|
109 ((RadNotification)n).getPayload(StateChange.class); |
|
110 |
|
111 EventQueue.invokeLater( |
|
112 new Runnable() { |
|
113 @Override |
|
114 public void run() { |
|
115 setServiceState(sc.getState(), |
|
116 sc.getNextState(), sc.getAuxState(), |
|
117 sc.getStateTime()); |
|
118 } |
|
119 }); |
|
120 } |
99 } |
121 }; |
100 }; |
122 |
101 |
123 // |
102 // |
124 // Constructors |
103 // Constructors |
219 public HyperlinkLabel getRestartLink() { |
198 public HyperlinkLabel getRestartLink() { |
220 return restart.getLabel(); |
199 return restart.getLabel(); |
221 } |
200 } |
222 |
201 |
223 public void init(ServiceTracker tracker) |
202 public void init(ServiceTracker tracker) |
224 throws InstanceNotFoundException, IOException { |
203 throws IOException { |
225 |
204 |
226 if (this.tracker != tracker) { |
205 if (this.tracker != tracker) { |
227 if (this.tracker != null) { |
206 if (this.tracker != null) { |
228 this.tracker.removePropertyChangeListener( |
207 this.tracker.removePropertyChangeListener( |
229 ServiceTracker.PROPERTY_SERVICE, serviceListener); |
208 ServiceTracker.PROPERTY_SERVICE, serviceListener); |
230 this.tracker.removeNotificationListener(notifyListener, |
|
231 SmfUtil.NOTIFY_FILTER_STATE_CHANGE, null); |
|
232 } |
209 } |
233 |
210 |
234 this.tracker = tracker; |
211 this.tracker = tracker; |
235 |
212 |
236 if (tracker != null) { |
213 if (tracker != null) { |
237 tracker.addPropertyChangeListener( |
214 tracker.addPropertyChangeListener( |
238 ServiceTracker.PROPERTY_SERVICE, serviceListener); |
215 ServiceTracker.PROPERTY_SERVICE, serviceListener); |
239 tracker.addNotificationListener(notifyListener, |
|
240 SmfUtil.NOTIFY_FILTER_STATE_CHANGE, null); |
|
241 } |
216 } |
242 |
217 |
243 serviceChanged(); |
218 serviceChanged(); |
244 } |
219 } |
245 } |
220 } |
404 private JTextArea createTextArea() { |
379 private JTextArea createTextArea() { |
405 return new FlowTextArea(); |
380 return new FlowTextArea(); |
406 } |
381 } |
407 |
382 |
408 private void serviceChanged() { |
383 private void serviceChanged() { |
409 ServiceMXBean service = tracker == null ? null : tracker.getService(); |
384 ServiceBean service = tracker == null ? null : tracker.getService(); |
410 |
385 |
411 Logger log = Logger.getLogger(getClass().getPackage().getName()); |
386 Logger log = Logger.getLogger(getClass().getPackage().getName()); |
412 |
387 |
413 boolean isInst = false; |
388 boolean isInst = false; |
414 if (service != null) { |
389 if (service != null) { |