use of com.intellij.execution.BeforeRunTask in project android by JetBrains.
the class PostSyncProjectSetup method setMakeStepInJUnitConfiguration.
private void setMakeStepInJUnitConfiguration(@NotNull BeforeRunTaskProvider targetProvider, @NotNull RunConfiguration runConfiguration) {
// Only "make" steps of beforeRunTasks should be overridden (see http://b.android.com/194704 and http://b.android.com/227280)
List<BeforeRunTask> newBeforeRunTasks = new LinkedList<>();
RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
for (BeforeRunTask beforeRunTask : runManager.getBeforeRunTasks(runConfiguration)) {
if (beforeRunTask.getProviderId().equals(CompileStepBeforeRun.ID)) {
BeforeRunTask task = targetProvider.createTask(runConfiguration);
if (task != null) {
task.setEnabled(true);
newBeforeRunTasks.add(task);
}
} else {
newBeforeRunTasks.add(beforeRunTask);
}
}
runManager.setBeforeRunTasks(runConfiguration, newBeforeRunTasks, false);
}
use of com.intellij.execution.BeforeRunTask in project android by JetBrains.
the class ApplicationRunParameters method addOrRemoveMakeTask.
private void addOrRemoveMakeTask(boolean add) {
final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
final ConfigurationSettingsEditorWrapper editor = ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.getData(dataContext);
if (editor == null) {
return;
}
final List<BeforeRunTask> makeTasks = new ArrayList<BeforeRunTask>();
for (BeforeRunTask task : editor.getStepsBeforeLaunch()) {
if (task instanceof CompileStepBeforeRun.MakeBeforeRunTask || task instanceof CompileStepBeforeRunNoErrorCheck.MakeBeforeRunTaskNoErrorCheck) {
makeTasks.add(task);
}
}
if (add) {
if (makeTasks.size() == 0) {
editor.addBeforeLaunchStep(new CompileStepBeforeRun.MakeBeforeRunTask());
} else {
for (BeforeRunTask task : makeTasks) {
task.setEnabled(true);
}
}
} else {
for (BeforeRunTask task : makeTasks) {
task.setEnabled(false);
}
}
}
use of com.intellij.execution.BeforeRunTask in project android by JetBrains.
the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.
public void testJUnitRunConfigurationSetup() {
when(myIdeInfo.isAndroidStudio()).thenReturn(true);
PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
mySetup.setUpProject(request, myProgressIndicator);
ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
for (RunConfiguration runConfiguration : junitRunConfigurations) {
assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
}
RunConfiguration runConfiguration = junitRunConfigurations.get(0);
List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
newTask.setEnabled(true);
tasks.add(newTask);
myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
mySetup.setUpProject(request, myProgressIndicator);
assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
use of com.intellij.execution.BeforeRunTask in project intellij-community by JetBrains.
the class BeforeRunStepsPanel method getAllRunBeforeRuns.
private void getAllRunBeforeRuns(BeforeRunTask task, Set<RunConfiguration> configurationSet) {
if (task instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask runTask = (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) task;
RunConfiguration configuration = runTask.getSettings().getConfiguration();
List<BeforeRunTask> tasks = RunManagerImpl.getInstanceImpl(configuration.getProject()).getBeforeRunTasks(configuration);
for (BeforeRunTask beforeRunTask : tasks) {
if (beforeRunTask instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
if (configurationSet.add(((RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) beforeRunTask).getSettings().getConfiguration()))
getAllRunBeforeRuns(beforeRunTask, configurationSet);
}
}
}
}
use of com.intellij.execution.BeforeRunTask in project intellij-community by JetBrains.
the class BeforeRunStepsPanel method doAddAction.
void doAddAction(AnActionButton button) {
if (isUnknown()) {
return;
}
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, 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()) {
@Override
public void actionPerformed(AnActionEvent e) {
BeforeRunTask task = provider.createTask(myRunConfiguration);
if (task != null) {
provider.configureTask(myRunConfiguration, task);
if (!provider.canExecuteTask(myRunConfiguration, task))
return;
} else {
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, Conditions.<AnAction>alwaysTrue());
popup.show(button.getPreferredPopupPoint());
}
Aggregations