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


Java ActionProvider.getSupportedActions方法代码示例

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


在下文中一共展示了ActionProvider.getSupportedActions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: hasAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public static boolean hasAction(Project project, String actionName) {
    ActionProvider ap = project.getLookup().lookup(ActionProvider.class);

    if (ap == null) {
        return false; // return false if no ActionProvider available
    }

    String[] actions = ap.getSupportedActions();

    for (int i = 0; i < actions.length; i++) {
        if ((actions[i] != null) && actionName.equals(actions[i])) {
            return true;
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProjectUtilities.java

示例3: supportsImages

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private static boolean supportsImages(
    @NullAllowed final ActionProvider ap,
    @NonNull final Lookup ctx) {
    if (ap == null) {
        return false;
    }
    String found = null;
    for (String action : ap.getSupportedActions()) {
        if (NativeBundleType.forCommand(action)!= null) {
            found = action;
            break;
        }
    }
    if (found == null) {
        return false;
    }
    return ap.isActionEnabled(found, ctx);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CreateBundleAction.java

示例4: forRoot

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Override
public CompileOnSaveAction forRoot(URL root) {
    try {
        final Project p = FileOwnerQuery.getOwner(root.toURI());
        if (p != null) {
            ActionProvider prov = p.getLookup().lookup(ActionProvider.class);  
            if (prov != null) {
                prov.getSupportedActions(); //Force initialization
            }
            final CosAction action = CosAction.getInstance(p);
            return action;
        }
    } catch (URISyntaxException e) {
        Exceptions.printStackTrace(e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:J2SEActionProvider.java

示例5: 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

示例6: 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

示例7: enabled

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
public boolean enabled(RerunType type) {
    if ((scriptFile == null) || (targets == null) || (targets.length == 0)){
        return false;
    }
    if (scriptFile.getName().equals(JUNIT_CUSTOM_FILENAME + ".xml")){   //NOI18N
        return true;
    }
    Project project = testSession.getProject();
    if(project == null) { // could not locate the project for which the testSession was invoked for
        return false;
    }
    ActionProvider actionProvider = project.getLookup().lookup(ActionProvider.class);
    if (actionProvider != null){
        boolean runSupported = false;
        for (String action : actionProvider.getSupportedActions()) {
            if (action.equals(targets[0])) {
                runSupported = true;
                break;
            }
        }
        if (runSupported && actionProvider.isActionEnabled(targets[0], lookup)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:JUnitExecutionManager.java

示例8: isEnabledAction

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
protected static boolean isEnabledAction(String command, FileObject fo, Lookup actionContext) {
    Project p = findProject(fo);
    if (p != null) {
        ActionProvider ap = p.getLookup().lookup(ActionProvider.class);
        if (ap != null && ap.getSupportedActions() != null && Arrays.asList(ap.getSupportedActions()).contains(command)) {
            return ap.isActionEnabled(command, actionContext);
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ExecJSAction.java

示例9: getActions

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
@Messages({
    "LBL_RerunTest=Run Again",
    "LBL_DebugTest=Debug"
})
@Override
public Action[] getActions(boolean context) {
    List<Action> actions = new ArrayList<Action>();
    Action preferred = getPreferredAction();
    if (preferred != null) {
        actions.add(preferred);
    }
    FileObject testFO = getTestcaseFileObject();                            
    if (testFO != null){
        Project suiteProject = FileOwnerQuery.getOwner(testFO);
        if (suiteProject != null) {
            ActionProvider actionProvider = suiteProject.getLookup().lookup(ActionProvider.class);
            if (actionProvider != null) {
                boolean runSupported = false;
                boolean debugSupported = false;
                for (String action : actionProvider.getSupportedActions()) {
                    if (!runSupported && action.equals(COMMAND_RUN_SINGLE_METHOD)) {
                        runSupported = true;
                        if (debugSupported) {
                            break;
                        }
                    }
                    if (!debugSupported && action.equals(COMMAND_DEBUG_SINGLE_METHOD)) {
                        debugSupported = true;
                        if (runSupported) {
                            break;
                        }
                    }
                }

                SingleMethod methodSpec = new SingleMethod(testFO, testcase.getName());
                Lookup nodeContext = Lookups.singleton(methodSpec);
                if (runSupported && actionProvider.isActionEnabled(COMMAND_RUN_SINGLE_METHOD,
                        nodeContext)) {
                    actions.add(new TestMethodNodeAction(actionProvider,
                            nodeContext,
                            COMMAND_RUN_SINGLE_METHOD,
                            Bundle.LBL_RerunTest()));
                }
                if (debugSupported && actionProvider.isActionEnabled(COMMAND_DEBUG_SINGLE_METHOD,
                        nodeContext)) {
                    actions.add(new TestMethodNodeAction(actionProvider,
                            nodeContext,
                            COMMAND_DEBUG_SINGLE_METHOD,
                            Bundle.LBL_DebugTest()));
                }
            }
        }
    }
    actions.addAll(Arrays.asList(super.getActions(context)));

    return actions.toArray(new Action[actions.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:MavenJUnitTestMethodNode.java

示例10: shouldBeEnabled

import org.netbeans.spi.project.ActionProvider; //导入方法依赖的package包/类
private boolean shouldBeEnabled () {
    if (editorContext.getCurrentLineNumber () < 0) {
        return false;
    }
    FileObject fo = editorContext.getCurrentFile();
    if (fo == null || !fo.hasExt("java")) {
        return false;
    }
    
    // check if current project supports this action
    Project p = MainProjectManager.getDefault ().getMainProject ();
    if (p == null) {
        return false;
    }
    synchronized (projectBreakpoints) {
        if (projectBreakpoints.containsKey(p)) {
            // Already debugging this project
            return false;
        }
    }
    ActionProvider 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.equals (sa [i])) {
            break;
        }
    }
    if (i == k) {
        return false;
    }

    // check if this action should be enabled
    return actionProvider.isActionEnabled (
            ActionProvider.COMMAND_DEBUG, 
            p.getLookup ()
        );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:RunToCursorActionProvider.java


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