Java Code Examples for org.netbeans.spi.project.ActionProvider#COMMAND_DEBUG_TEST_SINGLE

The following examples show how to use org.netbeans.spi.project.ActionProvider#COMMAND_DEBUG_TEST_SINGLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestNGExecutionManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String[] getActionNames(String[] targetNames) {
    String[] actions = new String[targetNames.length];
    for (int i = 0; i < targetNames.length; i++) {
        if (targetNames[i].equals("test-single")) {                      //NOI18N
            actions[i] = ActionProvider.COMMAND_TEST_SINGLE;
        } else if (targetNames[i].equals("debug-test")) {                //NOI18N
            actions[i] = ActionProvider.COMMAND_DEBUG_TEST_SINGLE;
        } else if (targetNames[i].equals("test-unit")) {                //NOI18N
            actions[i] = ActionProvider.COMMAND_TEST;
        } else if (targetNames[i].equals("test-method")) {                //NOI18N
            actions[i] = SingleMethod.COMMAND_RUN_SINGLE_METHOD;
        } else if (targetNames[i].equals("debug-test-single-nb")) {                //NOI18N
            String testMethods = properties.getProperty("test.methods");//NOI18N
            if (testMethods != null) {
                actions[i] = SingleMethod.COMMAND_DEBUG_SINGLE_METHOD;
            } else {
                actions[i] = ActionProvider.COMMAND_DEBUG_TEST_SINGLE;
            }
        } else {
            actions[i] = targetNames[i];
        }
    }
    return actions;
}
 
