18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
24 */ |
24 */ |
25 |
25 |
26 package com.oracle.solaris.vp.panels.browser.client.swing; |
26 package com.oracle.solaris.vp.panels.browser.client.swing; |
27 |
27 |
28 import java.beans.*; |
28 import java.beans.*; |
29 import java.util.*; |
29 import java.util.*; |
30 import java.util.logging.Level; |
30 import java.util.logging.Level; |
31 import com.oracle.solaris.rad.ObjectException; |
31 import com.oracle.solaris.rad.client.RadObjectException; |
32 import com.oracle.solaris.vp.panel.common.*; |
32 import com.oracle.solaris.vp.panel.common.*; |
33 import com.oracle.solaris.vp.panel.common.api.panel.*; |
33 import com.oracle.solaris.vp.panel.common.api.panel.*; |
34 import com.oracle.solaris.vp.panel.common.control.*; |
34 import com.oracle.solaris.vp.panel.common.control.*; |
35 import com.oracle.solaris.vp.panel.common.model.*; |
35 import com.oracle.solaris.vp.panel.common.model.*; |
36 import com.oracle.solaris.vp.panel.swing.control.PanelFrameControl; |
36 import com.oracle.solaris.vp.panel.swing.control.PanelFrameControl; |
50 |
50 |
51 private BrowserControl control_; |
51 private BrowserControl control_; |
52 private DefaultControl topControl; |
52 private DefaultControl topControl; |
53 private Map<String, PanelManagedObject> panels_ = |
53 private Map<String, PanelManagedObject> panels_ = |
54 new HashMap<String, PanelManagedObject>(); |
54 new HashMap<String, PanelManagedObject>(); |
55 private PanelMXBeanTracker panelBeanTracker; |
55 private PanelBeanTracker panelBeanTracker; |
56 |
56 |
57 private PropertyChangeListener beanListener = |
57 private PropertyChangeListener beanListener = |
58 new PropertyChangeListener() { |
58 new PropertyChangeListener() { |
59 @Override |
59 @Override |
60 public void propertyChange(PropertyChangeEvent event) { |
60 public void propertyChange(PropertyChangeEvent event) { |
72 public BrowserPanelDescriptor(String id, ClientContext context) |
72 public BrowserPanelDescriptor(String id, ClientContext context) |
73 throws TrackerException { |
73 throws TrackerException { |
74 |
74 |
75 super(id, context); |
75 super(id, context); |
76 |
76 |
77 panelBeanTracker = new PanelMXBeanTracker(getClientContext()); |
77 panelBeanTracker = new PanelBeanTracker(getClientContext()); |
78 panelBeanTracker.addPropertyChangeListener( |
78 panelBeanTracker.addPropertyChangeListener( |
79 MXBeanTracker.PROPERTY_BEAN, beanListener); |
79 BeanTracker.PROPERTY_BEAN, beanListener); |
80 |
80 |
81 beanChanged(); |
81 beanChanged(); |
82 |
82 |
83 control_ = new BrowserControl(this); |
83 control_ = new BrowserControl(this); |
84 topControl = new PanelFrameControl<BrowserPanelDescriptor>(this); |
84 topControl = new PanelFrameControl<BrowserPanelDescriptor>(this); |
110 public PanelManagedObject getPanel(String name) { |
110 public PanelManagedObject getPanel(String name) { |
111 return (panels_.get(name)); |
111 return (panels_.get(name)); |
112 } |
112 } |
113 |
113 |
114 private void beanChanged() { |
114 private void beanChanged() { |
115 PanelMXBean bean = panelBeanTracker.getBean(); |
115 Panel bean = panelBeanTracker.getBean(); |
116 |
116 |
117 panels_.clear(); |
117 panels_.clear(); |
118 clearChildren(); |
118 clearChildren(); |
119 |
119 |
120 if (bean != null) { |
120 if (bean != null) { |
121 try { |
121 try { |
122 for (String name : bean.getpanelNames()) { |
122 for (String name : bean.getpanelNames()) { |
123 try { |
123 try { |
124 CustomPanel custom = bean.getPanel(name, null); |
124 CustomPanel custom = bean.getPanel(name, null); |
125 panels_.put(name, new PanelManagedObject(custom)); |
125 panels_.put(name, new PanelManagedObject(custom)); |
126 } catch (ObjectException e) { |
126 } catch (RadObjectException e) { |
127 getLog().log(Level.SEVERE, |
127 getLog().log(Level.SEVERE, |
128 "could not load panel: " + name, e); |
128 "could not load panel: " + name, e); |
129 } |
129 } |
130 } |
130 } |
131 } catch (ObjectException e) { |
131 } catch (RadObjectException e) { |
132 getLog().log(Level.SEVERE, "could not get panel names", e); |
132 getLog().log(Level.SEVERE, "could not get panel names", e); |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 List<PanelManagedObject> list = |
136 List<PanelManagedObject> list = |