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

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

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

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

  1. @Override
  2. public javax.swing.Action getPreferredAction() {
  3. javax.swing.Action retValue;
  4. if (overridesAMethod("getDefaultAction")) { // NOI18N
  5. retValue = super.getPreferredAction();
  6. } else {
  7. retValue = original.getPreferredAction();
  8. }
  9. return retValue;
  10. }

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

  1. public javax.swing.Action getPreferredAction() {
  2. javax.swing.Action retValue;
  3. if (overridesAMethod ("getDefaultAction", new Class[0])) { // NOI18N
  4. retValue = super.getPreferredAction();
  5. } else {
  6. retValue = original.getPreferredAction();
  7. }
  8. return retValue;
  9. }

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

  1. public javax.swing.Action getPreferredAction() {
  2. javax.swing.Action retValue;
  3. if (overridesAMethod ("getDefaultAction", new Class[0])) { // NOI18N
  4. retValue = super.getPreferredAction();
  5. } else {
  6. retValue = original.getPreferredAction();
  7. }
  8. return retValue;
  9. }

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

  1. public boolean acceptNodes(Node[] nodes) {
  2. // don't allow multiple selections
  3. if ((nodes == null) || (nodes.length != 1)) {
  4. return false;
  5. }
  6. Node n = nodes[0];
  7. Action a = n.getPreferredAction();
  8. if ((a != null) && a.isEnabled()) {
  9. a.actionPerformed(new ActionEvent(n, 0, "")); // NOI18N
  10. return true;
  11. }
  12. return false;
  13. }
  14. };

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

  1. public boolean acceptNodes (Node[] nodes) {
  2. // don't allow multiple selections
  3. if ((nodes == null) || (nodes.length != 1)) {
  4. return false;
  5. }
  6. Node n = nodes[0];
  7. Action a = n.getPreferredAction();
  8. if (a != null && a.isEnabled()) {
  9. a.actionPerformed(new ActionEvent(n, 0, "")); // NOI18N
  10. return true;
  11. }
  12. return false;
  13. }
  14. };

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

  1. public boolean acceptNodes (Node[] nodes) {
  2. // don't allow multiple selections
  3. if ((nodes == null) || (nodes.length != 1)) {
  4. return false;
  5. }
  6. Node n = nodes[0];
  7. Action a = n.getPreferredAction();
  8. if (a != null && a.isEnabled()) {
  9. a.actionPerformed(new ActionEvent(n, 0, "")); // NOI18N
  10. return true;
  11. }
  12. return false;
  13. }
  14. };

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

  1. public void actionPerformed(ActionEvent evt) {
  2. Node[] nodes = manager.getSelectedNodes();
  3. if (nodes.length == 1) {
  4. Action a = nodes[0].getPreferredAction();
  5. if (a != null) {
  6. if (a.isEnabled()) {
  7. a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  8. } else {
  9. Toolkit.getDefaultToolkit().beep();
  10. }
  11. }
  12. }
  13. }

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

  1. public void actionPerformed(ActionEvent evt) {
  2. Node[] nodes = manager.getSelectedNodes();
  3. if (nodes.length == 1) {
  4. Action a = nodes[0].getPreferredAction();
  5. if (a != null) {
  6. if (a.isEnabled()) {
  7. a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  8. } else {
  9. Toolkit.getDefaultToolkit().beep();
  10. }
  11. }
  12. }
  13. }

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

  1. static void performPreferredActionOnNodes(Node[] nodes) {
  2. if (nodes.length > 0) {
  3. Action a = nodes[0].getPreferredAction();
  4. if (a == null) {
  5. return;
  6. }
  7. for (int i=1; i<nodes.length; i++) {
  8. Action ai = nodes[i].getPreferredAction();
  9. if (ai == null || !ai.equals(a)) {
  10. return;
  11. }
  12. }
  13. // switch to replacement action if there is some
  14. a = takeAction(a, nodes);
  15. if (a != null && a.isEnabled()) {
  16. a.actionPerformed(new ActionEvent(
  17. nodes.length == 1 ? nodes[0] : nodes,
  18. ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  19. } else {
  20. Toolkit.getDefaultToolkit().beep();
  21. }
  22. }
  23. }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-bugtracking-commons

  1. @Override
  2. public void keyTyped(KeyEvent e) {
  3. if (e.getKeyChar() == '\n') { // NOI18N
  4. int row = table.getSelectedRow();
  5. if (row != -1) {
  6. row = sorter.modelIndex(row);
  7. Action action = tableModel.getNodes()[row].getPreferredAction();
  8. if (action.isEnabled()) {
  9. action.actionPerformed(new ActionEvent(this, 0, "")); // NOI18N
  10. }
  11. }
  12. }
  13. }

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

  1. /**
  2. * Invoked when an action occurs.
  3. */
  4. public void actionPerformed(ActionEvent e) {
  5. if (treeTable.getSelectedColumn() != ((TreeTable)treeTable).getTreeColumnIndex())
  6. return;
  7. Node[] nodes = manager.getSelectedNodes();
  8. if (nodes.length == 1) {
  9. Action a = nodes[0].getPreferredAction();
  10. if (a != null) {
  11. if (a.isEnabled()) {
  12. a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  13. } else {
  14. Toolkit.getDefaultToolkit().beep();
  15. }
  16. }
  17. }
  18. }

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

  1. /**
  2. * Invoked when an action occurs.
  3. */
  4. public void actionPerformed(ActionEvent e) {
  5. if (treeTable.getSelectedColumn() != ((TreeTable)treeTable).getTreeColumnIndex())
  6. return;
  7. Node[] nodes = manager.getSelectedNodes();
  8. if (nodes.length == 1) {
  9. Action a = nodes[0].getPreferredAction();
  10. if (a != null) {
  11. if (a.isEnabled()) {
  12. a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  13. } else {
  14. Toolkit.getDefaultToolkit().beep();
  15. }
  16. }
  17. }
  18. }

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

  1. /**
  2. * Invoked when an action occurs.
  3. */
  4. @Override
  5. public void actionPerformed(ActionEvent e) {
  6. if (treeTable.getSelectedColumn() != ((TreeTable) treeTable).getTreeColumnIndex()) {
  7. return;
  8. }
  9. Node[] nodes = manager.getSelectedNodes();
  10. if (nodes.length == 1) {
  11. Action a = nodes[0].getPreferredAction();
  12. if (a != null) {
  13. if (a.isEnabled()) {
  14. a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  15. } else {
  16. Toolkit.getDefaultToolkit().beep();
  17. }
  18. }
  19. }
  20. }
  21. }

代码示例来源:origin: nl.cloudfarming.client/nbtaskfocus-core

  1. @Override
  2. public void run() {
  3. try {
  4. FileObject fo = FileUtil.toFileObject(new File(itemPath).getAbsoluteFile());
  5. DataObject newDo = DataObject.find(fo);
  6. final Node node = newDo.getNodeDelegate();
  7. Action a = node.getPreferredAction();
  8. if (a instanceof ContextAwareAction) {
  9. a = ((ContextAwareAction) a).createContextAwareInstance(node.getLookup());
  10. }
  11. if (a != null) {
  12. a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  13. }
  14. } catch (Exception ex) {
  15. //
  16. }
  17. }
  18. });

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

  1. @Override
  2. public void mouseClicked(MouseEvent e) {
  3. tree.stopEditing();
  4. int selRow = tree.getRowForLocation(e.getX(), e.getY());
  5. if ((selRow != -1) && SwingUtilities.isLeftMouseButton(e) && MouseUtils.isDoubleClick(e)) {
  6. // Default action.
  7. if (defaultActionEnabled) {
  8. TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
  9. Node node = Visualizer.findNode(selPath.getLastPathComponent());
  10. Action a = takeAction(node.getPreferredAction(), node);
  11. if (a != null) {
  12. if (a.isEnabled()) {
  13. a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  14. } else {
  15. Toolkit.getDefaultToolkit().beep();
  16. }
  17. e.consume();
  18. return;
  19. }
  20. }
  21. if (tree.isExpanded(selRow)) {
  22. tree.collapseRow(selRow);
  23. } else {
  24. tree.expandRow(selRow);
  25. }
  26. }
  27. }

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

  1. Node node = Visualizer.findNode (selPath.getLastPathComponent());
  2. Action a = node.getPreferredAction();
  3. if (a != null) {

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

  1. Node node = Visualizer.findNode (selPath.getLastPathComponent());
  2. Action a = node.getPreferredAction();
  3. if (a != null) {

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

  1. Action a = node.getPreferredAction();
  2. if (a != null && (modifiers & java.awt.event.InputEvent.CTRL_MASK) == 0) {
  3. if (a instanceof ContextAwareAction) {

代码示例来源:origin: nl.cloudfarming.client/stock-project

  1. @Override
  2. public Action[] getActions(boolean arg0) {
  3. Action[] nodeActions = new Action[6];
  4. nodeActions[0] = new OpenStockDetailsAction();
  5. nodeActions[1] = CommonProjectActions.copyProjectAction();
  6. nodeActions[2] = CommonProjectActions.deleteProjectAction();
  7. nodeActions[4] = CommonProjectActions.closeProjectAction();
  8. nodeActions[5] = getOriginal().getPreferredAction();
  9. return nodeActions;
  10. }

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

  1. /** Instantiates the template using informations provided by
  2. * the wizard.
  3. *
  4. * @param wiz the wizard
  5. * @return set of data objects that has been created (should contain
  6. * at least one)
  7. * @exception IOException if the instantiation fails
  8. */
  9. public java.util.Set instantiate(TemplateWizard wiz) throws IOException {
  10. String n = wiz.getTargetName ();
  11. DataFolder folder = wiz.getTargetFolder ();
  12. DataObject template = wiz.getTemplate ();
  13. DataObject obj = n == null ?
  14. template.createFromTemplate (folder)
  15. :
  16. template.createFromTemplate (folder, n);
  17. // run default action (hopefully should be here)
  18. final Node node = obj.getNodeDelegate ();
  19. final Action a = node.getPreferredAction();
  20. if (a != null) {
  21. SwingUtilities.invokeLater(new Runnable() {
  22. public void run() {
  23. a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
  24. }
  25. });
  26. }
  27. return java.util.Collections.singleton(obj);
  28. }

相关文章