From a57c667ee718cd7d21170cf8242381f7b5697e63 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 3 Apr 2012 17:05:37 +0200 Subject: [PATCH] Improve button labels on "delete from cvs" dialogs --- .../openapi/vcs/AbstractVcsHelper.java | 14 +++++++- .../intellij/util/ui/ConfirmationDialog.java | 29 ++++++++++++--- .../vcs/changes/ui/SelectFilePathsDialog.java | 14 ++++++-- .../vcs/impl/AbstractVcsHelperImpl.java | 35 +++++++++++++------ .../RemoveLocallyFileOrDirectoryAction.java | 18 +++++----- 5 files changed, 82 insertions(+), 28 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcsHelper.java b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcsHelper.java index 9289166d010f..8f36673d2417 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcsHelper.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcsHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,4 +150,16 @@ public abstract class AbstractVcsHelper { final String singleFileTitle, final String singleFilePromptTemplate, final VcsShowConfirmationOption confirmationOption); + + @Nullable + public Collection selectFilePathsToProcess(List files, + final String title, + @Nullable final String prompt, + final String singleFileTitle, + final String singleFilePromptTemplate, + final VcsShowConfirmationOption confirmationOption, + @Nullable String okActionName, + @Nullable String cancelActionName) { + return selectFilePathsToProcess(files, title, prompt, singleFileTitle, singleFilePromptTemplate, confirmationOption); + }; } diff --git a/platform/vcs-api/src/com/intellij/util/ui/ConfirmationDialog.java b/platform/vcs-api/src/com/intellij/util/ui/ConfirmationDialog.java index e86759e6057e..4fa80ba3b28c 100644 --- a/platform/vcs-api/src/com/intellij/util/ui/ConfirmationDialog.java +++ b/platform/vcs-api/src/com/intellij/util/ui/ConfirmationDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,14 +27,26 @@ public class ConfirmationDialog extends OptionsMessageDialog{ private final VcsShowConfirmationOption myOption; private String myDoNotShowAgainMessage; + private final String myOkActionName; + private final String myCancelActionName; public static boolean requestForConfirmation(@NotNull VcsShowConfirmationOption option, @NotNull Project project, @NotNull String message, @NotNull String title, @Nullable Icon icon) { + return requestForConfirmation(option, project, message, title, icon, null, null); + } + + public static boolean requestForConfirmation(@NotNull VcsShowConfirmationOption option, + @NotNull Project project, + @NotNull String message, + @NotNull String title, + @Nullable Icon icon, + @Nullable String okActionName, + @Nullable String cancelActionName) { if (option.getValue() == VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) return false; - final ConfirmationDialog dialog = new ConfirmationDialog(project, message, title, icon, option); + final ConfirmationDialog dialog = new ConfirmationDialog(project, message, title, icon, option, okActionName, cancelActionName); if (! option.isPersistent()) { dialog.setDoNotAskOption(null); } else { @@ -45,9 +57,16 @@ public class ConfirmationDialog extends OptionsMessageDialog{ } public ConfirmationDialog(Project project, final String message, String title, final Icon icon, final VcsShowConfirmationOption option) { + this(project, message, title, icon, option, null, null); + } + + public ConfirmationDialog(Project project, final String message, String title, final Icon icon, final VcsShowConfirmationOption option, + @Nullable String okActionName, @Nullable String cancelActionName) { super(project, message, title, icon); myOption = option; - init(); + myOkActionName = okActionName != null ? okActionName : CommonBundle.getYesButtonText(); + myCancelActionName = cancelActionName != null ? cancelActionName : CommonBundle.getNoButtonText(); + init(); } public void setDoNotShowAgainMessage(final String doNotShowAgainMessage) { @@ -61,11 +80,11 @@ public class ConfirmationDialog extends OptionsMessageDialog{ } protected String getOkActionName() { - return CommonBundle.message("button.yes"); + return myOkActionName; } protected String getCancelActionName() { - return CommonBundle.message("button.no"); + return myCancelActionName; } protected boolean isToBeShown() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilePathsDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilePathsDialog.java index e7568b018145..69d6da0b52a9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilePathsDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SelectFilePathsDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.intellij.openapi.vcs.VcsShowConfirmationOption; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import javax.swing.tree.DefaultTreeModel; import java.util.Collection; import java.util.List; @@ -31,10 +32,11 @@ import java.util.List; */ public class SelectFilePathsDialog extends AbstractSelectFilesDialog { - private ChangesTreeList myFileList; + private final ChangesTreeList myFileList; public SelectFilePathsDialog(final Project project, List originalFiles, final String prompt, - final VcsShowConfirmationOption confirmationOption) { + final VcsShowConfirmationOption confirmationOption, + @Nullable String okActionName, @Nullable String cancelActionName) { super(project, false, confirmationOption, prompt, true); myFileList = new ChangesTreeList(project, originalFiles, true, true, null, null) { protected DefaultTreeModel buildTreeModel(final List changes, ChangeNodeDecorator changeNodeDecorator) { @@ -54,6 +56,12 @@ public class SelectFilePathsDialog extends AbstractSelectFilesDialog { return null; } }; + if (okActionName != null) { + getOKAction().putValue(Action.NAME, okActionName); + } + if (cancelActionName != null) { + getCancelAction().putValue(Action.NAME, cancelActionName); + } myFileList.setChangesToDisplay(originalFiles); init(); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/AbstractVcsHelperImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/AbstractVcsHelperImpl.java index 7657356372da..1ae8907d3b65 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/AbstractVcsHelperImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/AbstractVcsHelperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,22 +170,25 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper { } @Nullable - public Collection selectFilePathsToProcess(final List files, - final String title, - @Nullable final String prompt, - final String singleFileTitle, - final String singleFilePromptTemplate, - final VcsShowConfirmationOption confirmationOption) { + public Collection selectFilePathsToProcess(List files, + String title, + @Nullable String prompt, + String singleFileTitle, + String singleFilePromptTemplate, + VcsShowConfirmationOption confirmationOption, + @Nullable String okActionName, + @Nullable String cancelActionName) { if (files.size() == 1 && singleFilePromptTemplate != null) { - String filePrompt = MessageFormat.format(singleFilePromptTemplate, files.get(0).getPresentableUrl()); - if (ConfirmationDialog - .requestForConfirmation(confirmationOption, myProject, filePrompt, singleFileTitle, Messages.getQuestionIcon())) { + final String filePrompt = MessageFormat.format(singleFilePromptTemplate, files.get(0).getPresentableUrl()); + if (ConfirmationDialog.requestForConfirmation(confirmationOption, myProject, filePrompt, singleFileTitle, + Messages.getQuestionIcon(), okActionName, cancelActionName)) { return files; } return null; } - SelectFilePathsDialog dlg = new SelectFilePathsDialog(myProject, files, prompt, confirmationOption); + final SelectFilePathsDialog dlg = + new SelectFilePathsDialog(myProject, files, prompt, confirmationOption, okActionName, cancelActionName); dlg.setTitle(title); if (! confirmationOption.isPersistent()) { dlg.setDoNotAskOption(null); @@ -194,6 +197,16 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper { return dlg.isOK() ? dlg.getSelectedFiles() : null; } + @Nullable + public Collection selectFilePathsToProcess(final List files, + final String title, + @Nullable final String prompt, + final String singleFileTitle, + final String singleFilePromptTemplate, + final VcsShowConfirmationOption confirmationOption) { + return selectFilePathsToProcess(files, title, prompt, singleFileTitle, singleFilePromptTemplate, confirmationOption, null, null); + } + public void showErrors(final List abstractVcsExceptions, @NotNull final String tabDisplayName) { showErrorsImpl(abstractVcsExceptions.isEmpty(), new Getter() { public VcsException get() { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/RemoveLocallyFileOrDirectoryAction.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/RemoveLocallyFileOrDirectoryAction.java index 0bd159c2614c..fb23687d8a56 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/RemoveLocallyFileOrDirectoryAction.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/RemoveLocallyFileOrDirectoryAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.cvsSupport2.actions; +import com.intellij.CommonBundle; import com.intellij.CvsBundle; import com.intellij.cvsSupport2.CvsUtil; import com.intellij.cvsSupport2.CvsVcs2; @@ -55,9 +56,8 @@ public class RemoveLocallyFileOrDirectoryAction extends ActionOnSelectedElement } protected CvsHandler getCvsHandler(CvsContext context) { - Project project = context.getProject(); + final Project project = context.getProject(); final boolean showDialog = myOptions.isToBeShown(project) || OptionsDialog.shiftIsPressed(context.getModifiers()); - return getCvsHandler(project, getFilesToRemove(context), showDialog); } @@ -68,7 +68,7 @@ public class RemoveLocallyFileOrDirectoryAction extends ActionOnSelectedElement private static CvsHandler getCvsHandler(final Project project, final Collection filesToRemove, final boolean showDialog) { - ArrayList files = new ArrayList(); + final ArrayList files = new ArrayList(); for (final File file : filesToRemove) { if (CvsUtil.fileIsLocallyAdded(file)) { @@ -88,14 +88,16 @@ public class RemoveLocallyFileOrDirectoryAction extends ActionOnSelectedElement null, CvsBundle.message("dialog.title.delete.file.from.cvs"), CvsBundle.message("confirmation.text.delete.file.from.cvs"), - CvsVcs2.getInstance(project).getRemoveConfirmation()); + CvsVcs2.getInstance(project).getRemoveConfirmation(), + CvsBundle.message("button.text.delete.from.cvs"), + CommonBundle.getCancelButtonText()); if (filesToBeRemoved == null || filesToBeRemoved.isEmpty()) return CvsHandler.NULL; } return CommandCvsHandler.createRemoveFilesHandler(project, ChangesUtil.filePathsToFiles(filesToBeRemoved)); } private static List filesToFilePaths(final ArrayList files) { - List result = new ArrayList(); + final List result = new ArrayList(); for(File f: files) { result.add(VcsContextFactory.SERVICE.getInstance().createFilePathOnDeleted(f, false)); } @@ -103,8 +105,8 @@ public class RemoveLocallyFileOrDirectoryAction extends ActionOnSelectedElement } protected Collection getFilesToRemove(CvsContext context) { - Collection deletedFileNames = context.getDeletedFileNames(); - ArrayList result = new ArrayList(); + final Collection deletedFileNames = context.getDeletedFileNames(); + final ArrayList result = new ArrayList(); for (final String deletedFileName : deletedFileNames) { result.add(new File(deletedFileName)); }