Java Code Examples for com.intellij.execution.RunnerAndConfigurationSettings#getConfiguration()
The following examples show how to use
com.intellij.execution.RunnerAndConfigurationSettings#getConfiguration() .
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: EditTestsAction.java From JHelper with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void performAction(AnActionEvent e) { Project project = e.getProject(); RunnerAndConfigurationSettings selectedConfiguration = RunManagerImpl.getInstanceImpl(project).getSelectedConfiguration(); if (selectedConfiguration == null) { return; } RunConfiguration configuration = selectedConfiguration.getConfiguration(); if (configuration instanceof TaskConfiguration) { TaskConfiguration taskConfiguration = (TaskConfiguration) configuration; Test[] originalTests = taskConfiguration.getTests(); EditTestsDialog dialog = new EditTestsDialog(originalTests, project); dialog.show(); if (!dialog.isOK()) { return; } Test[] newTests = dialog.getTests(); taskConfiguration.setTests(newTests); // @todo: save configuration } }
Example 2
Source File: ProjectUtils.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 6 votes |
/** * adds run configuration dynamically * @param module * @param mainClass * @param boardName */ public static void addProjectConfiguration(final Module module, final String mainClass, final String boardName) { final Runnable r = new Runnable() { @Override public void run() { final RunManager runManager = RunManager.getInstance(module.getProject()); final RunnerAndConfigurationSettings settings = runManager. createRunConfiguration(module.getName(), EmbeddedLinuxJVMConfigurationType.getInstance().getFactory()); final EmbeddedLinuxJVMRunConfiguration configuration = (EmbeddedLinuxJVMRunConfiguration) settings.getConfiguration(); configuration.setName(EmbeddedLinuxJVMBundle.message("runner.name", boardName)); configuration.getRunnerParameters().setRunAsRoot(true); configuration.getRunnerParameters().setMainclass(mainClass); runManager.addConfiguration(settings, false); runManager.setSelectedConfiguration(settings); final Notification notification = new Notification( Notifications.GROUPDISPLAY_ID, EmbeddedLinuxJVMBundle.getString("pi.connection.required"), EmbeddedLinuxJVMBundle.message("pi.connection.notsetup", boardName), NotificationType.INFORMATION); com.intellij.notification.Notifications.Bus.notify(notification); } }; r.run(); }
Example 3
Source File: MongoScriptRunConfigurationProducer.java From nosql4idea with Apache License 2.0 | 6 votes |
@Nullable @Override protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext configurationContext) { sourceFile = location.getPsiElement().getContainingFile(); if (sourceFile != null && sourceFile.getFileType().getName().toLowerCase().contains("javascript")) { Project project = sourceFile.getProject(); VirtualFile file = sourceFile.getVirtualFile(); RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, configurationContext); MongoRunConfiguration runConfiguration = (MongoRunConfiguration) settings.getConfiguration(); runConfiguration.setName(file.getName()); runConfiguration.setScriptPath(file.getPath()); Module module = ModuleUtil.findModuleForPsiElement(location.getPsiElement()); if (module != null) { runConfiguration.setModule(module); } return settings; } return null; }
Example 4
Source File: AbstractExternalSystemRuntimeConfigurationProducer.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @Override protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext context) { if (!(location instanceof ExternalSystemTaskLocation)) { return null; } ExternalSystemTaskLocation taskLocation = (ExternalSystemTaskLocation)location; mySourceElement = taskLocation.getPsiElement(); RunManagerEx runManager = RunManagerEx.getInstanceEx(taskLocation.getProject()); RunnerAndConfigurationSettings settings = runManager.createConfiguration("", getConfigurationFactory()); ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration)settings.getConfiguration(); ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings(); ExternalTaskExecutionInfo task = taskLocation.getTaskInfo(); taskExecutionSettings.setExternalProjectPath(task.getSettings().getExternalProjectPath()); taskExecutionSettings.setTaskNames(task.getSettings().getTaskNames()); configuration.setName(AbstractExternalSystemTaskConfigurationType.generateName(location.getProject(), taskExecutionSettings)); return settings; }
Example 5
Source File: BlazeAndroidRunConfigurationHandler.java From intellij with Apache License 2.0 | 6 votes |
/** Extract {@link BlazeCommandRunConfiguration} from the execution environment. */ static BlazeCommandRunConfiguration getCommandConfig(ExecutionEnvironment env) throws ExecutionException { RunnerAndConfigurationSettings settings = env.getRunnerAndConfigurationSettings(); if (settings == null) { throw new ExecutionException( "Invalid run configuration. Is the project sync state out of date?"); } RunConfiguration configFromEnv = settings.getConfiguration(); if (!(configFromEnv instanceof BlazeCommandRunConfiguration)) { throw new ExecutionException( "Invalid run configurations. Is the project sync state out of date?"); } return (BlazeCommandRunConfiguration) configFromEnv; }
Example 6
Source File: AttachDebuggerAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(AnActionEvent e) { Project project = e.getProject(); if (project == null || project.isDefault()) { super.update(e); return; } if (!FlutterSdkUtil.hasFlutterModules(project)) { // Hide this button in Android projects. e.getPresentation().setVisible(false); return; } RunConfiguration configuration = findRunConfig(project); boolean enabled; if (configuration == null) { RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); if (settings == null) { enabled = false; } else { configuration = settings.getConfiguration(); enabled = configuration instanceof SdkRunConfig; } } else { enabled = true; } if (enabled && (project.getUserData(ATTACH_IS_ACTIVE) != null)) { enabled = false; } e.getPresentation().setVisible(true); e.getPresentation().setEnabled(enabled); }
Example 7
Source File: DeleteTaskAction.java From JHelper with GNU Lesser General Public License v3.0 | 5 votes |
private static void selectSomeTaskConfiguration(RunManagerEx runManager) { for (RunnerAndConfigurationSettings settings : runManager.getAllSettings()) { if (settings.getConfiguration() instanceof TaskConfiguration) { runManager.setSelectedConfiguration(settings); return; } } }
Example 8
Source File: RunConfigurationSerializerTest.java From intellij with Apache License 2.0 | 5 votes |
@Before public final void doSetup() { runManager = RunManagerImpl.getInstanceImpl(getProject()); // Without BlazeProjectData, the configuration editor is always disabled. BlazeProjectDataManager mockProjectDataManager = new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder(workspaceRoot).build()); registerProjectService(BlazeProjectDataManager.class, mockProjectDataManager); RunnerAndConfigurationSettings runnerAndConfigurationSettings = runManager.createConfiguration( "Bazel Configuration", BlazeCommandRunConfigurationType.getInstance().getFactory()); runManager.addConfiguration(runnerAndConfigurationSettings, false); configuration = (BlazeCommandRunConfiguration) runnerAndConfigurationSettings.getConfiguration(); }
Example 9
Source File: CreateAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void perform(final ConfigurationContext context) { final RunManagerImpl runManager = (RunManagerImpl)context.getRunManager(); final RunnerAndConfigurationSettings configuration = context.getConfiguration(); final RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configuration.getFactory()); final RunConfiguration templateConfiguration = template.getConfiguration(); runManager.addConfiguration(configuration, runManager.isConfigurationShared(template), runManager.getBeforeRunTasks(templateConfiguration), false); runManager.setSelectedConfiguration(configuration); }
Example 10
Source File: MainMavenActionGroup.java From MavenHelper with Apache License 2.0 | 5 votes |
private void addRunConfigurations(List<AnAction> result, Project project, final MavenProjectInfo mavenProject) { final List<RunnerAndConfigurationSettings> configurationSettings = RunManager.getInstance(project).getConfigurationSettingsList( MavenRunConfigurationType.getInstance()); String directory = PathUtil.getCanonicalPath(mavenProject.mavenProject.getDirectory()); for (RunnerAndConfigurationSettings cfg : configurationSettings) { MavenRunConfiguration mavenRunConfiguration = (MavenRunConfiguration) cfg.getConfiguration(); if (directory.equals(PathUtil.getCanonicalPath(mavenRunConfiguration.getRunnerParameters().getWorkingDirPath()))) { result.add(getRunConfigurationAction(project, cfg)); } } }
Example 11
Source File: AndroidSyncTest.java From intellij with Apache License 2.0 | 5 votes |
public TestProjectArguments createTestProjectArguments() { Sdk android25 = MockSdkUtil.registerSdk(workspace, "25"); RunManager runManager = RunManagerImpl.getInstanceImpl(getProject()); RunnerAndConfigurationSettings runnerAndConfigurationSettings = runManager.createConfiguration( "Blaze Android Binary Run Configuration", BlazeCommandRunConfigurationType.getInstance().getFactory()); runManager.addConfiguration(runnerAndConfigurationSettings, false); BlazeCommandRunConfiguration configuration = (BlazeCommandRunConfiguration) runnerAndConfigurationSettings.getConfiguration(); TargetInfo target = TargetInfo.builder( Label.create("//java/com/android:app"), ANDROID_BINARY.getKind().getKindString()) .build(); configuration.setTargetInfo(target); workspace.createFile( new WorkspacePath("java/com/google/Source.java"), "package com.google;", "public class Source {}"); workspace.createFile( new WorkspacePath("java/com/google/Other.java"), "package com.google;", "public class Other {}"); VirtualFile javaRoot = workspace.createDirectory(new WorkspacePath("java/com/google")); TargetMap targetMap = targetMap( android_library("//java/com/google:lib") .java_toolchain_version("8") .res("res/values/strings.xml") .src("Source.java", "Other.java"), android_binary("//java/com/android:app")); return new TestProjectArguments(android25, targetMap, javaRoot); }
Example 12
Source File: BeforeRunStepsPanel.java From consulo with Apache License 2.0 | 5 votes |
void doReset(RunnerAndConfigurationSettings settings) { myRunConfiguration = settings.getConfiguration(); originalTasks.clear(); RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()); originalTasks.addAll(runManager.getBeforeRunTasks(myRunConfiguration)); myModel.replaceAll(originalTasks); myShowSettingsBeforeRunCheckBox.setSelected(settings.isEditBeforeRun()); myShowSettingsBeforeRunCheckBox.setEnabled(!(isUnknown())); myPanel.setVisible(checkBeforeRunTasksAbility(false)); updateText(); }
Example 13
Source File: BlazeNativeAndroidDebugger.java From intellij with Apache License 2.0 | 5 votes |
@NotNull @Override protected RunnerAndConfigurationSettings createRunnerAndConfigurationSettings( @NotNull Project project, @NotNull Module module, @NotNull Client client, @Nullable AndroidDebuggerState inputState) { String runConfigurationName = String.format( "%s %s Debugger (%d)", Blaze.getBuildSystem(project).getName(), getDisplayName(), client.getClientData().getPid()); RunnerAndConfigurationSettings runSettings = RunManager.getInstance(project) .createConfiguration( runConfigurationName, new BlazeAndroidNativeAttachConfigurationType.Factory()); BlazeAndroidNativeAttachConfiguration configuration = (BlazeAndroidNativeAttachConfiguration) runSettings.getConfiguration(); configuration.setClient(client); configuration.getAndroidDebuggerContext().setDebuggerType(getId()); configuration.getConfigurationModule().setModule(module); configuration.setConsoleProvider(getConsoleProvider()); // TODO(b/145707569): Copy debugger settings from inputState to state. See // NativeAndroidDebugger. AndroidDebuggerState state = configuration.getAndroidDebuggerContext().getAndroidDebuggerState(); if (state instanceof NativeAndroidDebuggerState) { NativeAndroidDebuggerState nativeState = (NativeAndroidDebuggerState) state; nativeState.setWorkingDir(WorkspaceRoot.fromProject(project).directory().getPath()); } return runSettings; }
Example 14
Source File: CopySourceAction.java From JHelper with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void performAction(AnActionEvent e) { Project project = e.getProject(); if (project == null) throw new NotificationException("No project found", "Are you in any project?"); Configurator configurator = project.getComponent(Configurator.class); Configurator.State configuration = configurator.getState(); RunManagerEx runManager = RunManagerEx.getInstanceEx(project); RunnerAndConfigurationSettings selectedConfiguration = runManager.getSelectedConfiguration(); if (selectedConfiguration == null) { return; } RunConfiguration runConfiguration = selectedConfiguration.getConfiguration(); if (!(runConfiguration instanceof TaskConfiguration)) { Notificator.showNotification( "Not a JHelper configuration", "You have to choose JHelper Task to copy", NotificationType.WARNING ); return; } CodeGenerationUtils.generateSubmissionFileForTask(project, (TaskConfiguration)runConfiguration); VirtualFile file = project.getBaseDir().findFileByRelativePath(configuration.getOutputFile()); if (file == null) throw new NotificationException("Couldn't find output file"); Document document = FileDocumentManager.getInstance().getDocument(file); if (document == null) throw new NotificationException("Couldn't open output file"); StringSelection selection = new StringSelection(document.getText()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); }
Example 15
Source File: AttachDebuggerAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(AnActionEvent e) { Project project = e.getProject(); if (project == null || project.isDefault()) { super.update(e); return; } if (!FlutterSdkUtil.hasFlutterModules(project)) { // Hide this button in Android projects. e.getPresentation().setVisible(false); return; } RunConfiguration configuration = findRunConfig(project); boolean enabled; if (configuration == null) { RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); if (settings == null) { enabled = false; } else { configuration = settings.getConfiguration(); enabled = configuration instanceof SdkRunConfig; } } else { enabled = true; } if (enabled && (project.getUserData(ATTACH_IS_ACTIVE) != null)) { enabled = false; } e.getPresentation().setVisible(true); e.getPresentation().setEnabled(enabled); }
Example 16
Source File: ConfigurationSettingsEditorWrapper.java From consulo with Apache License 2.0 | 5 votes |
private void doApply(final RunnerAndConfigurationSettings settings) { final RunConfiguration runConfiguration = settings.getConfiguration(); final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject()); runManager.setBeforeRunTasks(runConfiguration, myBeforeRunStepsPanel.getTasks(true), false); RunnerAndConfigurationSettings runManagerSettings = runManager.getSettings(runConfiguration); if (runManagerSettings != null) { runManagerSettings.setEditBeforeRun(myBeforeRunStepsPanel.needEditBeforeRun()); } else { settings.setEditBeforeRun(myBeforeRunStepsPanel.needEditBeforeRun()); } }
Example 17
Source File: SetJarManifestCommandLineShortener.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
@Override public void runConfigurationAdded(@NotNull RunnerAndConfigurationSettings settings) { if(settings.getConfiguration() instanceof ConfigurationWithCommandLineShortener) { ((ConfigurationWithCommandLineShortener)settings.getConfiguration()).setShortenCommandLine(ShortenCommandLine.MANIFEST); } }
Example 18
Source File: RunFlutterAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void actionPerformed(@NotNull AnActionEvent e) { // NOTE: When making changes here, consider making similar changes to ConnectAndroidDebuggerAction. FlutterInitializer.sendAnalyticsAction(this); final RunnerAndConfigurationSettings settings = getRunConfigSettings(e); if (settings == null) { return; } final RunConfiguration configuration = settings.getConfiguration(); if (!(configuration instanceof SdkRunConfig)) { // Action is disabled; shouldn't happen. return; } final SdkRunConfig sdkRunConfig = (SdkRunConfig)configuration.clone(); final SdkFields fields = sdkRunConfig.getFields(); final String additionalArgs = fields.getAdditionalArgs(); String flavorArg = null; if (fields.getBuildFlavor() != null) { flavorArg = "--flavor=" + fields.getBuildFlavor(); } final List<String> args = new ArrayList<>(); if (additionalArgs != null) { args.add(additionalArgs); } if (flavorArg != null) { args.add(flavorArg); } if (!args.isEmpty()) { fields.setAdditionalArgs(Joiner.on(" ").join(args)); } final Executor executor = getExecutor(myExecutorId); if (executor == null) { return; } final ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig); final ExecutionEnvironment env; try { env = builder.activeTarget().dataContext(e.getDataContext()).build(); } catch (IllegalStateException ex) { // We're seeing IllegalStateExceptions from here (#4067 - "Runner must be specified"), and are not sure of // the reason why. This adds a bit more diagnostics to the exception to help us determine what's going on. throw new IllegalStateException( ex.getMessage() + " (" + myExecutorId + "/" + myLaunchMode + "/" + getClass().getSimpleName() + ")"); } FlutterLaunchMode.addToEnvironment(env, myLaunchMode); ProgramRunnerUtil.executeConfiguration(env, false, true); }
Example 19
Source File: AttachDebuggerAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nullable PubRoot root, @NotNull DataContext context) { // NOTE: When making changes here, consider making similar changes to RunFlutterAction. FlutterInitializer.sendAnalyticsAction(this); RunConfiguration configuration = findRunConfig(project); if (configuration == null) { RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); if (settings == null) { showSelectConfigDialog(); return; } configuration = settings.getConfiguration(); if (!(configuration instanceof SdkRunConfig)) { if (project.isDefault() || !FlutterSdkUtil.hasFlutterModules(project)) { return; } showSelectConfigDialog(); return; } } SdkAttachConfig sdkRunConfig = new SdkAttachConfig((SdkRunConfig)configuration); SdkFields fields = sdkRunConfig.getFields(); String additionalArgs = fields.getAdditionalArgs(); String flavorArg = null; if (fields.getBuildFlavor() != null) { flavorArg = "--flavor=" + fields.getBuildFlavor(); } List<String> args = new ArrayList<>(); if (additionalArgs != null) { args.add(additionalArgs); } if (flavorArg != null) { args.add(flavorArg); } if (!args.isEmpty()) { fields.setAdditionalArgs(Joiner.on(" ").join(args)); } Executor executor = RunFlutterAction.getExecutor(ToolWindowId.DEBUG); if (executor == null) { return; } ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig); ExecutionEnvironment env = builder.activeTarget().dataContext(context).build(); FlutterLaunchMode.addToEnvironment(env, FlutterLaunchMode.DEBUG); if (project.getUserData(ATTACH_IS_ACTIVE) == null) { project.putUserData(ATTACH_IS_ACTIVE, ThreeState.fromBoolean(false)); onAttachTermination(project, (p) -> p.putUserData(ATTACH_IS_ACTIVE, null)); } ProgramRunnerUtil.executeConfiguration(env, false, true); }
Example 20
Source File: AttachDebuggerAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nullable PubRoot root, @NotNull DataContext context) { // NOTE: When making changes here, consider making similar changes to RunFlutterAction. FlutterInitializer.sendAnalyticsAction(this); RunConfiguration configuration = findRunConfig(project); if (configuration == null) { RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); if (settings == null) { showSelectConfigDialog(); return; } configuration = settings.getConfiguration(); if (!(configuration instanceof SdkRunConfig)) { if (project.isDefault() || !FlutterSdkUtil.hasFlutterModules(project)) { return; } showSelectConfigDialog(); return; } } SdkAttachConfig sdkRunConfig = new SdkAttachConfig((SdkRunConfig)configuration); SdkFields fields = sdkRunConfig.getFields(); String additionalArgs = fields.getAdditionalArgs(); String flavorArg = null; if (fields.getBuildFlavor() != null) { flavorArg = "--flavor=" + fields.getBuildFlavor(); } List<String> args = new ArrayList<>(); if (additionalArgs != null) { args.add(additionalArgs); } if (flavorArg != null) { args.add(flavorArg); } if (!args.isEmpty()) { fields.setAdditionalArgs(Joiner.on(" ").join(args)); } Executor executor = RunFlutterAction.getExecutor(ToolWindowId.DEBUG); if (executor == null) { return; } ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig); ExecutionEnvironment env = builder.activeTarget().dataContext(context).build(); FlutterLaunchMode.addToEnvironment(env, FlutterLaunchMode.DEBUG); if (project.getUserData(ATTACH_IS_ACTIVE) == null) { project.putUserData(ATTACH_IS_ACTIVE, ThreeState.fromBoolean(false)); onAttachTermination(project, (p) -> p.putUserData(ATTACH_IS_ACTIVE, null)); } ProgramRunnerUtil.executeConfiguration(env, false, true); }