diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java index f5ee5b8cbc90..ba1c99815c52 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java @@ -69,7 +69,7 @@ public class ChangelistConflictAccessProvider extends WritingAccessProvider { do { dialog = new ChangelistConflictDialog(myProject, new ArrayList<>(changeLists), denied); dialog.show(); - } while (dialog.isOK() && !dialog.getResolution().resolveConflict(myProject, changes)); + } while (dialog.isOK() && !dialog.getResolution().resolveConflict(myProject, changes, null)); IdeEventQueue.getInstance().setEventCount(savedEventCount); if (dialog.isOK()) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationPanel.java index a559d6bee399..520e897df963 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationPanel.java @@ -53,29 +53,20 @@ public class ChangelistConflictNotificationPanel extends EditorNotificationPanel final ChangeListManager manager = tracker.getChangeListManager(); myChangeList = changeList; myLabel.setText("File from non-active changelist is modified"); - createActionLabel("Move changes", new Runnable() { - public void run() { - ChangelistConflictResolution.MOVE.resolveConflict(myTracker.getProject(), myChangeList.getChanges()); - } - }).setToolTipText("Move changes to active changelist (" + manager.getDefaultChangeList().getName() + ")"); + createActionLabel("Move changes", () -> ChangelistConflictResolution.MOVE.resolveConflict(myTracker.getProject(), myChangeList.getChanges(), myFile)). + setToolTipText("Move changes to active changelist (" + manager.getDefaultChangeList().getName() + ")"); - createActionLabel("Switch changelist", new Runnable() { - public void run() { - Change change = myTracker.getChangeListManager().getChange(myFile); - if (change == null) { - Messages.showInfoMessage("No changes for this file", "Message"); - } - else { - ChangelistConflictResolution.SWITCH.resolveConflict(myTracker.getProject(), Collections.singletonList(change)); - } + createActionLabel("Switch changelist", () -> { + Change change = myTracker.getChangeListManager().getChange(myFile); + if (change == null) { + Messages.showInfoMessage("No changes for this file", "Message"); + } + else { + ChangelistConflictResolution.SWITCH.resolveConflict(myTracker.getProject(), Collections.singletonList(change), null); } }).setToolTipText("Set active changelist to '" + myChangeList.getName() + "'"); - createActionLabel("Ignore", new Runnable() { - public void run() { - myTracker.ignoreConflict(myFile, true); - } - }).setToolTipText("Hide this notification"); + createActionLabel("Ignore", () -> myTracker.ignoreConflict(myFile, true)).setToolTipText("Hide this notification"); myLinksPanel.add(new InplaceButton("Show options dialog", AllIcons.General.Settings, new ActionListener() { public void actionPerformed(ActionEvent e) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictResolution.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictResolution.java index 5a432311fa17..8f4ed69f477b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictResolution.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictResolution.java @@ -33,14 +33,14 @@ public enum ChangelistConflictResolution { SHELVE { @Override - public boolean resolveConflict(Project project, Collection changes) { + public boolean resolveConflict(Project project, Collection changes, VirtualFile selected) { LocalChangeList changeList = getManager(project).getChangeList(changes.iterator().next()); return CommitChangeListDialog.commitChanges(project, changes, changeList, new ShelveChangesCommitExecutor(project), null); }}, MOVE { @Override - public boolean resolveConflict(Project project, Collection changes) { + public boolean resolveConflict(Project project, Collection changes, VirtualFile selected) { ChangeListManagerImpl manager = getManager(project); Set changeLists = new HashSet<>(); for (Change change : changes) { @@ -53,7 +53,7 @@ public enum ChangelistConflictResolution { Messages.showInfoMessage(project, "The conflict seems to be resolved", "No Conflict Found"); return true; } - MoveChangesDialog dialog = new MoveChangesDialog(project, changes, changeLists, "Move Changes to Active Changelist"); + MoveChangesDialog dialog = new MoveChangesDialog(project, changes, changeLists, selected); if (dialog.showAndGet()) { manager.moveChangesTo(manager.getDefaultChangeList(), dialog.getIncludedChanges().toArray(new Change[changes.size()])); return true; @@ -63,7 +63,7 @@ public enum ChangelistConflictResolution { SWITCH { @Override - public boolean resolveConflict(Project project, Collection changes) { + public boolean resolveConflict(Project project, Collection changes, VirtualFile selected) { LocalChangeList changeList = getManager(project).getChangeList(changes.iterator().next()); assert changeList != null; getManager(project).setDefaultChangeList(changeList); @@ -72,7 +72,7 @@ public enum ChangelistConflictResolution { IGNORE { @Override - public boolean resolveConflict(Project project, Collection changes) { + public boolean resolveConflict(Project project, Collection changes, VirtualFile selected) { ChangeListManagerImpl manager = getManager(project); for (Change change : changes) { VirtualFile file = change.getVirtualFile(); @@ -83,7 +83,7 @@ public enum ChangelistConflictResolution { return true; }}; - public abstract boolean resolveConflict(Project project, Collection changes); + public abstract boolean resolveConflict(Project project, Collection changes, VirtualFile selected); private static ChangeListManagerImpl getManager(Project project) { return (ChangeListManagerImpl)ChangeListManager.getInstance(project); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/MoveChangesDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/MoveChangesDialog.java index ab1af092ea00..f7d8fbdc82c7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/MoveChangesDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/MoveChangesDialog.java @@ -16,6 +16,7 @@ package com.intellij.openapi.vcs.changes.conflicts; +import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.DefaultActionGroup; @@ -27,7 +28,9 @@ import com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator; import com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode; import com.intellij.openapi.vcs.changes.ui.ChangesTreeList; import com.intellij.openapi.vcs.changes.ui.TreeModelBuilder; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.components.JBCheckBox; import javax.swing.*; import javax.swing.tree.DefaultTreeModel; @@ -41,11 +44,16 @@ import java.util.Set; * @author Dmitry Avdeev */ public class MoveChangesDialog extends DialogWrapper { + private static final String MOVE_CHANGES_CURRENT_ONLY = "move.changes.current.only"; private final ChangesTreeList myTreeList; + private final List myChanges; + private final Collection mySelected; + private JBCheckBox myCheckBox; - public MoveChangesDialog(final Project project, Collection selected, final Set changeLists, String title) { + public MoveChangesDialog(final Project project, Collection selected, final Set changeLists, VirtualFile current) { super(project, true); - setTitle(title); + mySelected = selected; + setTitle("Move Changes to Active Changelist"); myTreeList = new ChangesTreeList(project, selected, true, false, null, null) { @Override @@ -68,15 +76,38 @@ public class MoveChangesDialog extends DialogWrapper { return null; } }; - ArrayList changes = new ArrayList<>(); + + myChanges = new ArrayList<>(); for (ChangeList list : changeLists) { - changes.addAll(list.getChanges()); + myChanges.addAll(list.getChanges()); } - myTreeList.setChangesToDisplay(changes); + myTreeList.setChangesToDisplay(myChanges, current); + + myCheckBox = new JBCheckBox("Select current file only"); + myCheckBox.setMnemonic('c'); + myCheckBox.addActionListener(e -> setSelected(myCheckBox.isSelected())); + + boolean selectCurrent = PropertiesComponent.getInstance().getBoolean(MOVE_CHANGES_CURRENT_ONLY); + myCheckBox.setSelected(selectCurrent); + setSelected(selectCurrent); init(); } + private void setSelected(boolean selected) { + myTreeList.excludeChanges(myChanges); + if (selected) { + Change selection = myTreeList.getLeadSelection(); + if (selection != null) { + myTreeList.includeChange(selection); + } + } + else { + myTreeList.includeChanges(mySelected); + } + PropertiesComponent.getInstance().setValue(MOVE_CHANGES_CURRENT_ONLY, selected); + } + @Override protected JComponent createCenterPanel() { JPanel panel = new JPanel(new BorderLayout()); @@ -102,4 +133,33 @@ public class MoveChangesDialog extends DialogWrapper { public boolean isOKActionEnabled() { return !getIncludedChanges().isEmpty(); } + + @Override + protected JComponent createSouthPanel() { + JComponent panel = super.createSouthPanel(); + return addDoNotShowCheckBox(panel, myCheckBox); + } + /* + + @NotNull + @Override + protected Action[] createLeftSideActions() { + return new Action[] { + new AbstractAction("Select &Current") { + @Override + public void actionPerformed(ActionEvent e) { + ChangesBrowserNode component = (ChangesBrowserNode)myTreeList.getSelectionPath().getLastPathComponent(); + myTreeList.excludeChanges(myChanges); + } + }, + + new AbstractAction("Select &All") { + @Override + public void actionPerformed(ActionEvent e) { + myTreeList.includeChanges(myChanges); + } + } + }; + } + */ } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java index 75e8fb6cf878..eae5f48ea59c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java @@ -311,12 +311,11 @@ public abstract class ChangesTreeList extends Tree implements TypeSafeDataPro } } } - } else { - if (toSelect != null) { - int rowInTree = findRowContainingFile((TreeNode)model.getRoot(), toSelect); - if (rowInTree > -1) { - selectedTreeRow = rowInTree; - } + } + if (toSelect != null) { + int rowInTree = findRowContainingFile((TreeNode)model.getRoot(), toSelect); + if (rowInTree > -1) { + selectedTreeRow = rowInTree; } }