com.intellij.openapi.vcs.FileStatus Java Examples
The following examples show how to use
com.intellij.openapi.vcs.FileStatus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChangesBrowserLocallyDeletedNode.java From consulo with Apache License 2.0 | 6 votes |
@Override public void render(@Nonnull ChangesBrowserNodeRenderer renderer, boolean selected, boolean expanded, boolean hasFocus) { // todo would be good to have render code in one place FilePath filePath = getUserObject().getPath(); renderer.appendFileName(filePath.getVirtualFile(), filePath.getName(), FileStatus.NOT_CHANGED.getColor()); if (renderer.isShowFlatten()) { FilePath parentPath = filePath.getParentPath(); if (parentPath != null) { renderer.append(spaceAndThinSpace() + parentPath.getPresentableUrl(), SimpleTextAttributes.GRAYED_ATTRIBUTES); } } else if (getFileCount() != 1 || getDirectoryCount() != 0) { appendCount(renderer); } renderer.setIcon(getIcon()); }
Example #2
Source File: DefaultInspectionToolPresentation.java From consulo with Apache License 2.0 | 6 votes |
@Override @Nonnull public FileStatus getProblemStatus(@Nonnull final CommonProblemDescriptor descriptor) { final GlobalInspectionContextImpl context = getContext(); if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){ if (myOldProblemElements != null){ final Set<CommonProblemDescriptor> allAvailable = new HashSet<CommonProblemDescriptor>(); for (CommonProblemDescriptor[] descriptors : myOldProblemElements.values()) { if (descriptors != null) { ContainerUtil.addAll(allAvailable, descriptors); } } final boolean old = containsDescriptor(descriptor, allAvailable); final boolean current = containsDescriptor(descriptor, getProblemToElements().keySet()); return calcStatus(old, current); } } return FileStatus.NOT_CHANGED; }
Example #3
Source File: TfsFileUtil.java From azure-devops-intellij with MIT License | 6 votes |
/** * Recursively look for files that have a status UNKNOWN * * @param files * @param fileStatusManager * @return */ public static boolean findUnknownFiles(final VirtualFile[] files, final FileStatusManager fileStatusManager) { for (VirtualFile file : files) { // if directory then check children if (file.isDirectory()) { if (findUnknownFiles(file.getChildren(), fileStatusManager)) { return true; } } else { final FileStatus fileStatus = fileStatusManager.getStatus(file); if (fileStatus == FileStatus.UNKNOWN) { return true; } } } return false; }
Example #4
Source File: MultipleItemAction.java From azure-devops-intellij with MIT License | 6 votes |
/** * This method enables the action if one or more items are selected. * * @param project * @param files * @return */ protected boolean isEnabled(final Project project, final VirtualFile[] files) { if (files.length == 0 || project == null) { return false; } final FileStatusManager fileStatusManager = FileStatusManager.getInstance(project); for (VirtualFile file : files) { final FileStatus fileStatus = fileStatusManager.getStatus(file); if (fileStatus != FileStatus.NOT_CHANGED && fileStatus != FileStatus.MODIFIED && fileStatus != FileStatus.HIJACKED) { return false; } } return true; }
Example #5
Source File: ChangeListsIndexes.java From consulo with Apache License 2.0 | 6 votes |
private void addChangeToIdx(final Change change, final VcsKey key) { final ContentRevision afterRevision = change.getAfterRevision(); final ContentRevision beforeRevision = change.getBeforeRevision(); if (afterRevision != null) { add(afterRevision.getFile(), change.getFileStatus(), key, beforeRevision == null ? VcsRevisionNumber.NULL : beforeRevision.getRevisionNumber()); } if (beforeRevision != null) { if (afterRevision != null) { if (! Comparing.equal(beforeRevision.getFile(), afterRevision.getFile())) { add(beforeRevision.getFile(), FileStatus.DELETED, key, beforeRevision.getRevisionNumber()); } } else { add(beforeRevision.getFile(), change.getFileStatus(), key, beforeRevision.getRevisionNumber()); } } }
Example #6
Source File: Switcher.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void customizeCellRenderer(@Nonnull JList<? extends FileInfo> list, FileInfo value, int index, boolean selected, boolean hasFocus) { Project project = mySwitcherPanel.project; VirtualFile virtualFile = value.getFirst(); String renderedName = value.getNameForRendering(); setIcon(VfsIconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project)); FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile); open = FileEditorManager.getInstance(project).isFileOpen(virtualFile); boolean hasProblem = WolfTheProblemSolver.getInstance(project).isProblemFile(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, hasProblem ? JBColor.red : null, EffectType.WAVE_UNDERSCORE, Font.PLAIN); append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including EPs Color color = EditorTabPresentationUtil.getFileBackgroundColor(project, virtualFile); if (!selected && color != null) { setBackground(color); } SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected); IdeDocumentHistoryImpl.appendTimestamp(project, this, virtualFile); }
Example #7
Source File: PluginsTableRenderer.java From consulo with Apache License 2.0 | 6 votes |
protected void updatePresentation(boolean isSelected, @Nonnull PluginDescriptor pluginNode, TableModel model) { final PluginDescriptor installed = PluginManager.getPlugin(myPluginDescriptor.getPluginId()); if (PluginManagerColumnInfo.isDownloaded(pluginNode) || installed != null && InstalledPluginsTableModel.wasUpdated(installed.getPluginId())) { if (!isSelected) { myName.setForeground(FileStatus.ADDED.getColor()); } } else if (pluginNode instanceof PluginNode && ((PluginNode)pluginNode).getStatus() == PluginNode.STATUS_INSTALLED || installed != null) { PluginId pluginId = pluginNode.getPluginId(); final boolean hasNewerVersion = InstalledPluginsTableModel.hasNewerVersion(pluginId); if (hasNewerVersion) { if (!isSelected) { myName.setForeground(FileStatus.MODIFIED.getColor()); } myStatus.setIcon(AllIcons.Nodes.Pluginobsolete); } } if (isIncompatible(myPluginDescriptor, model)) { myPanel.setToolTipText(whyIncompatible(myPluginDescriptor, model)); if (!isSelected) { myName.setForeground(JBColor.RED); } } }
Example #8
Source File: ReplaceFileConfirmationDialog.java From consulo with Apache License 2.0 | 6 votes |
public Collection<VirtualFile> collectModifiedFiles(VirtualFile[] files) { ArrayList<VirtualFile> result = new ArrayList<VirtualFile>(); 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; }
Example #9
Source File: ShowUpdatedDiffAction.java From consulo with Apache License 2.0 | 6 votes |
public MyDiffRequestChain(@javax.annotation.Nullable Project project, @Nonnull Iterable<Pair<FilePath, FileStatus>> iterable, @Nonnull Label before, @Nonnull Label after, @javax.annotation.Nullable FilePath filePath) { myProject = project; myBefore = before; myAfter = after; int selected = -1; for (Pair<FilePath, FileStatus> pair : iterable) { if (selected == -1 && pair.first.equals(filePath)) selected = myRequests.size(); myRequests.add(new MyDiffRequestProducer(pair.first, pair.second)); } if (selected != -1) myIndex = selected; }
Example #10
Source File: LineStatusTrackerManager.java From consulo with Apache License 2.0 | 6 votes |
private boolean shouldBeInstalled(@javax.annotation.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; }
Example #11
Source File: ShelvedChangeList.java From consulo with Apache License 2.0 | 6 votes |
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; }
Example #12
Source File: AbstractCommitChangesAction.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(final VcsContext vcsContext, final Presentation presentation) { super.update(vcsContext, presentation); if (presentation.isVisible() && presentation.isEnabled()) { final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists(); final Change[] selectedChanges = vcsContext.getSelectedChanges(); if (vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) { if (selectedChangeLists != null && selectedChangeLists.length > 0) { presentation.setEnabled(selectedChangeLists.length == 1); } else { presentation.setEnabled (selectedChanges != null && selectedChanges.length > 0); } } if (presentation.isEnabled() && selectedChanges != null) { final ChangeListManager changeListManager = ChangeListManager.getInstance(vcsContext.getProject()); for(Change c: selectedChanges) { if (c.getFileStatus() == FileStatus.HIJACKED && changeListManager.getChangeList(c) == null) { presentation.setEnabled(false); break; } } } } }
Example #13
Source File: ChangeGoToChangePopupAction.java From consulo with Apache License 2.0 | 6 votes |
@SuppressWarnings("AbstractMethodCallInConstructor") public Fake(@Nonnull Chain chain, int selection, @Nonnull Consumer<Integer> onSelected) { super(chain, onSelected); mySelection = selection; // we want to show ChangeBrowser-based popup, so have to create some fake changes List<? extends DiffRequestProducer> requests = chain.getRequests(); myChanges = new ArrayList<Change>(requests.size()); for (int i = 0; i < requests.size(); i++) { FilePath path = getFilePath(i); FileStatus status = getFileStatus(i); FakeContentRevision revision = new FakeContentRevision(path); myChanges.add(new Change(revision, revision, status)); } }
Example #14
Source File: VirtualFileListCellRenderer.java From consulo with Apache License 2.0 | 6 votes |
protected FileStatus getStatus(Object value, FilePath path) { final FileStatus fileStatus; if (value instanceof Change) { fileStatus = ((Change) value).getFileStatus(); } else { final VirtualFile virtualFile = path.getVirtualFile(); if (virtualFile != null) { fileStatus = myFileStatusManager.getStatus(virtualFile); } else { fileStatus = FileStatus.NOT_CHANGED; } } return fileStatus; }
Example #15
Source File: ShelvedBinaryFile.java From consulo with Apache License 2.0 | 5 votes |
public FileStatus getFileStatus() { if (BEFORE_PATH == null) { return FileStatus.ADDED; } if (SHELVED_PATH == null) { return FileStatus.DELETED; } return FileStatus.MODIFIED; }
Example #16
Source File: TfsFileUtilTest.java From azure-devops-intellij with MIT License | 5 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(virtualDirectory.isDirectory()).thenReturn(true); when(virtualFileAdded.isDirectory()).thenReturn(false); when(virtualFileUnknown.isDirectory()).thenReturn(false); when(fileStatusManager.getStatus(virtualFileAdded)).thenReturn(FileStatus.ADDED); when(fileStatusManager.getStatus(virtualFileUnknown)).thenReturn(FileStatus.UNKNOWN); }
Example #17
Source File: CommitLegendPanel.java From consulo with Apache License 2.0 | 5 votes |
public void update() { myRootPanel.clear(); appendText(myInfoCalculator.getNew(), myInfoCalculator.getIncludedNew(), FileStatus.ADDED, VcsBundle.message("commit.legend.new")); appendText(myInfoCalculator.getModified(), myInfoCalculator.getIncludedModified(), FileStatus.MODIFIED, VcsBundle.message("commit.legend.modified")); appendText(myInfoCalculator.getDeleted(), myInfoCalculator.getIncludedDeleted(), FileStatus.DELETED, VcsBundle.message("commit.legend.deleted")); appendText(myInfoCalculator.getUnversioned(), myInfoCalculator.getIncludedUnversioned(), FileStatus.UNKNOWN, VcsBundle.message("commit.legend.unversioned")); }
Example #18
Source File: CommitLegendPanel.java From consulo with Apache License 2.0 | 5 votes |
protected void appendText(int total, int included, @Nonnull FileStatus fileStatus, @Nonnull String labelName) { if (total > 0) { if (!isPanelEmpty()) { appendSpace(); } String pattern = total == included ? "%s %d" : "%s %d of %d"; String text = String.format(pattern, labelName, included, total); myRootPanel.append(text, new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, fileStatus.getColor())); } }
Example #19
Source File: VirtualFileListCellRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void customizeCellRenderer(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); }
Example #20
Source File: MoveChangesToAnotherListAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static List<Change> getChangesForSelectedFiles(@Nonnull Project project, @Nonnull VirtualFile[] selectedFiles, @Nonnull List<VirtualFile> unversionedFiles, @Nonnull 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; }
Example #21
Source File: ShowUpdatedDiffAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public DiffRequest process(@Nonnull UserDataHolder context, @Nonnull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException { try { DiffContent content1; DiffContent content2; DiffContentFactoryEx contentFactory = DiffContentFactoryEx.getInstanceEx(); if (FileStatus.ADDED.equals(myFileStatus)) { content1 = contentFactory.createEmpty(); } else { byte[] bytes1 = loadContent(myFilePath, myBefore); content1 = contentFactory.createFromBytes(myProject, bytes1, myFilePath); } if (FileStatus.DELETED.equals(myFileStatus)) { content2 = contentFactory.createEmpty(); } else { byte[] bytes2 = loadContent(myFilePath, myAfter); content2 = contentFactory.createFromBytes(myProject, bytes2, myFilePath); } String title = DiffRequestFactoryImpl.getContentTitle(myFilePath); return new SimpleDiffRequest(title, content1, content2, "Before update", "After update"); } catch (IOException e) { throw new DiffRequestProducerException("Can't load content", e); } }
Example #22
Source File: ChangesListView.java From consulo with Apache License 2.0 | 5 votes |
@javax.annotation.Nullable private static Change toHijackedChange(@Nonnull Project project, @Nonnull VirtualFile file) { VcsCurrentRevisionProxy before = VcsCurrentRevisionProxy.create(file, project); if (before != null) { ContentRevision afterRevision = new CurrentContentRevision(VcsUtil.getFilePath(file)); return new Change(before, afterRevision, FileStatus.HIJACKED); } return null; }
Example #23
Source File: ShowUpdatedDiffAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final DataContext dc = e.getDataContext(); if ((!isVisible(dc)) || (!isEnabled(dc))) return; final Project project = dc.getData(CommonDataKeys.PROJECT); final Iterable<Pair<FilePath, FileStatus>> iterable = e.getRequiredData(VcsDataKeys.UPDATE_VIEW_FILES_ITERABLE); final Label before = (Label)e.getRequiredData(VcsDataKeys.LABEL_BEFORE); final Label after = (Label)e.getRequiredData(VcsDataKeys.LABEL_AFTER); final FilePath selectedUrl = dc.getData(VcsDataKeys.UPDATE_VIEW_SELECTED_PATH); MyDiffRequestChain requestChain = new MyDiffRequestChain(project, iterable, before, after, selectedUrl); DiffManager.getInstance().showDiff(project, requestChain, DiffDialogHints.FRAME); }
Example #24
Source File: DefaultInspectionToolPresentation.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public FileStatus getElementStatus(final RefEntity element) { final GlobalInspectionContextImpl context = getContext(); if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){ if (myOldProblemElements != null){ final boolean old = RefUtil.contains(element, myOldProblemElements.keySet()); final boolean current = RefUtil.contains(element, getProblemElements().keySet()); return calcStatus(old, current); } } return FileStatus.NOT_CHANGED; }
Example #25
Source File: Change.java From consulo with Apache License 2.0 | 5 votes |
public Change(@Nullable final ContentRevision beforeRevision, @Nullable final ContentRevision afterRevision, @Nullable FileStatus fileStatus) { assert beforeRevision != null || afterRevision != null; myBeforeRevision = beforeRevision; myAfterRevision = afterRevision; myFileStatus = fileStatus == null ? convertStatus(beforeRevision, afterRevision) : fileStatus; myHash = -1; myOtherLayers = new HashMap<String, Change>(0); }
Example #26
Source File: CoverageListNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public FileStatus getFileStatus() { final PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() { @Nullable @Override public PsiFile compute() { Object value = getValue(); if (value instanceof PsiElement && ((PsiElement)value).isValid()) { return ((PsiElement)value).getContainingFile(); } return null; } }); return containingFile != null ? myFileStatusManager.getStatus(containingFile.getVirtualFile()) : super.getFileStatus(); }
Example #27
Source File: CSharpBaseGroupingRule.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable @Override public FileStatus getFileStatus() { T element = myPointer.getElement(); if(element == null) { return null; } return NavigationItemFileStatus.get((NavigationItem) element); }
Example #28
Source File: FileStatusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public FileStatus getStatus(@Nonnull final VirtualFile file) { if (file.getFileSystem() instanceof NonPhysicalFileSystem) { return FileStatus.SUPPRESSED; // do not leak light files via cache } FileStatus status = getCachedStatus(file); if (status == null || status == FileStatusNull.INSTANCE) { status = calcStatus(file); cacheChangedFileStatus(file, status); } return status; }
Example #29
Source File: NavigationItemFileStatus.java From consulo with Apache License 2.0 | 5 votes |
private static FileStatus getPsiElementFileStatus(PsiElement psiElement) { if (!psiElement.isPhysical()) return FileStatus.NOT_CHANGED; PsiFile contFile = psiElement.getContainingFile(); if (contFile == null) return FileStatus.NOT_CHANGED; VirtualFile vFile = contFile.getVirtualFile(); return vFile != null ? FileStatusManager.getInstance(psiElement.getProject()).getStatus(vFile) : FileStatus.NOT_CHANGED; }
Example #30
Source File: FileStatusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private void cacheChangedFileStatus(final VirtualFile virtualFile, final FileStatus fs) { myCachedStatuses.put(virtualFile, fs); if (FileStatus.NOT_CHANGED.equals(fs)) { final ThreeState parentingStatus = myFileStatusProvider.getNotChangedDirectoryParentingStatus(virtualFile); if (ThreeState.YES.equals(parentingStatus)) { myWhetherExactlyParentToChanged.put(virtualFile, true); } else if (ThreeState.UNSURE.equals(parentingStatus)) { myWhetherExactlyParentToChanged.put(virtualFile, false); } } else { myWhetherExactlyParentToChanged.remove(virtualFile); } }