Skip to content

Commit d15879f

Browse files
jisedlacthurka
authored andcommitted
Heap Viewer - various OQL improvements
- queries can be loaded/saved - queries can be managed in Options - editor improvements - UI cleanup
1 parent d8e4936 commit d15879f

File tree

14 files changed

+2075
-394
lines changed

14 files changed

+2075
-394
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build.xml.data.CRC32=6fac9eed
1+
build.xml.data.CRC32=a527e266
22
build.xml.script.CRC32=018997e7
33
build.xml.stylesheet.CRC32=[email protected]
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6-
nbproject/build-impl.xml.data.CRC32=6fac9eed
6+
nbproject/build-impl.xml.data.CRC32=a527e266
77
nbproject/build-impl.xml.script.CRC32=98bf6af8
88
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]

visualvm/heapviewer/nbproject/project.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
<specification-version>1.0</specification-version>
1616
</run-dependency>
1717
</dependency>
18+
<dependency>
19+
<code-name-base>com.sun.tools.visualvm.uisupport</code-name-base>
20+
<build-prerequisite/>
21+
<compile-dependency/>
22+
<run-dependency>
23+
<release-version>0</release-version>
24+
<specification-version>1.4</specification-version>
25+
</run-dependency>
26+
</dependency>
1827
<dependency>
1928
<code-name-base>org.netbeans.api.progress</code-name-base>
2029
<build-prerequisite/>
@@ -42,6 +51,15 @@
4251
<specification-version>1.144</specification-version>
4352
</run-dependency>
4453
</dependency>
54+
<dependency>
55+
<code-name-base>org.netbeans.modules.options.api</code-name-base>
56+
<build-prerequisite/>
57+
<compile-dependency/>
58+
<run-dependency>
59+
<release-version>1</release-version>
60+
<specification-version>1.46</specification-version>
61+
</run-dependency>
62+
</dependency>
4563
<dependency>
4664
<code-name-base>org.netbeans.modules.profiler.api</code-name-base>
4765
<build-prerequisite/>
@@ -108,6 +126,14 @@
108126
<specification-version>9.8</specification-version>
109127
</run-dependency>
110128
</dependency>
129+
<dependency>
130+
<code-name-base>org.openide.windows</code-name-base>
131+
<build-prerequisite/>
132+
<compile-dependency/>
133+
<run-dependency>
134+
<specification-version>6.77</specification-version>
135+
</run-dependency>
136+
</dependency>
111137
</module-dependencies>
112138
<friend-packages>
113139
<friend>com.sun.tools.visualvm.heapdump</friend>
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.sun.tools.visualvm.heapviewer.options;
27+
28+
import com.sun.tools.visualvm.core.options.UISupport;
29+
import com.sun.tools.visualvm.heapviewer.oql.CustomOQLQueries;
30+
import java.beans.PropertyChangeListener;
31+
import java.util.List;
32+
import java.util.Objects;
33+
import javax.swing.JComponent;
34+
import javax.swing.SwingUtilities;
35+
import org.netbeans.modules.profiler.heapwalk.OQLSupport;
36+
import org.netbeans.spi.options.OptionsPanelController;
37+
import org.openide.util.HelpCtx;
38+
import org.openide.util.Lookup;
39+
import org.openide.util.RequestProcessor;
40+
41+
/**
42+
*
43+
* @author Jiri Sedlacek
44+
*/
45+
@OptionsPanelController.TopLevelRegistration(
46+
id = "HeapViewerOptions",
47+
categoryName = "#HeapViewerOptionsCategory_Name",
48+
iconBase = "com/sun/tools/visualvm/heapviewer/options/heapViewer32.png",
49+
position = 1525)
50+
@org.openide.util.NbBundle.Messages({
51+
"HeapViewerOptionsCategory_Name=Heap Viewer"
52+
})
53+
public final class HeapViewerOptionsCategory extends OptionsPanelController {
54+
55+
private static final HelpCtx HELP_CTX = null;
56+
// private static final HelpCtx HELP_CTX = new HelpCtx("HeapViewerOptions.Help"); // NOI18N
57+
58+
public static final String OPTIONS_HANDLE = "HeapViewerOptions"; // NOI18N
59+
60+
private HeapViewerOptionsPanel settingsPanel;
61+
private JComponent settingsComponent;
62+
63+
64+
private HeapViewerOptionsPanel getPanel() {
65+
if (settingsPanel == null) settingsPanel = new HeapViewerOptionsPanel();
66+
return settingsPanel;
67+
}
68+
69+
public JComponent getComponent(Lookup lookup) {
70+
if (settingsComponent == null) settingsComponent = UISupport.createScrollableContainer(getPanel());
71+
return settingsComponent;
72+
}
73+
74+
public HelpCtx getHelpCtx() {
75+
return HELP_CTX;
76+
}
77+
78+
public boolean isChanged() {
79+
if (settingsPanel == null) return false;
80+
81+
List<OQLSupport.Query> master = CustomOQLQueries.instance().list();
82+
List<OQLSupport.Query> edited = getPanel().getQueries();
83+
84+
if (master.size() != edited.size()) return true;
85+
86+
for (int i = 0; i < master.size(); i++)
87+
if (!sameQuery(master.get(i), edited.get(i))) return true;
88+
89+
return false;
90+
}
91+
92+
public boolean isValid() {
93+
return true;
94+
}
95+
96+
public void applyChanges() {
97+
if (settingsPanel == null) return;
98+
CustomOQLQueries.instance().set(getPanel().getQueries());
99+
}
100+
101+
public void cancel() {
102+
}
103+
104+
public void update() {
105+
new RequestProcessor("OQL Scripts Loader").post(new Runnable() { // NOI18N
106+
public void run() {
107+
final List<OQLSupport.Query> queries = CustomOQLQueries.instance().list();
108+
SwingUtilities.invokeLater(new Runnable() {
109+
public void run() {
110+
getPanel().setQueries(queries);
111+
}
112+
});
113+
}
114+
});
115+
}
116+
117+
public void addPropertyChangeListener(PropertyChangeListener l) {
118+
}
119+
120+
public void removePropertyChangeListener(PropertyChangeListener l) {
121+
}
122+
123+
124+
private static boolean sameQuery(OQLSupport.Query query1, OQLSupport.Query query2) {
125+
if (!Objects.equals(query1.getName(), query2.getName())) return false;
126+
if (!Objects.equals(query1.getDescription(), query2.getDescription())) return false;
127+
return true;
128+
}
129+
130+
}

0 commit comments

Comments
 (0)