Search in sources :

Example 1 with VcsDirtyScopeManager

use of com.intellij.openapi.vcs.changes.VcsDirtyScopeManager in project intellij-community by JetBrains.

the class CreateExternalAction method doInBackground.

private static void doInBackground(@NotNull Project project, @NotNull VirtualFile file, String url, boolean checkout, String target) {
    SvnVcs vcs = SvnVcs.getInstance(project);
    VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
    File ioFile = virtualToIoFile(file);
    try {
        addToExternalProperty(vcs, ioFile, target, url);
        dirtyScopeManager.fileDirty(file);
        if (checkout) {
            UpdateClient client = vcs.getFactory(ioFile).createUpdateClient();
            client.setEventHandler(new SvnProgressCanceller());
            client.doUpdate(ioFile, SVNRevision.HEAD, Depth.UNKNOWN, false, false);
            file.refresh(true, true, () -> dirtyScopeManager.dirDirtyRecursively(file));
        }
    } catch (VcsException e) {
        AbstractVcsHelper.getInstance(project).showError(e, "Create External");
    }
}
Also used : UpdateClient(org.jetbrains.idea.svn.update.UpdateClient) SvnProgressCanceller(org.jetbrains.idea.svn.SvnProgressCanceller) ChangesUtil.getVcsForFile(com.intellij.openapi.vcs.changes.ChangesUtil.getVcsForFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)

Example 2 with VcsDirtyScopeManager

use of com.intellij.openapi.vcs.changes.VcsDirtyScopeManager in project intellij-community by JetBrains.

the class SynchronizeCurrentFileAction method postRefresh.

private static void postRefresh(Project project, VirtualFile[] files) {
    VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
    for (VirtualFile f : files) {
        if (f.isDirectory()) {
            dirtyScopeManager.dirDirtyRecursively(f);
        } else {
            dirtyScopeManager.fileDirty(f);
        }
    }
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    if (statusBar != null) {
        statusBar.setInfo(IdeBundle.message("action.sync.completed.successfully", getMessage(files)));
    }
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) StatusBar(com.intellij.openapi.wm.StatusBar) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)

Example 3 with VcsDirtyScopeManager

use of com.intellij.openapi.vcs.changes.VcsDirtyScopeManager in project intellij-community by JetBrains.

the class AddFileOrDirectoryAction method onActionPerformed.

@Override
protected void onActionPerformed(final CvsContext context, final CvsTabbedWindow tabbedWindow, final boolean successfully, final CvsHandler handler) {
    super.onActionPerformed(context, tabbedWindow, successfully, handler);
    final VirtualFile[] filesToAdd = context.getSelectedFiles();
    final VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(context.getProject());
    for (VirtualFile file : filesToAdd) {
        if (file.isDirectory()) {
            dirtyScopeManager.dirDirtyRecursively(file);
        } else {
            dirtyScopeManager.fileDirty(file);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)

Example 4 with VcsDirtyScopeManager

use of com.intellij.openapi.vcs.changes.VcsDirtyScopeManager in project intellij-community by JetBrains.

the class GitCheckoutProvider method clone.

public static void clone(final Project project, @NotNull final Git git, final Listener listener, final VirtualFile destinationParent, final String sourceRepositoryURL, final String directoryName, final String parentDirectory) {
    final AtomicBoolean cloneResult = new AtomicBoolean();
    new Task.Backgroundable(project, DvcsBundle.message("cloning.repository", sourceRepositoryURL)) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            cloneResult.set(doClone(project, git, directoryName, parentDirectory, sourceRepositoryURL));
        }

        @Override
        public void onSuccess() {
            if (!cloneResult.get()) {
                return;
            }
            DvcsUtil.addMappingIfSubRoot(project, FileUtil.join(parentDirectory, directoryName), GitVcs.NAME);
            destinationParent.refresh(true, true, new Runnable() {

                public void run() {
                    if (project.isOpen() && (!project.isDisposed()) && (!project.isDefault())) {
                        final VcsDirtyScopeManager mgr = VcsDirtyScopeManager.getInstance(project);
                        mgr.fileDirty(destinationParent);
                    }
                }
            });
            listener.directoryCheckedOut(new File(parentDirectory, directoryName), GitVcs.getKey());
            listener.checkoutCompleted();
        }
    }.queue();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)

Example 5 with VcsDirtyScopeManager

use of com.intellij.openapi.vcs.changes.VcsDirtyScopeManager in project intellij-community by JetBrains.

the class SvnFileSystemListener method refreshFiles.

private void refreshFiles(final Project project) {
    final List<VirtualFile> toRefreshFiles = new ArrayList<>();
    final List<VirtualFile> toRefreshDirs = new ArrayList<>();
    for (VirtualFile file : myFilesToRefresh) {
        if (file == null)
            continue;
        if (file.isDirectory()) {
            toRefreshDirs.add(file);
        } else {
            toRefreshFiles.add(file);
        }
    }
    // if refresh asynchronously, local changes would also be notified that they are dirty asynchronously,
    // and commit could be executed while not all changes are visible
    filterOutInvalid(myFilesToRefresh);
    RefreshQueue.getInstance().refresh(true, true, () -> {
        if (project.isDisposed())
            return;
        filterOutInvalid(toRefreshFiles);
        filterOutInvalid(toRefreshDirs);
        final VcsDirtyScopeManager vcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
        vcsDirtyScopeManager.filesDirty(toRefreshFiles, toRefreshDirs);
    }, myFilesToRefresh);
    myFilesToRefresh.clear();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)

Aggregations

VcsDirtyScopeManager (com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 File (java.io.File)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Task (com.intellij.openapi.progress.Task)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Project (com.intellij.openapi.project.Project)1 ProjectManagerListener (com.intellij.openapi.project.ProjectManagerListener)1 ChangesUtil.getVcsForFile (com.intellij.openapi.vcs.changes.ChangesUtil.getVcsForFile)1 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 StatusBar (com.intellij.openapi.wm.StatusBar)1 SvnProgressCanceller (org.jetbrains.idea.svn.SvnProgressCanceller)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 UpdateClient (org.jetbrains.idea.svn.update.UpdateClient)1