Skip to content

Commit 9b27269

Browse files
committed
Allow creating custom popup menu presenters which can optionally be disabled
1 parent 90fa85d commit 9b27269

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

visualvm/core/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ OpenIDE-Module: org.graalvm.visualvm.core/2
55
OpenIDE-Module-Layer: org/graalvm/visualvm/core/boot/layer.xml
66
OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/core/boot/Bundle.properties
77
OpenIDE-Module-Install: org/graalvm/visualvm/core/boot/Install.class
8-
OpenIDE-Module-Specification-Version: 2.0
8+
OpenIDE-Module-Specification-Version: 2.1
99

visualvm/core/src/org/graalvm/visualvm/core/explorer/ExplorerContextMenuFactory.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.openide.filesystems.FileUtil;
4343
import org.openide.loaders.DataFolder;
4444
import org.openide.loaders.DataObject;
45+
import org.openide.util.actions.Presenter;
4546

4647
/**
4748
* Class responsible for building explorer context menu.
@@ -100,7 +101,7 @@ JPopupMenu createPopupMenu() {
100101
if (!actions.isEmpty()) {
101102
for (Action action : actions) {
102103
if (action == null) popupMenu.addSeparator();
103-
else popupMenu.add(new DataSourceItem(action));
104+
else popupMenu.add(createItem(action));
104105
}
105106
}
106107

@@ -217,6 +218,12 @@ private List<Action> cleanupActions(List<Action> actions) {
217218
}
218219

219220

221+
private static JMenuItem createItem(Action action) {
222+
if (action instanceof Presenter.Popup) return ((Presenter.Popup)action).getPopupPresenter();
223+
else return new DataSourceItem(action);
224+
}
225+
226+
220227
private static class DataSourceItem extends JMenuItem {
221228
public DataSourceItem(Action action) {
222229
super(action);

0 commit comments

Comments
 (0)