mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RestoreUpdateTree — store in project cache, cleanup
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.update;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.StoragePathMacros;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectReloadState;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
@@ -14,43 +16,30 @@ import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@State(
|
||||
name = "RestoreUpdateTree",
|
||||
storages = @Storage(StoragePathMacros.WORKSPACE_FILE)
|
||||
)
|
||||
public class RestoreUpdateTree implements ProjectComponent, PersistentStateComponent<Element> {
|
||||
private final Project myProject;
|
||||
|
||||
@State(name = "RestoreUpdateTree", storages = {
|
||||
@Storage(StoragePathMacros.CACHE_FILE),
|
||||
@Storage(value = StoragePathMacros.WORKSPACE_FILE, deprecated = true),
|
||||
})
|
||||
public class RestoreUpdateTree implements PersistentStateComponent<Element> {
|
||||
private UpdateInfo myUpdateInfo;
|
||||
|
||||
public RestoreUpdateTree(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public static RestoreUpdateTree getInstance(Project project) {
|
||||
return project.getComponent(RestoreUpdateTree.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
StartupManager.getInstance(myProject).registerPostStartupActivity((DumbAwareRunnable)() -> {
|
||||
if (myUpdateInfo != null && !myUpdateInfo.isEmpty() && ProjectReloadState.getInstance(myProject).isAfterAutomaticReload()) {
|
||||
public RestoreUpdateTree(@NotNull Project project, @NotNull StartupManager startupManager) {
|
||||
startupManager.registerPostStartupActivity((DumbAwareRunnable)() -> {
|
||||
if (myUpdateInfo != null && !myUpdateInfo.isEmpty() && ProjectReloadState.getInstance(project).isAfterAutomaticReload()) {
|
||||
ActionInfo actionInfo = myUpdateInfo.getActionInfo();
|
||||
if (actionInfo != null) {
|
||||
ProjectLevelVcsManagerEx.getInstanceEx(myProject).showUpdateProjectInfo(myUpdateInfo.getFileInformation(),
|
||||
ProjectLevelVcsManagerEx.getInstanceEx(project).showUpdateProjectInfo(myUpdateInfo.getFileInformation(),
|
||||
VcsBundle.message("action.display.name.update"), actionInfo,
|
||||
false);
|
||||
CommittedChangesCache.getInstance(myProject).refreshIncomingChangesAsync();
|
||||
CommittedChangesCache.getInstance(project).refreshIncomingChangesAsync();
|
||||
}
|
||||
}
|
||||
myUpdateInfo = null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "RestoreUpdateTree";
|
||||
public static RestoreUpdateTree getInstance(Project project) {
|
||||
return project.getComponent(RestoreUpdateTree.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -58,12 +47,7 @@ public class RestoreUpdateTree implements ProjectComponent, PersistentStateCompo
|
||||
public Element getState() {
|
||||
Element element = new Element("state");
|
||||
if (myUpdateInfo != null && !myUpdateInfo.isEmpty()) {
|
||||
try {
|
||||
myUpdateInfo.writeExternal(element);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
myUpdateInfo.writeExternal(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user