mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-80668 Move changes to Active Changelist - usability
This commit is contained in:
+1
-1
@@ -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()) {
|
||||
|
||||
+10
-19
@@ -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) {
|
||||
|
||||
+6
-6
@@ -33,14 +33,14 @@ public enum ChangelistConflictResolution {
|
||||
|
||||
SHELVE {
|
||||
@Override
|
||||
public boolean resolveConflict(Project project, Collection<Change> changes) {
|
||||
public boolean resolveConflict(Project project, Collection<Change> 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<Change> changes) {
|
||||
public boolean resolveConflict(Project project, Collection<Change> changes, VirtualFile selected) {
|
||||
ChangeListManagerImpl manager = getManager(project);
|
||||
Set<ChangeList> 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<Change> changes) {
|
||||
public boolean resolveConflict(Project project, Collection<Change> 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<Change> changes) {
|
||||
public boolean resolveConflict(Project project, Collection<Change> 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<Change> changes);
|
||||
public abstract boolean resolveConflict(Project project, Collection<Change> changes, VirtualFile selected);
|
||||
|
||||
private static ChangeListManagerImpl getManager(Project project) {
|
||||
return (ChangeListManagerImpl)ChangeListManager.getInstance(project);
|
||||
|
||||
+65
-5
@@ -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<Change> myTreeList;
|
||||
private final List<Change> myChanges;
|
||||
private final Collection<Change> mySelected;
|
||||
private JBCheckBox myCheckBox;
|
||||
|
||||
public MoveChangesDialog(final Project project, Collection<Change> selected, final Set<ChangeList> changeLists, String title) {
|
||||
public MoveChangesDialog(final Project project, Collection<Change> selected, final Set<ChangeList> changeLists, VirtualFile current) {
|
||||
super(project, true);
|
||||
setTitle(title);
|
||||
mySelected = selected;
|
||||
setTitle("Move Changes to Active Changelist");
|
||||
myTreeList = new ChangesTreeList<Change>(project, selected, true, false, null, null) {
|
||||
|
||||
@Override
|
||||
@@ -68,15 +76,38 @@ public class MoveChangesDialog extends DialogWrapper {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
ArrayList<Change> 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<Change> component = (ChangesBrowserNode<Change>)myTreeList.getSelectionPath().getLastPathComponent();
|
||||
myTreeList.excludeChanges(myChanges);
|
||||
}
|
||||
},
|
||||
|
||||
new AbstractAction("Select &All") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myTreeList.includeChanges(myChanges);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -311,12 +311,11 @@ public abstract class ChangesTreeList<T> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user