Search in sources :

Example 6 with ProjectViewEdit

use of com.google.idea.blaze.base.projectview.ProjectViewEdit in project intellij by bazelbuild.

the class SuggestBuildShardingNotification method editProjectViewAndResync.

private static void editProjectViewAndResync(Project project, ProjectViewEditor editor) {
    ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, editor);
    if (edit == null) {
        Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
        return;
    }
    edit.apply();
    BlazeSyncManager.getInstance(project).incrementalProjectSync();
}
Also used : ProjectViewEdit(com.google.idea.blaze.base.projectview.ProjectViewEdit)

Example 7 with ProjectViewEdit

use of com.google.idea.blaze.base.projectview.ProjectViewEdit in project intellij by bazelbuild.

the class AddLibraryTargetDirectoryToProjectViewAction method addDirectoriesToProjectView.

static void addDirectoriesToProjectView(Project project, List<Library> libraries) {
    Set<WorkspacePath> workspacePaths = Sets.newHashSet();
    for (Library library : libraries) {
        WorkspacePath workspacePath = getDirectoryToAddForLibrary(project, library);
        if (workspacePath != null) {
            workspacePaths.add(workspacePath);
        }
    }
    ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
        ListSection<DirectoryEntry> existingSection = builder.getLast(DirectorySection.KEY);
        ListSection.Builder<DirectoryEntry> directoryBuilder = ListSection.update(DirectorySection.KEY, existingSection);
        for (WorkspacePath workspacePath : workspacePaths) {
            directoryBuilder.add(new DirectoryEntry(workspacePath, true));
        }
        builder.replace(existingSection, directoryBuilder);
        return true;
    });
    if (edit == null) {
        Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
        return;
    }
    edit.apply();
    BlazeSyncManager.getInstance(project).requestProjectSync(new BlazeSyncParams.Builder("Adding Library", BlazeSyncParams.SyncMode.INCREMENTAL).addProjectViewTargets(true).addWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) ProjectViewEdit(com.google.idea.blaze.base.projectview.ProjectViewEdit) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) Library(com.intellij.openapi.roots.libraries.Library) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)

Example 8 with ProjectViewEdit

use of com.google.idea.blaze.base.projectview.ProjectViewEdit in project intellij by bazelbuild.

the class AlwaysPresentGoSyncPlugin method fixLanguageSupport.

private static void fixLanguageSupport(Project project) {
    ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
        removeGoWorkspaceType(builder);
        addToAdditionalLanguages(builder);
        return true;
    });
    if (edit == null) {
        Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
        return;
    }
    edit.apply();
    BlazeSyncManager.getInstance(project).incrementalProjectSync();
}
Also used : ProjectViewEdit(com.google.idea.blaze.base.projectview.ProjectViewEdit)

Aggregations

ProjectViewEdit (com.google.idea.blaze.base.projectview.ProjectViewEdit)8 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 ListSection (com.google.idea.blaze.base.projectview.section.ListSection)2 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)2 Library (com.intellij.openapi.roots.libraries.Library)2 GenfilesPath (com.google.idea.blaze.android.projectview.GenfilesPath)1 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)1 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)1 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)1 Glob (com.google.idea.blaze.base.projectview.section.Glob)1 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)1 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1