1 package com
.intellij
.openapi
.vcs
.changes
.conflicts
;
3 import com
.intellij
.openapi
.project
.Project
;
4 import com
.intellij
.openapi
.vcs
.changes
.Change
;
5 import com
.intellij
.openapi
.vcs
.changes
.ChangeList
;
6 import com
.intellij
.openapi
.vcs
.changes
.ChangeListManagerImpl
;
7 import com
.intellij
.openapi
.vcs
.readOnlyHandler
.WritingAccessProvider
;
8 import com
.intellij
.openapi
.vfs
.VirtualFile
;
9 import org
.jetbrains
.annotations
.NotNull
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collection
;
13 import java
.util
.HashSet
;
14 import java
.util
.Collections
;
17 * @author Dmitry Avdeev
19 public class ChangelistConflictAccessProvider
implements WritingAccessProvider
{
21 private final Project myProject
;
22 private final ChangeListManagerImpl myManager
;
24 public ChangelistConflictAccessProvider(Project project
, ChangeListManagerImpl manager
) {
30 public Collection
<VirtualFile
> requestWriting(VirtualFile
... files
) {
31 ChangelistConflictTracker
.Options options
= myManager
.getConflictTracker().getOptions();
32 if (!options
.TRACKING_ENABLED
|| !options
.SHOW_DIALOG
) {
33 return Collections
.emptyList();
35 ArrayList
<VirtualFile
> denied
= new ArrayList
<VirtualFile
>();
36 for (VirtualFile file
: files
) {
37 if (file
!= null && !myManager
.getConflictTracker().isWritingAllowed(file
)) {
42 if (!denied
.isEmpty()) {
43 HashSet
<ChangeList
> changeLists
= new HashSet
<ChangeList
>();
44 ArrayList
<Change
> changes
= new ArrayList
<Change
>();
45 for (VirtualFile file
: denied
) {
46 changeLists
.add(myManager
.getChangeList(file
));
47 changes
.add(myManager
.getChange(file
));
50 ChangelistConflictDialog dialog
;
52 dialog
= new ChangelistConflictDialog(myProject
, new ArrayList
<ChangeList
>(changeLists
), denied
);
54 } while (dialog
.isOK() && !dialog
.getResolution().resolveConflict(myProject
, changes
));
57 options
.LAST_RESOLUTION
= dialog
.getResolution();
58 return Collections
.emptyList();