本文整理了Java中org.openide.nodes.Node.getPreferredAction()
方法的一些代码示例,展示了Node.getPreferredAction()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getPreferredAction()
方法的具体详情如下:
包路径:org.openide.nodes.Node
类名称:Node
方法名:getPreferredAction
[英]Gets the preferred action for this node. This action can but need not to be one from the action array returned from #getActions(boolean). In case it is, the popup menu created from those actions is encouraged to highlight the preferred action. Override in subclasses accordingly.
[中]获取此节点的首选操作。此操作可以但不必是#getActions(布尔值)返回的操作数组中的操作。在这种情况下,鼓励从这些操作创建的弹出菜单突出显示首选操作。相应地在子类中重写。
代码示例来源:origin: org.netbeans.api/org-openide-nodes
@Override
public javax.swing.Action getPreferredAction() {
javax.swing.Action retValue;
if (overridesAMethod("getDefaultAction")) { // NOI18N
retValue = super.getPreferredAction();
} else {
retValue = original.getPreferredAction();
}
return retValue;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public javax.swing.Action getPreferredAction() {
javax.swing.Action retValue;
if (overridesAMethod ("getDefaultAction", new Class[0])) { // NOI18N
retValue = super.getPreferredAction();
} else {
retValue = original.getPreferredAction();
}
return retValue;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public javax.swing.Action getPreferredAction() {
javax.swing.Action retValue;
if (overridesAMethod ("getDefaultAction", new Class[0])) { // NOI18N
retValue = super.getPreferredAction();
} else {
retValue = original.getPreferredAction();
}
return retValue;
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
public boolean acceptNodes(Node[] nodes) {
// don't allow multiple selections
if ((nodes == null) || (nodes.length != 1)) {
return false;
}
Node n = nodes[0];
Action a = n.getPreferredAction();
if ((a != null) && a.isEnabled()) {
a.actionPerformed(new ActionEvent(n, 0, "")); // NOI18N
return true;
}
return false;
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public boolean acceptNodes (Node[] nodes) {
// don't allow multiple selections
if ((nodes == null) || (nodes.length != 1)) {
return false;
}
Node n = nodes[0];
Action a = n.getPreferredAction();
if (a != null && a.isEnabled()) {
a.actionPerformed(new ActionEvent(n, 0, "")); // NOI18N
return true;
}
return false;
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public boolean acceptNodes (Node[] nodes) {
// don't allow multiple selections
if ((nodes == null) || (nodes.length != 1)) {
return false;
}
Node n = nodes[0];
Action a = n.getPreferredAction();
if (a != null && a.isEnabled()) {
a.actionPerformed(new ActionEvent(n, 0, "")); // NOI18N
return true;
}
return false;
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void actionPerformed(ActionEvent evt) {
Node[] nodes = manager.getSelectedNodes();
if (nodes.length == 1) {
Action a = nodes[0].getPreferredAction();
if (a != null) {
if (a.isEnabled()) {
a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void actionPerformed(ActionEvent evt) {
Node[] nodes = manager.getSelectedNodes();
if (nodes.length == 1) {
Action a = nodes[0].getPreferredAction();
if (a != null) {
if (a.isEnabled()) {
a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
static void performPreferredActionOnNodes(Node[] nodes) {
if (nodes.length > 0) {
Action a = nodes[0].getPreferredAction();
if (a == null) {
return;
}
for (int i=1; i<nodes.length; i++) {
Action ai = nodes[i].getPreferredAction();
if (ai == null || !ai.equals(a)) {
return;
}
}
// switch to replacement action if there is some
a = takeAction(a, nodes);
if (a != null && a.isEnabled()) {
a.actionPerformed(new ActionEvent(
nodes.length == 1 ? nodes[0] : nodes,
ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-bugtracking-commons
@Override
public void keyTyped(KeyEvent e) {
if (e.getKeyChar() == '\n') { // NOI18N
int row = table.getSelectedRow();
if (row != -1) {
row = sorter.modelIndex(row);
Action action = tableModel.getNodes()[row].getPreferredAction();
if (action.isEnabled()) {
action.actionPerformed(new ActionEvent(this, 0, "")); // NOI18N
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
if (treeTable.getSelectedColumn() != ((TreeTable)treeTable).getTreeColumnIndex())
return;
Node[] nodes = manager.getSelectedNodes();
if (nodes.length == 1) {
Action a = nodes[0].getPreferredAction();
if (a != null) {
if (a.isEnabled()) {
a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
if (treeTable.getSelectedColumn() != ((TreeTable)treeTable).getTreeColumnIndex())
return;
Node[] nodes = manager.getSelectedNodes();
if (nodes.length == 1) {
Action a = nodes[0].getPreferredAction();
if (a != null) {
if (a.isEnabled()) {
a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/**
* Invoked when an action occurs.
*/
@Override
public void actionPerformed(ActionEvent e) {
if (treeTable.getSelectedColumn() != ((TreeTable) treeTable).getTreeColumnIndex()) {
return;
}
Node[] nodes = manager.getSelectedNodes();
if (nodes.length == 1) {
Action a = nodes[0].getPreferredAction();
if (a != null) {
if (a.isEnabled()) {
a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
}
}
代码示例来源:origin: nl.cloudfarming.client/nbtaskfocus-core
@Override
public void run() {
try {
FileObject fo = FileUtil.toFileObject(new File(itemPath).getAbsoluteFile());
DataObject newDo = DataObject.find(fo);
final Node node = newDo.getNodeDelegate();
Action a = node.getPreferredAction();
if (a instanceof ContextAwareAction) {
a = ((ContextAwareAction) a).createContextAwareInstance(node.getLookup());
}
if (a != null) {
a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
}
} catch (Exception ex) {
//
}
}
});
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@Override
public void mouseClicked(MouseEvent e) {
tree.stopEditing();
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if ((selRow != -1) && SwingUtilities.isLeftMouseButton(e) && MouseUtils.isDoubleClick(e)) {
// Default action.
if (defaultActionEnabled) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
Node node = Visualizer.findNode(selPath.getLastPathComponent());
Action a = takeAction(node.getPreferredAction(), node);
if (a != null) {
if (a.isEnabled()) {
a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
} else {
Toolkit.getDefaultToolkit().beep();
}
e.consume();
return;
}
}
if (tree.isExpanded(selRow)) {
tree.collapseRow(selRow);
} else {
tree.expandRow(selRow);
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
Node node = Visualizer.findNode (selPath.getLastPathComponent());
Action a = node.getPreferredAction();
if (a != null) {
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
Node node = Visualizer.findNode (selPath.getLastPathComponent());
Action a = node.getPreferredAction();
if (a != null) {
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
Action a = node.getPreferredAction();
if (a != null && (modifiers & java.awt.event.InputEvent.CTRL_MASK) == 0) {
if (a instanceof ContextAwareAction) {
代码示例来源:origin: nl.cloudfarming.client/stock-project
@Override
public Action[] getActions(boolean arg0) {
Action[] nodeActions = new Action[6];
nodeActions[0] = new OpenStockDetailsAction();
nodeActions[1] = CommonProjectActions.copyProjectAction();
nodeActions[2] = CommonProjectActions.deleteProjectAction();
nodeActions[4] = CommonProjectActions.closeProjectAction();
nodeActions[5] = getOriginal().getPreferredAction();
return nodeActions;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders
/** Instantiates the template using informations provided by
* the wizard.
*
* @param wiz the wizard
* @return set of data objects that has been created (should contain
* at least one)
* @exception IOException if the instantiation fails
*/
public java.util.Set instantiate(TemplateWizard wiz) throws IOException {
String n = wiz.getTargetName ();
DataFolder folder = wiz.getTargetFolder ();
DataObject template = wiz.getTemplate ();
DataObject obj = n == null ?
template.createFromTemplate (folder)
:
template.createFromTemplate (folder, n);
// run default action (hopefully should be here)
final Node node = obj.getNodeDelegate ();
final Action a = node.getPreferredAction();
if (a != null) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
}
});
}
return java.util.Collections.singleton(obj);
}
内容来源于网络,如有侵权,请联系作者删除!