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
;
33 myProxyDispatcher
= new MyProxyDispatcher();
36 public void callNotify(final ChangeListCommand command
) {
37 myService
.execute(new Runnable() {
39 command
.doNotify(myDispatcher
);
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() {
52 myDispatcher
.getMulticaster().changeListAdded(list
);
57 public void changesRemoved(final Collection
<Change
> changes
, final ChangeList fromList
) {
58 myService
.execute(new Runnable() {
60 myDispatcher
.getMulticaster().changesRemoved(changes
, fromList
);
65 public void changesAdded(final Collection
<Change
> changes
, final ChangeList toList
) {
66 myService
.execute(new Runnable() {
68 myDispatcher
.getMulticaster().changesAdded(changes
, toList
);
73 public void changeListRemoved(final ChangeList list
) {
74 myService
.execute(new Runnable() {
76 myDispatcher
.getMulticaster().changeListRemoved(list
);
81 public void changeListChanged(final ChangeList list
) {
82 myService
.execute(new Runnable() {
84 myDispatcher
.getMulticaster().changeListChanged(list
);
89 public void changeListRenamed(final ChangeList list
, final String oldName
) {
90 myService
.execute(new Runnable() {
92 myDispatcher
.getMulticaster().changeListRenamed(list
, oldName
);
97 public void changeListCommentChanged(final ChangeList list
, final String oldComment
) {
98 myService
.execute(new Runnable() {
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() {
108 myDispatcher
.getMulticaster().changesMoved(changes
, fromList
, toList
);
113 public void defaultListChanged(final ChangeList oldDefaultList
, final ChangeList newDefaultList
) {
114 myService
.execute(new Runnable() {
116 myDispatcher
.getMulticaster().defaultListChanged(oldDefaultList
, newDefaultList
);
121 public void unchangedFileStatusChanged() {
122 myService
.execute(new Runnable() {
124 myDispatcher
.getMulticaster().unchangedFileStatusChanged();
129 public void changeListUpdateDone() {
130 myService
.execute(new Runnable() {
132 myDispatcher
.getMulticaster().changeListUpdateDone();