@Override public void rebuildList() { if (myInRebuildList) return; try { myInRebuildList = true; if (myChangesToDisplay == null) { // changes set not fixed === local changes final ChangeListManager manager = ChangeListManager.getInstance(myProject); myChangeListsMap = new HashMap<Change, LocalChangeList>(); final List<LocalChangeList> lists = manager.getChangeListsCopy(); Collection<Change> allChanges = new ArrayList<Change>(); for (LocalChangeList list : lists) { final Collection<Change> changes = list.getChanges(); allChanges.addAll(changes); for (Change change : changes) { myChangeListsMap.put(change, list); } } myAllChanges = allChanges; // refresh selected list also updateListsInChooser(); } super.rebuildList(); if (myRebuildListListener != null) { myRebuildListListener.run(); } } finally { myInRebuildList = false; } }
// todo terrible constructor public MultipleChangeListBrowser( Project project, List<? extends ChangeList> changeLists, List<Change> changes, Disposable parentDisposable, ChangeList initialListSelection, boolean capableOfExcludingChanges, boolean highlightProblems, Runnable rebuildListListener, @Nullable Runnable inclusionListener, AnAction... additionalActions) { super( project, changeLists, changes, initialListSelection, capableOfExcludingChanges, highlightProblems, inclusionListener, MyUseCase.LOCAL_CHANGES, null); myParentDisposable = parentDisposable; myRebuildListListener = rebuildListListener; myChangeListChooser = new ChangeListChooser(changeLists); myHeaderPanel.add(myChangeListChooser, BorderLayout.EAST); myShowingAllChangeLists = Comparing.haveEqualElements( changeLists, ChangeListManager.getInstance(project).getChangeLists()); ChangeListManager.getInstance(myProject).addChangeListListener(myChangeListListener); myExtender = new Extender(project, this, additionalActions); ActionManager actionManager = ActionManager.getInstance(); final AnAction moveAction = actionManager.getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST); actionManager.addAnActionListener( new AnActionListener.Adapter() { @Override public void afterActionPerformed( AnAction action, DataContext dataContext, AnActionEvent event) { if (moveAction.equals(action)) { rebuildList(); } } }, myParentDisposable); }
@Override public void dispose() { ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListListener); }