当前位置: 首页>>代码示例>>Java>>正文


Java ActionProvider.isActionEnabled方法代码示例

本文整理汇总了Java中org.netbeans.spi.project.ActionProvider.isActionEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ActionProvider.isActionEnabled方法的具体用法?Java ActionProvider.isActionEnabled怎么用?Java ActionProvider.isActionEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.spi.project.ActionProvider的用法示例。


在下文中一共展示了ActionProvider.isActionEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canDestroy

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public boolean canDestroy() {
    Project p = getLookup().lookup(Project.class);
    if (p == null) {
        return false;
    }
    ActionProvider ap = p.getLookup().lookup(ActionProvider.class);

    String[] sa = ap != null ? ap.getSupportedActions() : new String[0];
    int k = sa.length;

    for (int i = 0; i < k; i++) {
        if (ActionProvider.COMMAND_DELETE.equals(sa[i])) {
            return ap.isActionEnabled(ActionProvider.COMMAND_DELETE, getLookup());
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProjectsRootNode.java

示例2: supportsProfileFile

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
static boolean supportsProfileFile(String command, FileObject file) {
    Project p = file == null ? null : FileOwnerQuery.getOwner(file);
    if (p == null) return false;
    
    ActionProvider ap = p.getLookup().lookup(ActionProvider.class);
    try {
        if (ap != null && contains(ap.getSupportedActions(), command)) {
            ProjectProfilingSupport ppp = ProjectProfilingSupport.get(p);
            return ppp.isProfilingSupported() && ppp.isFileObjectSupported(file) &&
                   ap.isActionEnabled(command, getContext(file, p, command));
        }
    } catch (IllegalArgumentException e) {
        // command not supported
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FileSensitivePerformer.java

示例3: runAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private void runAction(String action) {
    Project project = getProject();
    if (project != null) {
        Lookup lookup = project.getLookup();
        if (fileForDocument != null) {
            try {
                DataObject dobj = DataObject.find(fileForDocument);
                lookup = dobj.getLookup();
            } catch (DataObjectNotFoundException ex) {
                Exceptions.printStackTrace(ex);
            }
        }

        ActionProvider provider = project.getLookup().lookup(ActionProvider.class);
        if (provider != null) {
            if (provider.isActionEnabled(action, lookup)) {
                provider.invokeAction(action, lookup);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CoverageSideBar.java

示例4: invokeAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private void invokeAction() {
    Project p = MainProjectManager.getDefault ().getMainProject ();
    ActionProvider actionProvider = p.getLookup ().lookup (
            ActionProvider.class
        );
    if (Arrays.asList(actionProvider.getSupportedActions ()).contains(ActionProvider.COMMAND_DEBUG_STEP_INTO) &&
        actionProvider.isActionEnabled(ActionProvider.COMMAND_DEBUG_STEP_INTO, p.getLookup())) {

        actionProvider.invokeAction (
                ActionProvider.COMMAND_DEBUG_STEP_INTO,
                p.getLookup ()
            );
    } else {
        Utilities.disabledActionBeep();
        setEnabled (
            ActionsManager.ACTION_STEP_INTO,
            false
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:StepIntoActionProvider.java

示例5: isActionEnabled

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public boolean isActionEnabled(String command, Lookup context) throws IllegalArgumentException {
    boolean supported = false;
    for (ActionProvider ap : delegates()) {
        if (Arrays.asList(ap.getSupportedActions()).contains(command)) {
            supported = true;
            boolean enabled = ap.isActionEnabled(command, context);
            LOG.log(Level.FINE, "delegate {0} says enabled={1} for {2} in {3}", new Object[] {ap, enabled, command, context});
            if (enabled) {
                return true;
            }
        }
    }
    if (supported) {
        return false;
    } else {
        // Not supported by anyone.
        throw new IllegalArgumentException(command);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:LookupMergerImpl.java

示例6: rerun

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public void rerun() {
    if ((properties.getProperty("test.includes") != null && properties.getProperty("test.includes").endsWith(".xml")) ||    //NOI18N
            (properties.getProperty("test.class") != null && properties.getProperty("test.class").endsWith(".xml"))) {   //NOI18N
        if (properties.getProperty("continue.after.failing.tests") == null) {   //NOI18N
            properties.setProperty("continue.after.failing.tests", "true");  //NOI18N
        }
        try {
            runAnt(FileUtil.toFileObject(scriptFile), targets, properties);
        } catch (IOException ex) {
            LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        }
    } else {
        Project project = testSession.getProject();
        if(ProjectManager.getDefault().isValid(project)) {
            ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class);
            String[] actionNames = getActionNames(targets);
            if (actionProvider != null) {
                if (Arrays.asList(actionProvider.getSupportedActions()).contains(actionNames[0])
                        && actionProvider.isActionEnabled(actionNames[0], lookup)) {
                    actionProvider.invokeAction(actionNames[0], lookup);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TestNGExecutionManager.java

示例7: getActions

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public Action[] getActions(boolean context) {
    List<Action> actions = new ArrayList<Action>();
    Action preferred = getPreferredAction();
    if (preferred != null) {
        actions.add(preferred);
    }

    FileObject testFO = ((JUnitTestSuite)getSuite()).getSuiteFO();
    if (testFO != null){
        ActionProvider actionProvider = OutputUtils.getActionProvider(testFO);
        if (actionProvider != null){
            List supportedActions = Arrays.asList(actionProvider.getSupportedActions());
            Lookup nodeContext = Lookups.singleton(testFO);

            if (supportedActions.contains(ActionProvider.COMMAND_TEST_SINGLE) &&
                    actionProvider.isActionEnabled(ActionProvider.COMMAND_TEST_SINGLE, nodeContext)) {
                actions.add(new TestMethodNodeAction(actionProvider, 
                        nodeContext, ActionProvider.COMMAND_TEST_SINGLE, Bundle.LBL_RerunTest()));
            }
            if (supportedActions.contains(ActionProvider.COMMAND_DEBUG_TEST_SINGLE) &&
                    actionProvider.isActionEnabled(ActionProvider.COMMAND_DEBUG_TEST_SINGLE, nodeContext)) {
                actions.add(new TestMethodNodeAction(actionProvider,
                        nodeContext, ActionProvider.COMMAND_DEBUG_TEST_SINGLE, Bundle.LBL_DebugTest()));
            }
        }
    }
    
    return actions.toArray(new Action[actions.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:AntJUnitTestsuiteNode.java

示例8: globalProvider

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private ActionProvider globalProvider(Lookup context) {
    for (ActionProvider ap : Lookup.getDefault().lookupAll(ActionProvider.class)) {
        if (Arrays.asList(ap.getSupportedActions()).contains(command) && ap.isActionEnabled(command, context)) {
            return ap;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:FileAction.java

示例9: supportsProfileProject

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
static boolean supportsProfileProject(String command, Project project) {
    if (project == null) return false;
    ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
    try {
        if (ap != null && contains(ap.getSupportedActions(), command)) {
            ProjectProfilingSupport ppp = ProjectProfilingSupport.get(project);
            return ppp.isProfilingSupported() && ap.isActionEnabled(command, project.getLookup());
        }
    } catch (IllegalArgumentException e) {
        // command not supported
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ProjectSensitivePerformer.java

示例10: runAllTests

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private void runAllTests(ActionEvent evt) {//GEN-FIRST:event_runAllTests
    Lookup lookup = project.getLookup();
    ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class);
    CoverageProvider coverageProvider = CoverageManagerImpl.getProvider(project);
    String action = ActionProvider.COMMAND_TEST;
    if (coverageProvider != null && coverageProvider.getTestAllAction() != null) {
        action = coverageProvider.getTestAllAction();
    }
    if (actionProvider != null) {
        if (actionProvider.isActionEnabled(ActionProvider.COMMAND_TEST, lookup)) {
            actionProvider.invokeAction(action, lookup);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CoverageReportTopComponent.java

示例11: invokeAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public void invokeAction(String command, Lookup context) throws IllegalArgumentException {
    for (ActionProvider ap : lkpResult.allInstances()) {
        if (Arrays.asList(ap.getSupportedActions()).contains(command) &&
            ap.isActionEnabled(command, context)) {
            ap.invokeAction(command, context);
            return;
        }
    }
    throw new IllegalArgumentException(String.format(command));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:LookupProviderSupport.java

示例12: shouldBeEnabled

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private boolean shouldBeEnabled () {
    
    // check if current project supports this action
    Project p = MainProjectManager.getDefault ().getMainProject ();
    if (p == null) {
        return false;
    }
    ActionProvider actionProvider = p.getLookup().lookup(ActionProvider.class);
    if (actionProvider == null) {
        return false;
    }
    String[] sa = actionProvider.getSupportedActions ();
    int i, k = sa.length;
    for (i = 0; i < k; i++) {
        if (ActionProvider.COMMAND_DEBUG_STEP_INTO.equals (sa [i])) {
            break;
        }
    }
    if (i == k) {
        return false;
    }
    
    if (DebuggerManager.getDebuggerManager().getDebuggerEngines().length > 0) {
        // Do not enable this non-contextual action when some debugging session is already running.
        return false;
    }
    // check if this action should be enabled
    return actionProvider.isActionEnabled (
        ActionProvider.COMMAND_DEBUG_STEP_INTO,
        p.getLookup ()
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:StepIntoActionProvider.java

示例13: shouldBeEnabled

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private boolean shouldBeEnabled () {
    // check if current debugger supports this action
    if (!debugger.canFixClasses()) {
        return false;
    }
    // check if current project supports this action
    isFixCommandSupported = false;
    Project p = getCurrentProject();
    if (p != null) {
        ActionProvider actionProvider = (ActionProvider) p.getLookup ().
            lookup (ActionProvider.class);
        if (actionProvider != null) {
            String[] sa = actionProvider.getSupportedActions ();
            int i, k = sa.length;
            for (i = 0; i < k; i++) {
                if (JavaProjectConstants.COMMAND_DEBUG_FIX.equals (sa [i])) {
                    break;
                }
            }
            isFixCommandSupported = i < k &&
                    actionProvider.isActionEnabled(JavaProjectConstants.COMMAND_DEBUG_FIX, getLookup());
        }
    }
    if (!isFixCommandSupported) {
        // No fix command, let's see whether we have some changed classes to reload:
        return ClassesToReload.getInstance().hasClassesToReload(debugger, getSourceRootsFO(sp));
        /*Sources sources = ProjectUtils.getSources(p);
        SourceGroup[] srcGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (SourceGroup srcGroup : srcGroups) {
            FileObject src = srcGroup.getRootFolder();
            if (hasClassesToReload(debugger, src)) {
                return true;
            }
        }
        return false;
         */
    } else {
        return true;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:FixActionProvider.java

示例14: enable

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public boolean enable(Project project) {
    if (ShellProjectUtils.findPlatform(project) == null) {
        return false;
    }
    ActionProvider p = project.getLookup().lookup(ActionProvider.class);
    if (p == null) {
        return false;
    }
    return p.isActionEnabled(ActionProvider.COMMAND_BUILD, Lookups.singleton(project));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:REPLAction2.java

示例15: perform

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@NbBundle.Messages({
    "ERR_CannotBuildProject=Could not build the project",
    "ERR_ProjectBuildFailed=Project build failed, please check Output window",
})
@Override
public void perform(Project project) {
    ActionProvider p = project.getLookup().lookup(ActionProvider.class);
    // check whether the is CoS enabled fo the project
    if (ShellProjectUtils.isCompileOnSave(project)) {
        doRunShell(project);
        return;
    }
    if (p == null || !p.isActionEnabled(ActionProvider.COMMAND_BUILD, Lookups.singleton(project))) {
        StatusDisplayer.getDefault().setStatusText(Bundle.ERR_CannotBuildProject());
        return;
    }
    p.invokeAction(ActionProvider.COMMAND_BUILD, Lookups.fixed(project, new ActionProgress() {
        @Override
        protected void started() {
            // no op
        }

        @Override
        public void finished(boolean success) {
            if (success) {
                doRunShell(project);
            } else {
                StatusDisplayer.getDefault().setStatusText(Bundle.ERR_ProjectBuildFailed());
            }
        }
    }));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:REPLAction2.java


注:本文中的org.netbeans.spi.project.ActionProvider.isActionEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。