IDEA-109872 (supplant long running on-frame-activation refresh sessions)

This commit is contained in:
Roman Shevchenko
2013-07-02 15:58:23 +02:00
parent 35bc53ff98
commit 1072cf8297
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
import com.intellij.openapi.vfs.newvfs.RefreshSession;
import com.intellij.util.Alarm;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -56,6 +57,8 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync
private final AtomicInteger myBlockSyncOnFrameActivationCount = new AtomicInteger();
private final Alarm myRefreshDelayAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
private long myRefreshSessionId = 0;
public static SaveAndSyncHandlerImpl getInstance(){
return (SaveAndSyncHandlerImpl) ApplicationManager.getApplication().getComponent(SaveAndSyncHandler.class);
}
@@ -168,7 +171,6 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync
if (canSyncOrSave()) {
refreshOpenFiles();
}
maybeRefresh(ModalityState.NON_MODAL);
}
}, 300, ModalityState.NON_MODAL);
@@ -178,7 +180,15 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync
public void maybeRefresh(@NotNull ModalityState modalityState) {
if (myBlockSyncOnFrameActivationCount.get() == 0) {
LOG.debug("VFS refresh started");
RefreshQueue.getInstance().refresh(true, true, null, modalityState, ManagingFS.getInstance().getLocalRoots());
RefreshQueue queue = RefreshQueue.getInstance();
queue.cancelSession(myRefreshSessionId);
RefreshSession session = queue.createSession(true, true, null, modalityState);
session.addAllFiles(ManagingFS.getInstance().getLocalRoots());
myRefreshSessionId = session.getId();
session.launch();
LOG.debug("VFS refresh finished");
}
}