Improve button labels on "delete from cvs" dialogs

This commit is contained in:
Bas Leijdekkers
2012-04-03 17:05:37 +02:00
parent 095eaa07e5
commit a57c667ee7
5 changed files with 82 additions and 28 deletions
@@ -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<FilePath> selectFilePathsToProcess(List<FilePath> 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);
};
}
@@ -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() {
@@ -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<FilePath> {
private ChangesTreeList<FilePath> myFileList;
private final ChangesTreeList<FilePath> myFileList;
public SelectFilePathsDialog(final Project project, List<FilePath> 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<FilePath>(project, originalFiles, true, true, null, null) {
protected DefaultTreeModel buildTreeModel(final List<FilePath> changes, ChangeNodeDecorator changeNodeDecorator) {
@@ -54,6 +56,12 @@ public class SelectFilePathsDialog extends AbstractSelectFilesDialog<FilePath> {
return null;
}
};
if (okActionName != null) {
getOKAction().putValue(Action.NAME, okActionName);
}
if (cancelActionName != null) {
getCancelAction().putValue(Action.NAME, cancelActionName);
}
myFileList.setChangesToDisplay(originalFiles);
init();
}
@@ -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<FilePath> selectFilePathsToProcess(final List<FilePath> files,
final String title,
@Nullable final String prompt,
final String singleFileTitle,
final String singleFilePromptTemplate,
final VcsShowConfirmationOption confirmationOption) {
public Collection<FilePath> selectFilePathsToProcess(List<FilePath> 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<FilePath> selectFilePathsToProcess(final List<FilePath> 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<VcsException> abstractVcsExceptions, @NotNull final String tabDisplayName) {
showErrorsImpl(abstractVcsExceptions.isEmpty(), new Getter<VcsException>() {
public VcsException get() {
@@ -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<File> filesToRemove,
final boolean showDialog) {
ArrayList<File> files = new ArrayList<File>();
final ArrayList<File> files = new ArrayList<File>();
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<FilePath> filesToFilePaths(final ArrayList<File> files) {
List<FilePath> result = new ArrayList<FilePath>();
final List<FilePath> result = new ArrayList<FilePath>();
for(File f: files) {
result.add(VcsContextFactory.SERVICE.getInstance().createFilePathOnDeleted(f, false));
}
@@ -103,8 +105,8 @@ public class RemoveLocallyFileOrDirectoryAction extends ActionOnSelectedElement
}
protected Collection<File> getFilesToRemove(CvsContext context) {
Collection<String> deletedFileNames = context.getDeletedFileNames();
ArrayList<File> result = new ArrayList<File>();
final Collection<String> deletedFileNames = context.getDeletedFileNames();
final ArrayList<File> result = new ArrayList<File>();
for (final String deletedFileName : deletedFileNames) {
result.add(new File(deletedFileName));
}