From b9042910f0bde42a39795862eed8c138baafcdda Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 21 Aug 2019 18:15:49 +0200 Subject: [PATCH] [ui] moves undo/redo-related messages to a platform bundle; drops duplicates GitOrigin-RevId: 9037ca8f7306ac76037d42f0497887c8f7fc66c8 --- .../EditorTypingAndNavigationUndoTest.java | 24 +++++++------------ .../command/impl/CannotUndoReportDialog.java | 8 +++---- .../intellij/openapi/command/impl/Redo.java | 12 +++++----- .../intellij/openapi/command/impl/Undo.java | 14 +++++------ .../openapi/command/impl/UndoManagerImpl.java | 3 +-- .../openapi/command/impl/UndoRedo.java | 10 ++++---- .../openapi/command/impl/UndoableGroup.java | 14 +++++------ .../src/messages/CommonBundle.properties | 15 ------------ .../src/messages/IdeBundle.properties | 14 ++++++++++- 9 files changed, 52 insertions(+), 62 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/openapi/command/undo/EditorTypingAndNavigationUndoTest.java b/java/java-tests/testSrc/com/intellij/openapi/command/undo/EditorTypingAndNavigationUndoTest.java index 6aad98050964..bd77bb2e7d95 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/command/undo/EditorTypingAndNavigationUndoTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/command/undo/EditorTypingAndNavigationUndoTest.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.undo; -import com.intellij.CommonBundle; import com.intellij.ide.DataManager; +import com.intellij.ide.IdeBundle; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.ApplicationManager; @@ -155,7 +155,7 @@ public class EditorTypingAndNavigationUndoTest extends EditorUndoTestCase { public void testStripTrailingSpacesNoCommand() { typeInText(" test"); enter(); - stripTrailingSpaces(false); + stripTrailingSpaces(); undoFirstEditor(); checkEditorState(" test", 8, 0, 0); } @@ -210,17 +210,11 @@ public class EditorTypingAndNavigationUndoTest extends EditorUndoTestCase { assertTrue(editor.getScrollingModel().getVisibleAreaOnScrollingFinished().contains(caretXY)); } - private void stripTrailingSpaces(boolean startCommand) { - final Runnable command = - () -> CommandProcessor.getInstance().runUndoTransparentAction(() -> WriteCommandAction.runWriteCommandAction(null, () -> { + private void stripTrailingSpaces() { + CommandProcessor.getInstance().runUndoTransparentAction( + () -> WriteCommandAction.runWriteCommandAction(null, () -> { ((DocumentImpl)getFirstEditor().getDocument()).stripTrailingSpaces(getProject()); })); - if (startCommand) { - executeCommand(command, "Save"); - } - else { - command.run(); - } } public void testEditingView() { @@ -299,11 +293,11 @@ public class EditorTypingAndNavigationUndoTest extends EditorUndoTestCase { undoFirstEditor(); checkEditorText(""); - assertEquals(CommonBundle.message("undo.command.confirmation.text", ActionsBundle.message("action.undo.description.empty")) + "?", + assertEquals(IdeBundle.message("undo.command", ActionsBundle.message("action.undo.description.empty")) + "?", message.get()); redoFirstEditor(); checkEditorText(" "); - assertEquals(CommonBundle.message("redo.command.confirmation.text", ActionsBundle.message("action.redo.description.empty")) + "?", + assertEquals(IdeBundle.message("redo.command", ActionsBundle.message("action.redo.description.empty")) + "?", message.get()); } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java index 12a2328cf2a6..568e6e7f49a8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/CannotUndoReportDialog.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; -import com.intellij.CommonBundle; +import com.intellij.ide.IdeBundle; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.command.undo.DocumentReference; @@ -66,7 +66,7 @@ public class CannotUndoReportDialog extends DialogWrapper implements DataProvide myProblemFilesList.setModel(model); EditSourceOnDoubleClickHandler.install(myProblemFilesList, () -> doOKAction()); EditSourceOnEnterKeyHandler.install(myProblemFilesList, () -> doOKAction()); - setTitle(CommonBundle.message("cannot.undo.dialog.title")); + setTitle(IdeBundle.message("cannot.undo.title")); myProblemMessageLabel.setText(problemText); myProblemMessageLabel.setIcon(Messages.getErrorIcon()); @@ -98,4 +98,4 @@ public class CannotUndoReportDialog extends DialogWrapper implements DataProvide } return null; } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/Redo.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/Redo.java index 2df3437bfeda..5886d5ae90f2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/Redo.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/Redo.java @@ -1,13 +1,13 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; -import com.intellij.CommonBundle; +import com.intellij.ide.IdeBundle; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.util.text.StringUtil; /** - * author: lesya + * @author lesya */ class Redo extends UndoRedo { Redo(UndoManagerImpl manager, FileEditor editor) { @@ -26,13 +26,13 @@ class Redo extends UndoRedo { @Override protected String getActionName() { - return CommonBundle.message("redo.confirmation.title"); + return IdeBundle.message("redo.dialog.title"); } @Override protected String getActionName(String commandName) { if (StringUtil.isEmpty(commandName)) commandName = ActionsBundle.message("action.redo.description.empty"); - return CommonBundle.message("redo.command.confirmation.text", commandName); + return IdeBundle.message("redo.command", commandName); } @Override @@ -59,4 +59,4 @@ class Redo extends UndoRedo { protected boolean isRedo() { return true; } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/Undo.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/Undo.java index acea0993768a..a51bf21cc577 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/Undo.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/Undo.java @@ -1,13 +1,13 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; -import com.intellij.CommonBundle; +import com.intellij.ide.IdeBundle; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.util.text.StringUtil; /** - * author: lesya + * @author lesya */ class Undo extends UndoRedo { Undo(UndoManagerImpl manager, FileEditor editor) { @@ -26,13 +26,13 @@ class Undo extends UndoRedo { @Override protected String getActionName() { - return CommonBundle.message("undo.dialog.title"); + return IdeBundle.message("undo.dialog.title"); } @Override protected String getActionName(String commandName) { - if (StringUtil.isEmpty(commandName))commandName = ActionsBundle.message("action.undo.description.empty"); - return CommonBundle.message("undo.command.confirmation.text", commandName); + if (StringUtil.isEmpty(commandName)) commandName = ActionsBundle.message("action.undo.description.empty"); + return IdeBundle.message("undo.command", commandName); } @Override @@ -59,4 +59,4 @@ class Undo extends UndoRedo { protected boolean isRedo() { return false; } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java index a9ac5c8d59e2..f8b23a5e6ac5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java @@ -1,7 +1,6 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; -import com.intellij.CommonBundle; import com.intellij.ide.DataManager; import com.intellij.idea.ActionsBundle; import com.intellij.openapi.Disposable; @@ -590,7 +589,7 @@ public class UndoManagerImpl extends UndoManager implements Disposable { private void flushMergers() { assert myProject == null || !myProject.isDisposed() : myProject; // Run dummy command in order to flush all mergers... - CommandProcessor.getInstance().executeCommand(myProject, EmptyRunnable.getInstance(), CommonBundle.message("drop.undo.history.command.name"), null); + CommandProcessor.getInstance().executeCommand(myProject, EmptyRunnable.getInstance(), "Dummy", null); } @TestOnly diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java index 549730620049..c77054300bf5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; -import com.intellij.CommonBundle; +import com.intellij.ide.IdeBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.TransactionGuard; import com.intellij.openapi.command.undo.DocumentReference; @@ -81,14 +81,14 @@ abstract class UndoRedo { public boolean execute(boolean drop, boolean disableConfirmation) { if (!myUndoableGroup.isUndoable()) { - reportCannotUndo(CommonBundle.message("cannot.undo.error.contains.nonundoable.changes.message"), + reportCannotUndo(IdeBundle.message("cannot.undo.error.contains.nonundoable.changes.message"), myUndoableGroup.getAffectedDocuments()); return false; } Set clashing = getStackHolder().collectClashingActions(myUndoableGroup); if (!clashing.isEmpty()) { - reportCannotUndo(CommonBundle.message("cannot.undo.error.other.affected.files.changed.message"), clashing); + reportCannotUndo(IdeBundle.message("cannot.undo.error.other.affected.files.changed.message"), clashing); return false; } @@ -195,7 +195,7 @@ abstract class UndoRedo { boolean confirmSwitchTo(@NotNull UndoRedo other) { final boolean[] isOk = new boolean[1]; TransactionGuard.getInstance().submitTransactionAndWait(() -> { - String message = CommonBundle.message("undo.conflicting.change.confirmation.message") + "\n" + + String message = IdeBundle.message("undo.conflicting.change.confirmation") + "\n" + getActionName(other.myUndoableGroup.getCommandName()) + "?"; isOk[0] = Messages.showOkCancelDialog(myManager.getProject(), message, getActionName(), Messages.getQuestionIcon()) == Messages.OK; @@ -224,4 +224,4 @@ abstract class UndoRedo { return myUndoableGroup.isGlobal() && myUndoableGroup.isUndoable() && !getStackHolder().collectClashingActions(myUndoableGroup).isEmpty(); } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java index 1ad00576ba38..684ba5db6161 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java @@ -1,10 +1,10 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; -import com.intellij.CommonBundle; import com.intellij.diagnostic.Dumpable; import com.intellij.history.LocalHistory; import com.intellij.history.LocalHistoryAction; +import com.intellij.ide.IdeBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.UndoConfirmationPolicy; import com.intellij.openapi.command.undo.DocumentReference; @@ -106,7 +106,7 @@ class UndoableGroup implements Dumpable { } LocalHistoryAction action; if (myProject != null && isGlobal()) { - String actionName = CommonBundle.message(isUndo ? "local.vcs.action.name.undo.command" : "local.vcs.action.name.redo.command", myCommandName); + String actionName = IdeBundle.message(isUndo ? "undo.command" : "redo.command", myCommandName); action = LocalHistory.getInstance().startAction(actionName); } else { @@ -288,12 +288,12 @@ class UndoableGroup implements Dumpable { String message; if (isUndo) { - title = CommonBundle.message("cannot.undo.dialog.title"); - message = CommonBundle.message("cannot.undo.message"); + title = IdeBundle.message("cannot.undo.title"); + message = IdeBundle.message("cannot.undo.message"); } else { - title = CommonBundle.message("cannot.redo.dialog.title"); - message = CommonBundle.message("cannot.redo.message"); + title = IdeBundle.message("cannot.redo.title"); + message = IdeBundle.message("cannot.redo.message"); } if (!ApplicationManager.getApplication().isUnitTestMode()) { diff --git a/platform/platform-resources-en/src/messages/CommonBundle.properties b/platform/platform-resources-en/src/messages/CommonBundle.properties index 5fabef2dbf19..ec6fa5204cd9 100644 --- a/platform/platform-resources-en/src/messages/CommonBundle.properties +++ b/platform/platform-resources-en/src/messages/CommonBundle.properties @@ -120,21 +120,6 @@ format.file.size.mbytes={0}Mb thread.dump.is.taken=Thread dump is taken. failed.to.take.thread.dump=Failed to take a thread dump. -cannot.undo.dialog.title=Cannot Undo -cannot.undo.error.other.affected.files.changed.message=Following files affected by this action have been already changed: -cannot.undo.error.contains.nonundoable.changes.message=Following files have changes that cannot be undone: -undo.conflicting.change.confirmation.message=Other files affected by this action have been already changed. -undo.dialog.title=Undo -redo.command.confirmation.text=Redo {0} -redo.confirmation.title=Redo -undo.command.confirmation.text=Undo {0} -cannot.redo.dialog.title=Cannot Redo -drop.undo.history.command.name=Dummy -cannot.undo.message=Cannot undo -cannot.redo.message=Cannot redo -local.vcs.action.name.undo.command=Undo {0} -local.vcs.action.name.redo.command=Redo {0} - error.reading.color.scheme.from.file.error.message=Error reading color scheme from {0} button.background=&Background button.load.file=Load File diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 3158d1ab9b1c..ad2408caa8a1 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -1403,4 +1403,16 @@ navigate.command.search.reference.progress.title=Searching for reference ''{0}'' project.directory.is.not.writable=Directory ''{0}'' doesn't seem to be writeable. Please choose another location. project.directory.is.already.taken=Directory ''{0}'' is already taken by the project ''{1}''. Please choose another location. -project.directory.is.not.directory=File ''{0}'' is not a directory. Please choose another location. \ No newline at end of file +project.directory.is.not.directory=File ''{0}'' is not a directory. Please choose another location. + +undo.command=Undo {0} +redo.command=Redo {0} +undo.dialog.title=Undo +redo.dialog.title=Redo +cannot.undo.title=Cannot Undo +cannot.undo.message=Cannot undo +cannot.redo.title=Cannot Redo +cannot.redo.message=Cannot redo +undo.conflicting.change.confirmation=Other files affected by this action have been already changed. +cannot.undo.error.other.affected.files.changed.message=Following files affected by this action have been already changed: +cannot.undo.error.contains.nonundoable.changes.message=Following files have changes that cannot be undone: \ No newline at end of file