當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.getPreferredAction方法代碼示例

本文整理匯總了Java中org.openide.nodes.Node.getPreferredAction方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getPreferredAction方法的具體用法?Java Node.getPreferredAction怎麽用?Java Node.getPreferredAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.nodes.Node的用法示例。


在下文中一共展示了Node.getPreferredAction方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invokeDefaultAction

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void invokeDefaultAction (final TopComponent tc) {
    performed = false;
    try {
        Node[] nodes = tc.getActivatedNodes ();
        assertNotNull ("View has the active nodes.", nodes);
        Node n = nodes.length > 0 ? nodes[0] : null;
        assertNotNull ("View has a active node.", n);
        
        final Action action = n.getPreferredAction ();
        action.actionPerformed (new ActionEvent (n, ActionEvent.ACTION_PERFORMED, ""));
        
        // wait to invoke action is propagated
        Thread.sleep (300);
    } catch (Exception x) {
        fail (x.getMessage ());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:DefaultActionTest.java

示例2: processDoubleClick

import org.openide.nodes.Node; //導入方法依賴的package包/類
private boolean processDoubleClick(MouseEvent e) {
    if (e.isShiftDown() || e.isControlDown() || e.isMetaDown()) {
        return false;
    }

    RADComponent metacomp = getMetaComponentAt(e.getPoint(), COMP_SELECTED);
    if (metacomp == null) {
        return true;
    }

    if (e.isAltDown()) {
        if (metacomp == formDesigner.getTopDesignComponent()) {
            metacomp = metacomp.getParentComponent();
            if (metacomp == null) {
                return true;
            }
        } else {
             return false;
        }
    }

    Node node = metacomp.getNodeReference();
    if (node != null) {
        Action action = node.getPreferredAction();
        if (action != null) {// && action.isEnabled()) {
            action.actionPerformed(new ActionEvent(
                    node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
            prevLeftMousePoint = null; // to prevent inplace editing on mouse release
            return true;
        }
    }

    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:HandleLayer.java

示例3: performOpenInEditorAction

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void performOpenInEditorAction(Node node) {
    // XXX how is this supposed to work ???
    Action action = node.getPreferredAction();
    if (action == null || !action.isEnabled()) action = new OpenInEditorAction();
    if (action.isEnabled()) {
        action.actionPerformed(new ActionEvent(this, 0, "")); // NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:UpdateResultsTable.java

示例4: showProfilerSnapshot

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void showProfilerSnapshot(ActionEvent e){
     File tempFile = null;
     try { 
         tempFile = File.createTempFile("selfsampler", ".npss"); // NOI18N
         tempFile = FileUtil.normalizeFile(tempFile);
         try (OutputStream os = new FileOutputStream(tempFile)) {
             os.write(slownData.getNpsContent());
         }

         File varLogs = logsDirectory();
         File gestures = (varLogs != null) ? new File(varLogs, "uigestures") : null; // NOI18N

         SelfSampleVFS fs;
         if (gestures != null && gestures.exists()) {
             fs = new SelfSampleVFS(
                     new String[]{"selfsampler.npss", "selfsampler.log"},
                     new File[]{tempFile, gestures});
         } else {
             fs = new SelfSampleVFS(
                     new String[]{"selfsampler.npss"},
                     new File[]{tempFile});
         }
         FileObject fo = fs.findResource("selfsampler.npss");
         final Node obj = DataObject.find(fo).getNodeDelegate();
         Action a = obj.getPreferredAction();
         if (a instanceof ContextAwareAction) {
             a = ((ContextAwareAction)a).createContextAwareInstance(obj.getLookup());
         }
         a.actionPerformed(e);
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    } finally {
        if (tempFile != null) tempFile.deleteOnExit();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:Installer.java

示例5: instantiate

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** 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 Set<DataObject> instantiate(TemplateWizard wiz) throws IOException {
    String n = wiz.getTargetName ();
    DataFolder folder = wiz.getTargetFolder ();
    DataObject template = wiz.getTemplate ();
    Map<String,Object> wizardProps = new HashMap<String, Object>();
    for (Map.Entry<String, ? extends Object> entry : wiz.getProperties().entrySet()) {
        wizardProps.put("wizard." + entry.getKey(), entry.getValue()); // NOI18N
    }
    
    DataObject obj = template.createFromTemplate (folder, n, wizardProps);

    // run default action (hopefully should be here)
    final Node node = obj.getNodeDelegate ();
    Action _a = node.getPreferredAction();
    if (_a instanceof ContextAwareAction) {
        _a = ((ContextAwareAction) _a).createContextAwareInstance(node.getLookup());
    }
    final Action a = _a;
    if (a != null) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
            }
        });
    }

    return Collections.singleton(obj);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:TemplateWizard.java

示例6: inspectNode

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void inspectNode(Node n) {
    n.getDisplayName();
    n.getHtmlDisplayName();
    n.getShortDescription();
    n.getIcon(BeanInfo.ICON_COLOR_16x16);
    n.canCopy();
    n.canCut();
    n.canRename();
    n.getNewTypes();
    n.getActions(true);
    n.getPreferredAction();
    inspectProperties(n);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:AsynchronousTest.java

示例7: performObjectAt

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** This method is called when user double-clicks on some object or
* presses Enter key.
* @param index Index of object in current explored context
*/
final void performObjectAt(int index, int modifiers) {
    if ((index < 0) || (index >= model.getSize())) {
        return;
    }

    VisualizerNode v = (VisualizerNode) model.getElementAt(index);
    Node node = v.node;

    // if DefaultProcessor is set, the default action is notified to it overriding the default action on nodes
    if (defaultProcessor != null) {
        defaultProcessor.actionPerformed(new ActionEvent(node, 0, null, modifiers));

        return;
    }

    if (showParentNode && NodeListModel.findVisualizerDepth(model, v) == -1) {
        try {
            manager.setExploredContextAndSelection(node.getParentNode(), new Node[] { node });
        } catch (PropertyVetoException ex) {
            // OK, let it be
        }
        return;
    }

    // on double click - invoke default action, if there is any
    // (unless user holds CTRL key what means that we should always dive into the context)
    Action a = node.getPreferredAction();

    if ((a != null) && ((modifiers & InputEvent.CTRL_MASK) == 0)) {
        a = TreeView.takeAction(a, node);

        if (a.isEnabled()) {
            a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
        } else {
            Utilities.disabledActionBeep();
        }
    }
    // otherwise dive into the context
    else if (traversalAllowed && (!node.isLeaf())) {
        manager.setExploredContext(node, manager.getSelectedNodes());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:ListView.java

示例8: openInEDT

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void openInEDT(FileObject fileObject, DataObject dataObject, int line) {
    Class<? extends Node.Cookie> cookieClass;        
    Node.Cookie cookie;
    
    if ((line != -1)
        && (   ((cookie = dataObject.getCookie(cookieClass = EditorCookie.Observable.class)) != null)
            || ((cookie = dataObject.getCookie(cookieClass = EditorCookie.class)) != null) )) {
        boolean ret = openByCookie(cookie, cookieClass, line);
        if (!ret) {
            showNotPlainFileWarning(fileObject);
        }
        return;
    } 
                        
    /* try to open the object using the default action */
    Node dataNode = dataObject.getNodeDelegate();        
    Action action = dataNode.getPreferredAction();
    if ((action != null)
            && !(action instanceof FileSystemAction)
            && !(action instanceof ToolsAction)) {
        if (log.isLoggable(FINEST)) {
            log.log(FINEST, " - using preferred action "            //NOI18N
                    + "(\"{0}\" - {1}) for opening the file",       //NOI18N
                    new Object[]{action.getValue(Action.NAME),
                        action.getClass().getName()});
        }

        if (action instanceof ContextAwareAction) {
            action = ((ContextAwareAction) action)
              .createContextAwareInstance(dataNode.getLookup());
            if (log.isLoggable(FINEST)) {
                log.finest("    - it is a ContextAwareAction");     //NOI18N
                log.log(FINEST, "    - using a context-aware "      //NOI18N
                        + "instance instead (\"{0}\" - {1})",       //NOI18N
                        new Object[]{action.getValue(Action.NAME),
                            action.getClass().getName()});
            }
        }

        log.finest("   - will call action.actionPerformed(...)");   //NOI18N
        final Action a = action;
        final Node n = dataNode;
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {

            @Override
            public void run() {
                a.actionPerformed(new ActionEvent(n, 0, ""));
            }
        });
        return;
    }             
    String fileName = fileObject.getNameExt();
    /* Try to grab an editor/open/edit/view cookie and open the object: */
    StatusDisplayer.getDefault().setStatusText(
            NbBundle.getMessage(DefaultOpenFileImpl.class,
                                "MSG_opening",                      //NOI18N
                                fileName));
    boolean success = openDataObjectByCookie(dataObject, line);
    if (success) {
        return;
    }        
    if (fileObject.isFolder() || FileUtil.isArchiveFile(fileObject)) {
        // select it in explorer:
        final Node node = dataObject.getNodeDelegate();
        if (node != null) {
            WindowManager.getDefault().invokeWhenUIReady(new Runnable() {

                @Override
                public void run() {
                    NodeOperation.getDefault().explore(node);
                }
            });
            return;
        }
    }
    showNotPlainFileWarning(fileObject);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:78,代碼來源:DefaultOpenFileImpl.java


注:本文中的org.openide.nodes.Node.getPreferredAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。