SVN auth
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / ignore / IgnoreGroupHelperAction.java
blob1e1bb386c68d3e8d09f61b4dd1e1096f965a49c4
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 org.jetbrains.idea.svn.ignore;
18 import com.intellij.openapi.actionSystem.AnActionEvent;
19 import com.intellij.openapi.actionSystem.DataContext;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.vcs.AbstractVcs;
22 import com.intellij.openapi.vcs.VcsException;
23 import com.intellij.openapi.vcs.changes.ChangeListManager;
24 import com.intellij.openapi.vfs.VirtualFile;
25 import org.jetbrains.idea.svn.SvnVcs;
26 import org.jetbrains.idea.svn.SvnStatusUtil;
27 import org.jetbrains.idea.svn.actions.BasicAction;
29 public class IgnoreGroupHelperAction extends BasicAction {
30 private boolean myAllCanBeIgnored;
31 private boolean myAllAreIgnored;
32 private FileIterationListener myListener;
34 protected String getActionName(final AbstractVcs vcs) {
35 return null;
38 public void update(final AnActionEvent e) {
39 myAllAreIgnored = true;
40 myAllCanBeIgnored = true;
42 super.update(e);
45 public void setFileIterationListener(final FileIterationListener listener) {
46 myListener = listener;
49 private boolean isEnabledImpl(final SvnVcs vcs, final VirtualFile file) {
50 final ChangeListManager clManager = ChangeListManager.getInstance(vcs.getProject());
52 if (SvnStatusUtil.isIgnoredInAnySense(clManager, file)) {
53 myAllCanBeIgnored = false;
54 return myAllAreIgnored | myAllCanBeIgnored;
55 } else if (clManager.isUnversioned(file)) {
56 // check parent
57 final VirtualFile parent = file.getParent();
58 if (parent != null) {
59 if ((! SvnStatusUtil.isIgnoredInAnySense(clManager, parent)) && (! clManager.isUnversioned(parent))) {
60 myAllAreIgnored = false;
61 return myAllAreIgnored | myAllCanBeIgnored;
65 myAllCanBeIgnored = false;
66 myAllAreIgnored = false;
67 return false;
70 protected boolean isEnabled(final Project project, final SvnVcs vcs, final VirtualFile file) {
71 final boolean result = isEnabledImpl(vcs, file);
72 if (result) {
73 myListener.onFileEnabled(file);
75 return result;
78 public boolean allCanBeIgnored() {
79 return myAllCanBeIgnored;
82 public boolean allAreIgnored() {
83 return myAllAreIgnored;
86 protected boolean needsFiles() {
87 return true;
90 protected void perform(final Project project, final SvnVcs activeVcs, final VirtualFile file, final DataContext context)
91 throws VcsException {
95 protected void batchPerform(final Project project, final SvnVcs activeVcs, final VirtualFile[] file, final DataContext context)
96 throws VcsException {
100 protected boolean isBatchAction() {
101 return false;