changelist conflict dialog refactored
[fedora-idea.git] / platform / vcs-impl / src / com / intellij / openapi / vcs / changes / conflicts / ChangelistConflictNotificationPanel.java
blob5b85bf66f0580dd115bb4e7808c630ddef96e8bf
1 package com.intellij.openapi.vcs.changes.conflicts;
3 import com.intellij.openapi.options.ShowSettingsUtil;
4 import com.intellij.openapi.util.IconLoader;
5 import com.intellij.openapi.vcs.changes.Change;
6 import com.intellij.openapi.vcs.changes.ChangeList;
7 import com.intellij.openapi.vcs.changes.ChangeListManager;
8 import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
9 import com.intellij.openapi.vfs.VirtualFile;
10 import com.intellij.ui.EditorNotificationPanel;
11 import com.intellij.ui.InplaceButton;
13 import javax.swing.*;
14 import java.awt.event.ActionEvent;
15 import java.awt.event.ActionListener;
16 import java.util.Collections;
17 import java.util.List;
19 /**
20 * @author Dmitry Avdeev
22 public class ChangelistConflictNotificationPanel extends EditorNotificationPanel {
24 private final ChangeList myChangeList;
25 private final Change myChange;
26 private final VirtualFile myFile;
27 private ChangelistConflictTracker myTracker;
29 public ChangelistConflictNotificationPanel(ChangelistConflictTracker tracker, VirtualFile file) {
31 myTracker = tracker;
32 myFile = file;
33 final ChangeListManager manager = tracker.getChangeListManager();
34 myChange = manager.getChange(file);
35 myChangeList = manager.getChangeList(myChange);
36 assert myChangeList != null;
37 myLabel.setText("File from non-active changelist is modified");
38 createActionLabel("Move changes", "move").
39 setToolTipText("Move changes to active changelist (" + manager.getDefaultChangeList().getName() + ")");
40 createActionLabel("Switch changelist", "switch").
41 setToolTipText("Set active changelist to '" + myChangeList.getName() + "'");
42 createActionLabel("Ignore", "ignore").
43 setToolTipText("Hide this notification");
44 setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
46 myLinksPanel.add(new InplaceButton("Show options dialog", IconLoader.getIcon("/general/ideOptions.png"), new ActionListener() {
47 public void actionPerformed(ActionEvent e) {
49 ShowSettingsUtil.getInstance().editConfigurable(myTracker.getProject(),
50 new ChangelistConflictConfigurable((ChangeListManagerImpl)manager));
52 }));
55 @Override
56 protected void executeAction(String actionId) {
57 if (actionId.equals("move")) {
58 MoveChangesDialog dialog =
59 new MoveChangesDialog(myTracker.getProject(), Collections.singletonList(myChange), Collections.singleton(myChangeList),
60 "Move Changes to Active Changelist");
61 dialog.show();
62 if (dialog.isOK()) {
63 ChangelistConflictResolution.MOVE.resolveConflict(myTracker.getProject(), dialog.getSelectedChanges());
65 } else if (actionId.equals("switch")) {
66 List<Change> changes = Collections.singletonList(myTracker.getChangeListManager().getChange(myFile));
67 ChangelistConflictResolution.SWITCH.resolveConflict(myTracker.getProject(), changes);
68 } else if (actionId.equals("ignore")) {
69 myTracker.ignoreConflict(myFile, true);