diff --git a/platform/vcs-log/impl/src/META-INF/vcs-log.xml b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
index fe0edad81a20..92d09a3e2548 100644
--- a/platform/vcs-log/impl/src/META-INF/vcs-log.xml
+++ b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
@@ -8,7 +8,7 @@
-
+
LOG_PROVIDER_EP = ExtensionPointName.create("com.intellij.logProvider");
private static final Logger LOG = Logger.getInstance(VcsLogManager.class);
@@ -60,23 +59,32 @@ public class VcsLogManager implements Disposable {
@Nullable private Runnable myRecreateMainLogHandler;
private volatile VcsLogUiImpl myUi;
- private VcsLogDataManager myDataManager;
- private VcsLogColorManagerImpl myColorManager;
- private VcsLogTabsWatcher myTabsLogRefresher;
- private PostponableLogRefresher myPostponableRefresher;
+ @NotNull private final VcsLogDataManager myDataManager;
+ @NotNull private final VcsLogColorManagerImpl myColorManager;
+ @NotNull private final VcsLogTabsWatcher myTabsLogRefresher;
+ @NotNull private final PostponableLogRefresher myPostponableRefresher;
- public VcsLogManager(@NotNull Project project, @NotNull VcsLogTabsProperties uiProperties) {
+ public VcsLogManager(@NotNull Project project, @NotNull VcsLogTabsProperties uiProperties, @NotNull Collection roots) {
myProject = project;
myUiProperties = uiProperties;
- }
- public VcsLogDataManager getDataManager() {
- return myDataManager;
+ Map logProviders = findLogProviders(roots, myProject);
+ myDataManager = new VcsLogDataManager(myProject, logProviders, new MyFatalErrorsConsumer());
+ myPostponableRefresher = new PostponableLogRefresher(myDataManager);
+ myTabsLogRefresher = new VcsLogTabsWatcher(myProject, myPostponableRefresher, myDataManager);
+
+ refreshLogOnVcsEvents(logProviders, myPostponableRefresher, myDataManager);
+
+ myColorManager = new VcsLogColorManagerImpl(logProviders.keySet());
+
+ myDataManager.refreshCompletely();
+
+ Disposer.register(project, this);
}
@NotNull
- protected Collection getVcsRoots() {
- return Arrays.asList(ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots());
+ public VcsLogDataManager getDataManager() {
+ return myDataManager;
}
public void watchTab(@NotNull String contentTabName, @NotNull VcsLogUiImpl logUi) {
@@ -102,30 +110,12 @@ public class VcsLogManager implements Disposable {
@NotNull
public VcsLogUiImpl createLog(@NotNull String logId) {
- initData();
-
VcsLogUiProperties properties = myUiProperties.createProperties(logId);
VcsLogFiltererImpl filterer =
new VcsLogFiltererImpl(myProject, myDataManager, PermanentGraph.SortType.values()[properties.getBekSortType()]);
return new VcsLogUiImpl(myDataManager, myProject, myColorManager, properties, filterer);
}
- public boolean initData() {
- if (myDataManager != null) return true;
-
- Map logProviders = findLogProviders(getVcsRoots(), myProject);
- myDataManager = new VcsLogDataManager(myProject, logProviders, new MyFatalErrorsConsumer());
- myPostponableRefresher = new PostponableLogRefresher(myDataManager);
- myTabsLogRefresher = new VcsLogTabsWatcher(myProject, myPostponableRefresher, myDataManager);
-
- refreshLogOnVcsEvents(logProviders, myPostponableRefresher, myDataManager);
-
- myColorManager = new VcsLogColorManagerImpl(logProviders.keySet());
-
- myDataManager.refreshCompletely();
- return false;
- }
-
private static void refreshLogOnVcsEvents(@NotNull Map logProviders,
@NotNull VcsLogRefresher refresher,
@NotNull Disposable disposableParent) {
@@ -175,17 +165,17 @@ public class VcsLogManager implements Disposable {
}
public void disposeLog() {
- if (myDataManager != null) Disposer.dispose(myDataManager);
-
- myDataManager = null;
- myTabsLogRefresher = null;
- myPostponableRefresher = null;
- myColorManager = null;
+ Disposer.dispose(myDataManager);
myUi = null;
}
+ /*
+ * Use VcsLogProjectManager to get main log.
+ * */
+ @Nullable
+ @Deprecated
public static VcsLogManager getInstance(@NotNull Project project) {
- return ServiceManager.getService(project, VcsLogManager.class);
+ return ServiceManager.getService(project, VcsLogProjectManager.class).getLogManager();
}
@Override
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogProjectManager.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogProjectManager.java
new file mode 100644
index 000000000000..b7d69535e647
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogProjectManager.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.impl;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import com.intellij.openapi.vcs.VcsRoot;
+import com.intellij.vcs.log.data.VcsLogDataManager;
+import com.intellij.vcs.log.data.VcsLogTabsProperties;
+import com.intellij.vcs.log.ui.VcsLogUiImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.util.Arrays;
+import java.util.Collection;
+
+public class VcsLogProjectManager {
+ @NotNull private final Project myProject;
+ @NotNull private final VcsLogTabsProperties myUiProperties;
+
+ private VcsLogManager myLogManager;
+ @Nullable private Runnable myRecreateMainLogHandler;
+
+ public VcsLogProjectManager(@NotNull Project project, @NotNull VcsLogTabsProperties uiProperties) {
+ myProject = project;
+ myUiProperties = uiProperties;
+ }
+
+ public VcsLogDataManager getDataManager() {
+ return myLogManager.getDataManager();
+ }
+
+ @NotNull
+ protected Collection getVcsRoots() {
+ return Arrays.asList(ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots());
+ }
+
+ public void watchTab(@NotNull String contentTabName, @NotNull VcsLogUiImpl logUi) {
+ myLogManager.watchTab(contentTabName, logUi);
+ }
+
+ @NotNull
+ public JComponent initMainLog(@NotNull String contentTabName) {
+ initData();
+ return myLogManager.initMainLog(contentTabName);
+ }
+
+ @NotNull
+ public VcsLogUiImpl createLog(@NotNull String logId) {
+ initData();
+ return myLogManager.createLog(logId);
+ }
+
+ public boolean initData() {
+ if (myLogManager != null) return true;
+ myLogManager = new VcsLogManager(myProject, myUiProperties, getVcsRoots());
+ myLogManager.setRecreateMainLogHandler(myRecreateMainLogHandler);
+ return false;
+ }
+
+ public void setRecreateMainLogHandler(@Nullable Runnable recreateMainLogHandler) {
+ myRecreateMainLogHandler = recreateMainLogHandler;
+ }
+
+ /**
+ * The instance of the {@link VcsLogUiImpl} or null if the log was not initialized yet.
+ */
+ @Nullable
+ public VcsLogUiImpl getMainLogUi() {
+ return myLogManager.getMainLogUi();
+ }
+
+ public void disposeLog() {
+ if (myLogManager != null) Disposer.dispose(myLogManager);
+
+ myLogManager = null;
+ }
+
+ public static VcsLogProjectManager getInstance(@NotNull Project project) {
+ return ServiceManager.getService(project, VcsLogProjectManager.class);
+ }
+
+ public VcsLogManager getLogManager() {
+ return myLogManager;
+ }
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/statistics/VcsLogRepoSizeCollector.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/statistics/VcsLogRepoSizeCollector.java
index e59fc4bad728..945ee95e1fe5 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/statistics/VcsLogRepoSizeCollector.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/statistics/VcsLogRepoSizeCollector.java
@@ -29,7 +29,7 @@ import com.intellij.vcs.log.VcsLogProvider;
import com.intellij.vcs.log.data.DataPack;
import com.intellij.vcs.log.data.VcsLogDataManager;
import com.intellij.vcs.log.graph.PermanentGraph;
-import com.intellij.vcs.log.impl.VcsLogManager;
+import com.intellij.vcs.log.impl.VcsLogProjectManager;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
@@ -46,7 +46,7 @@ public class VcsLogRepoSizeCollector extends AbstractApplicationUsagesCollector
@NotNull
@Override
public Set getProjectUsages(@NotNull Project project) throws CollectUsagesException {
- VcsLogManager logManager = VcsLogManager.getInstance(project);
+ VcsLogProjectManager logManager = VcsLogProjectManager.getInstance(project);
VcsLogDataManager dataManager = logManager.getDataManager();
if (dataManager != null) {
DataPack dataPack = dataManager.getDataPack();
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/OpenAnotherLogTabAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/OpenAnotherLogTabAction.java
index df62ebc4c73e..a72fca42e941 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/OpenAnotherLogTabAction.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/OpenAnotherLogTabAction.java
@@ -20,7 +20,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.vcs.log.impl.VcsLogContentProvider;
-import com.intellij.vcs.log.impl.VcsLogManager;
+import com.intellij.vcs.log.impl.VcsLogProjectManager;
import com.intellij.vcs.log.ui.VcsLogUiImpl;
public class OpenAnotherLogTabAction extends DumbAwareAction {
@@ -34,7 +34,7 @@ public class OpenAnotherLogTabAction extends DumbAwareAction {
e.getPresentation().setEnabledAndVisible(false);
return;
}
- VcsLogUiImpl mainLogUi = VcsLogManager.getInstance(e.getProject()).getMainLogUi();
+ VcsLogUiImpl mainLogUi = VcsLogProjectManager.getInstance(e.getProject()).getMainLogUi();
if (mainLogUi == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/RefreshLogAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/RefreshLogAction.java
index 9ebdc0bf043b..55253f635b14 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/RefreshLogAction.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/RefreshLogAction.java
@@ -22,7 +22,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.vcs.log.VcsLogDataKeys;
import com.intellij.vcs.log.data.VcsLogDataManager;
-import com.intellij.vcs.log.impl.VcsLogManager;
+import com.intellij.vcs.log.impl.VcsLogProjectManager;
public class RefreshLogAction extends RefreshAction {
public RefreshLogAction() {
@@ -32,7 +32,7 @@ public class RefreshLogAction extends RefreshAction {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
- VcsLogManager.getInstance(project).getDataManager().refreshCompletely();
+ VcsLogProjectManager.getInstance(project).getDataManager().refreshCompletely();
}
@Override
@@ -42,7 +42,8 @@ public class RefreshLogAction extends RefreshAction {
e.getPresentation().setEnabledAndVisible(false);
}
else {
- VcsLogDataManager dataManager = VcsLogManager.getInstance(project).getDataManager();
+ VcsLogProjectManager projectManager = VcsLogProjectManager.getInstance(project);
+ VcsLogDataManager dataManager = projectManager.getDataManager();
e.getPresentation().setEnabledAndVisible(dataManager != null && e.getData(VcsLogDataKeys.VCS_LOG_UI) != null);
}
}
diff --git a/plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java b/plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java
index b1c6f8951888..e3b55312c847 100644
--- a/plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java
+++ b/plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java
@@ -38,7 +38,7 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import com.intellij.vcs.log.VcsLog;
import com.intellij.vcs.log.impl.VcsLogContentProvider;
-import com.intellij.vcs.log.impl.VcsLogManager;
+import com.intellij.vcs.log.impl.VcsLogProjectManager;
import com.intellij.vcs.log.ui.VcsLogUiImpl;
import git4idea.GitVcs;
import git4idea.i18n.GitBundle;
@@ -106,7 +106,7 @@ public class GitShowCommitInLogAction extends DumbAwareAction {
return;
}
- VcsLogManager logManager = VcsLogManager.getInstance(project);
+ VcsLogProjectManager logManager = VcsLogProjectManager.getInstance(project);
if (logManager == null) {
showLogNotReadyMessage(project);
return;
@@ -145,14 +145,14 @@ public class GitShowCommitInLogAction extends DumbAwareAction {
super.update(e);
Project project = e.getProject();
e.getPresentation().setEnabled(project != null &&
- VcsLogManager.getInstance(project) != null &&
+ VcsLogProjectManager.getInstance(project) != null &&
getRevisionNumber(e) != null &&
Comparing.equal(getVcsKey(e), GitVcs.getKey()));
}
@Nullable
private static VcsLog findLog(@NotNull Project project) {
- VcsLogManager manager = VcsLogManager.getInstance(project);
+ VcsLogProjectManager manager = VcsLogProjectManager.getInstance(project);
if (manager != null) {
VcsLogUiImpl ui = manager.getMainLogUi();
if (ui != null) {
diff --git a/plugins/git4idea/src/git4idea/log/GitShowExternalLogAction.java b/plugins/git4idea/src/git4idea/log/GitShowExternalLogAction.java
index 16deabacab91..c57c80078ec8 100644
--- a/plugins/git4idea/src/git4idea/log/GitShowExternalLogAction.java
+++ b/plugins/git4idea/src/git4idea/log/GitShowExternalLogAction.java
@@ -127,18 +127,13 @@ public class GitShowExternalLogAction extends DumbAwareAction {
for (VirtualFile root : roots) {
repositoryManager.addExternalRepository(root, GitRepositoryImpl.getInstance(root, project, true));
}
- VcsLogManager manager = new VcsLogManager(project, ServiceManager.getService(project, VcsLogTabsProperties.class)) {
- @NotNull
- @Override
- protected Collection getVcsRoots() {
- return ContainerUtil.map(roots, new Function() {
- @Override
- public VcsRoot fun(VirtualFile root) {
- return new VcsRoot(vcs, root);
- }
- });
- }
- };
+ VcsLogManager manager = new VcsLogManager(project, ServiceManager.getService(project, VcsLogTabsProperties.class),
+ ContainerUtil.map(roots, new Function() {
+ @Override
+ public VcsRoot fun(VirtualFile root) {
+ return new VcsRoot(vcs, root);
+ }
+ }));
return new MyContentComponent(manager.initMainLog(tabName), roots, new Disposable() {
@Override
public void dispose() {