com.intellij.openapi.vcs.changes.ChangeList Java Examples
The following examples show how to use
com.intellij.openapi.vcs.changes.ChangeList.
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: SwarmReview.java From p4ic4idea with Apache License 2.0 | 6 votes |
@NotNull private static Answer<Integer> createSwarmReview(@NotNull final Project project, @NotNull final ClientConfig clientConfig, @NotNull final SwarmClient swarmClient, @NotNull final ChangeList ideChangelist, @NotNull final P4ChangelistId changelistId) { return Answer.background(sink -> CreateSwarmReviewDialog.show(project, clientConfig, ideChangelist, new CreateSwarmReviewDialog.OnCompleteListener() { @Override public void create(String description, List<SwarmReviewPanel.Reviewer> reviewers, List<FilePath> files) { shelveFiles(project, clientConfig, changelistId, files) .mapQueryAsync(r -> sendCreateReview(project, swarmClient, description, changelistId, reviewers)) .whenCompleted(sink::resolve) .whenServerError(e -> sink.resolve(-1)); } @Override public void cancel() { sink.resolve(-1); } }) ); }
Example #2
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 #3
Source File: CreateSwarmReviewAction.java From p4ic4idea with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@NotNull VcsContext event) { final Project project = event.getProject(); if (project == null) { return; } final ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null) { return; } final List<ChangeList> changeLists = getSelectedChangeLists(event); if (changeLists.isEmpty()) { return; } if (ApplicationManager.getApplication().isDispatchThread()) { ApplicationManager.getApplication().saveAll(); } ApplicationManager.getApplication().executeOnPooledThread(() -> createSwarmReviews(project, registry, changeLists)); }
Example #4
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 #5
Source File: VcsRevisionNumberArrayRule.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public List<VcsRevisionNumber> getRevisionNumbers(@Nonnull DataProvider dataProvider) { VcsRevisionNumber revisionNumber = dataProvider.getDataUnchecked(VcsDataKeys.VCS_REVISION_NUMBER); if (revisionNumber != null) { return Collections.singletonList(revisionNumber); } ChangeList[] changeLists = dataProvider.getDataUnchecked(VcsDataKeys.CHANGE_LISTS); if (changeLists != null && changeLists.length > 0) { List<CommittedChangeList> committedChangeLists = ContainerUtil.findAll(changeLists, CommittedChangeList.class); if (!committedChangeLists.isEmpty()) { ContainerUtil.sort(committedChangeLists, CommittedChangeListByDateComparator.DESCENDING); return ContainerUtil.mapNotNull(committedChangeLists, CommittedChangeListToRevisionNumberFunction.INSTANCE); } } VcsFileRevision[] fileRevisions = dataProvider.getDataUnchecked(VcsDataKeys.VCS_FILE_REVISIONS); if (fileRevisions != null && fileRevisions.length > 0) { return ContainerUtil.mapNotNull(fileRevisions, FileRevisionToRevisionNumberFunction.INSTANCE); } return null; }
Example #6
Source File: MockChangelistBuilder.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void processChangeInList(Change change, @Nullable ChangeList changeList, VcsKey vcsKey) { assertEquals(expectedKey, vcsKey); if (changeList == null) { addChange(null, change); } else { // ensure the changelist exists in the gate. gate.getExisting(changeList.getName()); addChange(changeList.getName(), change); } }
Example #7
Source File: CommitCompletionContributor.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Override public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) { PsiFile file = parameters.getOriginalFile(); Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); if (document != null) { DataContext dataContext = document.getUserData(CommitMessage.DATA_CONTEXT_KEY); if (dataContext != null) { result.stopHere(); if (parameters.getInvocationCount() > 0) { ChangeList[] lists = dataContext.getData(VcsDataKeys.CHANGE_LISTS); if (lists != null) { String prefix = TextFieldWithAutoCompletionListProvider.getCompletionPrefix(parameters); CompletionResultSet insensitive = result.caseInsensitive().withPrefixMatcher(new CamelHumpMatcher(prefix)); for (ChangeList list : lists) { for (Change change : list.getChanges()) { VirtualFile virtualFile = change.getVirtualFile(); if (virtualFile != null) { LookupElementBuilder element = LookupElementBuilder.create(virtualFile.getName()). withIcon(VirtualFilePresentation.getAWTIcon(virtualFile)); insensitive.addElement(element); } } } } } } } }
Example #8
Source File: ChangesBrowser.java From consulo with Apache License 2.0 | 5 votes |
public ChangesBrowser(Project project, List<? extends ChangeList> changeLists, List<Change> changes, ChangeList initialListSelection, boolean capableOfExcludingChanges, boolean highlightProblems, @Nullable Runnable inclusionListener, MyUseCase useCase, @Nullable VirtualFile toSelect) { super(project, changes, capableOfExcludingChanges, highlightProblems, inclusionListener, useCase, toSelect, Change.class); init(); setInitialSelection(changeLists, changes, initialListSelection); rebuildList(); }
Example #9
Source File: ChangeListChooserPanel.java From consulo with Apache License 2.0 | 5 votes |
public void setDefaultSelection(final ChangeList defaultSelection) { if (defaultSelection == null) { selectActiveChangeListIfExist(); } else { myExistingListsCombo.setSelectedItem(defaultSelection.getName()); } updateDescription(); updateEnabled(); }
Example #10
Source File: ChangelistConflictDialog.java From consulo with Apache License 2.0 | 5 votes |
public ChangelistConflictDialog(Project project, List<ChangeList> changeLists, List<VirtualFile> conflicts) { super(project); myProject = project; setTitle("Resolve Changelist Conflict"); myFileList.setCellRenderer(new FileListRenderer()); myFileList.setModel(new CollectionListModel(conflicts)); ChangeListManagerImpl manager = ChangeListManagerImpl.getInstanceImpl(myProject); ChangelistConflictResolution resolution = manager.getConflictTracker().getOptions().LAST_RESOLUTION; if (changeLists.size() > 1) { mySwitchToChangelistRadioButton.setEnabled(false); if (resolution == ChangelistConflictResolution.SWITCH) { resolution = ChangelistConflictResolution.IGNORE; } } mySwitchToChangelistRadioButton.setText(VcsBundle.message("switch.to.changelist", changeLists.iterator().next().getName())); myMoveChangesToActiveRadioButton.setText(VcsBundle.message("move.to.changelist", manager.getDefaultChangeList().getName())); switch (resolution) { case SHELVE: myShelveChangesRadioButton.setSelected(true); break; case MOVE: myMoveChangesToActiveRadioButton.setSelected(true); break; case SWITCH: mySwitchToChangelistRadioButton.setSelected(true) ; break; case IGNORE: myIgnoreRadioButton.setSelected(true); break; } init(); }
Example #11
Source File: AlienChangeListBrowser.java From consulo with Apache License 2.0 | 5 votes |
public AlienChangeListBrowser(final Project project, final List<? extends ChangeList> changeLists, final List<Change> changes, final ChangeList initialListSelection, final boolean capableOfExcludingChanges, final boolean highlightProblems, final AbstractVcs vcs) { super(project, changeLists, changes, initialListSelection, capableOfExcludingChanges, highlightProblems, null, MyUseCase.LOCAL_CHANGES, null); myChanges = changes; myVcs = vcs; rebuildList(); }
Example #12
Source File: P4ChangelistListener.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void changesMoved(final Collection<Change> changes, final ChangeList fromList, final ChangeList toList) { LOG.debug("changesMoved: " + fromList + " to " + toList); // This is just like a "changes added" command, // in the sense that the old list doesn't matter too much. changesAdded(changes, toList); }
Example #13
Source File: CreateSwarmReviewAction.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override protected void update(@NotNull final VcsContext event, @NotNull final Presentation presentation) { Project project = event.getProject(); if (project == null) { presentation.setEnabled(false); presentation.setVisible(false); return; } ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null) { presentation.setEnabled(false); presentation.setVisible(false); return; } List<ChangeList> changeLists = getSelectedChangeLists(event); if (changeLists.isEmpty()) { presentation.setEnabled(false); presentation.setVisible(false); return; } // Restrict to just 1 changelist to create a review. if (changeLists.size() != 1) { presentation.setEnabled(false); presentation.setVisible(true); return; } boolean hasChanges = false; for (ChangeList changeList : changeLists) { if (!changeList.getChanges().isEmpty()) { hasChanges = true; break; } } presentation.setEnabled(hasChanges); presentation.setVisible(true); }
Example #14
Source File: SvnDiffProvider.java From review-board-idea-plugin with Apache License 2.0 | 5 votes |
@Override public boolean isFromRevision(Project project, AnActionEvent action) throws VcsException { ChangeList[] data = action.getData(VcsDataKeys.CHANGE_LISTS); if (data != null && data.length > 0 && data[0] instanceof CommittedChangeList) { return true; } else { return false; } }
Example #15
Source File: P4ChangelistListener.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void changesRemoved(@NotNull final Collection<Change> changes, @NotNull final ChangeList fromList) { if (LOG.isDebugEnabled()) { LOG.debug("changesRemoved: changes " + changes); LOG.debug("changesRemoved: changelist " + fromList.getName() + "; [" + fromList.getComment() + "]; " + fromList.getClass().getSimpleName()); } // This is called when a file change is removed from a changelist, not when a changelist is deleted. // A revert will move the file it out of the changelist. // Note that if a change is removed, it is usually added or // moved, so we can ignore this call. }
Example #16
Source File: CreateSwarmReviewAction.java From p4ic4idea with Apache License 2.0 | 5 votes |
private void createSwarmReviews(@NotNull Project project, @NotNull ProjectConfigRegistry registry, @NotNull List<ChangeList> changeLists) { Answer<Integer> next = Answer.resolve(0); for (ChangeList ideChangeList : changeLists) { if (ideChangeList instanceof LocalChangeList) { try { Collection<P4ChangelistId> p4Changelists = CacheComponent.getInstance(project).getServerOpenedCache().first. getP4ChangesFor((LocalChangeList) ideChangeList); if (!p4Changelists.isEmpty()) { for (P4ChangelistId p4Changelist : p4Changelists) { next = next.mapAsync(x -> SwarmReview.createOrEditSwarmReview(project, registry, ideChangeList, p4Changelist)); // Failure reporting is handled by the SwarmReview class. } // Skip the notOnServer message. continue; } } catch (InterruptedException e) { InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>( new VcsInterruptedException("Timeout or interruption while reading list of changes", e))); } } SwarmErrorMessage.send(project).notOnServer(new SwarmErrorMessage.SwarmEvent(null), ideChangeList); } }
Example #17
Source File: P4ChangelistListener.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void changeListCommentChanged(final ChangeList list, final String oldComment) { LOG.debug("changeListCommentChanged: " + list); // This is the same logic as with the name change. changeListRenamed(list, list.getName()); }
Example #18
Source File: ChangeListChooser.java From consulo with Apache License 2.0 | 5 votes |
public ChangeListChooser(@Nonnull Project project, @Nonnull Collection<? extends ChangeList> changelists, @javax.annotation.Nullable ChangeList defaultSelection, final String title, @javax.annotation.Nullable final String suggestedName) { super(project, false); myProject = project; ChangeListEditHandler handler; for (ChangeList changelist : changelists) { handler = ((LocalChangeListImpl)changelist).getEditHandler(); if (handler != null) { break; } } myPanel = new ChangeListChooserPanel(myProject, new NullableConsumer<String>() { public void consume(final @javax.annotation.Nullable String errorMessage) { setOKActionEnabled(errorMessage == null); setErrorText(errorMessage); } }); myPanel.init(); myPanel.setChangeLists(changelists); myPanel.setDefaultSelection(defaultSelection); setTitle(title); if (suggestedName != null) { myPanel.setSuggestedName(suggestedName); } init(); }
Example #19
Source File: SvnDiffProvider.java From review-board-idea-plugin with Apache License 2.0 | 5 votes |
@Override public String generateDiff(Project project, AnActionEvent action) throws VcsException { String diffContent; if (isFromRevision(project, action)) { ChangeList[] data = action.getData(VcsDataKeys.CHANGE_LISTS); diffContent = fromRevisions(project, project.getBaseDir(), ((CommittedChangeList) data[data.length - 1]).getNumber(), ((CommittedChangeList) data[0]).getNumber()); } else { final Change[] changes = action.getData(VcsDataKeys.CHANGES); diffContent = fromHead(project, project.getBaseDir(), changes); } return diffContent; }
Example #20
Source File: ChangeListDetailsAction.java From consulo with Apache License 2.0 | 5 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS); if (changeLists != null && changeLists.length > 0 && changeLists [0] instanceof CommittedChangeList) { showDetailsPopup(project, (CommittedChangeList) changeLists [0]); } }
Example #21
Source File: GetCommittedChangelistAction.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void actionPerformed(@Nonnull final VcsContext context) { Collection<FilePath> filePaths = getFilePaths(context); final List<ChangeList> selectedChangeLists = new ArrayList<>(); final ChangeList[] selectionFromContext = context.getSelectedChangeLists(); if (selectionFromContext != null) { Collections.addAll(selectedChangeLists, selectionFromContext); } final List<CommittedChangeList> incomingChanges = CommittedChangesCache.getInstance(context.getProject()).getCachedIncomingChanges(); final List<CommittedChangeList> intersectingChanges = new ArrayList<>(); if (incomingChanges != null) { for(CommittedChangeList changeList: incomingChanges) { if (!selectedChangeLists.contains(changeList)) { for(Change change: changeList.getChanges()) { if (filePaths.contains(ChangesUtil.getFilePath(change))) { intersectingChanges.add(changeList); break; } } } } } if (intersectingChanges.size() > 0) { int rc = Messages.showOkCancelDialog( context.getProject(), VcsBundle.message("get.committed.changes.intersecting.prompt", intersectingChanges.size(), selectedChangeLists.size()), VcsBundle.message("get.committed.changes.title"), Messages.getQuestionIcon()); if (rc != Messages.OK) return; } super.actionPerformed(context); }
Example #22
Source File: GetCommittedChangelistAction.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void update(@Nonnull final VcsContext vcsContext, @Nonnull final Presentation presentation) { super.update(vcsContext, presentation); final ChangeList[] changeLists = vcsContext.getSelectedChangeLists(); presentation.setEnabled(presentation.isEnabled() && CommittedChangesCache.getInstance(vcsContext.getProject()).getCachedIncomingChanges() != null && changeLists != null && changeLists.length > 0); }
Example #23
Source File: GetCommittedChangelistAction.java From consulo with Apache License 2.0 | 5 votes |
private static Collection<FilePath> getFilePaths(final VcsContext context) { final Set<FilePath> files = new HashSet<>(); final ChangeList[] selectedChangeLists = context.getSelectedChangeLists(); if (selectedChangeLists != null) { for(ChangeList changelist: selectedChangeLists) { for(Change change: changelist.getChanges()) { files.add(ChangesUtil.getFilePath(change)); } } } return files; }
Example #24
Source File: RevertSelectedChangesAction.java From consulo with Apache License 2.0 | 5 votes |
private static boolean allSelectedChangeListsAreRevertable(AnActionEvent e) { ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS); if (changeLists == null) { return true; } for (ChangeList list : changeLists) { if (list instanceof CommittedChangeList) { if (!((CommittedChangeList)list).isModifiable()) { return false; } } } return true; }
Example #25
Source File: SetDefaultChangeListAction.java From consulo with Apache License 2.0 | 5 votes |
public void update(AnActionEvent e) { ChangeList[] lists = e.getData(VcsDataKeys.CHANGE_LISTS); final boolean visible = lists != null && lists.length == 1 && lists[0] instanceof LocalChangeList && !((LocalChangeList)lists[0]).isDefault(); if (e.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) e.getPresentation().setVisible(visible); else e.getPresentation().setEnabled(visible); }
Example #26
Source File: AddChangeListAction.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings({"HardCodedStringLiteral"}) private static String getUniqueName(final Project project) { int unnamedcount = 0; for (ChangeList list : ChangeListManagerImpl.getInstanceImpl(project).getChangeListsCopy()) { if (list.getName().startsWith("Unnamed")) { unnamedcount++; } } return unnamedcount == 0 ? "Unnamed" : "Unnamed (" + unnamedcount + ")"; }
Example #27
Source File: RemoveChangeListAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e) { final Project project = e.getRequiredData(CommonDataKeys.PROJECT); final ChangeList[] selectedLists = e.getRequiredData(VcsDataKeys.CHANGE_LISTS); //noinspection unchecked ChangeListRemoveConfirmation.processLists(project, true, (Collection)Arrays.asList(selectedLists), new ChangeListRemoveConfirmation() { @Override public boolean askIfShouldRemoveChangeLists(@Nonnull List<? extends LocalChangeList> lists) { return RemoveChangeListAction.askIfShouldRemoveChangeLists(lists, project); } }); }
Example #28
Source File: RenameChangeListAction.java From consulo with Apache License 2.0 | 5 votes |
public void update(AnActionEvent e) { ChangeList[] lists = e.getData(VcsDataKeys.CHANGE_LISTS); final boolean visible = lists != null && lists.length == 1 && lists[0] instanceof LocalChangeList && !((LocalChangeList)lists[0]).isReadOnly(); if (e.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) e.getPresentation().setVisible(visible); else e.getPresentation().setEnabled(visible); }
Example #29
Source File: RemoveChangeListAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(@Nonnull AnActionEvent e) { ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS); boolean visible = canRemoveChangeLists(e.getProject(), changeLists); Presentation presentation = e.getPresentation(); presentation.setEnabled(visible); presentation .setText(ActionsBundle.message("action.ChangesView.RemoveChangeList.text", changeLists != null && changeLists.length > 1 ? 1 : 0)); if (e.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) { presentation.setVisible(visible); } presentation.setDescription(ArrayUtil.isEmpty(e.getData(VcsDataKeys.CHANGES)) ? presentation.getText() : getDescription(changeLists)); }
Example #30
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; }