[vcs-log] rename isMultipleRoots to hasMultiplePaths and add default implementation

GitOrigin-RevId: 3cb58d9ba27ccdcb252314d4c1476aa9c0287932
This commit is contained in:
Julia Beliaeva
2019-06-14 23:06:19 +03:00
committed by intellij-monorepo-bot
parent 777ce06b14
commit cb501335b3
10 changed files with 16 additions and 19 deletions
@@ -12,6 +12,6 @@ class SetRepositoryChangesGroupingAction : SetChangesGroupingAction() {
override fun update(e: AnActionEvent): Unit = super.update(e).also {
val colorManager = e.project?.let(::getColorManager)
e.presentation.isEnabledAndVisible = e.presentation.isEnabledAndVisible && colorManager?.isMultipleRoots ?: false
e.presentation.isEnabledAndVisible = e.presentation.isEnabledAndVisible && colorManager?.hasMultiplePaths() ?: false
}
}
@@ -44,7 +44,7 @@ public class VcsLogFeaturesCollector extends ProjectUsagesCollector {
addEnumUsage(properties, defaultProperties, usages, "sort", BEK_SORT_TYPE);
if (ui.getColorManager().isMultipleRoots()) {
if (ui.getColorManager().hasMultiplePaths()) {
addBooleanUsage(properties, defaultProperties, usages, "roots", CommonUiProperties.SHOW_ROOT_NAMES);
}
@@ -32,7 +32,9 @@ public interface VcsLogColorManager {
/**
* Tells if there are several paths currently shown in the log.
*/
boolean isMultipleRoots();
default boolean hasMultiplePaths() {
return getPaths().size() > 1;
}
/**
* Returns paths managed by this manager.
@@ -56,12 +56,7 @@ public class VcsLogColorManagerImpl implements VcsLogColorManager {
public static JBColor getBackgroundColor(@NotNull final Color baseRootColor) {
return new JBColor(() -> ColorUtil.mix(baseRootColor, UIUtil.getTableBackground(), 0.75));
}
@Override
public boolean isMultipleRoots() {
return myPaths2Colors.size() > 1;
}
@NotNull
@Override
public Color getPathColor(@NotNull FilePath path) {
@@ -149,7 +149,7 @@ public class GoToHashOrRefPopup {
@Override
public LookupElementBuilder createLookupBuilder(@NotNull VcsRef item) {
LookupElementBuilder lookupBuilder = super.createLookupBuilder(item);
if (myColorManager.isMultipleRoots()) {
if (myColorManager.hasMultiplePaths()) {
ColorIcon icon = JBUI.scale(new ColorIcon(15, VcsLogGraphTable.getRootBackgroundColor(item.getRoot(), myColorManager)));
lookupBuilder = lookupBuilder.withTypeText(getTypeText(item), icon, true).withTypeIconRightAligned(true);
}
@@ -165,14 +165,14 @@ public class GoToHashOrRefPopup {
@Nullable
@Override
protected String getTailText(@NotNull VcsRef item) {
if (!myColorManager.isMultipleRoots()) return null;
if (!myColorManager.hasMultiplePaths()) return null;
return "";
}
@Nullable
@Override
protected String getTypeText(@NotNull VcsRef item) {
if (!myColorManager.isMultipleRoots()) return null;
if (!myColorManager.hasMultiplePaths()) return null;
String text = myCachedRootNames.get(item.getRoot());
if (text == null) {
return VcsImplUtil.getShortVcsRootName(myProject, item.getRoot());
@@ -38,6 +38,6 @@ public class ShowRootsColumnAction extends BooleanPropertyToggleAction {
public void update(@NotNull AnActionEvent e) {
super.update(e);
VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
if (ui == null || !((AbstractVcsLogUi)ui).getColorManager().isMultipleRoots()) e.getPresentation().setEnabledAndVisible(false);
if (ui == null || !((AbstractVcsLogUi)ui).getColorManager().hasMultiplePaths()) e.getPresentation().setEnabledAndVisible(false);
}
}
@@ -176,7 +176,7 @@ class StructureFilterPopupComponent extends FilterPopupComponent<FilterPair<VcsL
Set<VirtualFile> roots = getAllRoots();
List<AnAction> rootActions = new ArrayList<>();
if (myColorManager.isMultipleRoots()) {
if (myColorManager.hasMultiplePaths()) {
for (VirtualFile root : ContainerUtil.sorted(roots, FILE_BY_NAME_COMPARATOR)) {
rootActions.add(new SelectVisibleRootAction(root));
}
@@ -298,7 +298,7 @@ public class CommitPanel extends JBPanel {
}
public void setRoot(@NotNull VirtualFile root) {
if (myColorManager.isMultipleRoots()) {
if (myColorManager.hasMultiplePaths()) {
JBColor color = VcsLogGraphTable.getRootBackgroundColor(root, myColorManager);
myIcon = JBUI.scale(new ColorIcon(ROOT_ICON_SIZE, color));
myTooltipText = root.getPath();
@@ -162,7 +162,7 @@ public class GraphTableController {
CommitId commitId = myLogData.getCommitId(commit);
if (commitId != null) {
balloonText = "Jump to commit" + " " + commitId.getHash().toShortString();
if (myColorManager.isMultipleRoots()) {
if (myColorManager.hasMultiplePaths()) {
balloonText += " in " + commitId.getRoot().getName();
}
}
@@ -208,7 +208,7 @@ public class GraphTableController {
}
private void performRootColumnAction() {
if (myColorManager.isMultipleRoots() && myProperties.exists(CommonUiProperties.SHOW_ROOT_NAMES)) {
if (myColorManager.hasMultiplePaths() && myProperties.exists(CommonUiProperties.SHOW_ROOT_NAMES)) {
VcsLogUsageTriggerCollector.triggerUsage("RootColumnClick");
myProperties.set(CommonUiProperties.SHOW_ROOT_NAMES, !myProperties.get(CommonUiProperties.SHOW_ROOT_NAMES));
}
@@ -398,7 +398,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
private void setRootColumnSize() {
TableColumn column = getRootColumn();
int rootWidth;
if (!myColorManager.isMultipleRoots()) {
if (!myColorManager.hasMultiplePaths()) {
rootWidth = 0;
}
else if (!isShowRootNames()) {
@@ -669,7 +669,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
if (lastRow >= 0) {
g.setColor(getStyle(lastRow, convertColumnIndexToView(COMMIT_COLUMN), hasFocus(), false).getBackground());
g.fillRect(x, y, width, height);
if (myColorManager.isMultipleRoots()) {
if (myColorManager.hasMultiplePaths()) {
g.setColor(getPathBackgroundColor((FilePath)getModel().getValueAt(lastRow, ROOT_COLUMN), myColorManager));
int rootWidth = getRootColumn().getWidth();