31
31
import com .sun .tools .visualvm .core .ui .DataSourceView ;
32
32
import com .sun .tools .visualvm .core .ui .DesktopUtils ;
33
33
import com .sun .tools .visualvm .core .ui .components .DataViewComponent ;
34
+ import com .sun .tools .visualvm .core .ui .components .DataViewComponent .DetailsView ;
34
35
import com .sun .tools .visualvm .profiling .presets .PresetSelector ;
35
36
import com .sun .tools .visualvm .profiling .presets .ProfilerPresets ;
36
37
import com .sun .tools .visualvm .uisupport .HTMLLabel ;
@@ -79,6 +80,7 @@ final class ApplicationProfilerView extends DataSourceView {
79
80
private static final String IMAGE_PATH =
80
81
"com/sun/tools/visualvm/profiler/resources/profiler.png" ; // NOI18N
81
82
83
+ private DataViewComponent dvc ;
82
84
private MasterViewSupport masterViewSupport ;
83
85
private CPUSettingsSupport cpuSettings ;
84
86
private MemorySettingsSupport memorySettings ;
@@ -140,20 +142,35 @@ private PresetSelector createSelector(Runnable presetSynchronizer, Application a
140
142
protected DataViewComponent createComponent () {
141
143
Application application = (Application )getDataSource ();
142
144
ProfilingResultsSupport profilingResultsSupport = new ProfilingResultsSupport ();
143
- masterViewSupport = new MasterViewSupport (application , profilingResultsSupport , cpuSettings , memorySettings , jdbcSettings , classSharingBreaksProfiling );
144
145
145
- DataViewComponent dvc = new DataViewComponent (
146
- masterViewSupport . getMasterView (),
147
- new DataViewComponent . MasterViewConfiguration ( false ) );
146
+ final DetailsView cpuSettingsView = cpuSettings . getDetailsView ();
147
+ final DetailsView memorySettingsView = memorySettings . getDetailsView ();
148
+ final DetailsView jdbcSettingsView = jdbcSettings . getDetailsView ( );
148
149
150
+ masterViewSupport = new MasterViewSupport (application , profilingResultsSupport , cpuSettings , memorySettings , jdbcSettings , classSharingBreaksProfiling ) {
151
+ void showCPUSettings () {
152
+ if (dvc != null ) {
153
+ dvc .selectDetailsView (cpuSettingsView );
154
+ dvc .showDetailsArea (DataViewComponent .TOP_RIGHT );
155
+ }
156
+ }
157
+ void showMemorySettings () {
158
+ if (dvc != null ) {
159
+ dvc .selectDetailsView (memorySettingsView );
160
+ dvc .showDetailsArea (DataViewComponent .TOP_RIGHT );
161
+ }
162
+ }
163
+ };
164
+
165
+ dvc = new DataViewComponent (masterViewSupport .getMasterView (), new DataViewComponent .MasterViewConfiguration (false ));
149
166
dvc .configureDetailsArea (new DataViewComponent .DetailsAreaConfiguration (NbBundle .getMessage (ApplicationProfilerView .class , "LBL_Profiling_results" ), false ), DataViewComponent .TOP_LEFT ); // NOI18N
150
167
dvc .addDetailsView (profilingResultsSupport .getDetailsView (), DataViewComponent .TOP_LEFT );
151
168
152
169
dvc .configureDetailsArea (new DataViewComponent .DetailsAreaConfiguration (NbBundle .getMessage (ApplicationProfilerView .class , "LBL_Settings" ), true ), DataViewComponent .TOP_RIGHT ); // NOI18N
153
- dvc .addDetailsView (cpuSettings . getDetailsView () , DataViewComponent .TOP_RIGHT );
154
- dvc .addDetailsView (memorySettings . getDetailsView () , DataViewComponent .TOP_RIGHT );
155
- dvc .addDetailsView (jdbcSettings . getDetailsView () , DataViewComponent .TOP_RIGHT );
156
- dvc .hideDetailsArea (DataViewComponent .TOP_RIGHT );
170
+ dvc .addDetailsView (cpuSettingsView , DataViewComponent .TOP_RIGHT );
171
+ dvc .addDetailsView (memorySettingsView , DataViewComponent .TOP_RIGHT );
172
+ dvc .addDetailsView (jdbcSettingsView , DataViewComponent .TOP_RIGHT );
173
+ // dvc.hideDetailsArea(DataViewComponent.TOP_RIGHT);
157
174
158
175
return dvc ;
159
176
}
@@ -169,7 +186,7 @@ protected void removed() {
169
186
170
187
// --- General data --------------------------------------------------------
171
188
172
- private static class MasterViewSupport extends JPanel implements ProfilingStateListener , DataRemovedListener <Application >, ActionListener , PropertyChangeListener {
189
+ private static abstract class MasterViewSupport extends JPanel implements ProfilingStateListener , DataRemovedListener <Application >, ActionListener , PropertyChangeListener {
173
190
174
191
private Application application ;
175
192
private ProfilingResultsSupport profilingResultsView ;
@@ -215,6 +232,11 @@ public MasterViewSupport(final Application application, ProfilingResultsSupport
215
232
}
216
233
217
234
235
+ abstract void showCPUSettings ();
236
+
237
+ abstract void showMemorySettings ();
238
+
239
+
218
240
public DataViewComponent .MasterView getMasterView () {
219
241
return new DataViewComponent .MasterView (NbBundle .getMessage (ApplicationProfilerView .class , "LBL_Profiler" ), null , this ); // NOI18N
220
242
}
@@ -271,6 +293,7 @@ private void handleCPUProfiling() {
271
293
internalChange = true ;
272
294
cpuButton .setSelected (false );
273
295
internalChange = false ;
296
+ showCPUSettings ();
274
297
ProfilerDialogs .displayError (NbBundle .getMessage (ApplicationProfilerView .class , "MSG_Incorrect_CPU_settings" )); // NOI18N
275
298
} else {
276
299
cpuSettingsSupport .saveSettings ();
@@ -297,19 +320,27 @@ private void handleMemoryProfiling() {
297
320
cpuButton .setSelected (false );
298
321
jdbcButton .setSelected (false );
299
322
internalChange = false ;
300
- memorySettingsSupport .saveSettings ();
301
- if (NetBeansProfiler .getDefaultNB ().getProfilingState () == NetBeansProfiler .PROFILING_RUNNING ) {
302
- ProfilerUtils .runInProfilerRequestProcessor (new Runnable () {
303
- public void run () {
304
- NetBeansProfiler .getDefaultNB ().modifyCurrentProfiling (memorySettingsSupport .getSettings ());
305
- }
306
- });
323
+ if (!memorySettingsSupport .settingsValid ()) {
324
+ internalChange = true ;
325
+ memoryButton .setSelected (false );
326
+ internalChange = false ;
327
+ showMemorySettings ();
328
+ ProfilerDialogs .displayError (NbBundle .getMessage (ApplicationProfilerView .class , "MSG_Incorrect_Memory_settings" )); // NOI18N
307
329
} else {
308
- disableControlButtons ();
309
- ProfilerSupport .getInstance ().setProfiledApplication (application );
310
- ProfilerUtils .runInProfilerRequestProcessor (new Runnable () {
311
- public void run () { startProfiling (application , memorySettingsSupport .getSettings ()); }
312
- });
330
+ memorySettingsSupport .saveSettings ();
331
+ if (NetBeansProfiler .getDefaultNB ().getProfilingState () == NetBeansProfiler .PROFILING_RUNNING ) {
332
+ ProfilerUtils .runInProfilerRequestProcessor (new Runnable () {
333
+ public void run () {
334
+ NetBeansProfiler .getDefaultNB ().modifyCurrentProfiling (memorySettingsSupport .getSettings ());
335
+ }
336
+ });
337
+ } else {
338
+ disableControlButtons ();
339
+ ProfilerSupport .getInstance ().setProfiledApplication (application );
340
+ ProfilerUtils .runInProfilerRequestProcessor (new Runnable () {
341
+ public void run () { startProfiling (application , memorySettingsSupport .getSettings ()); }
342
+ });
343
+ }
313
344
}
314
345
}
315
346
}
0 commit comments