Search in sources :

Example 6 with FavoriteTask

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());
}
Also used : Expectations(org.jmock.Expectations) FavoritesEditor(org.gradle.gradleplugin.foundation.favorites.FavoritesEditor) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask) Test(org.junit.Test)

Example 7 with FavoriteTask

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());
}
Also used : FavoritesEditor(org.gradle.gradleplugin.foundation.favorites.FavoritesEditor) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask) Test(org.junit.Test)

Example 8 with FavoriteTask

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));
}
Also used : FavoriteTaskWrapper(org.gradle.openapi.wrappers.foundation.favorites.FavoriteTaskWrapper) FavoriteTaskVersion1(org.gradle.openapi.external.foundation.favorites.FavoriteTaskVersion1) ArrayList(java.util.ArrayList) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Example 9 with FavoriteTask

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));
}
Also used : SwingEditFavoriteInteraction(org.gradle.gradleplugin.userinterface.swing.generic.SwingEditFavoriteInteraction) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Example 10 with FavoriteTask

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();
    }
}
Also used : FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Aggregations

FavoriteTask (org.gradle.gradleplugin.foundation.favorites.FavoriteTask)26 FavoritesEditor (org.gradle.gradleplugin.foundation.favorites.FavoritesEditor)19 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 Expectations (org.jmock.Expectations)5 File (java.io.File)3 FavoriteTaskVersion1 (org.gradle.openapi.external.foundation.favorites.FavoriteTaskVersion1)3 TestUtility (org.gradle.foundation.TestUtility)2 SwingEditFavoriteInteraction (org.gradle.gradleplugin.userinterface.swing.generic.SwingEditFavoriteInteraction)1 FavoriteTaskWrapper (org.gradle.openapi.wrappers.foundation.favorites.FavoriteTaskWrapper)1