org.openide.nodes.Node.getContextMenu()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中org.openide.nodes.Node.getContextMenu()方法的一些代码示例,展示了Node.getContextMenu()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getContextMenu()方法的具体详情如下:
包路径:org.openide.nodes.Node
类名称:Node
方法名:getContextMenu

Node.getContextMenu介绍

[英]Make a context menu for this node. The menu is constructed from the set of actions returned by #getActions.
[中]为此节点创建上下文菜单。菜单由#getActions返回的一组操作构成。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-explorer

  1. /**
  2. * Find relevant actions and call the factory to create a popup.
  3. */
  4. private JPopupMenu createPopup(Point p) {
  5. int[] selRows = outline.getSelectedRows();
  6. ArrayList<Node> al = new ArrayList<Node> (selRows.length);
  7. for (int i = 0; i < selRows.length; i++) {
  8. Node n = getNodeFromRow(selRows[i]);
  9. if (n != null) {
  10. al.add(n);
  11. }
  12. }
  13. Node[] arr = al.toArray (new Node[al.size ()]);
  14. if (arr.length == 0) {
  15. if (manager.getRootContext() != null) {
  16. // display the context menu of the root node
  17. JPopupMenu popup = manager.getRootContext().getContextMenu();
  18. if (popup != null && popup.getSubElements().length > 0) {
  19. popupFactory.addNoFilterItem(outline, popup);
  20. return popup;
  21. }
  22. }
  23. // we'll have an empty popup
  24. }
  25. p = SwingUtilities.convertPoint(this, p, outline);
  26. int column = outline.columnAtPoint(p);
  27. int row = outline.rowAtPoint(p);
  28. return popupFactory.createPopupMenu(row, column, arr, outline);
  29. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

  1. void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
  2. Node[] ns = manager.getSelectedNodes ();
  3. JPopupMenu popup = null;
  4. if (ns.length > 0) {
  5. // if any nodes are selected --> find theirs actions
  6. Action[] actions = NodeOp.findActions (ns);
  7. popup = Utilities.actionsToPopup (actions, this);
  8. } else {
  9. // if none node is selected --> get context actions from view's root
  10. if (manager.getRootContext () != null) {
  11. popup = manager.getRootContext ().getContextMenu ();
  12. }
  13. }
  14. int cnt = 0;
  15. if ( popup == null ) {
  16. popup = SystemAction.createPopupMenu( new SystemAction[] {} );
  17. }
  18. popup.add( newMenu );
  19. createPopup ( xpos, ypos, popup );
  20. }

代码示例来源:origin: org.netbeans.api/org-openide-explorer

  1. void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
  2. Node[] ns = manager.getSelectedNodes();
  3. JPopupMenu popup = null;
  4. if (ns.length > 0) {
  5. // if any nodes are selected --> find theirs actions
  6. Action[] actions = NodeOp.findActions(ns);
  7. popup = Utilities.actionsToPopup(actions, this);
  8. } else {
  9. // if none node is selected --> get context actions from view's root
  10. if (manager.getRootContext() != null) {
  11. popup = manager.getRootContext().getContextMenu();
  12. }
  13. }
  14. int cnt = 0;
  15. if (popup == null) {
  16. popup = SystemAction.createPopupMenu(new SystemAction[] { });
  17. }
  18. popup.add(newMenu);
  19. createPopup(xpos, ypos, popup);
  20. }

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

  1. void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
  2. Node[] ns = manager.getSelectedNodes ();
  3. JPopupMenu popup = null;
  4. if (ns.length > 0) {
  5. // if any nodes are selected --> find theirs actions
  6. Action[] actions = NodeOp.findActions (ns);
  7. popup = Utilities.actionsToPopup (actions, this);
  8. } else {
  9. // if none node is selected --> get context actions from view's root
  10. if (manager.getRootContext () != null) {
  11. popup = manager.getRootContext ().getContextMenu ();
  12. }
  13. }
  14. int cnt = 0;
  15. if ( popup == null ) {
  16. popup = SystemAction.createPopupMenu( new SystemAction[] {} );
  17. }
  18. popup.add( newMenu );
  19. createPopup ( xpos, ypos, popup );
  20. }

代码示例来源:origin: org.netbeans.api/org-openide-explorer

  1. void createPopup(int xpos, int ypos) {
  2. // bugfix #23932, don't create if it's disabled
  3. if (isPopupAllowed()) {
  4. Node[] selNodes = manager.getSelectedNodes();
  5. if (selNodes.length > 0) {
  6. Action[] actions = NodeOp.findActions(selNodes);
  7. if (actions.length > 0) {
  8. createPopup(xpos, ypos, Utilities.actionsToPopup(actions, this));
  9. }
  10. } else if (manager.getRootContext() != null) {
  11. JPopupMenu popup = manager.getRootContext().getContextMenu();
  12. if (popup != null) {
  13. createPopup(xpos, ypos, popup);
  14. }
  15. }
  16. }
  17. }

相关文章