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

The following examples show how to use org.netbeans.spi.project.ActionProvider#COMMAND_RUN . 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: AbstractOutputHandler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean isProtectedWait(Project proj, RunConfig config) {
    String action = config.getActionName();
    if(action == null || proj == null || !RunUtils.isCompileOnSaveEnabled(proj)) {
        return false;
    }
    switch(action) {
        case ActionProvider.COMMAND_RUN: 
        case ActionProvider.COMMAND_RUN_SINGLE:
        case ActionProvider.COMMAND_DEBUG:
        case ActionProvider.COMMAND_DEBUG_SINGLE:
        case ActionProviderImpl.COMMAND_DEBUG_MAIN:
        case ActionProviderImpl.COMMAND_RUN_MAIN:
            return true;
        default:
            return false;
    }
}
 
Example 2
Source File: RemoteBuildPropertiesProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
@SuppressWarnings("fallthrough")
public Set<String> createConcealedProperties(@NonNull final String command, @NonNull final Lookup context) {
    Parameters.notNull("command", command); //NOI18N
    Parameters.notNull("context", context); //NOI18N
    switch (command) {
        case ActionProvider.COMMAND_RUN:
        case ActionProvider.COMMAND_DEBUG:
        case ActionProvider.COMMAND_PROFILE:
            final RemotePlatform rp = Utilities.getRemotePlatform(prj);
            if (rp != null) {
            final ConnectionMethod.Authentification.Kind kind = rp.getConnectionMethod().getAuthentification().getKind();
                switch (kind) {
                    case PASSWORD:
                        return Collections.singleton(PROP_PASSWD);
                    case KEY:
                        return Collections.singleton(PROP_PASSPHRASE);
                    default:
                        throw new IllegalStateException(kind.name());
                }
            }
        default:
            return Collections.<String>emptySet();
    }
}
 
Example 3
Source File: J2eeActionsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isActionEnable(String action, Project project, Lookup lookup) {
    final String packagingType = project.getLookup().lookup(NbMavenProject.class).getPackagingType();
    if ("app-client".equals(packagingType)) {
        return false;
    }
    switch (action) {
        case ACT_DEBUG:
        case ACT_RUN:
        case ACT_PROFILE:
            //only enable for doc root fileobjects..
            return true;
        case ActionProvider.COMMAND_RUN:
        case ActionProvider.COMMAND_DEBUG:
        case ActionProvider.COMMAND_PROFILE:
            //performance, don't read the xml file to figure enablement..
            return true;
        default:
            return false;
    }
}
 
Example 4
Source File: Actions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Action runProject() {
    Action a = new ProjectAction(
        ActionProvider.COMMAND_RUN, 
        NbBundle.getMessage(Actions.class, "LBL_RunProjectAction_Name"),
        NbBundle.getMessage(Actions.class, "LBL_RunProjectAction_Name_popup"),
        null,
        null ); 
    a.putValue("iconBase","org/netbeans/modules/project/ui/resources/runCurrentProject.gif"); //NOI18N
    return a;
}
 
Example 5
Source File: Actions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Action runMainProject() {
    Action a = new MainProjectActionWithHistory(
        ActionProvider.COMMAND_RUN,
        NbBundle.getMessage(Actions.class, "LBL_RunMainProjectAction_Name"),null); //NOI18N
    a.putValue("iconBase","org/netbeans/modules/project/ui/resources/runProject.png"); //NOI18N
    return a;
}
 
Example 6
Source File: AndroidProjectActionProvider.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public String[] getSupportedActions() {
    return new String[]{ActionProvider.COMMAND_REBUILD, ActionProvider.COMMAND_BUILD,
        AndroidConstants.COMMAND_BUILD_TEST,
        ActionProvider.COMMAND_CLEAN,
        ActionProvider.COMMAND_RUN,
        ActionProvider.COMMAND_TEST,
        ActionProvider.COMMAND_DEBUG,};
}
 
Example 7
Source File: AndroidProjectActionProvider.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public void invokeAction(String command, Lookup context) throws IllegalArgumentException {
     switch (command) {
            case ActionProvider.COMMAND_REBUILD:
                callGradleRebuild();
                break;
            case ActionProvider.COMMAND_BUILD:
                callGradleBuild();
                break;
            case ActionProvider.COMMAND_CLEAN:
                callGradleClean();
                break;
        }
    if (project.getLookup().lookup(AndroidProject.class) != null) {
        switch (command) {
            case AndroidConstants.COMMAND_BUILD_TEST:
                callAndroidTest();
                break;
            case ActionProvider.COMMAND_RUN:
                callLaunch(COMMAND_RUN);
                break;
            case ActionProvider.COMMAND_DEBUG:
                callLaunch(COMMAND_DEBUG);
                break;
        }
    }
}
 
Example 8
Source File: Launches.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static MainActivityConfiguration getActivityConfiguration(String command, Project project) {
    switch (command) {
        case ActionProvider.COMMAND_RUN:
        case ActionProvider.COMMAND_TEST:
        case ActionProvider.COMMAND_TEST_SINGLE:
            return project.getLookup().lookup(RunActivityConfiguration.class);
        default:
            return project.getLookup().lookup(DebugActivityConfiguration.class);
    }
}
 
Example 9
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 10
Source File: RemoteBuildPropertiesProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
@SuppressWarnings("fallthrough")
public Map<String, String> createAdditionalProperties(
        @NonNull final String command,
        @NonNull final Lookup context) {
    Parameters.notNull("command", command); //NOI18N
    Parameters.notNull("context", context); //NOI18N
    switch (command) {
        case ActionProvider.COMMAND_RUN:
        case ActionProvider.COMMAND_DEBUG:            
        case ActionProvider.COMMAND_PROFILE:
            final RemotePlatform rp = Utilities.getRemotePlatform(prj);
            if (rp != null) {
                final ConnectionMethod.Authentification auth = rp.getConnectionMethod().getAuthentification();                    
                Map<String,String> res = new HashMap<>();
                String target = Utilities.getTargetOSForRP(
                    rp.getSystemProperties().get("os.name"),    //NOI18N
                    rp.getSystemProperties().get("os.arch"),    //NOI18N
                    rp.getSystemProperties().get("sun.arch.abi"),   //NOI18N
                    rp.getSystemProperties().get(("java.vm.name"))); //NOI18N
                res.put(PROP_JAVA_SPEC_VER, rp.getSystemProperties().get("java.specification.version").replace(".","")); //NOI18N
                res.put(PROP_OS_ARCH_RP, target);
                res.put(PROP_FILENAME_RP, target.replace("-", "").replace("15","")); //NOI18N
                switch (auth.getKind()) {
                    case PASSWORD:
                        res.put(
                            PROP_PASSWD,
                            ((ConnectionMethod.Authentification.Password)auth).getPassword());
                        break;
                    case KEY:
                        res.put(
                            PROP_PASSPHRASE,
                            ((ConnectionMethod.Authentification.Key)auth).getPassPhrase());
                        break;
                    default:
                        throw new IllegalStateException(auth.getKind().name());
                }
                return Collections.unmodifiableMap(res);
            }
        default:
            return Collections.<String,String>emptyMap();
    }
}
 
Example 11
Source File: RunProjectCommand.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public String getCommandId() {
    return ActionProvider.COMMAND_RUN;
}
 
Example 12
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;
}