diff --git a/platform/vcs-log/api/resources/messages/VcsLogBundle.properties b/platform/vcs-log/api/resources/messages/VcsLogBundle.properties index 14bc91e43572..f7e8c394ed39 100644 --- a/platform/vcs-log/api/resources/messages/VcsLogBundle.properties +++ b/platform/vcs-log/api/resources/messages/VcsLogBundle.properties @@ -156,3 +156,9 @@ vcs.log.filter.tooltip.click.to.see.only={0}+Click to see only \\"{1}\\" vcs.log.filter.tooltip.no.roots.selected=No Roots Selected vcs.log.filter.tooltip.roots=Roots: vcs.log.filter.tooltip.folders=Folders: +graph.sort.linear=Linear +graph.sort.linear.description=In case of merge show incoming commits on top of main branch commits as if they were rebased +graph.sort.standard=Standard +graph.sort.standard.description=In case of merge show incoming commits first (directly below merge commit) +graph.sort.off=Off +graph.sort.off.description=Sort commits topologically and by date diff --git a/platform/vcs-log/graph-api/src/com/intellij/vcs/log/graph/PermanentGraph.java b/platform/vcs-log/graph-api/src/com/intellij/vcs/log/graph/PermanentGraph.java index 83d84244079a..ba3a4c017b7f 100644 --- a/platform/vcs-log/graph-api/src/com/intellij/vcs/log/graph/PermanentGraph.java +++ b/platform/vcs-log/graph-api/src/com/intellij/vcs/log/graph/PermanentGraph.java @@ -16,7 +16,6 @@ package com.intellij.vcs.log.graph; import com.intellij.openapi.util.Condition; -import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -61,15 +60,14 @@ public interface PermanentGraph { Condition getContainedInBranchCondition(@NotNull Collection currentBranchHead); enum SortType { - Normal("Off", "Sort commits topologically and by date"), - Bek("Standard", "In case of merge show incoming commits first (directly below merge commit)"), - LinearBek("Linear", "In case of merge show incoming commits on top of main branch commits as if they were rebased"); + Normal("Off", "Sort commits topologically and by date"), // NON-NLS + Bek("Standard", "In case of merge show incoming commits first (directly below merge commit)"), // NON-NLS + LinearBek("Linear", "In case of merge show incoming commits on top of main branch commits as if they were rebased"); // NON-NLS @NotNull private final String myPresentation; @NotNull private final String myDescription; - SortType(@NotNull @Nls(capitalization = Nls.Capitalization.Title) String presentation, - @NotNull @Nls(capitalization = Nls.Capitalization.Sentence) String description) { + SortType(@NotNull String presentation, @NotNull String description) { myPresentation = presentation; myDescription = description; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserPopupAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserPopupAction.java index b6d401b6a236..7dbcd3dc3f2b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserPopupAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserPopupAction.java @@ -16,6 +16,7 @@ import com.intellij.vcs.log.graph.PermanentGraph; import com.intellij.vcs.log.impl.MainVcsLogUiProperties; import com.intellij.vcs.log.impl.VcsLogUiProperties; import com.intellij.vcs.log.ui.VcsLogInternalDataKeys; +import com.intellij.vcs.log.util.GraphSortPresentationUtil; import icons.VcsLogIcons; import org.jetbrains.annotations.NotNull; @@ -55,8 +56,8 @@ public class IntelliSortChooserPopupAction extends DumbAwareAction { VcsLogUiProperties properties = e.getData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES); e.getPresentation().setEnabled(properties != null); if (properties != null && properties.exists(MainVcsLogUiProperties.BEK_SORT_TYPE)) { - String description = VcsLogBundle.message("vcs.log.action.intellisort.title", - properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE).getName()); + String sortName = GraphSortPresentationUtil.getLocalizedName(properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE)); + String description = VcsLogBundle.message("vcs.log.action.intellisort.title", sortName); e.getPresentation().setDescription(description); e.getPresentation().setText(description); } @@ -70,7 +71,9 @@ public class IntelliSortChooserPopupAction extends DumbAwareAction { SelectIntelliSortTypeAction(@NotNull VcsLogUi ui, @NotNull VcsLogUiProperties properties, @NotNull PermanentGraph.SortType sortType) { - super(sortType.getName(), sortType.getDescription() + ".", null); + super(() -> GraphSortPresentationUtil.getLocalizedName(sortType), + () -> GraphSortPresentationUtil.getLocalizedDescription(sortType) + ".", + null); myUI = ui; myProperties = properties; mySortType = sortType; diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserToggleAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserToggleAction.java index b15ca4a16ada..5e53997ae882 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserToggleAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/IntelliSortChooserToggleAction.java @@ -27,6 +27,7 @@ import com.intellij.vcs.log.impl.MainVcsLogUiProperties; import com.intellij.vcs.log.impl.VcsLogUiProperties; import com.intellij.vcs.log.ui.VcsLogInternalDataKeys; import com.intellij.vcs.log.util.BekUtil; +import com.intellij.vcs.log.util.GraphSortPresentationUtil; import icons.VcsLogIcons; import org.jetbrains.annotations.NotNull; @@ -66,11 +67,15 @@ public class IntelliSortChooserToggleAction extends ToggleAction implements Dumb e.getPresentation().setEnabled(BekUtil.isBekEnabled() && logUI != null); if (properties != null && properties.exists(MainVcsLogUiProperties.BEK_SORT_TYPE)) { - String description = properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE) == PermanentGraph.SortType.Normal ? - VcsLogBundle.message("vcs.log.action.turn.intellisort.on", - StringUtil.toLowerCase(PermanentGraph.SortType.Bek.getDescription())) : - VcsLogBundle.message("vcs.log.action.turn.intellisort.off", - StringUtil.toLowerCase(PermanentGraph.SortType.Normal.getDescription())); + String description; + if (properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE) == PermanentGraph.SortType.Normal) { + String localizedDescription = GraphSortPresentationUtil.getLocalizedDescription(PermanentGraph.SortType.Bek); + description = VcsLogBundle.message("vcs.log.action.turn.intellisort.on", StringUtil.toLowerCase(localizedDescription)); + } + else { + String localizedDescription = GraphSortPresentationUtil.getLocalizedDescription(PermanentGraph.SortType.Normal); + description = VcsLogBundle.message("vcs.log.action.turn.intellisort.off", StringUtil.toLowerCase(localizedDescription)); + } e.getPresentation().setDescription(description); e.getPresentation().setText(description); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/util/GraphSortPresentationUtil.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/util/GraphSortPresentationUtil.kt new file mode 100644 index 000000000000..fb91ef12a3ff --- /dev/null +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/util/GraphSortPresentationUtil.kt @@ -0,0 +1,25 @@ +// Copyright 2000-2020 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.vcs.log.util + +import com.intellij.vcs.log.VcsLogBundle +import com.intellij.vcs.log.graph.PermanentGraph + +object GraphSortPresentationUtil { + + @JvmStatic + val PermanentGraph.SortType.localizedName: String + get() = when (this) { + PermanentGraph.SortType.Normal -> VcsLogBundle.message("graph.sort.off") + PermanentGraph.SortType.Bek -> VcsLogBundle.message("graph.sort.standard") + PermanentGraph.SortType.LinearBek -> VcsLogBundle.message("graph.sort.linear") + } + + @JvmStatic + val PermanentGraph.SortType.LocalizedDescription: String + get() = when (this) { + PermanentGraph.SortType.Normal -> VcsLogBundle.message("graph.sort.off.description") + PermanentGraph.SortType.Bek -> VcsLogBundle.message("graph.sort.standard.description") + PermanentGraph.SortType.LinearBek -> VcsLogBundle.message("graph.sort.linear.description") + } +} +