mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
svn: Refactored "SvnStatusUtil", "IgnoreGroupHelperAction"
This commit is contained in:
@@ -21,32 +21,31 @@ import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SvnStatusUtil {
|
||||
private SvnStatusUtil() {
|
||||
}
|
||||
|
||||
public static boolean isUnderControl(final Project project, final VirtualFile file) {
|
||||
final ChangeListManager clManager = ChangeListManager.getInstance(project);
|
||||
return (! isIgnoredInAnySense(clManager, file)) && (! clManager.isUnversioned(file));
|
||||
public static boolean isUnderControl(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return isUnderControl(vcs.getProject(), file);
|
||||
}
|
||||
|
||||
public static boolean isAdded(final Project project, final VirtualFile file) {
|
||||
final FileStatus status = FileStatusManager.getInstance(project).getStatus(file);
|
||||
return FileStatus.ADDED.equals(status);
|
||||
public static boolean isUnderControl(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
return !isIgnoredInAnySense(project, file) && !ChangeListManager.getInstance(project).isUnversioned(file);
|
||||
}
|
||||
|
||||
public static boolean isExplicitlyLocked(final Project project, final VirtualFile file) {
|
||||
final ChangeListManager clManager = ChangeListManager.getInstance(project);
|
||||
return ((ChangeListManagerImpl) clManager).isLogicallyLocked(file);
|
||||
public static boolean isAdded(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return FileStatus.ADDED.equals(FileStatusManager.getInstance(vcs.getProject()).getStatus(file));
|
||||
}
|
||||
|
||||
public static boolean isIgnoredInAnySense(final ChangeListManager clManager, final VirtualFile file) {
|
||||
return clManager.isIgnoredFile(file) || FileStatus.IGNORED.equals(clManager.getStatus(file));
|
||||
public static boolean isExplicitlyLocked(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return ChangeListManagerImpl.getInstanceImpl(vcs.getProject()).isLogicallyLocked(file);
|
||||
}
|
||||
|
||||
public static boolean fileCanBeAdded(final Project project, final VirtualFile file) {
|
||||
final ChangeListManager clManager = ChangeListManager.getInstance(project);
|
||||
return isIgnoredInAnySense(clManager, file) || clManager.isUnversioned(file);
|
||||
public static boolean isIgnoredInAnySense(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
ChangeListManager manager = ChangeListManager.getInstance(project);
|
||||
|
||||
return manager.isIgnoredFile(file) || FileStatus.IGNORED.equals(manager.getStatus(file));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,13 +586,9 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fileIsUnderVcs(FilePath path) {
|
||||
final ChangeListManager clManager = ChangeListManager.getInstance(myProject);
|
||||
final VirtualFile file = path.getVirtualFile();
|
||||
if (file == null) {
|
||||
return false;
|
||||
}
|
||||
return !SvnStatusUtil.isIgnoredInAnySense(clManager, file) && !clManager.isUnversioned(file);
|
||||
public boolean fileIsUnderVcs(@NotNull FilePath path) {
|
||||
VirtualFile file = path.getVirtualFile();
|
||||
return file != null && SvnStatusUtil.isUnderControl(this, file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CleanupAction extends BasicAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return SvnStatusUtil.isUnderControl(vcs.getProject(), file);
|
||||
return SvnStatusUtil.isUnderControl(vcs, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,10 +38,7 @@ public class LockAction extends BasicAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return !file.isDirectory() &&
|
||||
isUnderControl(vcs.getProject(), file) &&
|
||||
!isAdded(vcs.getProject(), file) &&
|
||||
!isExplicitlyLocked(vcs.getProject(), file);
|
||||
return !file.isDirectory() && isUnderControl(vcs, file) && !isAdded(vcs, file) && !isExplicitlyLocked(vcs, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MarkResolvedAction extends BasicAction {
|
||||
FileStatus status = FileStatusManager.getInstance(vcs.getProject()).getStatus(file);
|
||||
|
||||
return file.isDirectory()
|
||||
? SvnStatusUtil.isUnderControl(vcs.getProject(), file)
|
||||
? SvnStatusUtil.isUnderControl(vcs, file)
|
||||
: FileStatus.MERGED_WITH_CONFLICTS.equals(status) ||
|
||||
FileStatus.MERGED_WITH_BOTH_CONFLICTS.equals(status) ||
|
||||
FileStatus.MERGED_WITH_PROPERTY_CONFLICTS.equals(status);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RelocateAction extends BasicAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return SvnStatusUtil.isUnderControl(vcs.getProject(), file);
|
||||
return SvnStatusUtil.isUnderControl(vcs, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class UnlockAction extends BasicAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return !file.isDirectory() && SvnStatusUtil.isExplicitlyLocked(vcs.getProject(), file);
|
||||
return !file.isDirectory() && SvnStatusUtil.isExplicitlyLocked(vcs, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class CreateBranchOrTagAction extends BasicAction {
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
return SvnStatusUtil.isUnderControl(vcs.getProject(), file);
|
||||
return SvnStatusUtil.isUnderControl(vcs, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ public class IgnoreGroupHelperAction {
|
||||
private boolean myAllAreIgnored;
|
||||
private FileIterationListener myListener;
|
||||
|
||||
public void update(@NotNull final AnActionEvent e) {
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
myAllAreIgnored = true;
|
||||
myAllCanBeIgnored = true;
|
||||
|
||||
@@ -53,24 +53,20 @@ public class IgnoreGroupHelperAction {
|
||||
Stream.of(files).allMatch(file -> isEnabled(vcs, file));
|
||||
}
|
||||
|
||||
public void setFileIterationListener(final FileIterationListener listener) {
|
||||
public void setFileIterationListener(FileIterationListener listener) {
|
||||
myListener = listener;
|
||||
}
|
||||
|
||||
private boolean isEnabledImpl(final SvnVcs vcs, final VirtualFile file) {
|
||||
final ChangeListManager clManager = ChangeListManager.getInstance(vcs.getProject());
|
||||
|
||||
if (SvnStatusUtil.isIgnoredInAnySense(clManager, file)) {
|
||||
private boolean isEnabledImpl(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
if (SvnStatusUtil.isIgnoredInAnySense(vcs.getProject(), file)) {
|
||||
myAllCanBeIgnored = false;
|
||||
return myAllAreIgnored | myAllCanBeIgnored;
|
||||
} else if (clManager.isUnversioned(file)) {
|
||||
// check parent
|
||||
final VirtualFile parent = file.getParent();
|
||||
if (parent != null) {
|
||||
if ((! SvnStatusUtil.isIgnoredInAnySense(clManager, parent)) && (! clManager.isUnversioned(parent))) {
|
||||
myAllAreIgnored = false;
|
||||
return myAllAreIgnored | myAllCanBeIgnored;
|
||||
}
|
||||
return myAllAreIgnored;
|
||||
}
|
||||
else if (ChangeListManager.getInstance(vcs.getProject()).isUnversioned(file)) {
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null && SvnStatusUtil.isUnderControl(vcs, parent)) {
|
||||
myAllAreIgnored = false;
|
||||
return myAllCanBeIgnored;
|
||||
}
|
||||
}
|
||||
myAllCanBeIgnored = false;
|
||||
@@ -78,8 +74,8 @@ public class IgnoreGroupHelperAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull final VirtualFile file) {
|
||||
final boolean result = isEnabledImpl(vcs, file);
|
||||
protected boolean isEnabled(@NotNull SvnVcs vcs, @NotNull VirtualFile file) {
|
||||
boolean result = isEnabledImpl(vcs, file);
|
||||
if (result) {
|
||||
myListener.onFileEnabled(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user