use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class ReplaceFileConfirmationDialog method collectModifiedFiles.
public Collection<VirtualFile> collectModifiedFiles(VirtualFile[] files) {
ArrayList<VirtualFile> result = new ArrayList<>();
if (files == null)
return result;
for (int i = 0; i < files.length; i++) {
VirtualFile file = files[i];
if (myProgressIndicator != null) {
myProgressIndicator.setText(VcsBundle.message("progress.text.searching.for.modified.files"));
myProgressIndicator.setText2(file.getPresentableUrl());
}
FileStatus status = myFileStatusManager.getStatus(file);
if (status != FileStatus.NOT_CHANGED) {
result.add(file);
if (result.size() > 1)
return result;
}
result.addAll(collectModifiedFiles(file.getChildren()));
}
return result;
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class UsageViewTreeCellRenderer method patchAttrs.
private static SimpleTextAttributes patchAttrs(@NotNull Node node, @NotNull SimpleTextAttributes original) {
if (node.isExcluded()) {
original = new SimpleTextAttributes(original.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT, original.getFgColor(), original.getWaveColor());
}
if (node instanceof GroupNode) {
UsageGroup group = ((GroupNode) node).getGroup();
FileStatus fileStatus = group != null ? group.getFileStatus() : null;
if (fileStatus != null && fileStatus != FileStatus.NOT_CHANGED) {
original = new SimpleTextAttributes(original.getStyle(), fileStatus.getColor(), original.getWaveColor());
}
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
if (parent != null && parent.isRoot()) {
original = new SimpleTextAttributes(original.getStyle() | SimpleTextAttributes.STYLE_BOLD, original.getFgColor(), original.getWaveColor());
}
}
return original;
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class ShelvedChangeList method getChanges.
public List<ShelvedChange> getChanges(Project project) {
if (myChanges == null) {
try {
myChanges = new ArrayList<>();
final List<? extends FilePatch> list = ShelveChangesManager.loadPatchesWithoutContent(project, PATH, null);
for (FilePatch patch : list) {
FileStatus status;
if (patch.isNewFile()) {
status = FileStatus.ADDED;
} else if (patch.isDeletedFile()) {
status = FileStatus.DELETED;
} else {
status = FileStatus.MODIFIED;
}
myChanges.add(new ShelvedChange(PATH, patch.getBeforeName(), patch.getAfterName(), status));
}
} catch (Exception e) {
LOG.error("Failed to parse the file patch: [" + PATH + "]", e);
}
}
return myChanges;
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class VirtualFileListCellRenderer method customizeCellRenderer.
@Override
protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) {
final FilePath path = TreeModelBuilder.getPathForObject(value);
renderIcon(path);
final FileStatus fileStatus = myIgnoreFileStatus ? FileStatus.NOT_CHANGED : getStatus(value, path);
append(getName(path), new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, fileStatus.getColor(), null));
putParentPath(value, path, path);
setBackground(selected ? (hasFocus ? UIUtil.getListSelectionBackground() : UIUtil.getListUnfocusedSelectionBackground()) : UIUtil.getListBackground());
}
use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.
the class GitChangeUtils method parseChanges.
/**
* Parse changes from lines
*
* @param project the context project
* @param vcsRoot the git root
* @param thisRevision the current revision
* @param parentRevision the parent revision for this change list
* @param s the lines to parse
* @param changes a list of changes to update
* @param ignoreNames a set of names ignored during collection of the changes
* @throws VcsException if the input format does not matches expected format
*/
private static void parseChanges(Project project, VirtualFile vcsRoot, @Nullable GitRevisionNumber thisRevision, @Nullable GitRevisionNumber parentRevision, StringScanner s, Collection<Change> changes, final Set<String> ignoreNames) throws VcsException {
while (s.hasMoreData()) {
FileStatus status = null;
if (s.isEol()) {
s.nextLine();
continue;
}
if ("CADUMRT".indexOf(s.peek()) == -1) {
// exit if there is no next character
return;
}
String[] tokens = s.line().split("\t");
final ContentRevision before;
final ContentRevision after;
final String path = tokens[tokens.length - 1];
switch(tokens[0].charAt(0)) {
case 'C':
case 'A':
before = null;
status = FileStatus.ADDED;
after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false, false, true);
break;
case 'U':
status = FileStatus.MERGED_WITH_CONFLICTS;
case 'M':
if (status == null) {
status = FileStatus.MODIFIED;
}
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, false, true, true);
after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false, false, true);
break;
case 'D':
status = FileStatus.DELETED;
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, true, true, true);
after = null;
break;
case 'R':
status = FileStatus.MODIFIED;
before = GitContentRevision.createRevision(vcsRoot, tokens[1], parentRevision, project, true, true, true);
after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false, false, true);
break;
case 'T':
status = FileStatus.MODIFIED;
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, true, true, true);
after = GitContentRevision.createRevisionForTypeChange(project, vcsRoot, path, thisRevision, true);
break;
default:
throw new VcsException("Unknown file status: " + Arrays.asList(tokens));
}
if (ignoreNames == null || !ignoreNames.contains(path)) {
changes.add(new Change(before, after, status));
}
}
}
Aggregations