diff options
Diffstat (limited to 'plugins/git4idea/src/git4idea/branch/GitSmartOperationDialog.java')
-rw-r--r-- | plugins/git4idea/src/git4idea/branch/GitSmartOperationDialog.java | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/plugins/git4idea/src/git4idea/branch/GitSmartOperationDialog.java b/plugins/git4idea/src/git4idea/branch/GitSmartOperationDialog.java index c7f7f9ab476e..9c2ef4a8d107 100644 --- a/plugins/git4idea/src/git4idea/branch/GitSmartOperationDialog.java +++ b/plugins/git4idea/src/git4idea/branch/GitSmartOperationDialog.java @@ -19,8 +19,6 @@ import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vcs.changes.ui.ChangesBrowser; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.components.JBLabel; import com.intellij.util.ui.UIUtil; @@ -29,7 +27,6 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.event.ActionEvent; -import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import static com.intellij.openapi.util.text.StringUtil.capitalize; @@ -39,29 +36,26 @@ import static com.intellij.openapi.util.text.StringUtil.capitalize; * "Your local changes to the following files would be overwritten by merge/checkout" * happens. * Displays the list of these files and proposes to make a "smart" merge or checkout. - * - * @author Kirill Likhodedov */ public class GitSmartOperationDialog extends DialogWrapper { public static final int SMART_EXIT_CODE = OK_EXIT_CODE; public static final int FORCE_EXIT_CODE = NEXT_USER_EXIT_CODE; - - private final Project myProject; - private final List<Change> myChanges; + + @NotNull private final JComponent myFileBrowser; @NotNull private final String myOperationTitle; - private final boolean myForceButton; + private final boolean myShowForceButton; /** * Shows the dialog with the list of local changes preventing merge/checkout and returns the dialog exit code. */ - static int showAndGetAnswer(@NotNull final Project project, @NotNull final List<Change> changes, @NotNull final String operationTitle, - final boolean forceButton) { + static int showAndGetAnswer(@NotNull final Project project, @NotNull final JComponent fileBrowser, + @NotNull final String operationTitle, final boolean showForceButton) { final AtomicInteger exitCode = new AtomicInteger(); UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { - GitSmartOperationDialog dialog = new GitSmartOperationDialog(project, changes, operationTitle, forceButton); + GitSmartOperationDialog dialog = new GitSmartOperationDialog(project, fileBrowser, operationTitle, showForceButton); ServiceManager.getService(project, GitPlatformFacade.class).showDialog(dialog); exitCode.set(dialog.getExitCode()); } @@ -69,15 +63,18 @@ public class GitSmartOperationDialog extends DialogWrapper { return exitCode.get(); } - private GitSmartOperationDialog(@NotNull Project project, @NotNull List<Change> changes, @NotNull String operationTitle, - boolean forceButton) { + private GitSmartOperationDialog(@NotNull Project project, @NotNull JComponent fileBrowser, @NotNull String operationTitle, + boolean showForceButton) { super(project); - myProject = project; - myChanges = changes; + myFileBrowser = fileBrowser; myOperationTitle = operationTitle; - myForceButton = forceButton; - setOKButtonText("Smart " + capitalize(myOperationTitle)); - setCancelButtonText("Don't " + capitalize(myOperationTitle)); + myShowForceButton = showForceButton; + String capitalizedOperation = capitalize(myOperationTitle); + setTitle("Git " + capitalizedOperation + " Problem"); + + setOKButtonText("Smart " + capitalizedOperation); + getOKAction().putValue(Action.SHORT_DESCRIPTION, "Stash local changes, " + operationTitle + ", unstash"); + setCancelButtonText("Don't " + capitalizedOperation); getCancelAction().putValue(FOCUSED_ACTION, Boolean.TRUE); init(); } @@ -85,8 +82,8 @@ public class GitSmartOperationDialog extends DialogWrapper { @NotNull @Override protected Action[] createLeftSideActions() { - if (myForceButton) { - return new Action[] {new ForceCheckoutAction(myOperationTitle) }; + if (myShowForceButton) { + return new Action[] {new ForceCheckoutAction(myOperationTitle) }; } return new Action[0]; } @@ -102,10 +99,7 @@ public class GitSmartOperationDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - ChangesBrowser changesBrowser = - new ChangesBrowser(myProject, null, myChanges, null, false, true, null, ChangesBrowser.MyUseCase.LOCAL_CHANGES, null); - changesBrowser.setChangesToDisplay(myChanges); - return changesBrowser; + return myFileBrowser; } @Override @@ -118,6 +112,7 @@ public class GitSmartOperationDialog extends DialogWrapper { ForceCheckoutAction(@NotNull String operationTitle) { super("&Force " + capitalize(operationTitle)); + putValue(Action.SHORT_DESCRIPTION, capitalize(operationTitle) + " and overwrite local changes"); } @Override |