Search in sources :

Example 1 with ProjectView

use of org.gradle.foundation.ProjectView in project gradle by gradle.

the class TaskTreeTab method createTreePanel.

private Component createTreePanel() {
    treeComponent = new TaskTreeComponent(gradlePluginLord, new TaskTreeComponent.Interaction() {

        public void rightClick(JTree tree, int x, int y) {
            enableThingsAppropriately();
            popupMenu.show(tree, x, y);
        }

        public void taskInvoked(TaskView task, boolean isCtrlKeyDown) {
            if (isCtrlKeyDown) {
                gradlePluginLord.addExecutionRequestToQueue(task, false, "-a");
            } else {
                gradlePluginLord.addExecutionRequestToQueue(task, false);
            }
        }

        public void projectInvoked(ProjectView project) {
            executeDefaultTasksInProject(project);
        }
    });
    treeComponent.getTree().addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            enableThingsAppropriately();
        }
    });
    defaultTreeBackground = treeComponent.getTree().getBackground();
    treeScrollPane = new JScrollPane();
    //change the color to better indicate that
    treeComponent.getTree().setBackground(workingBackgroundColor);
    showTextInViewport("Has not built projects/tasks yet.");
    return treeScrollPane;
}
Also used : TaskView(org.gradle.foundation.TaskView) AlternateUIInteraction(org.gradle.gradleplugin.userinterface.AlternateUIInteraction) SwingAddMultipleFavoritesInteraction(org.gradle.gradleplugin.userinterface.swing.generic.SwingAddMultipleFavoritesInteraction) TreeSelectionListener(javax.swing.event.TreeSelectionListener) ProjectView(org.gradle.foundation.ProjectView) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) TaskTreeComponent(org.gradle.gradleplugin.userinterface.swing.generic.TaskTreeComponent)

Example 2 with ProjectView

use of org.gradle.foundation.ProjectView in project gradle by gradle.

the class ProjectWrapper method convertProjects.

/**
     * Converts the list of ProjectView objects to ProjectVersion1 objects. It just wraps them.
     *
     * @param projectViewList the source projects
     * @return the projects wrapped in ProjectWrappers.
     */
public static List<ProjectVersion1> convertProjects(List<ProjectView> projectViewList) {
    List<ProjectVersion1> returnProjects = new ArrayList<ProjectVersion1>();
    if (projectViewList != null) {
        Iterator<ProjectView> projectViewIterator = projectViewList.iterator();
        while (projectViewIterator.hasNext()) {
            ProjectView projectView = projectViewIterator.next();
            returnProjects.add(new ProjectWrapper(projectView));
        }
    }
    return returnProjects;
}
Also used : ArrayList(java.util.ArrayList) ProjectView(org.gradle.foundation.ProjectView) ProjectVersion1(org.gradle.openapi.external.foundation.ProjectVersion1)

Example 3 with ProjectView

use of org.gradle.foundation.ProjectView in project gradle by gradle.

the class AllProjectsAndTasksVisitor method visitProjects.

public static <P, T> List<P> visitProjects(Visitor<P, T> visitor, ProjectAndTaskFilter filter, List<ProjectView> projects, P parentProjectObject) {
    List<P> projectObjects = new ArrayList<P>();
    Iterator<ProjectView> iterator = projects.iterator();
    while (iterator.hasNext()) {
        ProjectView project = iterator.next();
        if (filter.doesAllowProject(project)) {
            P userProjectObject = visitor.visitProject(project, parentProjectObject);
            projectObjects.add(userProjectObject);
            //visit sub projects
            visitProjects(visitor, filter, project.getSubProjects(), userProjectObject);
            //visit tasks
            visitTasks(visitor, filter, project, userProjectObject);
        }
    }
    return projectObjects;
}
Also used : ArrayList(java.util.ArrayList) ProjectView(org.gradle.foundation.ProjectView)

Example 4 with ProjectView

use of org.gradle.foundation.ProjectView in project gradle by gradle.

the class TaskTreePopulationVisitor method visitProjects.

private static <P, T> List<P> visitProjects(Visitor<P, T> visitor, ProjectAndTaskFilter filter, List<ProjectView> sourceProjects, P parentProjectObject, Comparator<ProjectView> projectSorter, Comparator<TaskView> taskSorter) {
    List<P> projectObjects = new ArrayList<P>();
    //make a copy because we're going to sort them.
    sourceProjects = CollectionUtils.sort(sourceProjects, projectSorter);
    Iterator<ProjectView> iterator = sourceProjects.iterator();
    int index = 0;
    while (iterator.hasNext()) {
        ProjectView project = iterator.next();
        if (filter.doesAllowProject(project)) {
            P userProjectObject = visitor.visitProject(project, index, parentProjectObject);
            projectObjects.add(userProjectObject);
            //visit sub projects
            List<P> subProjectObjects = visitProjects(visitor, filter, project.getSubProjects(), userProjectObject, projectSorter, taskSorter);
            //visit tasks. Notice that we pass in the number of subprojects as a starting index. This is so they'll come afterwards.
            List<T> taskObjects = visitTasks(visitor, filter, project, subProjectObjects.size(), userProjectObject, taskSorter);
            visitor.completedVisitingProject(userProjectObject, subProjectObjects, taskObjects);
        }
        index++;
    }
    return projectObjects;
}
Also used : ProjectView(org.gradle.foundation.ProjectView)

Example 5 with ProjectView

use of org.gradle.foundation.ProjectView in project gradle by gradle.

the class TaskTreeTab method editSelectedFiles.

/**
     * This opens the selected files. This gets the 'parent' of this to do it for us. This facilitates using this inside an IDE (you get the IDE to open it).
     */
private void editSelectedFiles() {
    TaskTreeComponent.MultipleSelection tasks = treeComponent.getSelectedProjectsAndTasks();
    Iterator<ProjectView> iterator = tasks.projects.iterator();
    while (iterator.hasNext()) {
        ProjectView projectView = iterator.next();
        File file = projectView.getBuildFile();
        if (file != null) {
            alternateUIInteraction.editFile(file, -1);
        }
    }
}
Also used : ProjectView(org.gradle.foundation.ProjectView) File(java.io.File) TaskTreeComponent(org.gradle.gradleplugin.userinterface.swing.generic.TaskTreeComponent)

Aggregations

ProjectView (org.gradle.foundation.ProjectView)7 ArrayList (java.util.ArrayList)2 TaskTreeComponent (org.gradle.gradleplugin.userinterface.swing.generic.TaskTreeComponent)2 File (java.io.File)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 TaskView (org.gradle.foundation.TaskView)1 AlternateUIInteraction (org.gradle.gradleplugin.userinterface.AlternateUIInteraction)1 SwingAddMultipleFavoritesInteraction (org.gradle.gradleplugin.userinterface.swing.generic.SwingAddMultipleFavoritesInteraction)1 ProjectVersion1 (org.gradle.openapi.external.foundation.ProjectVersion1)1