IDEA-27603 (Indicate which branch is being worked on)
[fedora-idea.git] / platform / vcs-impl / src / com / intellij / openapi / vcs / changes / DelayedNotificator.java
blob22a59d92d51c222454924efd497203661b92825d
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.openapi.vcs.changes;
18 import com.intellij.openapi.vcs.changes.local.ChangeListCommand;
19 import com.intellij.util.EventDispatcher;
21 import java.util.Collection;
22 import java.util.concurrent.ScheduledExecutorService;
24 public class DelayedNotificator {
25 private final EventDispatcher<ChangeListListener> myDispatcher;
26 // this is THE SAME service as is used for change list manager update (i.e. one thread for both processes)
27 private final ScheduledExecutorService myService;
28 private final MyProxyDispatcher myProxyDispatcher;
30 public DelayedNotificator(EventDispatcher<ChangeListListener> dispatcher, final ScheduledExecutorService service) {
31 myDispatcher = dispatcher;
32 myService = service;
33 myProxyDispatcher = new MyProxyDispatcher();
36 public void callNotify(final ChangeListCommand command) {
37 myService.execute(new Runnable() {
38 public void run() {
39 command.doNotify(myDispatcher);
41 });
44 public ChangeListListener getProxyDispatcher() {
45 return myProxyDispatcher;
48 private class MyProxyDispatcher implements ChangeListListener {
49 public void changeListAdded(final ChangeList list) {
50 myService.execute(new Runnable() {
51 public void run() {
52 myDispatcher.getMulticaster().changeListAdded(list);
54 });
57 public void changesRemoved(final Collection<Change> changes, final ChangeList fromList) {
58 myService.execute(new Runnable() {
59 public void run() {
60 myDispatcher.getMulticaster().changesRemoved(changes, fromList);
62 });
65 public void changesAdded(final Collection<Change> changes, final ChangeList toList) {
66 myService.execute(new Runnable() {
67 public void run() {
68 myDispatcher.getMulticaster().changesAdded(changes, toList);
70 });
73 public void changeListRemoved(final ChangeList list) {
74 myService.execute(new Runnable() {
75 public void run() {
76 myDispatcher.getMulticaster().changeListRemoved(list);
78 });
81 public void changeListChanged(final ChangeList list) {
82 myService.execute(new Runnable() {
83 public void run() {
84 myDispatcher.getMulticaster().changeListChanged(list);
86 });
89 public void changeListRenamed(final ChangeList list, final String oldName) {
90 myService.execute(new Runnable() {
91 public void run() {
92 myDispatcher.getMulticaster().changeListRenamed(list, oldName);
94 });
97 public void changeListCommentChanged(final ChangeList list, final String oldComment) {
98 myService.execute(new Runnable() {
99 public void run() {
100 myDispatcher.getMulticaster().changeListCommentChanged(list, oldComment);
105 public void changesMoved(final Collection<Change> changes, final ChangeList fromList, final ChangeList toList) {
106 myService.execute(new Runnable() {
107 public void run() {
108 myDispatcher.getMulticaster().changesMoved(changes, fromList, toList);
113 public void defaultListChanged(final ChangeList oldDefaultList, final ChangeList newDefaultList) {
114 myService.execute(new Runnable() {
115 public void run() {
116 myDispatcher.getMulticaster().defaultListChanged(oldDefaultList, newDefaultList);
121 public void unchangedFileStatusChanged() {
122 myService.execute(new Runnable() {
123 public void run() {
124 myDispatcher.getMulticaster().unchangedFileStatusChanged();
129 public void changeListUpdateDone() {
130 myService.execute(new Runnable() {
131 public void run() {
132 myDispatcher.getMulticaster().changeListUpdateDone();