ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / platform / vcs-impl / src / com / intellij / openapi / vcs / changes / DirtBuilder.java
blob4b2e59f4a30b1cd264e3c99c364ac94001976a62
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.FilePathImpl;
19 import com.intellij.openapi.vcs.VcsRoot;
21 import java.util.Collection;
22 import java.util.HashSet;
23 import java.util.Set;
25 public class DirtBuilder implements DirtBuilderReader {
26 private final VcsGuess myGuess;
28 private final Set<FilePathUnderVcs> myFiles;
29 private final Set<FilePathUnderVcs> myDirs;
30 private boolean myEverythingDirty;
32 public DirtBuilder(final VcsGuess guess) {
33 myGuess = guess;
34 myDirs = new HashSet<FilePathUnderVcs>();
35 myFiles = new HashSet<FilePathUnderVcs>();
36 myEverythingDirty = false;
39 public DirtBuilder(final DirtBuilder builder) {
40 myGuess = builder.myGuess;
41 myDirs = new HashSet<FilePathUnderVcs>(builder.myDirs);
42 myFiles = new HashSet<FilePathUnderVcs>(builder.myFiles);
43 myEverythingDirty = builder.myEverythingDirty;
46 public void reset() {
47 myFiles.clear();
48 myDirs.clear();
49 myEverythingDirty = false;
52 public void everythingDirty() {
53 myEverythingDirty = true;
56 public void addDirtyFile(final VcsRoot root) {
57 myFiles.add(new FilePathUnderVcs(new FilePathImpl(root.path), root.vcs));
60 public void addDirtyDirRecursively(final VcsRoot root) {
61 myDirs.add(new FilePathUnderVcs(new FilePathImpl(root.path), root.vcs));
64 public void addDirtyFile(final FilePathUnderVcs root) {
65 myFiles.add(root);
68 public void addDirtyDirRecursively(final FilePathUnderVcs root) {
69 myDirs.add(root);
72 public boolean isEverythingDirty() {
73 return myEverythingDirty;
76 public Collection<FilePathUnderVcs> getFilesForVcs() {
77 return myFiles;
80 public Collection<FilePathUnderVcs> getDirsForVcs() {
81 return myDirs;
84 public boolean isEmpty() {
85 return myFiles.isEmpty() && myDirs.isEmpty();