vcs: Refactor "VcsConfigurationChangeListener" - @NotNull

GitOrigin-RevId: 22998ab726b30d08b41662705d6a9473551966ce
This commit is contained in:
Konstantin Kolosovsky
2019-12-18 13:03:45 +00:00
committed by intellij-monorepo-bot
parent 67f9062dcb
commit c3d3938c2a
6 changed files with 25 additions and 39 deletions
@@ -224,8 +224,8 @@ public class CommittedChangesPanel extends JPanel implements DataProvider, Dispo
myDisposed = true;
}
public void passCachedListsToListener(final VcsConfigurationChangeListener.DetailedNotification notification,
final Project project, final VirtualFile root) {
public void passCachedListsToListener(@NotNull VcsConfigurationChangeListener.DetailedNotification notification,
@Nullable VirtualFile root) {
final List<CommittedChangeList> resultList = new ArrayList<>();
myBrowser.reportLoadedLists(new CommittedChangeListsListener() {
@Override
@@ -241,7 +241,7 @@ public class CommittedChangesPanel extends JPanel implements DataProvider, Dispo
@Override
public void onAfterEndReport() {
if (!resultList.isEmpty()) {
notification.execute(project, root, resultList);
notification.execute(myProject, root, resultList);
}
}
});
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2019 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.changes.committed;
import com.intellij.openapi.application.ApplicationManager;
@@ -18,6 +18,9 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
import static com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener.BRANCHES_CHANGED;
import static com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE;
public class CommittedChangesViewManager implements ChangesViewContentProvider {
private final MessageBus myBus;
private MessageBusConnection myConnection;
@@ -36,12 +39,7 @@ public class CommittedChangesViewManager implements ChangesViewContentProvider {
if (myComponent == null) {
myComponent = new CommittedChangesPanel(myProject, provider, provider.createDefaultSettings(), null, null);
myConnection.subscribe(VcsConfigurationChangeListener.BRANCHES_CHANGED, new VcsConfigurationChangeListener.Notification() {
@Override
public void execute(final Project project, final VirtualFile vcsRoot) {
sendUpdateCachedListsMessage(vcsRoot);
}
});
myConnection.subscribe(BRANCHES_CHANGED, (project, vcsRoot) -> sendUpdateCachedListsMessage(vcsRoot));
}
else {
myComponent.setProvider(provider);
@@ -50,10 +48,11 @@ public class CommittedChangesViewManager implements ChangesViewContentProvider {
}
}
private void sendUpdateCachedListsMessage(final VirtualFile vcsRoot) {
private void sendUpdateCachedListsMessage(@Nullable VirtualFile vcsRoot) {
ApplicationManager.getApplication().invokeLater(
() -> myComponent.passCachedListsToListener(myBus.syncPublisher(VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE),
myProject, vcsRoot), o -> (! myProject.isOpen()) || myProject.isDisposed() || myComponent == null);
() -> myComponent.passCachedListsToListener(myBus.syncPublisher(BRANCHES_CHANGED_RESPONSE), vcsRoot),
o -> !myProject.isOpen() || myProject.isDisposed() || myComponent == null
);
}
@Override
@@ -1,24 +1,12 @@
/*
* Copyright 2000-2009 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.
*/
// Copyright 2000-2019 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.changes.committed;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -27,10 +15,10 @@ public interface VcsConfigurationChangeListener {
Topic<DetailedNotification> BRANCHES_CHANGED_RESPONSE = new Topic<>("branch mapping changed (detailed)", DetailedNotification.class);
interface Notification {
void execute(final Project project, final VirtualFile vcsRoot);
void execute(@NotNull Project project, @NotNull VirtualFile vcsRoot);
}
interface DetailedNotification {
void execute(final Project project, final VirtualFile vcsRoot, final List<CommittedChangeList> cachedList);
void execute(@NotNull Project project, @Nullable VirtualFile vcsRoot, @NotNull List<CommittedChangeList> cachedList);
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2019 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 org.jetbrains.idea.svn.branchConfig
@@ -10,7 +10,7 @@ import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.progress.util.BackgroundTaskUtil.syncPublisher
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.ProjectLevelVcsManager
import com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener
import com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener.BRANCHES_CHANGED
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl
import com.intellij.openapi.vcs.impl.VcsInitObject
import com.intellij.openapi.vfs.LocalFileSystem
@@ -65,8 +65,7 @@ class SvnBranchConfigurationManager(private val myProject: Project,
svnBranchConfigManager.updateForRoot(vcsRoot, InfoStorage(configuration, InfoReliability.setByUser), true)
SvnBranchMapperManager.getInstance().notifyBranchesChanged(myProject, vcsRoot, configuration)
syncPublisher<VcsConfigurationChangeListener.Notification>(myProject, VcsConfigurationChangeListener.BRANCHES_CHANGED).execute(
myProject, vcsRoot)
syncPublisher(myProject, BRANCHES_CHANGED).execute(myProject, vcsRoot)
}
override fun getState(): ConfigurationBean = ConfigurationBean().apply {
@@ -1,11 +1,10 @@
// 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.
// Copyright 2000-2019 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 org.jetbrains.idea.svn.history;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ZipperUpdater;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser;
import com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener;
import com.intellij.util.Consumer;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
@@ -17,6 +16,7 @@ import java.util.ArrayList;
import java.util.List;
import static com.intellij.openapi.vcs.ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED;
import static com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener.BRANCHES_CHANGED;
public class MergeInfoUpdatesListener {
private final static int DELAY = 300;
@@ -37,7 +37,7 @@ public class MergeInfoUpdatesListener {
myMergeInfoRefreshActions = new ArrayList<>();
myMergeInfoRefreshActions.add(action);
myConnection.subscribe(VcsConfigurationChangeListener.BRANCHES_CHANGED, (project, vcsRoot) -> callReloadMergeInfo());
myConnection.subscribe(BRANCHES_CHANGED, (project, vcsRoot) -> callReloadMergeInfo());
final Consumer<Boolean> reloadConsumer = aBoolean -> {
if (Boolean.TRUE.equals(aBoolean)) {
callReloadMergeInfo();
@@ -12,7 +12,6 @@ import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.committed.DecoratorManager;
import com.intellij.openapi.vcs.changes.committed.VcsCommittedListsZipper;
import com.intellij.openapi.vcs.changes.committed.VcsCommittedViewAuxiliary;
import com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
import com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor;
@@ -45,6 +44,7 @@ import java.util.*;
import static com.intellij.openapi.application.ApplicationManager.getApplication;
import static com.intellij.openapi.progress.ProgressManager.progress;
import static com.intellij.openapi.progress.ProgressManager.progress2;
import static com.intellij.openapi.vcs.changes.committed.VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE;
import static java.util.Collections.singletonList;
import static org.jetbrains.idea.svn.SvnBundle.message;
@@ -65,7 +65,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
myZipper = new SvnCommittedListsZipper(myVcs);
myConnection = myVcs.getProject().getMessageBus().connect();
myConnection.subscribe(VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE,
myConnection.subscribe(BRANCHES_CHANGED_RESPONSE,
(project, vcsRoot, cachedList) -> getApplication().invokeLater(() -> {
cachedList.stream().filter(SvnChangeList.class::isInstance).map(SvnChangeList.class::cast)
.filter(list -> vcsRoot == null || vcsRoot.equals(list.getVcsRoot()))