com.intellij.openapi.vcs.changes.ChangeListManager Java Examples
The following examples show how to use
com.intellij.openapi.vcs.changes.ChangeListManager.
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: VcsVFSListener.java From consulo with Apache License 2.0 | 6 votes |
protected VcsVFSListener(@Nonnull Project project, @Nonnull AbstractVcs vcs) { myProject = project; myVcs = vcs; myChangeListManager = ChangeListManager.getInstance(project); myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject); final MyVirtualFileListener myVFSListener = new MyVirtualFileListener(); final MyCommandAdapter myCommandListener = new MyCommandAdapter(); myVcsManager = ProjectLevelVcsManager.getInstance(project); myAddOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, vcs); myRemoveOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, vcs); VirtualFileManager.getInstance().addVirtualFileListener(myVFSListener, this); CommandProcessor.getInstance().addCommandListener(myCommandListener, this); myVcsFileListenerContextHelper = VcsFileListenerContextHelper.getInstance(myProject); }
Example #2
Source File: RemoveChangeListAction.java From consulo with Apache License 2.0 | 6 votes |
static boolean confirmActiveChangeListRemoval(@Nonnull Project project, @Nonnull List<? extends LocalChangeList> lists, boolean empty) { List<LocalChangeList> remainingLists = ChangeListManager.getInstance(project).getChangeListsCopy(); remainingLists.removeAll(lists); // don't ask "Which changelist to make active" if there is only one option anyway // unless there are some changes to be moved - give user a chance to cancel deletion if (remainingLists.size() == 1 && empty) { ChangeListManager.getInstance(project).setDefaultChangeList(remainingLists.get(0)); return true; } String[] remainingListsNames = remainingLists.stream().map(ChangeList::getName).toArray(String[]::new); int nameIndex = Messages.showChooseDialog(project, empty ? VcsBundle.message("changes.remove.active.empty.prompt") : VcsBundle.message("changes.remove.active.prompt"), VcsBundle.message("changes.remove.active.title"), Messages.getQuestionIcon(), remainingListsNames, remainingListsNames[0]); if (nameIndex < 0) return false; ChangeListManager.getInstance(project).setDefaultChangeList(remainingLists.get(nameIndex)); return true; }
Example #3
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 #4
Source File: AddChangeListAction.java From consulo with Apache License 2.0 | 6 votes |
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); NewChangelistDialog dlg = new NewChangelistDialog(project); dlg.show(); if (dlg.getExitCode() == DialogWrapper.OK_EXIT_CODE) { String name = dlg.getName(); if (name.length() == 0) { name = getUniqueName(project); } final LocalChangeList list = ChangeListManager.getInstance(project).addChangeList(name, dlg.getDescription()); if (dlg.isNewChangelistActive()) { ChangeListManager.getInstance(project).setDefaultChangeList(list); } dlg.getPanel().changelistCreatedOrChanged(list); } }
Example #5
Source File: PluginSetup.java From p4ic4idea with Apache License 2.0 | 6 votes |
public MockLocalChangeList addIdeChangelist(String name, String comment, boolean isDefault) { MockLocalChangeList ideChangeList = new MockLocalChangeList() .withName(name) .withComment(comment) .withIsDefault(isDefault); ChangeListManager cm = getMockChangelistManager(); if (isDefault) { when(cm.getDefaultChangeList()).thenReturn(ideChangeList); } when(cm.getChangeList(name)).thenReturn(ideChangeList); when(cm.findChangeList(name)).thenReturn(ideChangeList); List<LocalChangeList> currentChanges = cm.getChangeLists(); if (currentChanges == null) { currentChanges = new ArrayList<>(); } else { currentChanges = new ArrayList<>(currentChanges); } currentChanges.add(ideChangeList); when(cm.getChangeLists()).thenReturn(currentChanges); when(cm.getChangeListsCopy()).thenReturn(currentChanges); return ideChangeList; }
Example #6
Source File: ChangeListChooserPanel.java From consulo with Apache License 2.0 | 6 votes |
/** * Method used as getResult, usually invoked inside doOkAction */ @Nullable public LocalChangeList getSelectedList(Project project) { ChangeListManager manager = ChangeListManager.getInstance(project); String changeListName = myListPanel.getChangeListName(); LocalChangeList localChangeList = manager.findChangeList(changeListName); if (localChangeList == null) { localChangeList = manager.addChangeList(changeListName, myListPanel.getDescription()); myListPanel.changelistCreatedOrChanged(localChangeList); } else { //update description if changed localChangeList.setComment(myListPanel.getDescription()); } rememberSettings(project, localChangeList.isDefault(), myListPanel.getMakeActiveCheckBox().isSelected()); if (myListPanel.getMakeActiveCheckBox().isSelected()) { manager.setDefaultChangeList(localChangeList); } return localChangeList; }
Example #7
Source File: P4Vcs.java From p4ic4idea with Apache License 2.0 | 6 votes |
@Override protected void activate() { tempFileWatchDog.start(); if (myVFSListener == null) { myVFSListener = new P4VFSListener(getProject(), this); } // VcsCompat.getInstance().setupPlugin(myProject); ChangeListManager.getInstance(myProject).addChangeListListener(changelistListener); projectMessageBusConnection = myProject.getMessageBus().connect(); appMessageBusConnection = ApplicationManager.getApplication().getMessageBus().connect(); // If additional actions need to happen at plugin startup time, add them here to execute in // a background thread. }
Example #8
Source File: CommonCheckinFilesAction.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @Override protected LocalChangeList getInitiallySelectedChangeList(@Nonnull VcsContext context, @Nonnull Project project) { ChangeListManager manager = ChangeListManager.getInstance(project); LocalChangeList defaultChangeList = manager.getDefaultChangeList(); LocalChangeList result = null; for (FilePath root : getRoots(context)) { if (root.getVirtualFile() == null) continue; Collection<Change> changes = manager.getChangesIn(root); if (defaultChangeList != null && containsAnyChange(defaultChangeList, changes)) { return defaultChangeList; } result = changes.stream().findFirst().map(manager::getChangeList).orElse(null); } return ObjectUtils.chooseNotNull(result, defaultChangeList); }
Example #9
Source File: VcsHandleType.java From consulo with Apache License 2.0 | 5 votes |
public VcsHandleType(AbstractVcs vcs) { super(VcsBundle.message("handle.ro.file.status.type.using.vcs", vcs.getDisplayName()), true); myVcs = vcs; myChangeListManager = ChangeListManager.getInstance(myVcs.getProject()); myChangeFunction = new NullableFunction<VirtualFile, Change>() { @Override public Change fun(VirtualFile file) { return myChangeListManager.getChange(file); } }; }
Example #10
Source File: ApplyPatchAction.java From consulo with Apache License 2.0 | 5 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getRequiredData(CommonDataKeys.PROJECT); if (ChangeListManager.getInstance(project).isFreezedWithNotification("Can not apply patch now")) return; FileDocumentManager.getInstance().saveAllDocuments(); VirtualFile vFile = null; final String place = e.getPlace(); if (isProjectOrScopeView(place) || ActionPlaces.MAIN_MENU.equals(place)) { vFile = e.getData(CommonDataKeys.VIRTUAL_FILE); } if (isPatchFile(vFile)) { showApplyPatch(project, vFile); } else { final FileChooserDescriptor descriptor = ApplyPatchDifferentiatedDialog.createSelectPatchDescriptor(); final VcsApplicationSettings settings = VcsApplicationSettings.getInstance(); final VirtualFile toSelect = settings.PATCH_STORAGE_LOCATION == null ? null : LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(settings.PATCH_STORAGE_LOCATION)); FileChooser.chooseFile(descriptor, project, toSelect).doWhenDone(file -> { final VirtualFile parent = file.getParent(); if (parent != null) { settings.PATCH_STORAGE_LOCATION = FileUtil.toSystemDependentName(parent.getPath()); } showApplyPatch(project, file); }); } }
Example #11
Source File: NewEditChangelistPanel.java From consulo with Apache License 2.0 | 5 votes |
protected void nameChangedImpl(final Project project, final LocalChangeList initial) { String name = getChangeListName(); if (name == null || name.trim().length() == 0) { nameChanged("Cannot create new changelist with empty name."); } else if ((initial == null || !name.equals(initial.getName())) && ChangeListManager.getInstance(project).findChangeList(name) != null) { nameChanged(VcsBundle.message("new.changelist.duplicate.name.error")); } else { nameChanged(null); } }
Example #12
Source File: DiffShelvedChangesAction.java From consulo with Apache License 2.0 | 5 votes |
public static void showShelvedChangesDiff(final DataContext dc) { final Project project = dc.getData(CommonDataKeys.PROJECT); if (project == null) return; if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return; ShelvedChangeList[] changeLists = dc.getData(ShelvedChangesViewManager.SHELVED_CHANGELIST_KEY); if (changeLists == null) { changeLists = dc.getData(ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY); } if (changeLists == null || changeLists.length != 1) return; final List<ShelvedChange> textChanges = changeLists[0].getChanges(project); final List<ShelvedBinaryFile> binaryChanges = changeLists[0].getBinaryFiles(); final List<MyDiffRequestProducer> diffRequestProducers = new ArrayList<>(); processTextChanges(project, textChanges, diffRequestProducers); processBinaryFiles(project, binaryChanges, diffRequestProducers); Collections.sort(diffRequestProducers, ChangeDiffRequestComparator.getInstance()); // selected changes inside lists final Set<Object> selectedChanges = new HashSet<>(); selectedChanges.addAll(ContainerUtil.notNullize(dc.getData(ShelvedChangesViewManager.SHELVED_CHANGE_KEY))); selectedChanges.addAll(ContainerUtil.notNullize(dc.getData(ShelvedChangesViewManager.SHELVED_BINARY_FILE_KEY))); int index = 0; for (int i = 0; i < diffRequestProducers.size(); i++) { MyDiffRequestProducer producer = diffRequestProducers.get(i); if (selectedChanges.contains(producer.getBinaryChange()) || selectedChanges.contains(producer.getTextChange())) { index = i; break; } } MyDiffRequestChain chain = new MyDiffRequestChain(diffRequestProducers, index); DiffManager.getInstance().showDiff(project, chain, DiffDialogHints.FRAME); }
Example #13
Source File: IgnoreUnversionedAction.java From consulo with Apache License 2.0 | 5 votes |
public void actionPerformed(@Nonnull AnActionEvent e) { Project project = e.getRequiredData(CommonDataKeys.PROJECT); if (!ChangeListManager.getInstance(project).isFreezedWithNotification(null)) { List<VirtualFile> files = e.getRequiredData(UNVERSIONED_FILES_DATA_KEY).collect(Collectors.toList()); ChangesBrowserBase<?> browser = e.getData(ChangesBrowserBase.DATA_KEY); Runnable callback = browser == null ? null : () -> { browser.rebuildList(); //noinspection unchecked browser.getViewer().excludeChanges((List)files); }; IgnoreUnversionedDialog.ignoreSelectedFiles(project, files, callback); } }
Example #14
Source File: VcsRootProblemNotifier.java From consulo with Apache License 2.0 | 5 votes |
private VcsRootProblemNotifier(@Nonnull Project project) { myProject = project; mySettings = VcsConfiguration.getInstance(myProject); myChangeListManager = ChangeListManager.getInstance(project); myProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(myProject); myVcsManager = ProjectLevelVcsManager.getInstance(project); myReportedUnregisteredRoots = new HashSet<>(mySettings.IGNORED_UNREGISTERED_ROOTS); }
Example #15
Source File: IdeChangelistMapImpl.java From p4ic4idea with Apache License 2.0 | 5 votes |
@NotNull @Override public Map<P4ChangelistId, LocalChangeList> getLinkedIdeChanges() throws InterruptedException { Map<P4ChangelistId, LocalChangeList> ret = new HashMap<>(); for (Map.Entry<P4ChangelistId, String> entry : cache.getLinkedChangelistIds().entrySet()) { ret.put(entry.getKey(), ChangeListManager.getInstance(project).getChangeList(entry.getValue())); } return ret; }
Example #16
Source File: RefreshAction.java From consulo with Apache License 2.0 | 5 votes |
public static void doRefresh(final Project project) { if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return; FileDocumentManager.getInstance().saveAllDocuments(); invokeCustomRefreshes(project); VirtualFileManager.getInstance().asyncRefresh(new Runnable() { public void run() { // already called in EDT or under write action if (!project.isDisposed()) { VcsDirtyScopeManager.getInstance(project).markEverythingDirty(); } } }); }
Example #17
Source File: AbstractShowDiffAction.java From consulo with Apache License 2.0 | 5 votes |
protected void actionPerformed(VcsContext vcsContext) { final Project project = vcsContext.getProject(); if (project == null) return; if (ChangeListManager.getInstance(project).isFreezedWithNotification("Can not " + vcsContext.getActionName() + " now")) return; final VirtualFile selectedFile = vcsContext.getSelectedFiles()[0]; final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); final AbstractVcs vcs = vcsManager.getVcsFor(selectedFile); final DiffProvider diffProvider = vcs.getDiffProvider(); final DiffActionExecutor actionExecutor = getExecutor(diffProvider, selectedFile, project); actionExecutor.showDiff(); }
Example #18
Source File: RemoveChangeListAction.java From consulo with Apache License 2.0 | 5 votes |
private static boolean canRemoveChangeLists(@javax.annotation.Nullable Project project, @javax.annotation.Nullable ChangeList[] lists) { if (project == null || lists == null || lists.length == 0) return false; int allChangeListsCount = ChangeListManager.getInstance(project).getChangeListsNumber(); for(ChangeList changeList: lists) { if (!(changeList instanceof LocalChangeList)) return false; LocalChangeList localChangeList = (LocalChangeList) changeList; if (localChangeList.isReadOnly()) return false; if (localChangeList.isDefault() && allChangeListsCount <= lists.length) return false; } return true; }
Example #19
Source File: ApplyPatchDifferentiatedDialog.java From consulo with Apache License 2.0 | 5 votes |
private void showDiff() { if (ChangeListManager.getInstance(myProject).isFreezedWithNotification(null)) return; if (myPatches.isEmpty() || (!myContainBasedChanges)) return; final List<AbstractFilePatchInProgress.PatchChange> changes = getAllChanges(); Collections.sort(changes, myMyChangeComparator); List<AbstractFilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges(); int selectedIdx = 0; final List<DiffRequestProducer> diffRequestPresentableList = new ArrayList<>(changes.size()); if (selectedChanges.isEmpty()) { selectedChanges = changes; } if (!selectedChanges.isEmpty()) { final AbstractFilePatchInProgress.PatchChange c = selectedChanges.get(0); for (AbstractFilePatchInProgress.PatchChange change : changes) { final AbstractFilePatchInProgress patchInProgress = change.getPatchInProgress(); if (!patchInProgress.baseExistsOrAdded()) { diffRequestPresentableList.add(createBaseNotFoundErrorRequest(patchInProgress)); } else { diffRequestPresentableList.add(patchInProgress.getDiffRequestProducers(myProject, myReader)); } if (change.equals(c)) { selectedIdx = diffRequestPresentableList.size() - 1; } } } if (diffRequestPresentableList.isEmpty()) return; MyDiffRequestChain chain = new MyDiffRequestChain(diffRequestPresentableList, changes, selectedIdx); DiffManager.getInstance().showDiff(myProject, chain, DiffDialogHints.DEFAULT); }
Example #20
Source File: EditChangelistDialog.java From consulo with Apache License 2.0 | 5 votes |
protected void doOKAction() { String oldName = myList.getName(); String oldComment = myList.getComment(); if (!Comparing.equal(oldName, myPanel.getChangeListName()) && ChangeListManager.getInstance(myProject).findChangeList(myPanel.getChangeListName()) != null) { Messages.showErrorDialog(myPanel.getContent(), VcsBundle.message("changes.dialog.editchangelist.error.already.exists", myPanel.getChangeListName()), VcsBundle.message("changes.dialog.editchangelist.title")); return; } if (!Comparing.equal(oldName, myPanel.getChangeListName(), true) || !Comparing.equal(oldComment, myPanel.getDescription(), true)) { final ChangeListManager clManager = ChangeListManager.getInstance(myProject); final String newName = myPanel.getChangeListName(); if (! myList.getName().equals(newName)) { clManager.editName(myList.getName(), newName); } final String newDescription = myPanel.getDescription(); if (! myList.getComment().equals(newDescription)) { clManager.editComment(myList.getName(), newDescription); } } if (!myList.isDefault() && myPanel.getMakeActiveCheckBox().isSelected()) { ChangeListManager.getInstance(myProject).setDefaultChangeList(myList); } myPanel.changelistCreatedOrChanged(myList); super.doOKAction(); }
Example #21
Source File: ChangesBrowserChangeNode.java From consulo with Apache License 2.0 | 5 votes |
private void appendSwitched(@Nonnull ChangesBrowserNodeRenderer renderer, @Nullable VirtualFile file) { if (file != null && !myProject.isDefault()) { String branch = ChangeListManager.getInstance(myProject).getSwitchedBranch(file); if (branch != null) { renderer.append(spaceAndThinSpace() + "[switched to " + branch + "]", SimpleTextAttributes.REGULAR_ATTRIBUTES); } } }
Example #22
Source File: ChangelistConflictDialog.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected Action[] createLeftSideActions() { return new Action[] { new AbstractAction("&Configure...") { public void actionPerformed(ActionEvent e) { ChangeListManagerImpl manager = (ChangeListManagerImpl)ChangeListManager.getInstance(myProject); ShowSettingsUtil.getInstance().editConfigurable(myPanel, new ChangelistConflictConfigurable(manager)); } }}; }
Example #23
Source File: ShowDiffWithLocalAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e) { Project project = e.getRequiredData(CommonDataKeys.PROJECT); if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return; VcsRevisionNumber currentRevisionNumber = e.getRequiredData(VcsDataKeys.HISTORY_SESSION).getCurrentRevisionNumber(); VcsFileRevision selectedRevision = e.getRequiredData(VcsDataKeys.VCS_FILE_REVISIONS)[0]; FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH); if (currentRevisionNumber != null && selectedRevision != null) { DiffFromHistoryHandler diffHandler = ObjectUtil.notNull(e.getRequiredData(VcsDataKeys.HISTORY_PROVIDER).getHistoryDiffHandler(), new StandardDiffFromHistoryHandler()); diffHandler.showDiffForTwo(project, filePath, selectedRevision, new CurrentRevision(filePath.getVirtualFile(), currentRevisionNumber)); } }
Example #24
Source File: FormatChangedTextUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * Allows to answer if given file has changes in comparison with VCS. * * @param file target file * @return <code>true</code> if given file has changes; <code>false</code> otherwise */ public static boolean hasChanges(@Nonnull PsiFile file) { final Project project = file.getProject(); final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { final Change change = ChangeListManager.getInstance(project).getChange(virtualFile); return change != null; } return false; }
Example #25
Source File: FormatChangedTextUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * Allows to answer if given file or any file below the given directory (any level of nesting) has changes in comparison with VCS. * * @param file target directory to check * @param project target project * @return <code>true</code> if given file or any file below the given directory has changes in comparison with VCS; * <code>false</code> otherwise */ public static boolean hasChanges(@Nonnull VirtualFile file, @Nonnull Project project) { final Collection<Change> changes = ChangeListManager.getInstance(project).getChangesIn(file); for (Change change : changes) { if (change.getType() == Change.Type.NEW || change.getType() == Change.Type.MODIFICATION) { return true; } } return false; }
Example #26
Source File: FormatChangedTextUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static List<PsiFile> getChangedFilesFromDirs(@Nonnull Project project, @Nonnull List<PsiDirectory> dirs) { ChangeListManager changeListManager = ChangeListManager.getInstance(project); Collection<Change> changes = ContainerUtil.newArrayList(); for (PsiDirectory dir : dirs) { changes.addAll(changeListManager.getChangesIn(dir.getVirtualFile())); } return getChangedFiles(project, changes); }
Example #27
Source File: ChangeListTodosPanel.java From consulo with Apache License 2.0 | 5 votes |
public ChangeListTodosPanel(Project project,TodoPanelSettings settings, Content content){ super(project,settings,false,content); ChangeListManager changeListManager = ChangeListManager.getInstance(project); final MyChangeListManagerListener myChangeListManagerListener = new MyChangeListManagerListener(); changeListManager.addChangeListListener(myChangeListManagerListener); Disposer.register(this, new Disposable() { @Override public void dispose() { ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListManagerListener); } }); myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this); }
Example #28
Source File: CustomChangelistTodosTreeBuilder.java From consulo with Apache License 2.0 | 5 votes |
public CustomChangelistTodosTreeBuilder(JTree tree, Project project, final String title, final Collection<? extends TodoItem> todoItems) { super(tree, project); myProject = project; myTitle = title; myMap = new MultiMap<>(); myIncludedFiles = new HashSet<>(); myChangeListManager = ChangeListManager.getInstance(myProject); initMap(todoItems); initHelper(); }
Example #29
Source File: ChangeListTodosTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean accept(final PsiFile psiFile) { if (!psiFile.isValid()) return false; boolean isAffected = false; final Collection<Change> changes = ChangeListManager.getInstance(myProject).getDefaultChangeList().getChanges(); for (Change change : changes) { if (change.affectsFile(VfsUtil.virtualToIoFile(psiFile.getVirtualFile()))) { isAffected = true; break; } } return isAffected && (myTodoFilter != null && myTodoFilter.accept(mySearchHelper, psiFile) || (myTodoFilter == null && mySearchHelper.getTodoItemsCount(psiFile) > 0)); }
Example #30
Source File: GitLabOpenInBrowserAction.java From IDEA-GitLab-Integration with MIT License | 5 votes |
@Override public void update(final AnActionEvent e) { Project project = e.getData(PlatformDataKeys.PROJECT); VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); if (project == null || project.isDefault() || virtualFile == null) { setVisibleEnabled(e, false, false); return; } final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile); if (gitRepository == null) { setVisibleEnabled(e, false, false); return; } ChangeListManager changeListManager = ChangeListManager.getInstance(project); if (changeListManager.isUnversioned(virtualFile)) { setVisibleEnabled(e, true, false); return; } Change change = changeListManager.getChange(virtualFile); if (change != null && change.getType() == Change.Type.NEW) { setVisibleEnabled(e, true, false); return; } setVisibleEnabled(e, true, true); }