Search in sources :

Example 1 with FileStatusManager

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

the class LineStatusTrackerManager method shouldBeInstalled.

private boolean shouldBeInstalled(@Nullable final VirtualFile virtualFile) {
    if (isDisabled())
        return false;
    if (virtualFile == null || virtualFile instanceof LightVirtualFile)
        return false;
    final FileStatusManager statusManager = FileStatusManager.getInstance(myProject);
    if (statusManager == null)
        return false;
    if (!myStatusProvider.isSupported(virtualFile)) {
        log("shouldBeInstalled failed: no support found", virtualFile);
        return false;
    }
    final FileStatus status = statusManager.getStatus(virtualFile);
    if (status == FileStatus.NOT_CHANGED || status == FileStatus.ADDED || status == FileStatus.UNKNOWN || status == FileStatus.IGNORED) {
        log("shouldBeInstalled skipped: status=" + status, virtualFile);
        return false;
    }
    return true;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager)

Example 2 with FileStatusManager

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

the class FileOrDirectoryTreeNode method getAttributes.

@NotNull
@Override
public SimpleTextAttributes getAttributes() {
    if (!getFilePointer().isValid()) {
        return myInvalidAttributes;
    }
    VirtualFile file = getFilePointer().getFile();
    FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
    FileStatus status = fileStatusManager.getStatus(file);
    SimpleTextAttributes attributes = getAttributesFor(status);
    return myFilterAttributes == null ? attributes : SimpleTextAttributes.merge(myFilterAttributes, attributes);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileStatus(com.intellij.openapi.vcs.FileStatus) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with FileStatusManager

use of com.intellij.openapi.vcs.FileStatusManager 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 4 with FileStatusManager

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

the class FileEditorManagerImpl method getFileColor.

//-------------------------------------------------------
/**
   * @return color of the {@code file} which corresponds to the
   *         file's status
   */
public Color getFileColor(@NotNull final VirtualFile file) {
    final FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
    Color statusColor = fileStatusManager != null ? fileStatusManager.getStatus(file).getColor() : UIUtil.getLabelForeground();
    if (statusColor == null)
        statusColor = UIUtil.getLabelForeground();
    return statusColor;
}
Also used : FileStatusManager(com.intellij.openapi.vcs.FileStatusManager)

Example 5 with FileStatusManager

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

the class CloseEditorsActionBase method getFilesToClose.

protected ArrayList<Pair<EditorComposite, EditorWindow>> getFilesToClose(final AnActionEvent event) {
    final ArrayList<Pair<EditorComposite, EditorWindow>> res = new ArrayList<>();
    final DataContext dataContext = event.getDataContext();
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    final EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
    final EditorWindow[] windows;
    if (editorWindow != null) {
        windows = new EditorWindow[] { editorWindow };
    } else {
        windows = editorManager.getWindows();
    }
    final FileStatusManager fileStatusManager = FileStatusManager.getInstance(project);
    if (fileStatusManager != null) {
        for (int i = 0; i != windows.length; ++i) {
            final EditorWindow window = windows[i];
            final EditorComposite[] editors = window.getEditors();
            for (final EditorComposite editor : editors) {
                if (isFileToClose(editor, window)) {
                    res.add(Pair.create(editor, window));
                }
            }
        }
    }
    return res;
}
Also used : Project(com.intellij.openapi.project.Project) ArrayList(java.util.ArrayList) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorComposite(com.intellij.openapi.fileEditor.impl.EditorComposite) Pair(com.intellij.openapi.util.Pair) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager)

Aggregations

FileStatusManager (com.intellij.openapi.vcs.FileStatusManager)6 FileStatus (com.intellij.openapi.vcs.FileStatus)3 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)1 EditorComposite (com.intellij.openapi.fileEditor.impl.EditorComposite)1 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)1 Project (com.intellij.openapi.project.Project)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1