mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Refactor "CommittedChangesListener" - provide default implementation, @NotNull, cleanup
Deprecate "CommittedChangesAdapter" GitOrigin-RevId: c35fbf33f085df551484d4ecf95432b73d7cf27e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b336ce68c2
commit
67f9062dcb
+3
-28
@@ -1,34 +1,9 @@
|
||||
// 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.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @deprecated Use {@link CommittedChangesListener}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CommittedChangesAdapter implements CommittedChangesListener {
|
||||
@Override
|
||||
public void changesLoaded(RepositoryLocation location, List<CommittedChangeList> changes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changesCleared() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void presentationChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshErrorStatusChanged(@Nullable VcsException lastError) {
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -437,7 +437,7 @@ public class CommittedChangesCache extends SimplePersistentStateComponent<Commit
|
||||
return changes;
|
||||
}
|
||||
|
||||
private void fireChangesLoaded(final RepositoryLocation location, final List<CommittedChangeList> changes) {
|
||||
private void fireChangesLoaded(@NotNull RepositoryLocation location, @NotNull List<CommittedChangeList> changes) {
|
||||
MessageBusUtil.invokeLaterIfNeededOnSyncPublisher(myProject, COMMITTED_TOPIC, listener -> listener.changesLoaded(location, changes));
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ public class CommittedChangesCache extends SimplePersistentStateComponent<Commit
|
||||
|
||||
// todo: fix - would externally loaded necessarily for file? i.e. just not efficient now
|
||||
@NotNull
|
||||
private List<CommittedChangeList> refreshCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
|
||||
private List<CommittedChangeList> refreshCache(@NotNull ChangesCacheFile cacheFile) throws VcsException, IOException {
|
||||
debug("Refreshing cache for " + cacheFile.getLocation());
|
||||
final List<CommittedChangeList> newLists = new ArrayList<>();
|
||||
|
||||
@@ -458,7 +458,7 @@ public class CommittedChangesCache extends SimplePersistentStateComponent<Commit
|
||||
final Pair<Long, List<CommittedChangeList>> externalLists = myExternallyLoadedChangeLists.get(location.getKey());
|
||||
final long latestChangeList = getLatestListForFile(cacheFile);
|
||||
if ((externalLists != null) && (latestChangeList == externalLists.first.longValue())) {
|
||||
newLists.addAll(appendLoadedChanges(cacheFile, location, externalLists.second));
|
||||
newLists.addAll(appendLoadedChanges(cacheFile, externalLists.second));
|
||||
myExternallyLoadedChangeLists.clear();
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ public class CommittedChangesCache extends SimplePersistentStateComponent<Commit
|
||||
defaultSettings.STRICTLY_AFTER = true;
|
||||
final List<CommittedChangeList> newChanges = provider.getCommittedChanges(defaultSettings, location, maxCount);
|
||||
debug("Loaded " + newChanges.size() + " new changelists");
|
||||
newLists.addAll(appendLoadedChanges(cacheFile, location, newChanges));
|
||||
newLists.addAll(appendLoadedChanges(cacheFile, newChanges));
|
||||
|
||||
return newLists;
|
||||
}
|
||||
@@ -493,11 +493,11 @@ public class CommittedChangesCache extends SimplePersistentStateComponent<Commit
|
||||
LOG.debug(message);
|
||||
}
|
||||
|
||||
private List<CommittedChangeList> appendLoadedChanges(final ChangesCacheFile cacheFile, final RepositoryLocation location,
|
||||
private List<CommittedChangeList> appendLoadedChanges(@NotNull ChangesCacheFile cacheFile,
|
||||
@NotNull List<? extends CommittedChangeList> newChanges) throws IOException {
|
||||
final List<CommittedChangeList> savedChanges = writeChangesInReadAction(cacheFile, newChanges);
|
||||
if (savedChanges.size() > 0) {
|
||||
fireChangesLoaded(location, savedChanges);
|
||||
fireChangesLoaded(cacheFile.getLocation(), savedChanges);
|
||||
}
|
||||
return savedChanges;
|
||||
}
|
||||
@@ -629,8 +629,7 @@ public class CommittedChangesCache extends SimplePersistentStateComponent<Commit
|
||||
}
|
||||
}
|
||||
|
||||
public void commitMessageChanged(final AbstractVcs vcs,
|
||||
final RepositoryLocation location, final long number, final String newMessage) {
|
||||
public void commitMessageChanged(@NotNull RepositoryLocation location, long number, String newMessage) {
|
||||
myTaskQueue.run(() -> {
|
||||
final ChangesCacheFile file = myCachesHolder.haveCache(location);
|
||||
if (file != null) {
|
||||
|
||||
+16
-23
@@ -1,34 +1,27 @@
|
||||
/*
|
||||
* 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.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface CommittedChangesListener {
|
||||
void changesLoaded(RepositoryLocation location, List<CommittedChangeList> changes);
|
||||
void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges);
|
||||
void changesCleared();
|
||||
void presentationChanged();
|
||||
void refreshErrorStatusChanged(@Nullable VcsException lastError);
|
||||
default void changesLoaded(@NotNull RepositoryLocation location, @NotNull List<CommittedChangeList> changes) {
|
||||
}
|
||||
|
||||
default void incomingChangesUpdated(@Nullable List<CommittedChangeList> receivedChanges) {
|
||||
}
|
||||
|
||||
default void changesCleared() {
|
||||
}
|
||||
|
||||
default void presentationChanged() {
|
||||
}
|
||||
|
||||
default void refreshErrorStatusChanged(@Nullable VcsException lastError) {
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -12,6 +12,7 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -83,9 +84,9 @@ public class CommittedChangesViewManager implements ChangesViewContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private class MyCommittedChangesListener extends CommittedChangesAdapter {
|
||||
private class MyCommittedChangesListener implements CommittedChangesListener {
|
||||
@Override
|
||||
public void changesLoaded(RepositoryLocation location, List<CommittedChangeList> changes) {
|
||||
public void changesLoaded(@NotNull RepositoryLocation location, @NotNull List<CommittedChangeList> changes) {
|
||||
presentationChanged();
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ public class CommittedChangesViewManager implements ChangesViewContentProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshErrorStatusChanged(@Nullable final VcsException lastError) {
|
||||
public void refreshErrorStatusChanged(@Nullable VcsException lastError) {
|
||||
if (lastError != null) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, lastError.getMessage(), MessageType.ERROR);
|
||||
}
|
||||
|
||||
+2
-2
@@ -42,9 +42,9 @@ public class IncomingChangesIndicator {
|
||||
myProject = project;
|
||||
myCache = cache;
|
||||
final MessageBusConnection connection = bus.connect();
|
||||
connection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
|
||||
connection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesListener() {
|
||||
@Override
|
||||
public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
|
||||
public void incomingChangesUpdated(@Nullable List<CommittedChangeList> receivedChanges) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> refreshIndicator());
|
||||
}
|
||||
});
|
||||
|
||||
+6
-5
@@ -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.actionSystem.ActionGroup;
|
||||
@@ -18,6 +18,7 @@ import com.intellij.util.Consumer;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -92,14 +93,14 @@ public class IncomingChangesViewProvider implements ChangesViewContentProvider {
|
||||
});
|
||||
}
|
||||
|
||||
private class MyCommittedChangesListener extends CommittedChangesAdapter {
|
||||
private class MyCommittedChangesListener implements CommittedChangesListener {
|
||||
@Override
|
||||
public void changesLoaded(final RepositoryLocation location, final List<CommittedChangeList> changes) {
|
||||
public void changesLoaded(@NotNull RepositoryLocation location, @NotNull List<CommittedChangeList> changes) {
|
||||
updateModel(true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incomingChangesUpdated(final List<CommittedChangeList> receivedChanges) {
|
||||
public void incomingChangesUpdated(@Nullable List<CommittedChangeList> receivedChanges) {
|
||||
updateModel(true, true);
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ public class IncomingChangesViewProvider implements ChangesViewContentProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshErrorStatusChanged(@Nullable final VcsException lastError) {
|
||||
public void refreshErrorStatusChanged(@Nullable VcsException lastError) {
|
||||
if (lastError != null) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(myProject, lastError.getMessage(), MessageType.ERROR);
|
||||
}
|
||||
|
||||
+3
-3
@@ -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;
|
||||
@@ -44,9 +44,9 @@ public class OutdatedVersionNotifier {
|
||||
myCache = cache;
|
||||
myProject = project;
|
||||
MessageBusConnection busConnection = messageBus.connect();
|
||||
busConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
|
||||
busConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesListener() {
|
||||
@Override
|
||||
public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
|
||||
public void incomingChangesUpdated(@Nullable List<CommittedChangeList> receivedChanges) {
|
||||
if (myCache.getCachedIncomingChanges() == null) {
|
||||
requestLoadIncomingChanges();
|
||||
}
|
||||
|
||||
+6
-4
@@ -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;
|
||||
@@ -21,6 +21,8 @@ import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.RunAll;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -338,17 +340,17 @@ public class CommittedChangesCacheTest extends HeavyPlatformTestCase {
|
||||
return MockCommittedChangesProvider.createMockChange(new File(myContentRoot.getPath(), path).toString(), revision);
|
||||
}
|
||||
|
||||
private static class MockListener extends CommittedChangesAdapter {
|
||||
private static class MockListener implements CommittedChangesListener {
|
||||
private final List<CommittedChangeList> myLoadedChanges = new ArrayList<>();
|
||||
private final List<List<CommittedChangeList>> myIncomingChangesUpdates = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void changesLoaded(RepositoryLocation location, List<CommittedChangeList> changes) {
|
||||
public void changesLoaded(@NotNull RepositoryLocation location, @NotNull List<CommittedChangeList> changes) {
|
||||
myLoadedChanges.addAll(changes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incomingChangesUpdated(final List<CommittedChangeList> receivedChanges) {
|
||||
public void incomingChangesUpdated(@Nullable List<CommittedChangeList> receivedChanges) {
|
||||
myIncomingChangesUpdates.add(receivedChanges);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.history;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -8,8 +8,8 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.changes.committed.ChangesBunch;
|
||||
import com.intellij.openapi.vcs.changes.committed.CommittedChangesAdapter;
|
||||
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
|
||||
import com.intellij.openapi.vcs.changes.committed.CommittedChangesListener;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
@@ -36,10 +36,9 @@ public class LoadedRevisionsCache implements Disposable {
|
||||
myMap = (ApplicationManager.getApplication().isUnitTestMode()) ? new HashMap<>() : ContainerUtil.createSoftMap();
|
||||
|
||||
myConnection = project.getMessageBus().connect();
|
||||
myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
|
||||
|
||||
myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesListener() {
|
||||
@Override
|
||||
public void changesLoaded(final RepositoryLocation location, final List<CommittedChangeList> changes) {
|
||||
public void changesLoaded(@NotNull RepositoryLocation location, @NotNull List<CommittedChangeList> changes) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
myMap.clear();
|
||||
setRefreshTime(System.currentTimeMillis());
|
||||
|
||||
@@ -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.history;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -141,7 +141,7 @@ public class SvnEditCommitMessageAction extends DumbAwareAction {
|
||||
myListener.consume(myNewMessage);
|
||||
}
|
||||
if (! myProject.isDefault()) {
|
||||
CommittedChangesCache.getInstance(myProject).commitMessageChanged(myVcs, myLocation, myNumber, myNewMessage);
|
||||
CommittedChangesCache.getInstance(myProject).commitMessageChanged(myLocation, myNumber, myNewMessage);
|
||||
}
|
||||
if (myFromVersionControl) {
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(myProject, "Revision #" + myNumber + " comment " +
|
||||
|
||||
Reference in New Issue
Block a user