本文整理了Java中org.openide.nodes.Node.getContextMenu()
方法的一些代码示例,展示了Node.getContextMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getContextMenu()
方法的具体详情如下:
包路径:org.openide.nodes.Node
类名称: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
/**
* Find relevant actions and call the factory to create a popup.
*/
private JPopupMenu createPopup(Point p) {
int[] selRows = outline.getSelectedRows();
ArrayList<Node> al = new ArrayList<Node> (selRows.length);
for (int i = 0; i < selRows.length; i++) {
Node n = getNodeFromRow(selRows[i]);
if (n != null) {
al.add(n);
}
}
Node[] arr = al.toArray (new Node[al.size ()]);
if (arr.length == 0) {
if (manager.getRootContext() != null) {
// display the context menu of the root node
JPopupMenu popup = manager.getRootContext().getContextMenu();
if (popup != null && popup.getSubElements().length > 0) {
popupFactory.addNoFilterItem(outline, popup);
return popup;
}
}
// we'll have an empty popup
}
p = SwingUtilities.convertPoint(this, p, outline);
int column = outline.columnAtPoint(p);
int row = outline.rowAtPoint(p);
return popupFactory.createPopupMenu(row, column, arr, outline);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
Node[] ns = manager.getSelectedNodes ();
JPopupMenu popup = null;
if (ns.length > 0) {
// if any nodes are selected --> find theirs actions
Action[] actions = NodeOp.findActions (ns);
popup = Utilities.actionsToPopup (actions, this);
} else {
// if none node is selected --> get context actions from view's root
if (manager.getRootContext () != null) {
popup = manager.getRootContext ().getContextMenu ();
}
}
int cnt = 0;
if ( popup == null ) {
popup = SystemAction.createPopupMenu( new SystemAction[] {} );
}
popup.add( newMenu );
createPopup ( xpos, ypos, popup );
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
Node[] ns = manager.getSelectedNodes();
JPopupMenu popup = null;
if (ns.length > 0) {
// if any nodes are selected --> find theirs actions
Action[] actions = NodeOp.findActions(ns);
popup = Utilities.actionsToPopup(actions, this);
} else {
// if none node is selected --> get context actions from view's root
if (manager.getRootContext() != null) {
popup = manager.getRootContext().getContextMenu();
}
}
int cnt = 0;
if (popup == null) {
popup = SystemAction.createPopupMenu(new SystemAction[] { });
}
popup.add(newMenu);
createPopup(xpos, ypos, popup);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
Node[] ns = manager.getSelectedNodes ();
JPopupMenu popup = null;
if (ns.length > 0) {
// if any nodes are selected --> find theirs actions
Action[] actions = NodeOp.findActions (ns);
popup = Utilities.actionsToPopup (actions, this);
} else {
// if none node is selected --> get context actions from view's root
if (manager.getRootContext () != null) {
popup = manager.getRootContext ().getContextMenu ();
}
}
int cnt = 0;
if ( popup == null ) {
popup = SystemAction.createPopupMenu( new SystemAction[] {} );
}
popup.add( newMenu );
createPopup ( xpos, ypos, popup );
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
void createPopup(int xpos, int ypos) {
// bugfix #23932, don't create if it's disabled
if (isPopupAllowed()) {
Node[] selNodes = manager.getSelectedNodes();
if (selNodes.length > 0) {
Action[] actions = NodeOp.findActions(selNodes);
if (actions.length > 0) {
createPopup(xpos, ypos, Utilities.actionsToPopup(actions, this));
}
} else if (manager.getRootContext() != null) {
JPopupMenu popup = manager.getRootContext().getContextMenu();
if (popup != null) {
createPopup(xpos, ypos, popup);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!