Java Code Examples for com.intellij.execution.BeforeRunTaskProvider#createTask()
The following examples show how to use
com.intellij.execution.BeforeRunTaskProvider#createTask() .
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: 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 3
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()); }