Skip to content

Commit 53eab06

Browse files
jisedlacthurka
authored andcommitted
Open external heap dump in full view similar to .nps snapshots.
1 parent b9bbe20 commit 53eab06

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

visualvm/heapdump/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ OpenIDE-Module: com.sun.tools.visualvm.heapdump/0
55
OpenIDE-Module-Install: com/sun/tools/visualvm/heapdump/Installer.class
66
OpenIDE-Module-Layer: com/sun/tools/visualvm/heapdump/resources/layer.xml
77
OpenIDE-Module-Localizing-Bundle: com/sun/tools/visualvm/heapdump/Bundle.properties
8-
OpenIDE-Module-Specification-Version: 1.1
8+
OpenIDE-Module-Specification-Version: 1.2
99

visualvm/heapdump/nbproject/project.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@
101101
<specification-version>7.13.1</specification-version>
102102
</run-dependency>
103103
</dependency>
104+
<dependency>
105+
<code-name-base>org.openide.filesystems</code-name-base>
106+
<build-prerequisite/>
107+
<compile-dependency/>
108+
<run-dependency>
109+
<specification-version>9.11</specification-version>
110+
</run-dependency>
111+
</dependency>
112+
<dependency>
113+
<code-name-base>org.openide.loaders</code-name-base>
114+
<build-prerequisite/>
115+
<compile-dependency/>
116+
<run-dependency>
117+
<specification-version>7.67</specification-version>
118+
</run-dependency>
119+
</dependency>
104120
<dependency>
105121
<code-name-base>org.openide.modules</code-name-base>
106122
<build-prerequisite/>
@@ -109,6 +125,14 @@
109125
<specification-version>7.3.1</specification-version>
110126
</run-dependency>
111127
</dependency>
128+
<dependency>
129+
<code-name-base>org.openide.nodes</code-name-base>
130+
<build-prerequisite/>
131+
<compile-dependency/>
132+
<run-dependency>
133+
<specification-version>7.46</specification-version>
134+
</run-dependency>
135+
</dependency>
112136
<dependency>
113137
<code-name-base>org.openide.util</code-name-base>
114138
<build-prerequisite/>
@@ -117,6 +141,14 @@
117141
<specification-version>8.6.1</specification-version>
118142
</run-dependency>
119143
</dependency>
144+
<dependency>
145+
<code-name-base>org.openide.util.lookup</code-name-base>
146+
<build-prerequisite/>
147+
<compile-dependency/>
148+
<run-dependency>
149+
<specification-version>8.34</specification-version>
150+
</run-dependency>
151+
</dependency>
120152
<dependency>
121153
<code-name-base>org.openide.util.ui</code-name-base>
122154
<build-prerequisite/>

visualvm/heapdump/src/com/sun/tools/visualvm/heapdump/impl/Bundle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ LBL_Loading_Heap_Dump=Loading Heap Dump...
4545

4646
LBL_Loading_Heap_Dump_failed=Loading Heap Dump failed.
4747

48+
MSG_Opening_Heap_Dump=Opening Heap Dump...
49+
50+
MSG_Opening_Heap_Dump_failed=Opening heap dump failed.
51+
4852
CAPTION_Remote_heap_dump=Remote Heap Dump
4953

5054
MSG_Remote_heap_dump=&Heap dump file to be created on the remote system\:

visualvm/heapdump/src/com/sun/tools/visualvm/heapdump/impl/HeapDumpCategory.java

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,34 @@
2626
package com.sun.tools.visualvm.heapdump.impl;
2727

2828
import com.sun.tools.visualvm.core.snapshot.SnapshotCategory;
29-
import com.sun.tools.visualvm.core.ui.DataSourceWindowManager;
3029
import com.sun.tools.visualvm.heapdump.HeapDump;
3130
import java.io.File;
3231
import java.io.FileNotFoundException;
3332
import java.io.IOException;
3433
import java.io.RandomAccessFile;
34+
import java.util.logging.Level;
35+
import java.util.logging.Logger;
36+
import javax.swing.SwingUtilities;
3537
import javax.swing.filechooser.FileFilter;
38+
import org.netbeans.api.actions.Openable;
39+
import org.netbeans.api.progress.ProgressHandle;
40+
import org.netbeans.api.progress.ProgressHandleFactory;
41+
import org.openide.filesystems.FileObject;
42+
import org.openide.filesystems.FileUtil;
43+
import org.openide.loaders.DataObject;
3644
import org.openide.util.NbBundle;
45+
import org.openide.util.RequestProcessor;
3746

3847
/**
3948
*
4049
* @author Jiri Sedlacek
4150
* @author Tomas Hurka
4251
*/
4352
public class HeapDumpCategory extends SnapshotCategory<HeapDump> {
53+
54+
private static final Logger LOGGER =
55+
Logger.getLogger(HeapDumpCategory.class.getName());
56+
4457
private static final String HPROF_HEADER = "JAVA PROFILE 1.0";
4558
private static final long MIN_HPROF_SIZE = 1024*1024L;
4659
private static final String NAME = NbBundle.getMessage(HeapDumpCategory.class, "LBL_Heap_Dumps"); // NOI18N
@@ -56,7 +69,39 @@ public boolean supportsOpenSnapshot() {
5669
}
5770

5871
public void openSnapshot(File file) {
59-
DataSourceWindowManager.sharedInstance().openDataSource(new HeapDumpImpl(file, null));
72+
RequestProcessor.getDefault().post(new Runnable() {
73+
public void run() {
74+
ProgressHandle pHandle = null;
75+
try {
76+
pHandle = ProgressHandleFactory.createHandle(
77+
NbBundle.getMessage(HeapDumpCategory.class,
78+
"MSG_Opening_Heap_Dump")); // NOI18N
79+
pHandle.setInitialDelay(0);
80+
pHandle.start();
81+
try {
82+
FileObject fileObject = FileUtil.toFileObject(file);
83+
DataObject dobj = DataObject.find(fileObject);
84+
Openable openCookie = dobj.getLookup().lookup(Openable.class);
85+
openCookie.open();
86+
} catch (Exception e) {
87+
LOGGER.log(Level.INFO, "Error loading profiler snapshot", e); // NOI18N
88+
// TODO: enable once HeapDump module is a friend of Profiler API
89+
// SwingUtilities.invokeLater(new Runnable() {
90+
// public void run() {
91+
// ProfilerDialogs.displayError(
92+
// NbBundle.getMessage(HeapDumpCategory.class,
93+
// "MSG_Opening_Heap_Dump_failed")); // NOI18N
94+
// }
95+
// });
96+
}
97+
} finally {
98+
final ProgressHandle pHandleF = pHandle;
99+
SwingUtilities.invokeLater(new Runnable() {
100+
public void run() { if (pHandleF != null) pHandleF.finish(); }
101+
});
102+
}
103+
}
104+
});
60105
}
61106

62107
protected boolean isSnapshot(File file) {

0 commit comments

Comments
 (0)