|
25 | 25 | package org.graalvm.visualvm.lib.profiler.snaptracer.impl;
|
26 | 26 |
|
27 | 27 | import java.io.IOException;
|
28 |
| -import java.lang.reflect.InvocationHandler; |
29 |
| -import java.lang.reflect.InvocationTargetException; |
30 |
| -import java.lang.reflect.Method; |
31 |
| -import java.lang.reflect.Proxy; |
32 | 28 | import java.util.HashMap;
|
33 | 29 | import java.util.List;
|
34 | 30 | import java.util.Map;
|
|
39 | 35 | import org.graalvm.visualvm.lib.profiler.SampledCPUSnapshot;
|
40 | 36 | import org.graalvm.visualvm.lib.profiler.snaptracer.logs.LogReader;
|
41 | 37 | import org.openide.filesystems.FileObject;
|
42 |
| -import org.openide.util.Exceptions; |
43 |
| -import org.openide.util.ImageUtilities; |
44 |
| -import org.openide.util.Lookup; |
45 | 38 |
|
46 | 39 | /** Reads xml log and npss snapshot from file.
|
47 | 40 | *
|
@@ -111,7 +104,6 @@ public LogRecordInfo getLogInfoForValue(long loggerValue) {
|
111 | 104 |
|
112 | 105 | assert rec != null : "Null record for value "+index; // NOI18N
|
113 | 106 | info = new LogRecordInfo(rec);
|
114 |
| - LogRecordDecorator.decorate(info); |
115 | 107 | infosMap.put(index, info);
|
116 | 108 | }
|
117 | 109 | return info;
|
@@ -212,69 +204,4 @@ public Icon getIcon() {
|
212 | 204 | return icon;
|
213 | 205 | }
|
214 | 206 | }
|
215 |
| - |
216 |
| - private static final class LogRecordDecorator implements InvocationHandler { |
217 |
| - |
218 |
| - private static final String DECORATIONS_CLASS = "org.netbeans.lib.uihandler.Decorations"; // NOI18N |
219 |
| - private static final String DECORABLE_CLASS = "org.netbeans.lib.uihandler.Decorable"; // NOI18N |
220 |
| - private static final String DECORATE_METHOD = "decorate"; // NOI18N |
221 |
| - private static final String DECORABLE_SETNAME_METHOD = "setName"; // NOI18N |
222 |
| - private static final String DECORABLE_SETDISPLAYNAME_METHOD = "setDisplayName"; // NOI18N |
223 |
| - private static final String DECORABLE_SETICONBASE_METHOD = "setIconBaseWithExtension"; // NOI18N |
224 |
| - private static final String DECORABLE_SETSHORTDESCRIPTOR_METHOD = "setShortDescription"; // NOI18N |
225 |
| - private LogRecordInfo recInfo; |
226 |
| - private LogRecord rec; |
227 |
| - |
228 |
| - LogRecordDecorator(LogRecordInfo info) { |
229 |
| - recInfo = info; |
230 |
| - rec = info.record; |
231 |
| - } |
232 |
| - |
233 |
| - private void decorateRecord() { |
234 |
| - try { |
235 |
| - ClassLoader c = Lookup.getDefault().lookup(ClassLoader.class); |
236 |
| - Class decorationClass = Class.forName(DECORATIONS_CLASS, true, c); |
237 |
| - Class decorableClass = Class.forName(DECORABLE_CLASS, true, c); |
238 |
| - Object decorable = Proxy.newProxyInstance(c, new Class[]{decorableClass}, this); |
239 |
| - Method decorate = decorationClass.getDeclaredMethod(DECORATE_METHOD, LogRecord.class, decorableClass); |
240 |
| - decorate.setAccessible(true); |
241 |
| - decorate.invoke(null, rec, decorable); |
242 |
| - } catch (IllegalAccessException ex) { |
243 |
| - Exceptions.printStackTrace(ex); |
244 |
| - } catch (IllegalArgumentException ex) { |
245 |
| - Exceptions.printStackTrace(ex); |
246 |
| - } catch (InvocationTargetException ex) { |
247 |
| - Exceptions.printStackTrace(ex); |
248 |
| - } catch (NoSuchMethodException ex) { |
249 |
| - Exceptions.printStackTrace(ex); |
250 |
| - } catch (SecurityException ex) { |
251 |
| - Exceptions.printStackTrace(ex); |
252 |
| - } catch (ClassNotFoundException ex) { |
253 |
| - Exceptions.printStackTrace(ex); |
254 |
| - } |
255 |
| - } |
256 |
| - |
257 |
| - @Override |
258 |
| - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
259 |
| - String methodName = method.getName(); |
260 |
| - if (DECORABLE_SETNAME_METHOD.equals(methodName)) { |
261 |
| - recInfo.setName((String) args[0]); |
262 |
| - } |
263 |
| - if (DECORABLE_SETDISPLAYNAME_METHOD.equals(methodName)) { |
264 |
| - recInfo.setDisplayName((String) args[0]); |
265 |
| - } |
266 |
| - if (DECORABLE_SETSHORTDESCRIPTOR_METHOD.equals(methodName)) { |
267 |
| - recInfo.setToolTip((String) args[0]); |
268 |
| - } |
269 |
| - if (DECORABLE_SETICONBASE_METHOD.equals(methodName)) { |
270 |
| - String iconBase = (String) args[0]; |
271 |
| - recInfo.setIcon(ImageUtilities.loadImageIcon(iconBase, true)); |
272 |
| - } |
273 |
| - return null; |
274 |
| - } |
275 |
| - |
276 |
| - static void decorate(LogRecordInfo info) { |
277 |
| - new LogRecordDecorator(info).decorateRecord(); |
278 |
| - } |
279 |
| - } |
280 | 207 | }
|
0 commit comments