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.application.ApplicationManager;
19 import com.intellij.openapi.vcs.FilePath;
26 public class DeletedFilesHolder implements FileHolder {
27 private final Map<String, LocallyDeletedChange> myFiles = new HashMap<String, LocallyDeletedChange>();
29 public void cleanAll() {
33 public void takeFrom(final DeletedFilesHolder holder) {
35 myFiles.putAll(holder.myFiles);
38 public void cleanScope(final VcsDirtyScope scope) {
39 ApplicationManager.getApplication().runReadAction(new Runnable() {
44 final List<LocallyDeletedChange> currentFiles = new ArrayList<LocallyDeletedChange>(myFiles.values());
45 for (LocallyDeletedChange change : currentFiles) {
46 if (scope.belongsTo(change.getPath())) {
47 myFiles.remove(change.getPresentableUrl());
54 public HolderType getType() {
55 return HolderType.DELETED;
58 public void addFile(final LocallyDeletedChange change) {
59 myFiles.put(change.getPresentableUrl(), change);
62 public List<LocallyDeletedChange> getFiles() {
63 return new ArrayList<LocallyDeletedChange>(myFiles.values());
66 public boolean isContainedInLocallyDeleted(final FilePath filePath) {
67 final String url = filePath.getPresentableUrl();
68 return myFiles.containsKey(url);
71 public DeletedFilesHolder copy() {
72 final DeletedFilesHolder copyHolder = new DeletedFilesHolder();
73 copyHolder.myFiles.putAll(myFiles);
77 public boolean equals(final Object o) {
78 if (this == o) return true;
79 if (o == null || getClass() != o.getClass()) return false;
81 final DeletedFilesHolder that = (DeletedFilesHolder)o;
83 if (!myFiles.equals(that.myFiles)) return false;
88 public int hashCode() {
89 return myFiles.hashCode();