35
35
import java .beans .PropertyChangeEvent ;
36
36
import java .beans .PropertyChangeListener ;
37
37
import java .util .Set ;
38
+ import javax .swing .JCheckBoxMenuItem ;
39
+ import javax .swing .JMenuItem ;
40
+ import org .openide .awt .Mnemonics ;
38
41
import org .openide .util .NbBundle ;
42
+ import org .openide .util .actions .Presenter ;
39
43
40
44
/**
41
45
*
42
46
* @author Jiri Sedlacek
43
47
* @author Tomas Hurka
44
48
* @author Luis-Miguel Alventosa
45
49
*/
46
- class HeapDumpOnOOMEAction extends SingleDataSourceAction <Application > {
50
+ class HeapDumpOnOOMEAction extends SingleDataSourceAction <Application > implements Presenter . Popup {
47
51
48
52
private boolean oomeEnabled ;
49
53
private Application lastSelectedApplication ;
@@ -81,13 +85,6 @@ protected boolean isEnabled(Application application) {
81
85
82
86
private void updateState (Jvm jvm ) {
83
87
oomeEnabled = jvm .isDumpOnOOMEnabled ();
84
- if (oomeEnabled ) {
85
- putValue (NAME , NbBundle .getMessage (HeapDumpOnOOMEAction .class , "LBL_Disable_Heap_Dump_on_OOME" )); // NOI18N
86
- putValue (SHORT_DESCRIPTION , NbBundle .getMessage (HeapDumpOnOOMEAction .class , "DESCR_Disable_Heap_Dump_on_OOME" )); // NOI18N
87
- } else {
88
- putValue (NAME , NbBundle .getMessage (HeapDumpOnOOMEAction .class , "LBL_Enable_Heap_Dump_on_OOME" )); // NOI18N
89
- putValue (SHORT_DESCRIPTION , NbBundle .getMessage (HeapDumpOnOOMEAction .class , "DESCR_Enable_Heap_Dump_on_OOME" )); // NOI18N
90
- }
91
88
}
92
89
93
90
protected void updateState (Set <Application > applications ) {
@@ -99,6 +96,15 @@ protected void updateState(Set<Application> applications) {
99
96
}
100
97
101
98
99
+ @ Override
100
+ public JMenuItem getPopupPresenter () {
101
+ JMenuItem presenter = new JCheckBoxMenuItem (this );
102
+ Mnemonics .setLocalizedText (presenter , NbBundle .getMessage (HeapDumpOnOOMEAction .class , "LBL_Heap_Dump_on_OOME" )); // NOI18N
103
+ presenter .setSelected (oomeEnabled );
104
+ return presenter ;
105
+ }
106
+
107
+
102
108
private HeapDumpOnOOMEAction () {
103
109
super (Application .class );
104
110
}
0 commit comments