Search in sources :

Example 21 with FileStatus

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileStatus(com.intellij.openapi.vcs.FileStatus) ArrayList(java.util.ArrayList)

Example 22 with FileStatus

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;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 23 with FileStatus

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;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) FilePatch(com.intellij.openapi.diff.impl.patch.FilePatch) InvalidDataException(com.intellij.openapi.util.InvalidDataException) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 24 with FileStatus

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());
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) FileStatus(com.intellij.openapi.vcs.FileStatus) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 25 with FileStatus

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));
        }
    }
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) VcsException(com.intellij.openapi.vcs.VcsException) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) GitContentRevision(git4idea.GitContentRevision) Change(com.intellij.openapi.vcs.changes.Change)

Aggregations

FileStatus (com.intellij.openapi.vcs.FileStatus)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 Change (com.intellij.openapi.vcs.changes.Change)7 NotNull (org.jetbrains.annotations.NotNull)6 FilePath (com.intellij.openapi.vcs.FilePath)5 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)5 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)4 FileStatusManager (com.intellij.openapi.vcs.FileStatusManager)3 ArrayList (java.util.ArrayList)3 PsiElement (com.intellij.psi.PsiElement)2 GitContentRevision (git4idea.GitContentRevision)2 RefElement (com.intellij.codeInspection.reference.RefElement)1 RefEntity (com.intellij.codeInspection.reference.RefEntity)1 NavigationItemFileStatus (com.intellij.navigation.NavigationItemFileStatus)1 Application (com.intellij.openapi.application.Application)1 FilePatch (com.intellij.openapi.diff.impl.patch.FilePatch)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 Project (com.intellij.openapi.project.Project)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1