Search in sources :

Example 11 with FavoriteTask

use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.

the class FavoritesEditorWrapper method getFavoriteTasks.

public List<FavoriteTaskVersion1> getFavoriteTasks() {
    List<FavoriteTaskVersion1> returnedTasks = new ArrayList<FavoriteTaskVersion1>();
    Iterator<FavoriteTask> taskIterator = favoritesEditor.getFavoriteTasks().iterator();
    while (taskIterator.hasNext()) {
        FavoriteTask favoriteTask = taskIterator.next();
        returnedTasks.add(new FavoriteTaskWrapper(favoriteTask));
    }
    return returnedTasks;
}
Also used : FavoriteTaskVersion1(org.gradle.openapi.external.foundation.favorites.FavoriteTaskVersion1) ArrayList(java.util.ArrayList) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Example 12 with FavoriteTask

use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.

the class FavoritesEditorWrapper method removeFavorites.

public void removeFavorites(List<FavoriteTaskVersion1> favoritesToRemove) {
    List<FavoriteTask> favoriteTasksToRemove = new ArrayList<FavoriteTask>();
    Iterator<FavoriteTaskVersion1> iterator = favoritesToRemove.iterator();
    while (iterator.hasNext()) {
        FavoriteTaskVersion1 favoriteTaskVersion1 = iterator.next();
        favoriteTasksToRemove.add(getFavoriteTask(favoriteTaskVersion1));
    }
    favoritesEditor.removeFavorites(favoriteTasksToRemove);
}
Also used : FavoriteTaskVersion1(org.gradle.openapi.external.foundation.favorites.FavoriteTaskVersion1) ArrayList(java.util.ArrayList) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Example 13 with FavoriteTask

use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.

the class FavoritesEditorWrapper method editFavorite.

public String editFavorite(FavoriteTaskVersion1 favoriteTaskVersion1, final String newFullCommandLine, final String newDisplayName, final boolean newAlwaysShowOutput) {
    final StringHolder stringHolder = new StringHolder();
    FavoriteTask favoriteTask = getFavoriteTask(favoriteTaskVersion1);
    favoritesEditor.editFavorite(favoriteTask, new FavoritesEditor.EditFavoriteInteraction() {

        public boolean editFavorite(FavoritesEditor.EditibleFavoriteTask favoriteTask) {
            favoriteTask.fullCommandLine = newFullCommandLine;
            favoriteTask.displayName = newDisplayName;
            favoriteTask.alwaysShowOutput = newAlwaysShowOutput;
            return true;
        }

        public void reportError(String error) {
            stringHolder.string = error;
        }
    });
    return stringHolder.string;
}
Also used : FavoritesEditor(org.gradle.gradleplugin.foundation.favorites.FavoritesEditor) FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Example 14 with FavoriteTask

use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.

the class FavoriteTasksTab method populate.

private void populate() {
    model.clear();
    Iterator<FavoriteTask> taskIterator = favoritesEditor.getFavoriteTasks().iterator();
    while (taskIterator.hasNext()) {
        FavoriteTask favoriteTask = taskIterator.next();
        model.addElement(favoriteTask);
    }
}
Also used : FavoriteTask(org.gradle.gradleplugin.foundation.favorites.FavoriteTask)

Example 15 with FavoriteTask

use of org.gradle.gradleplugin.foundation.favorites.FavoriteTask in project gradle by gradle.

the class GradlePluginLord method addExecutionRequestToQueue.

/**
     * 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 Request addExecutionRequestToQueue(List<FavoriteTask> favorites) {
    if (favorites.isEmpty()) {
        return null;
    }
    FavoriteTask firstFavoriteTask = favorites.get(0);
    String displayName;
    String fullCommandLine;
    boolean alwaysShowOutput = firstFavoriteTask.alwaysShowOutput();
    if (favorites.size() == 1) {
        displayName = firstFavoriteTask.getDisplayName();
        fullCommandLine = firstFavoriteTask.getFullCommandLine();
    } else {
        displayName = "Multiple (" + firstFavoriteTask.getDisplayName() + ", ... )";
        fullCommandLine = FavoritesEditor.combineFavoriteCommandLines(favorites);
    }
    return addExecutionRequestToQueue(fullCommandLine, displayName, alwaysShowOutput);
}
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