Search in sources :

Example 11 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class BookmarkItem method setupRenderer.

public static void setupRenderer(SimpleColoredComponent renderer, Project project, Bookmark bookmark, boolean selected) {
    VirtualFile file = bookmark.getFile();
    if (!file.isValid()) {
        return;
    }
    PsiManager psiManager = PsiManager.getInstance(project);
    PsiElement fileOrDir = file.isDirectory() ? psiManager.findDirectory(file) : psiManager.findFile(file);
    if (fileOrDir != null) {
        renderer.setIcon(fileOrDir.getIcon(0));
    }
    String description = bookmark.getDescription();
    if (description != null) {
        renderer.append(description + " ", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
    }
    FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(file);
    TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN);
    renderer.append(file.getName(), SimpleTextAttributes.fromTextAttributes(attributes));
    if (bookmark.getLine() >= 0) {
        renderer.append(":", SimpleTextAttributes.GRAYED_ATTRIBUTES);
        renderer.append(String.valueOf(bookmark.getLine() + 1), SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }
    renderer.append(" (" + VfsUtilCore.getRelativeLocation(file, project.getBaseDir()) + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    if (!selected) {
        FileColorManager colorManager = FileColorManager.getInstance(project);
        if (fileOrDir instanceof PsiFile) {
            Color color = colorManager.getRendererBackground((PsiFile) fileOrDir);
            if (color != null) {
                renderer.setBackground(color);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileStatus(com.intellij.openapi.vcs.FileStatus) PsiManager(com.intellij.psi.PsiManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement)

Example 12 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class AbstractTreeNode method setForcedForeground.

protected void setForcedForeground(@NotNull PresentationData presentation) {
    final FileStatus status = getFileStatus();
    Color fgColor = getFileStatusColor(status);
    fgColor = fgColor == null ? status.getColor() : fgColor;
    if (valueIsCut()) {
        fgColor = CopyPasteManager.CUT_COLOR;
    }
    if (presentation.getForcedTextForeground() == null) {
        presentation.setForcedTextForeground(fgColor);
    }
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus)

Example 13 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class FileEditorManagerImpl method isChanged.

@Override
public boolean isChanged(@NotNull final EditorComposite editor) {
    final FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
    if (fileStatusManager == null)
        return false;
    FileStatus status = fileStatusManager.getStatus(editor.getFile());
    return status != FileStatus.UNKNOWN && status != FileStatus.NOT_CHANGED;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager)

Example 14 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class MoveChangesToAnotherListAction method getChangesForSelectedFiles.

@NotNull
private static List<Change> getChangesForSelectedFiles(@NotNull Project project, @NotNull VirtualFile[] selectedFiles, @NotNull List<VirtualFile> unversionedFiles, @NotNull List<VirtualFile> changedFiles) {
    List<Change> changes = new ArrayList<>();
    ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    for (VirtualFile vFile : selectedFiles) {
        Change change = changeListManager.getChange(vFile);
        if (change == null) {
            FileStatus status = changeListManager.getStatus(vFile);
            if (FileStatus.UNKNOWN.equals(status)) {
                unversionedFiles.add(vFile);
                changedFiles.add(vFile);
            } else if (FileStatus.NOT_CHANGED.equals(status) && vFile.isDirectory()) {
                addAllChangesUnderPath(changeListManager, VcsUtil.getFilePath(vFile), changes, changedFiles);
            }
        } else {
            FilePath afterPath = ChangesUtil.getAfterPath(change);
            if (afterPath != null && afterPath.isDirectory()) {
                addAllChangesUnderPath(changeListManager, afterPath, changes, changedFiles);
            } else {
                changes.add(change);
                changedFiles.add(vFile);
            }
        }
    }
    return changes;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) FileStatus(com.intellij.openapi.vcs.FileStatus) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class SelectInChangesViewTarget method canSelect.

public boolean canSelect(final SelectInContext context) {
    final VirtualFile file = context.getVirtualFile();
    FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(file);
    return ProjectLevelVcsManager.getInstance(myProject).getAllActiveVcss().length != 0 && !fileStatus.equals(FileStatus.NOT_CHANGED);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileStatus(com.intellij.openapi.vcs.FileStatus)

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