Skip to content

Commit 3d0066e

Browse files
committed
More Profiler settings improvements
- updated tooltips - higlight empty settings - code cleanup
1 parent e11a494 commit 3d0066e

File tree

7 files changed

+46
-24
lines changed

7 files changed

+46
-24
lines changed

visualvm/profiler/src/com/sun/tools/visualvm/profiler/ApplicationProfilerView.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.sun.tools.visualvm.core.ui.DataSourceView;
3232
import com.sun.tools.visualvm.core.ui.DesktopUtils;
3333
import com.sun.tools.visualvm.core.ui.components.DataViewComponent;
34-
import com.sun.tools.visualvm.core.ui.components.DataViewComponent.DetailsView;
3534
import com.sun.tools.visualvm.profiling.presets.PresetSelector;
3635
import com.sun.tools.visualvm.profiling.presets.ProfilerPresets;
3736
import com.sun.tools.visualvm.uisupport.HTMLLabel;
@@ -143,20 +142,16 @@ protected DataViewComponent createComponent() {
143142
Application application = (Application)getDataSource();
144143
ProfilingResultsSupport profilingResultsSupport = new ProfilingResultsSupport();
145144

146-
final DetailsView cpuSettingsView = cpuSettings.getDetailsView();
147-
final DetailsView memorySettingsView = memorySettings.getDetailsView();
148-
final DetailsView jdbcSettingsView = jdbcSettings.getDetailsView();
149-
150145
masterViewSupport = new MasterViewSupport(application, profilingResultsSupport, cpuSettings, memorySettings, jdbcSettings, classSharingBreaksProfiling) {
151146
void showCPUSettings() {
152147
if (dvc != null) {
153-
dvc.selectDetailsView(cpuSettingsView);
148+
cpuSettings.highlightInvalidSettings(dvc);
154149
dvc.showDetailsArea(DataViewComponent.TOP_RIGHT);
155150
}
156151
}
157152
void showMemorySettings() {
158153
if (dvc != null) {
159-
dvc.selectDetailsView(memorySettingsView);
154+
memorySettings.highlightInvalidSettings(dvc);
160155
dvc.showDetailsArea(DataViewComponent.TOP_RIGHT);
161156
}
162157
}
@@ -167,9 +162,9 @@ void showMemorySettings() {
167162
dvc.addDetailsView(profilingResultsSupport.getDetailsView(), DataViewComponent.TOP_LEFT);
168163

169164
dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration(NbBundle.getMessage(ApplicationProfilerView.class, "LBL_Settings"), true), DataViewComponent.TOP_RIGHT); // NOI18N
170-
dvc.addDetailsView(cpuSettingsView, DataViewComponent.TOP_RIGHT);
171-
dvc.addDetailsView(memorySettingsView, DataViewComponent.TOP_RIGHT);
172-
dvc.addDetailsView(jdbcSettingsView, DataViewComponent.TOP_RIGHT);
165+
dvc.addDetailsView(cpuSettings.getDetailsView(), DataViewComponent.TOP_RIGHT);
166+
dvc.addDetailsView(memorySettings.getDetailsView(), DataViewComponent.TOP_RIGHT);
167+
dvc.addDetailsView(jdbcSettings.getDetailsView(), DataViewComponent.TOP_RIGHT);
173168
// dvc.hideDetailsArea(DataViewComponent.TOP_RIGHT);
174169

175170
return dvc;

visualvm/profiler/src/com/sun/tools/visualvm/profiler/CPUSettingsSupport.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ public abstract class CPUSettingsSupport {
4747
private ProfilerCPUPanel panel;
4848
private PresetSelector selector;
4949

50+
private DataViewComponent.DetailsView detailsView;
51+
5052

5153
DataViewComponent.DetailsView getDetailsView() {
52-
return new DataViewComponent.DetailsView(NbBundle.getMessage(
53-
CPUSettingsSupport.class, "LBL_Cpu_settings"), null, 10, // NOI18N
54-
new ScrollableContainer(getComponent()), null);
54+
if (detailsView == null) {
55+
detailsView = new DataViewComponent.DetailsView(NbBundle.getMessage(
56+
CPUSettingsSupport.class, "LBL_Cpu_settings"), null, 10, // NOI18N
57+
new ScrollableContainer(getComponent()), null);
58+
}
59+
return detailsView;
5560
}
5661

5762
public JComponent getComponent() {
@@ -75,6 +80,11 @@ void copySettings(CPUSettingsSupport settings) {
7580

7681
public boolean settingsValid() { return panel.settingsValid(); }
7782

83+
public void highlightInvalidSettings(DataViewComponent dvc) {
84+
panel.highlighInvalid();
85+
dvc.selectDetailsView(getDetailsView());
86+
}
87+
7888
public abstract PresetSelector createSelector(Runnable presetSynchronizer);
7989

8090

visualvm/profiler/src/com/sun/tools/visualvm/profiler/MemorySettingsSupport.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ public abstract class MemorySettingsSupport {
4747
private ProfilerMemoryPanel panel;
4848
private PresetSelector selector;
4949

50+
private DataViewComponent.DetailsView detailsView;
51+
5052

5153
DataViewComponent.DetailsView getDetailsView() {
52-
return new DataViewComponent.DetailsView(NbBundle.getMessage(
53-
MemorySettingsSupport.class, "LBL_Memory_settings"), null, 20, // NOI18N
54-
new ScrollableContainer(getComponent()), null);
54+
if (detailsView == null) {
55+
detailsView = new DataViewComponent.DetailsView(NbBundle.getMessage(
56+
MemorySettingsSupport.class, "LBL_Memory_settings"), null, 20, // NOI18N
57+
new ScrollableContainer(getComponent()), null);
58+
}
59+
return detailsView;
5560
}
5661

5762
public JComponent getComponent() {
@@ -75,6 +80,11 @@ void copySettings(MemorySettingsSupport settings) {
7580

7681
public boolean settingsValid() { return panel.settingsValid(); }
7782

83+
public void highlightInvalidSettings(DataViewComponent dvc) {
84+
panel.highlighInvalid();
85+
dvc.selectDetailsView(getDetailsView());
86+
}
87+
7888
public abstract PresetSelector createSelector(Runnable presetSynchronizer);
7989

8090

visualvm/profiling/src/com/sun/tools/visualvm/profiling/presets/Bundle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ LBL_Profile_Incl_S=&Profile only packages\:
5757

5858
LBL_Profile_Excl_S=&Do not profile packages\:
5959

60-
TOOLTIP_Root_Classes=<html>Profile methods of these classes or packages:<br><br><code>&nbsp;org.mypackage.**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package and subpackages<br><code>&nbsp;org.mypackage.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package<br><code>&nbsp;org.mypackage.MyClass&nbsp;&nbsp;</code>single class<br></html>
60+
TOOLTIP_Root_Classes=<html>Profile methods of these classes or packages:<br><br><code>&nbsp;org.mypackage.**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package and subpackages<br><code>&nbsp;org.mypackage.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package<br><code>&nbsp;org.mypackage.MyClass&nbsp;&nbsp;</code>single class<br><br>Special case:<br><br><code>&nbsp;* or **</code>&nbsp;&nbsp;include all classes<br></html>
6161

6262
TOOLTIP_Query_Filter=<html>Limit profiled SQL queries based on the text filter (contains).<br><br>Empty filter profiles all SQL queries.</html>
6363

@@ -71,7 +71,7 @@ TOOLTIP_Inclusive_Filter_S=Only code of these packages will be profiled
7171

7272
TOOLTIP_Exclusive_Filter_S=All code except these packages will be profiled
7373

74-
TOOLTIP_Instrumentation_Filter=<html>Include/exclude profiling outgoing calls from these classes or packages:<br><br><code>&nbsp;org.mypackage.**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package and subpackages<br><code>&nbsp;org.mypackage.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package<br><code>&nbsp;org.mypackage.MyClass&nbsp;&nbsp;</code>single class<br><br>Special case:<br><br><code>&nbsp;&lt;empty&gt;</code> or <code>*&nbsp;&nbsp;</code>include all classes<br></html>
74+
TOOLTIP_Instrumentation_Filter=<html>Include/exclude profiling outgoing calls from these classes or packages:<br><br><code>&nbsp;org.mypackage.**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package and subpackages<br><code>&nbsp;org.mypackage.*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>all classes in package<br><code>&nbsp;org.mypackage.MyClass&nbsp;&nbsp;</code>single class<br><br>Special case:<br><br><code>&nbsp;&lt;empty&gt; or * or **</code>&nbsp;&nbsp;include all classes<br></html>
7575

7676
TOOLTIP_Allocations=Only object allocations are recorded
7777

visualvm/profiling/src/com/sun/tools/visualvm/profiling/presets/ProfilerCPUPanel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ public ProfilingSettings getSettings() {
115115

116116
public boolean settingsValid() { return rootsValid && filtersValid; }
117117

118+
public void highlighInvalid() {
119+
if (getRootsValue().isEmpty()) rootsArea.getTextArea().setText(ProfilerPresets.DEFINE_CLASSES);
120+
}
121+
118122
public void loadFromPreset(ProfilerPreset preset) {
119123
if (preset == null) return;
120124

visualvm/profiling/src/com/sun/tools/visualvm/profiling/presets/ProfilerMemoryPanel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ public ProfilingSettings getSettings() {
104104

105105
public boolean settingsValid() { return rootsValid; }
106106

107+
public void highlighInvalid() {
108+
if (getFilterValue().isEmpty()) filtersArea.getTextArea().setText(ProfilerPresets.DEFINE_CLASSES);
109+
}
110+
107111
public void loadFromPreset(ProfilerPreset preset) {
108112
if (preset == null) return;
109113

visualvm/profiling/src/com/sun/tools/visualvm/profiling/presets/ProfilerPresets.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public final class ProfilerPresets {
7070
private ProfilerPreset presetToCreate;
7171

7272
private final Set<WeakReference<PresetSelector>> selectors;
73+
74+
static final String DEFINE_CLASSES = NbBundle.getMessage(ProfilerPresets.class, "HINT_Define_roots"); // NOI18N
7375

7476

7577
public static synchronized ProfilerPresets getInstance() {
@@ -253,12 +255,9 @@ private static String getDefaultFiltersS() {
253255
}
254256

255257
private static String getDefaultRootsP(Application application) {
256-
if (application == null) return NbBundle.getMessage(
257-
ProfilerPresets.class, "HINT_Define_roots"); // NOI18N
258+
if (application == null) return DEFINE_CLASSES;
258259
String mainClass = getMainClass(application);
259-
if ("".equals(mainClass)) { // unknown main class
260-
return NbBundle.getMessage(ProfilerPresets.class, "HINT_Define_roots"); // NOI18N
261-
}
260+
if ("".equals(mainClass)) return DEFINE_CLASSES; // unknown main class
262261
int dotIndex = mainClass.lastIndexOf("."); // NOI18N
263262
if (dotIndex == -1) return mainClass; // default package
264263
else return mainClass.substring(0, dotIndex + 1) + "**"; // NOI18N
@@ -274,7 +273,7 @@ private static String getDefaultFiltersP(String defaultRoots) {
274273
}
275274

276275
private static String getDefaultMemoryFilterP(Application application) {
277-
return NbBundle.getMessage(ProfilerPresets.class, "HINT_Define_roots"); // NOI18N
276+
return DEFINE_CLASSES; // NOI18N
278277
}
279278

280279

0 commit comments

Comments
 (0)