Commit 088ae2cb authored by Julia Beliaeva's avatar Julia Beliaeva
Browse files

[vcs-log] extract interface VcsLogTabsProperties

parent 13aecda8
Branches unavailable Tags unavailable
No related merge requests found
Showing with 23 additions and 14 deletions
+23 -14
......@@ -38,7 +38,7 @@ public class VcsLogManager implements Disposable {
private static final Logger LOG = Logger.getInstance(VcsLogManager.class);
@NotNull private final Project myProject;
@NotNull private final VcsLogProjectTabsProperties myUiProperties;
@NotNull private final VcsLogTabsProperties myUiProperties;
@Nullable private final Consumer<Throwable> myRecreateMainLogHandler;
@NotNull private final VcsLogData myLogData;
......@@ -46,12 +46,12 @@ public class VcsLogManager implements Disposable {
@NotNull private final VcsLogTabsWatcher myTabsLogRefresher;
@NotNull private final PostponableLogRefresher myPostponableRefresher;
public VcsLogManager(@NotNull Project project, @NotNull VcsLogProjectTabsProperties uiProperties, @NotNull Collection<VcsRoot> roots) {
public VcsLogManager(@NotNull Project project, @NotNull VcsLogTabsProperties uiProperties, @NotNull Collection<VcsRoot> roots) {
this(project, uiProperties, roots, true, null);
}
public VcsLogManager(@NotNull Project project,
@NotNull VcsLogProjectTabsProperties uiProperties,
@NotNull VcsLogTabsProperties uiProperties,
@NotNull Collection<VcsRoot> roots,
boolean scheduleRefreshImmediately,
@Nullable Consumer<Throwable> recreateHandler) {
......@@ -96,7 +96,7 @@ public class VcsLogManager implements Disposable {
}
@NotNull
public VcsLogProjectTabsProperties getUiProperties() {
public VcsLogTabsProperties getUiProperties() {
return myUiProperties;
}
......
......@@ -17,7 +17,7 @@ import static com.intellij.util.containers.ContainerUtil.*;
import static java.util.Comparator.comparingInt;
@State(name = "Vcs.Log.Tabs.Properties", storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE)})
public class VcsLogProjectTabsProperties implements PersistentStateComponent<VcsLogProjectTabsProperties.State> {
public class VcsLogProjectTabsProperties implements PersistentStateComponent<VcsLogProjectTabsProperties.State>, VcsLogTabsProperties {
public static final String MAIN_LOG_ID = "MAIN";
private static final int RECENTLY_FILTERED_VALUES_LIMIT = 10;
@NotNull private final VcsLogApplicationSettings myAppSettings;
......@@ -65,6 +65,7 @@ public class VcsLogProjectTabsProperties implements PersistentStateComponent<Vcs
}
}
@Override
@NotNull
public MainVcsLogUiProperties createProperties(@NotNull final String id) {
myState.TAB_STATES.putIfAbsent(id, new VcsLogUiPropertiesImpl.State());
......
......@@ -14,12 +14,15 @@ import java.util.List;
public class VcsLogTabsManager {
@NotNull private final Project myProject;
@NotNull private final VcsLogProjectTabsProperties myUiProperties;
private boolean myIsLogDisposing = false;
public VcsLogTabsManager(@NotNull Project project,
@NotNull MessageBus messageBus,
@NotNull VcsLogProjectTabsProperties uiProperties,
@NotNull Disposable parent) {
myProject = project;
myUiProperties = uiProperties;
messageBus.connect(parent).subscribe(VcsProjectLog.VCS_PROJECT_LOG_CHANGED, new VcsProjectLog.ProjectLogListener() {
@Override
......@@ -37,7 +40,7 @@ public class VcsLogTabsManager {
@CalledInAwt
private void createLogTabs(@NotNull VcsLogManager manager) {
List<String> tabIds = manager.getUiProperties().getTabs();
List<String> tabIds = myUiProperties.getTabs();
for (String tabId : tabIds) {
openLogTab(manager, tabId, false);
}
......@@ -48,19 +51,15 @@ public class VcsLogTabsManager {
}
private void openLogTab(@NotNull VcsLogManager manager, @NotNull String tabId, boolean focus) {
VcsLogManager.VcsLogUiFactory<? extends VcsLogUiImpl> factory =
new PersistentVcsLogUiFactory(manager.getMainLogUiFactory(tabId), manager.getUiProperties());
VcsLogManager.VcsLogUiFactory<? extends VcsLogUiImpl> factory = new PersistentVcsLogUiFactory(manager.getMainLogUiFactory(tabId));
VcsLogContentUtil.openLogTab(myProject, manager, VcsLogContentProvider.TAB_NAME, tabId, factory, focus);
}
private class PersistentVcsLogUiFactory implements VcsLogManager.VcsLogUiFactory<VcsLogUiImpl> {
private final VcsLogManager.VcsLogUiFactory<? extends VcsLogUiImpl> myFactory;
@NotNull private final VcsLogProjectTabsProperties myUiProperties;
public PersistentVcsLogUiFactory(@NotNull VcsLogManager.VcsLogUiFactory<? extends VcsLogUiImpl> factory,
@NotNull VcsLogProjectTabsProperties properties) {
public PersistentVcsLogUiFactory(@NotNull VcsLogManager.VcsLogUiFactory<? extends VcsLogUiImpl> factory) {
myFactory = factory;
myUiProperties = properties;
}
@Override
......
// 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.vcs.log.impl;
import org.jetbrains.annotations.NotNull;
public interface VcsLogTabsProperties {
@NotNull
MainVcsLogUiProperties createProperties(@NotNull String id);
}
......@@ -47,7 +47,7 @@ public class VcsProjectLog implements Disposable {
private static final int RECREATE_LOG_TRIES = 5;
@NotNull private final Project myProject;
@NotNull private final MessageBus myMessageBus;
@NotNull private final VcsLogProjectTabsProperties myUiProperties;
@NotNull private final VcsLogTabsProperties myUiProperties;
@NotNull private final VcsLogTabsManager myTabsManager;
@NotNull
......@@ -60,7 +60,7 @@ public class VcsProjectLog implements Disposable {
myProject = project;
myMessageBus = messageBus;
myUiProperties = uiProperties;
myTabsManager = new VcsLogTabsManager(project, messageBus, this);
myTabsManager = new VcsLogTabsManager(project, messageBus, uiProperties, this);
}
@Nullable
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment