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) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panel.swing.control; |
|
27 |
|
28 import java.awt.Component; |
|
29 import javax.swing.JScrollPane; |
|
30 import com.oracle.solaris.vp.panel.common.ClientContext; |
|
31 import com.oracle.solaris.vp.panel.common.model.*; |
|
32 import com.oracle.solaris.vp.panel.swing.model.ManagedObjectPropInfo; |
|
33 import com.oracle.solaris.vp.panel.swing.view.*; |
|
34 import com.oracle.solaris.vp.util.common.propinfo.*; |
|
35 import com.oracle.solaris.vp.util.misc.finder.Finder; |
|
36 import com.oracle.solaris.vp.util.swing.ExtScrollPane; |
|
37 |
|
38 public class DebugObjectsTab extends SwingControl<PanelDescriptor, JScrollPane> |
|
39 { |
|
40 // |
|
41 // Inner classes |
|
42 // |
|
43 |
|
44 public static class ClassPropInfo |
|
45 extends AbstractPropInfo<ManagedObject, String> { |
|
46 |
|
47 // |
|
48 // Static data |
|
49 // |
|
50 |
|
51 private static final String LABEL = |
|
52 Finder.getString("property.label.class"); |
|
53 |
|
54 private static final String DESCRIPTION = |
|
55 Finder.getString("property.description.class"); |
|
56 |
|
57 /** |
|
58 * Available instance to mitigate object creation |
|
59 */ |
|
60 public static final ClassPropInfo instance = new ClassPropInfo(); |
|
61 |
|
62 // |
|
63 // Constructors |
|
64 // |
|
65 |
|
66 public ClassPropInfo() { |
|
67 super(LABEL, DESCRIPTION, true, false); |
|
68 } |
|
69 |
|
70 // |
|
71 // PropInfo methods |
|
72 // |
|
73 |
|
74 @Override |
|
75 public String getValue(ManagedObject o) { |
|
76 return o.getClass().getName(); |
|
77 } |
|
78 } |
|
79 |
|
80 // |
|
81 // Static data |
|
82 // |
|
83 |
|
84 private static final String ID = "objects-debug"; |
|
85 |
|
86 private static final String ID_LABEL = |
|
87 Finder.getString("property.label.id"); |
|
88 |
|
89 private static final String ID_DESCRIPTION = |
|
90 Finder.getString("property.description.id"); |
|
91 |
|
92 @SuppressWarnings({"unchecked"}) |
|
93 protected static final PropInfo<ManagedObject, ?>[] |
|
94 PROPERTIES = new PropInfo[] { |
|
95 ManagedObjectPropInfo.instance, |
|
96 new ReflectionPropInfo(ID_LABEL, ID_DESCRIPTION, true, false, "id"), |
|
97 ClassPropInfo.instance, |
|
98 }; |
|
99 |
|
100 // |
|
101 // Instance data |
|
102 // |
|
103 |
|
104 private ManagedObject pObject; |
|
105 private ManagedObjectTreeTable table; |
|
106 |
|
107 // |
|
108 // Constructors |
|
109 // |
|
110 |
|
111 public DebugObjectsTab(ClientContext context, ManagedObject pObject) { |
|
112 super(ID, pObject.getName(), context); |
|
113 this.pObject = pObject; |
|
114 } |
|
115 |
|
116 public DebugObjectsTab(PanelDescriptor descriptor) { |
|
117 super(ID, descriptor.getName(), descriptor); |
|
118 this.pObject = descriptor; |
|
119 } |
|
120 |
|
121 // |
|
122 // SwingControl methods |
|
123 // |
|
124 |
|
125 @Override |
|
126 protected JScrollPane createComponent() { |
|
127 ManagedObjectTreeTableModel model = |
|
128 new ManagedObjectTreeTableModel(pObject, PROPERTIES); |
|
129 |
|
130 table = new ManagedObjectTreeTable(model, null, null); |
|
131 return new ExtScrollPane(table); |
|
132 } |
|
133 |
|
134 // |
|
135 // DebugObjectsTab methods |
|
136 // |
|
137 |
|
138 public ManagedObjectTreeTable getTable() { |
|
139 return table; |
|
140 } |
|
141 } |
|