changelist conflict dialog refactored
[fedora-idea.git] / platform / vcs-impl / src / com / intellij / openapi / vcs / changes / conflicts / ChangelistConflictDialog.java
blob1266cf0881bbf4607f08f78eaf53dee45616ef75
1 package com.intellij.openapi.vcs.changes.conflicts;
3 import com.intellij.openapi.options.ShowSettingsUtil;
4 import com.intellij.openapi.project.Project;
5 import com.intellij.openapi.ui.DialogWrapper;
6 import com.intellij.openapi.vcs.VcsBundle;
7 import com.intellij.openapi.vcs.changes.ChangeList;
8 import com.intellij.openapi.vcs.changes.ChangeListManager;
9 import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
10 import com.intellij.openapi.vcs.readOnlyHandler.FileListRenderer;
11 import com.intellij.openapi.vfs.VirtualFile;
12 import com.intellij.ui.CollectionListModel;
14 import javax.swing.*;
15 import java.awt.event.ActionEvent;
16 import java.util.List;
18 /**
19 * @author Dmitry Avdeev
21 public class ChangelistConflictDialog extends DialogWrapper {
23 private JPanel myPanel;
25 private JRadioButton myShelveChangesRadioButton;
26 private JRadioButton myMoveChangesToActiveRadioButton;
27 private JRadioButton mySwitchToChangelistRadioButton;
28 private JRadioButton myIgnoreRadioButton;
29 private JList myFileList;
31 private final Project myProject;
33 public ChangelistConflictDialog(Project project, List<ChangeList> changeLists, List<VirtualFile> conflicts) {
34 super(project);
35 myProject = project;
37 setTitle("Resolve Changelist Conflict");
39 myFileList.setCellRenderer(new FileListRenderer());
40 myFileList.setModel(new CollectionListModel(conflicts));
42 ChangeListManagerImpl manager = ChangeListManagerImpl.getInstanceImpl(myProject);
43 ChangelistConflictResolution resolution = manager.getConflictTracker().getOptions().LAST_RESOLUTION;
45 if (changeLists.size() > 1) {
46 mySwitchToChangelistRadioButton.setEnabled(false);
47 if (resolution == ChangelistConflictResolution.SWITCH) {
48 resolution = ChangelistConflictResolution.IGNORE;
51 mySwitchToChangelistRadioButton.setText(VcsBundle.message("switch.to.changelist", changeLists.iterator().next().getName()));
52 myMoveChangesToActiveRadioButton.setText(VcsBundle.message("move.to.changelist", manager.getDefaultChangeList().getName()));
54 switch (resolution) {
56 case SHELVE:
57 myShelveChangesRadioButton.setSelected(true);
58 break;
59 case MOVE:
60 myMoveChangesToActiveRadioButton.setSelected(true);
61 break;
62 case SWITCH:
63 mySwitchToChangelistRadioButton.setSelected(true) ;
64 break;
65 case IGNORE:
66 myIgnoreRadioButton.setSelected(true);
67 break;
69 init();
72 @Override
73 protected JComponent createCenterPanel() {
74 return myPanel;
77 public ChangelistConflictResolution getResolution() {
78 if (myShelveChangesRadioButton.isSelected())
79 return ChangelistConflictResolution.SHELVE;
80 if (myMoveChangesToActiveRadioButton.isSelected())
81 return ChangelistConflictResolution.MOVE;
82 if (mySwitchToChangelistRadioButton.isSelected())
83 return ChangelistConflictResolution.SWITCH;
84 return ChangelistConflictResolution.IGNORE;
87 @Override
88 protected Action[] createLeftSideActions() {
89 return new Action[] { new AbstractAction("&Configure...") {
90 public void actionPerformed(ActionEvent e) {
91 ChangeListManagerImpl manager = (ChangeListManagerImpl)ChangeListManager.getInstance(myProject);
92 ShowSettingsUtil.getInstance().editConfigurable(myPanel, new ChangelistConflictConfigurable(manager));
94 }};