notifyListeners method readded, unnecessary messageBus field removed (getProject().getMessageBus using instead )

This commit is contained in:
Nadya Zabrodina
2013-06-10 13:49:41 +04:00
parent 169a2ea155
commit 562bab1288
4 changed files with 11 additions and 13 deletions
@@ -19,7 +19,6 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.messages.MessageBus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,7 +29,6 @@ public abstract class RepositoryImpl implements Repository, Disposable {
@NotNull private final Project myProject;
@NotNull private final VirtualFile myRootDir;
@Nullable private final MessageBus myMessageBus;
@NotNull protected volatile State myState;
@@ -42,8 +40,6 @@ public abstract class RepositoryImpl implements Repository, Disposable {
myProject = project;
myRootDir = dir;
Disposer.register(parentDisposable, this);
myMessageBus = project.getMessageBus();
}
@Override
@@ -86,11 +82,6 @@ public abstract class RepositoryImpl implements Repository, Disposable {
public void dispose() {
}
@Nullable
public MessageBus getMessageBus() {
return myMessageBus;
}
@Override
public boolean equals(Object o) {
@@ -164,9 +164,7 @@ public class GitRepositoryImpl extends RepositoryImpl implements GitRepository,
myRemotes = config.parseRemotes();
readRepository(myRemotes);
myBranchTrackInfos = config.parseTrackInfos(myBranches.getLocalBranches(), myBranches.getRemoteBranches());
if (!Disposer.isDisposed(getProject()) && getMessageBus() != null) {
getMessageBus().syncPublisher(GIT_REPO_CHANGE).repositoryChanged(this);
}
notifyListeners();
}
private void readRepository(@NotNull Collection<GitRemote> remotes) {
@@ -176,6 +174,12 @@ public class GitRepositoryImpl extends RepositoryImpl implements GitRepository,
myBranches = myReader.readBranches(remotes);
}
protected void notifyListeners() {
if (!Disposer.isDisposed(getProject())) {
getProject().getMessageBus().syncPublisher(GIT_REPO_CHANGE).repositoryChanged(this);
}
}
@Override
public String toLogString() {
return String.format("GitRepository{myCurrentBranch=%s, myCurrentRevision='%s', myState=%s, myRootDir=%s}",
@@ -45,6 +45,9 @@ class GitTestInitUtil {
// the constructor and notifyListeners() should probably be private
// getPresentableUrl should probably be final, and we should have a better VirtualFile implementation for tests.
GitRepository repository = new GitRepositoryImpl(new MockVirtualFile(rootDir), platformFacade, project, project, true) {
@Override
protected void notifyListeners() {
}
@NotNull
@Override
@@ -98,7 +98,7 @@ public class HgRepositoryImpl extends RepositoryImpl implements HgRepository {
public void update() {
readRepository();
if (!Disposer.isDisposed(getProject())) {
getMessageBus().syncPublisher(HgVcs.STATUS_TOPIC).update(getProject(), getRoot());
getProject().getMessageBus().syncPublisher(HgVcs.STATUS_TOPIC).update(getProject(), getRoot());
}
}