Example 2
Source File: DefaultReplaceTokenProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override public String convert(String action, Lookup lookup) {
    if (SingleMethod.COMMAND_DEBUG_SINGLE_METHOD.equals(action)) {
        return ActionProvider.COMMAND_DEBUG_TEST_SINGLE;
    }
    if (SingleMethod.COMMAND_RUN_SINGLE_METHOD.equals(action)) {
        return ActionProvider.COMMAND_TEST_SINGLE;
    }
    if (ActionProvider.COMMAND_RUN_SINGLE.equals(action) ||
        ActionProvider.COMMAND_DEBUG_SINGLE.equals(action) ||
        ActionProvider.COMMAND_PROFILE_SINGLE.equals(action)) {
        FileObject[] fos = extractFileObjectsfromLookup(lookup);
        if (fos.length > 0) {
            FileObject fo = fos[0];
            if ("text/x-java".equals(fo.getMIMEType())) {//NOI18N
                Sources srcs = ProjectUtils.getSources(project);
                SourceGroup[] grp = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
                for (int i = 0; i < grp.length; i++) {
                    String relPath = FileUtil.getRelativePath(grp[i].getRootFolder(), fo);
                    if (relPath != null) {
                        if (SourceUtils.isMainClass(relPath.replaceFirst("[.]java$", "").replace('/', '.'), ClasspathInfo.create(fo), true)) {
                            return action + ".main";//NOI18N
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
Example 3
Source File: JavaActionProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NonNull
public ScriptAction createDefaultScriptAction(
        @NonNull final String command,
        final boolean javaModelSensitive,
        final boolean scanSensitive,
        final boolean enabledInCoS,
        @NonNull final Supplier<? extends String[]> targets,
        @NullAllowed final CustomFileExecutor customFileExecutor) {
    Parameters.notNull("command", command);         //NOI18N
    Parameters.notNull("targets", targets);         //NOI18N
    switch (command) {
        case ActionProvider.COMMAND_CLEAN:
            return createNonCosAction(command, false, javaModelSensitive, scanSensitive, enabledInCoS, targets, Collections.emptyMap());
        case ActionProvider.COMMAND_REBUILD:
            return createNonCosAction(command, true, javaModelSensitive, scanSensitive, enabledInCoS, targets, Collections.emptyMap());
        case ActionProvider.COMMAND_BUILD:
            return createBuildAction(javaModelSensitive, scanSensitive, enabledInCoS, targets, mfs);
        case ActionProvider.COMMAND_RUN:
        case ActionProvider.COMMAND_DEBUG:
        case ActionProvider.COMMAND_DEBUG_STEP_INTO:
        case ActionProvider.COMMAND_PROFILE:
            return createRunAction(command, javaModelSensitive, scanSensitive, enabledInCoS, targets, mfs, mainClassServices);
        case ActionProvider.COMMAND_TEST:
            return createNonCosAction(command, true, javaModelSensitive, scanSensitive, enabledInCoS, targets, Collections.singletonMap("ignore.failing.tests", "true"));  //NOI18N);
        case ActionProvider.COMMAND_COMPILE_SINGLE:
            return createCompileSingleAction(javaModelSensitive, scanSensitive, enabledInCoS, sourceRoots, testRoots, targets);
        case ActionProvider.COMMAND_RUN_SINGLE:
        case ActionProvider.COMMAND_DEBUG_SINGLE:
        case ActionProvider.COMMAND_PROFILE_SINGLE:
            return createRunSingleAction(
                    command, javaModelSensitive, scanSensitive, enabledInCoS,
                    sourceRoots, testRoots, targets, customFileExecutor);
        case ActionProvider.COMMAND_TEST_SINGLE:
            return createTestSingleAction(javaModelSensitive, scanSensitive, enabledInCoS, sourceRoots, testRoots, targets);
        case ActionProvider.COMMAND_DEBUG_TEST_SINGLE:
        case ActionProvider.COMMAND_PROFILE_TEST_SINGLE:
            return createDebugTestSingleAction(command, javaModelSensitive, scanSensitive, enabledInCoS, sourceRoots, testRoots, targets);
        case SingleMethod.COMMAND_RUN_SINGLE_METHOD:
        case SingleMethod.COMMAND_DEBUG_SINGLE_METHOD:
            return createRunSingleMethodAction(command, javaModelSensitive, scanSensitive, enabledInCoS, testRoots, targets);
        case JavaProjectConstants.COMMAND_DEBUG_FIX:
            return createDebugFixAction(command, javaModelSensitive, scanSensitive, enabledInCoS, sourceRoots, testRoots, targets);
        default:
            throw new UnsupportedOperationException(String.format("Unsupported command: %s", command)); //NOI18N
    }
}
 
Example 4
Source File: ActionProviderImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages({
    "# {0} - artifactId", "TXT_Run=Run ({0})",
    "# {0} - artifactId", "TXT_Debug=Debug ({0})",
    "# {0} - artifactId", "TXT_ApplyCodeChanges=Apply Code Changes ({0})",
    "# {0} - artifactId", "TXT_Profile=Profile ({0})",
    "# {0} - artifactId", "TXT_Test=Test ({0})",
    "# {0} - artifactId", "TXT_Build=Build ({0})",
    "# {0} - artifactId", "TXT_Delete=Delete ({0})",
})

static String taskName(Project project, String action, Lookup lkp) {
    String title;
    DataObject dobj = lkp.lookup(DataObject.class);
    String dobjName = dobj != null ? dobj.getName() : "";
    Project prj = project != null ? project : lkp.lookup(Project.class);
    String prjLabel = prj != null ? ProjectUtils.getInformation(prj).getDisplayName() : "No Project on Lookup"; //NOI18N
    switch (action) {
        case ActionProvider.COMMAND_RUN:
            title = TXT_Run(prjLabel);
            break;
        case ActionProvider.COMMAND_DEBUG:
            title = TXT_Debug(prjLabel);
            break;
        case ActionProvider.COMMAND_DELETE:
            title = TXT_Delete(prjLabel);
            break;
        case ActionProvider.COMMAND_PROFILE:
            title = TXT_Profile(prjLabel);
            break;
        case ActionProvider.COMMAND_TEST:
            title = TXT_Test(prjLabel);
            break;
        case ActionProvider.COMMAND_RUN_SINGLE:
            title = TXT_Run(dobjName);
            break;
        case ActionProvider.COMMAND_DEBUG_SINGLE:
        case ActionProvider.COMMAND_DEBUG_TEST_SINGLE:
            title = TXT_Debug(dobjName);
            break;
        case ActionProvider.COMMAND_PROFILE_SINGLE:
        case ActionProvider.COMMAND_PROFILE_TEST_SINGLE:
            title = TXT_Profile(dobjName);
            break;
        case ActionProvider.COMMAND_TEST_SINGLE:
            title = TXT_Test(dobjName);
            break;
        case "debug.fix":
            title = TXT_ApplyCodeChanges(prjLabel);
            break;
        default:
            title = TXT_Build(prjLabel);
    }
    return title;
}