com.intellij.execution.RunManagerEx Java Examples
The following examples show how to use
com.intellij.execution.RunManagerEx.
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: AbstractArtifactsBeforeRunTaskProvider.java From consulo with Apache License 2.0 | 6 votes |
public AbstractArtifactsBeforeRunTaskProvider(Project project, Key<T> id) { myProject = project; myId = id; project.getMessageBus().connect().subscribe(ArtifactManager.TOPIC, new ArtifactListener() { @Override public void artifactRemoved(@Nonnull Artifact artifact) { final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject); for (RunConfiguration configuration : runManager.getAllConfigurationsList()) { final List<T> tasks = runManager.getBeforeRunTasks(configuration, getId()); for (AbstractArtifactsBeforeRunTask task : tasks) { final String artifactName = artifact.getName(); final List<ArtifactPointer> pointersList = task.getArtifactPointers(); final ArtifactPointer[] pointers = pointersList.toArray(new ArtifactPointer[pointersList.size()]); for (ArtifactPointer pointer : pointers) { if (pointer.getName().equals(artifactName) && ArtifactManager.getInstance(myProject).findArtifact(artifactName) == null) { task.removeArtifact(pointer); } } } } } }); }
Example #2
Source File: RunConfigurationNode.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(PresentationData presentation) { RunnerAndConfigurationSettings configurationSettings = getConfigurationSettings(); boolean isStored = RunManager.getInstance(getProject()).hasSettings(configurationSettings); presentation.addText(configurationSettings.getName(), isStored ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES); RunDashboardContributor contributor = RunDashboardContributor.getContributor(configurationSettings.getType()); Image icon = null; if (contributor != null) { DashboardRunConfigurationStatus status = contributor.getStatus(this); if (DashboardRunConfigurationStatus.STARTED.equals(status)) { icon = getExecutorIcon(); } else if (DashboardRunConfigurationStatus.FAILED.equals(status)) { icon = status.getIcon(); } } if (icon == null) { icon = RunManagerEx.getInstanceEx(getProject()).getConfigurationIcon(configurationSettings); } presentation.setIcon(isStored ? icon : ImageEffects.grayed(icon)); if (contributor != null) { contributor.updatePresentation(presentation, this); } }
Example #3
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 #4
Source File: DeleteTaskAction.java From JHelper with GNU Lesser General Public License v3.0 | 6 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?"); } RunManagerEx runManager = RunManagerEx.getInstanceEx(project); RunnerAndConfigurationSettings selectedConfiguration = runManager.getSelectedConfiguration(); if (selectedConfiguration == null) { return; } RunConfiguration configuration = selectedConfiguration.getConfiguration(); if (configuration instanceof TaskConfiguration) { removeFiles(project, (TaskConfiguration) configuration); runManager.removeConfiguration(selectedConfiguration); selectSomeTaskConfiguration(runManager); } else { Notificator.showNotification( "Not a JHelper configuration", "To delete a configuration you should choose it first", NotificationType.WARNING ); } }
Example #5
Source File: BlazeRunConfigurationSyncListener.java From intellij with Apache License 2.0 | 6 votes |
private static boolean enableBlazeBeforeRunTask(BlazeCommandRunConfiguration config) { @SuppressWarnings("rawtypes") List<BeforeRunTask> tasks = RunManagerEx.getInstanceEx(config.getProject()).getBeforeRunTasks(config); if (tasks.stream().noneMatch(t -> t.getProviderId().equals(BlazeBeforeRunTaskProvider.ID))) { return addBlazeBeforeRunTask(config); } boolean changed = false; for (BeforeRunTask<?> task : tasks) { if (task.getProviderId().equals(BlazeBeforeRunTaskProvider.ID) && !task.isEnabled()) { changed = true; task.setEnabled(true); } } return changed; }
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: 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 #8
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 #9
Source File: StartDebugConnectionAction.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public void doDebug(Project project, ServerConnectionManager connectionManager) { RunManagerEx runManager = RunManagerEx.getInstanceEx(project); if(runManager != null) { connectionManager.connectInDebugMode(runManager); } else { getMessageManager(project).showAlert("action.debug.configuration.failure"); } }
Example #10
Source File: ServerConnectionManager.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public void connectInDebugMode(RunManagerEx runManager) { ServerConfiguration serverConfiguration = selectionHandler.getCurrentConfiguration(); // Create Remote Connection to Server using the IntelliJ Run / Debug Connection //AS TODO: It is working but the configuration is listed and made persistent. That is not too bad because //AS TODO: after changes a reconnect will update the configuration. RemoteConfigurationType remoteConfigurationType = new RemoteConfigurationType(); RunConfiguration runConfiguration = remoteConfigurationType.getFactory().createTemplateConfiguration(myProject); RemoteConfiguration remoteConfiguration = (RemoteConfiguration) runConfiguration; // Server means if you are listening. If not you are attaching. remoteConfiguration.SERVER_MODE = false; remoteConfiguration.USE_SOCKET_TRANSPORT = true; remoteConfiguration.HOST = serverConfiguration.getHost(); remoteConfiguration.PORT = serverConfiguration.getConnectionDebugPort() + ""; // Set a Name of the Configuration so that it is properly listed. remoteConfiguration.setName(serverConfiguration.getName()); RunnerAndConfigurationSettings configuration = new RunnerAndConfigurationSettingsImpl( (RunManagerImpl) runManager, runConfiguration, false ); runManager.setTemporaryConfiguration(configuration); //AS TODO: Make sure that this is the proper way to obtain the DEBUG Executor Executor executor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG); ExecutionUtil.runConfiguration(configuration, executor); // Update the Modules with the Remote Sling Server OsgiClient osgiClient = obtainOSGiClient(); if(osgiClient != null) { BundleStatus status = checkAndUpdateSupportBundle(false); if(status != BundleStatus.failed) { checkModules(osgiClient); } } }
Example #11
Source File: TestRecorderBlazeCommandRunConfigurationTest.java From intellij with Apache License 2.0 | 5 votes |
@Test public void testSuitableRunConfigurations() { addConfigurations(); List<RunConfiguration> allConfigurations = RunManagerEx.getInstanceEx(getProject()).getAllConfigurationsList(); assertThat(allConfigurations.size()).isEqualTo(2); List<RunConfiguration> suitableConfigurations = TestRecorderAction.getSuitableRunConfigurations(getProject()); assertThat(suitableConfigurations.size()).isEqualTo(1); assertThat(suitableConfigurations.get(0).getName()).isEqualTo("AndroidBinaryConfiguration"); }
Example #12
Source File: RunFlutterAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable public static RunnerAndConfigurationSettings getRunConfigSettings(@Nullable AnActionEvent event) { if (event == null) { return null; } final Project project = event.getProject(); if (project == null) { return null; } return RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); }
Example #13
Source File: AttachDebuggerAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable public static RunConfiguration findRunConfig(Project project) { // Look for a Flutter run config. If exactly one is found then return it otherwise return null. RunManagerEx mgr = RunManagerEx.getInstanceEx(project); List<RunConfiguration> configs = mgr.getAllConfigurationsList(); int count = 0; RunConfiguration sdkConfig = null; for (RunConfiguration config : configs) { if (config instanceof SdkRunConfig) { count += 1; sdkConfig = config; } } return count == 1 ? sdkConfig : null; }
Example #14
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 #15
Source File: RunFlutterAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable public static RunnerAndConfigurationSettings getRunConfigSettings(@Nullable AnActionEvent event) { if (event == null) { return null; } final Project project = event.getProject(); if (project == null) { return null; } return RunManagerEx.getInstanceEx(project).getSelectedConfiguration(); }
Example #16
Source File: AttachDebuggerAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable public static RunConfiguration findRunConfig(Project project) { // Look for a Flutter run config. If exactly one is found then return it otherwise return null. RunManagerEx mgr = RunManagerEx.getInstanceEx(project); List<RunConfiguration> configs = mgr.getAllConfigurationsList(); int count = 0; RunConfiguration sdkConfig = null; for (RunConfiguration config : configs) { if (config instanceof SdkRunConfig) { count += 1; sdkConfig = config; } } return count == 1 ? sdkConfig : null; }
Example #17
Source File: BlazeCommandRunConfiguration.java From intellij with Apache License 2.0 | 4 votes |
@Override public void checkConfiguration() throws RuntimeConfigurationException { // Our handler check is not valid when we don't have BlazeProjectData. if (BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData() == null) { throw new RuntimeConfigurationError( "Configuration cannot be run until project has been synced."); } boolean hasBlazeBeforeRunTask = RunManagerEx.getInstanceEx(getProject()).getBeforeRunTasks(this).stream() .anyMatch( task -> task.getProviderId().equals(BlazeBeforeRunTaskProvider.ID) && task.isEnabled()); if (!hasBlazeBeforeRunTask) { throw new RuntimeConfigurationError( String.format( "Invalid run configuration: the %s before run task is missing. Please re-run sync " + "to add it back", Blaze.buildSystemName(getProject()))); } handler.checkConfiguration(); PendingRunConfigurationContext pendingContext = this.pendingContext; if (pendingContext != null && !pendingContext.isDone()) { return; } ImmutableList<String> targetPatterns = this.targetPatterns; if (targetPatterns.isEmpty()) { throw new RuntimeConfigurationError( String.format( "You must specify a %s target expression.", Blaze.buildSystemName(getProject()))); } for (String pattern : targetPatterns) { if (Strings.isNullOrEmpty(pattern)) { throw new RuntimeConfigurationError( String.format( "You must specify a %s target expression.", Blaze.buildSystemName(getProject()))); } if (!pattern.startsWith("//") && !pattern.startsWith("@")) { throw new RuntimeConfigurationError( "You must specify the full target expression, starting with // or @"); } String error = TargetExpression.validate(pattern); if (error != null) { throw new RuntimeConfigurationError(error); } } }
Example #18
Source File: DeployableJarRunConfigurationProducer.java From intellij with Apache License 2.0 | 4 votes |
private void setDeployableJarGeneratorTask(RunConfigurationBase config) { Project project = config.getProject(); RunManagerEx runManager = RunManagerEx.getInstanceEx(project); runManager.setBeforeRunTasks( config, ImmutableList.of(new GenerateDeployableJarTaskProvider.Task())); }
Example #19
Source File: BashConfigurationType.java From BashSupport with Apache License 2.0 | 4 votes |
@Override public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) { //the last param has to be false because we do not want a fallback to the template (we're creating it right now) (avoiding a SOE) RunManagerEx.getInstanceEx(configuration.getProject()).setBeforeRunTasks(configuration, Collections.<BeforeRunTask>emptyList(), false); }
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); }
Example #21
Source File: XQueryRunConfigurationProducer.java From intellij-xquery with Apache License 2.0 | 4 votes |
private Module getPredefinedModule(Location location) { return ((XQueryRunConfiguration) RunManagerEx.getInstanceEx(location.getProject()) .getConfigurationTemplate(getConfigurationFactory()) .getConfiguration()).getConfigurationModule().getModule(); }
Example #22
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); }