com.intellij.execution.BeforeRunTaskProvider Java Examples
The following examples show how to use
com.intellij.execution.BeforeRunTaskProvider.
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: BlazeRunConfigurationSyncListener.java From intellij with Apache License 2.0 | 6 votes |
private static boolean addBlazeBeforeRunTask(BlazeCommandRunConfiguration config) { BeforeRunTaskProvider<?> provider = BlazeBeforeRunTaskProvider.getProvider(config.getProject(), BlazeBeforeRunTaskProvider.ID); if (provider == null) { return false; } BeforeRunTask<?> task = provider.createTask(config); if (task == null) { return false; } task.setEnabled(true); List<BeforeRunTask<?>> beforeRunTasks = new ArrayList<>(config.getBeforeRunTasks()); beforeRunTasks.add(task); config.setBeforeRunTasks(beforeRunTasks); return true; }
Example #2
Source File: PantsIntegrationTestCase.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
protected void assertAndRunPantsMake(JUnitConfiguration runConfiguration) { RunManager runManager = RunManager.getInstance(myProject); assertTrue(runManager instanceof RunManagerImpl); RunManagerImpl runManagerImpl = (RunManagerImpl) runManager; RunnerAndConfigurationSettings runnerAndConfigurationSettings = runManagerImpl.createConfiguration(runConfiguration, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]); runManagerImpl.addConfiguration(runnerAndConfigurationSettings, false); // Make sure PantsMake is the one and only task before JUnit run. List<BeforeRunTask<?>> beforeRunTaskList = runManagerImpl.getBeforeRunTasks(runConfiguration); assertEquals(1, beforeRunTaskList.size()); BeforeRunTask task = beforeRunTaskList.iterator().next(); assertEquals(PantsMakeBeforeRun.ID, task.getProviderId()); /* * Manually invoke BeforeRunTask as {@link ExecutionManager#compileAndRun} launches another task asynchronously, * and there is no way to catch that. */ BeforeRunTaskProvider provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId()); assertNotNull(String.format("Cannot find BeforeRunTaskProvider for id='%s'", task.getProviderId()), provider); assertTrue(provider.executeTask(null, runConfiguration, null, task)); }
Example #3
Source File: BeforeRunStepsPanel.java From consulo with Apache License 2.0 | 6 votes |
private boolean checkBeforeRunTasksAbility(boolean checkOnlyAddAction) { if (isUnknown()) { return false; } Set<Key> activeProviderKeys = getActiveProviderKeys(); final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EP_NAME, myRunConfiguration.getProject()); for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) { if (provider.createTask(myRunConfiguration) != null) { if (!checkOnlyAddAction) { return true; } else if (!provider.isSingleton() || !activeProviderKeys.contains(provider.getId())) { return true; } } } return false; }
Example #4
Source File: BeforeRunStepsPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> getSelection() { final int index = myList.getSelectedIndex(); if (index == -1) return null; BeforeRunTask task = myModel.getElementAt(index); Key providerId = task.getProviderId(); BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), providerId); return provider != null ? Pair.create(task, provider) : null; }
Example #5
Source File: BeforeRunStepsPanel.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void customizeCellRenderer(@Nonnull JList<? extends BeforeRunTask> list, BeforeRunTask value, int index, boolean selected, boolean hasFocus) { BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), value.getProviderId()); if (provider != null) { setIcon(provider.getTaskIcon(value)); append(provider.getDescription(value)); } }
Example #6
Source File: BeforeRunStepsPanel.java From consulo with Apache License 2.0 | 4 votes |
void doAddAction(AnActionButton button) { if (isUnknown()) { return; } final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); final List<BeforeRunTaskProvider<BeforeRunTask>> providers = BeforeRunTaskProvider.EP_NAME.getExtensionList(myRunConfiguration.getProject()); Set<Key> activeProviderKeys = getActiveProviderKeys(); DefaultActionGroup actionGroup = new DefaultActionGroup(null, false); for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) { if (provider.createTask(myRunConfiguration) == null) continue; if (activeProviderKeys.contains(provider.getId()) && provider.isSingleton()) continue; AnAction providerAction = new AnAction(provider.getName(), null, provider.getIcon()) { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { BeforeRunTask task = provider.createTask(myRunConfiguration); if (task == null) { return; } provider.configureTask(myRunConfiguration, task).doWhenProcessed(() -> { if (!provider.canExecuteTask(myRunConfiguration, task)) return; task.setEnabled(true); Set<RunConfiguration> configurationSet = new HashSet<>(); getAllRunBeforeRuns(task, configurationSet); if (configurationSet.contains(myRunConfiguration)) { JOptionPane.showMessageDialog(BeforeRunStepsPanel.this, ExecutionBundle.message("before.launch.panel.cyclic_dependency_warning", myRunConfiguration.getName(), provider.getDescription(task)), ExecutionBundle.message("warning.common.title"), JOptionPane.WARNING_MESSAGE); return; } addTask(task); myListener.fireStepsBeforeRunChanged(); }); } }; actionGroup.add(providerAction); } final ListPopup popup = popupFactory .createActionGroupPopup(ExecutionBundle.message("add.new.run.configuration.acrtion.name"), actionGroup, SimpleDataContext.getProjectContext(myRunConfiguration.getProject()), false, false, false, null, -1, Condition.TRUE); popup.show(button.getPreferredPopupPoint()); }