use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.
the class FavoritesTest method testAddingFavorites.
/**
* This tests adding a favorite task. We'll verify that we get notified and that the task is added properly.
*/
@Test
public void testAddingFavorites() {
FavoritesEditor editor = new FavoritesEditor();
Assert.assertTrue(editor.getFavoriteTasks().isEmpty());
final FavoritesEditor.FavoriteTasksObserver observer = context.mock(FavoritesEditor.FavoriteTasksObserver.class);
context.checking(new Expectations() {
{
one(observer).favoritesChanged();
}
});
editor.addFavoriteTasksObserver(observer, false);
editor.addFavorite(mySubProject1Comple, true);
context.assertIsSatisfied();
//make sure it was added properly
FavoriteTask favoriteTask = editor.getFavoriteTasks().get(0);
Assert.assertEquals("mysubproject1:compile", favoriteTask.getDisplayName());
Assert.assertEquals("mysubproject1:compile", favoriteTask.getFullCommandLine());
Assert.assertTrue(favoriteTask.alwaysShowOutput());
//now add another one, this time set alwaysShowOutput to false
context.checking(new Expectations() {
{
one(observer).favoritesChanged();
}
});
editor.addFavorite(mySubSubProjectDoc, false);
context.assertIsSatisfied();
//make sure it was added properly
favoriteTask = editor.getFavoriteTasks().get(1);
Assert.assertEquals("mysubproject1:mysubsubproject:doc", favoriteTask.getDisplayName());
Assert.assertEquals("mysubproject1:mysubsubproject:doc", favoriteTask.getFullCommandLine());
Assert.assertFalse(favoriteTask.alwaysShowOutput());
}
use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.
the class FavoritesTest method testEditingFavoriteBlankDisplayName.
/**
* Edits a favorite and makes the display name blank. This is not allowed. We're expecting an error.
*/
@Test
public void testEditingFavoriteBlankDisplayName() {
FavoritesEditor editor = new FavoritesEditor();
Assert.assertTrue(editor.getFavoriteTasks().isEmpty());
//add a task
editor.addFavorite(mySubProject1Comple, true);
//make sure they were added properly
FavoriteTask favoriteTask = editor.getFavoriteTasks().get(0);
Assert.assertEquals("mysubproject1:compile", favoriteTask.getFullCommandLine());
//now perform the actual edit. Leave the full name alone, but use a blank full name
editExpectingError(editor, favoriteTask, "", favoriteTask.getFullCommandLine());
}
use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.
the class GradleInterfaceWrapperVersion2 method executeFavorites.
/**
* Executes several favorites commands at once as a single command. This has the affect of simply concatenating all the favorite command lines into a single line.
*
* @param favorites a list of favorites. If just one favorite, it executes it normally. If multiple favorites, it executes them all at once as a single command.
*/
public RequestVersion1 executeFavorites(List<FavoriteTaskVersion1> favorites) {
List<FavoriteTask> tasks = new ArrayList<FavoriteTask>();
Iterator<FavoriteTaskVersion1> iterator = favorites.iterator();
while (iterator.hasNext()) {
FavoriteTaskVersion1 favoriteTaskVersion1 = iterator.next();
FavoriteTaskWrapper wrapper = (FavoriteTaskWrapper) favoriteTaskVersion1;
tasks.add(wrapper.getFavoriteTask());
}
return wrapRequest(gradlePluginLord.addExecutionRequestToQueue(tasks));
}
use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.
the class FavoriteTasksTab method editTask.
private void editTask() {
FavoriteTask selectedFavoriteTask = getFirstSelectedFavoriteTask();
//if the user has kept these two in synch, we'll continue to keep them in synch.
favoritesEditor.editFavorite(selectedFavoriteTask, new SwingEditFavoriteInteraction(SwingUtilities.getWindowAncestor(mainPanel), "Edit Favorite", SwingEditFavoriteInteraction.SynchronizeType.OnlyIfAlreadySynchronized));
}
use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.
the class OutputPanel method addToFavorites.
/**
* Adds the current request to the favorites and allows the user to edit it.
*/
private void addToFavorites() {
if (request == null) {
return;
}
String fullCommandLine = request.getFullCommandLine();
String displayName = request.getDisplayName();
FavoriteTask favoriteTask = gradlePluginLord.getFavoritesEditor().addFavorite(fullCommandLine, displayName, false);
if (favoriteTask != null) {
gradlePluginLord.getFavoritesEditor().editFavorite(favoriteTask, new SwingEditFavoriteInteraction(SwingUtilities.getWindowAncestor(this), "Edit Favorite", SwingEditFavoriteInteraction.SynchronizeType.OnlyIfAlreadySynchronized));
enableAddToFavoritesAppropriately();
}
}
Aggregations