[vcs] [RD] IJPL-160237 Get rid of vcs-api dependency on the frontend side.

GitOrigin-RevId: 24d76803793805f2916fcbfab6d1b46707422bca
This commit is contained in:
Denis Zaichenko
2024-12-27 16:33:30 +00:00
committed by intellij-monorepo-bot
parent 4493c71cb4
commit d9705da367
10 changed files with 73 additions and 56 deletions
@@ -36,7 +36,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.vcs" />
<orderEntry type="module" module-name="intellij.platform.util.ui" />
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
<orderEntry type="module" module-name="intellij.platform.core.ui" />
@@ -0,0 +1,5 @@
changes.nodetitle.empty.changelist.name=<empty name>
shelve.default.path.rendering=<project root>
changes.nodetitle.changecount={0,choice, 0#No files|1#1 file|2#{0} files}
changes.nodetitle.directory.changecount={0,choice, 0#No directories|1#1 directory|2#{0} directories}
changes.nodetitle.directory.file.changecount={0,choice, 0#No directories|1#1 directory|2#{0} directories} and {1,choice, 0#no files|1#1 file|2#{1} files}
@@ -0,0 +1,20 @@
// Copyright 2000-2021 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.impl.frontend
import com.intellij.DynamicBundle
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
internal object VcsFrontendBundle {
const val BUNDLE: @NonNls String = "messages.VcsFrontendBundle"
val INSTANCE: DynamicBundle = DynamicBundle(VcsFrontendBundle::class.java, BUNDLE)
@JvmStatic
fun message(
key: @PropertyKey(resourceBundle = BUNDLE) String,
vararg params: Any,
): @Nls String {
return INSTANCE.getMessage(key, *params)
}
}
@@ -0,0 +1,26 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.impl.frontend
import com.intellij.openapi.components.*
import com.intellij.util.xmlb.XmlSerializerUtil
import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
@Service(Service.Level.PROJECT)
@State(name = "VcsFrontendConfiguration", storages = [Storage(StoragePathMacros.WORKSPACE_FILE)])
class VcsFrontendConfiguration : PersistentStateComponent<VcsFrontendConfiguration> {
var shelveDetailsPreviewShown: Boolean = false
override fun getState(): VcsFrontendConfiguration {
return this
}
override fun loadState(state: VcsFrontendConfiguration) {
XmlSerializerUtil.copyBean(state, this)
}
companion object {
@JvmStatic
fun getInstance(project: com.intellij.openapi.project.Project): VcsFrontendConfiguration = project.service()
}
}
@@ -14,9 +14,6 @@ import com.intellij.vcs.impl.frontend.changes.ChangesTree
import com.intellij.vcs.impl.shared.rhizome.RepositoryCountEntity
import com.jetbrains.rhizomedb.entities
import com.jetbrains.rhizomedb.entity
import fleet.kernel.rete.each
import fleet.kernel.rete.filter
import fleet.kernel.rete.first
import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
@@ -6,7 +6,6 @@ import com.intellij.openapi.application.EDT
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.SimpleToolWindowPanel
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vcs.VcsConfiguration
import com.intellij.openapi.vcs.changes.DiffPreview
import com.intellij.openapi.wm.ToolWindowId
import com.intellij.openapi.wm.ToolWindowManager
@@ -16,6 +15,7 @@ import com.intellij.ui.ScrollPaneFactory
import com.intellij.ui.components.panels.Wrapper
import com.intellij.util.ui.JBUI
import com.intellij.util.ui.components.BorderLayoutPanel
import com.intellij.vcs.impl.frontend.VcsFrontendConfiguration
import com.intellij.vcs.impl.frontend.changes.EDITOR_TAB_DIFF_PREVIEW
import com.intellij.vcs.impl.frontend.changes.actions.SHOW_DIFF_ACTION_ID
import com.intellij.vcs.impl.frontend.navigation.FrontendNavigateToSourceAction
@@ -40,7 +40,7 @@ class ShelfToolWindowPanel(private val project: Project, tree: ShelfTree, cs: Co
private val diffEditorPreview = ShelfTreeEditorDiffPreview(tree, cs, project)
private var splitterPreview: ShelveSplitterDiffPreview? = null
private val vcsConfiguration = VcsConfiguration.getInstance(project)
private val vcsConfiguration = VcsFrontendConfiguration.getInstance(project)
init {
mainPanelContent.setContent(shelvePanel)
@@ -65,7 +65,7 @@ class ShelfToolWindowPanel(private val project: Project, tree: ShelfTree, cs: Co
if (!isPanelVertical()) {
cs.launch(Dispatchers.EDT) {
splitterPreview = ShelveSplitterDiffPreview(splitterComponent)
DiffPreview.setPreviewVisible(splitterPreview!!, vcsConfiguration.SHELVE_DETAILS_PREVIEW_SHOWN)
DiffPreview.setPreviewVisible(splitterPreview!!, vcsConfiguration.shelveDetailsPreviewShown)
}
}
}
@@ -121,14 +121,14 @@ class ShelfToolWindowPanel(private val project: Project, tree: ShelfTree, cs: Co
inner class TogglePreviewAction() : ToggleAction() {
override fun isSelected(e: AnActionEvent): Boolean {
return vcsConfiguration.SHELVE_DETAILS_PREVIEW_SHOWN
return vcsConfiguration.shelveDetailsPreviewShown
}
override fun setSelected(e: AnActionEvent, state: Boolean) {
val preview = splitterPreview
if (preview != null) {
DiffPreview.setPreviewVisible(preview, state)
vcsConfiguration.SHELVE_DETAILS_PREVIEW_SHOWN = state
vcsConfiguration.shelveDetailsPreviewShown = state
}
}
@@ -1,39 +1,23 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.impl.frontend.shelf.tree;
import com.intellij.diagnostic.PluginException;
import com.intellij.ide.util.treeView.FileNameComparator;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.UserDataHolderEx;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.VfsPresentationUtil;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.DirtyUI;
import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.ObjectUtils;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.Convertor;
import com.intellij.util.containers.JBIterable;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.*;
import com.intellij.vcs.impl.frontend.VcsFrontendBundle;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.List;
import java.util.Objects;
import java.util.function.ToIntFunction;
import static com.intellij.util.FontUtil.spaceAndThinSpace;
@@ -145,7 +129,11 @@ public abstract class ChangesBrowserNode<T> extends DefaultMutableTreeNode imple
return (JBIterable<ChangesBrowserNode<?>>)iterable;
}
public void render(@NotNull JTree tree, @NotNull ChangesBrowserNodeRenderer renderer, boolean selected, boolean expanded, boolean hasFocus) {
public void render(@NotNull JTree tree,
@NotNull ChangesBrowserNodeRenderer renderer,
boolean selected,
boolean expanded,
boolean hasFocus) {
render(renderer, selected, expanded, hasFocus);
}
@@ -164,10 +152,10 @@ public abstract class ChangesBrowserNode<T> extends DefaultMutableTreeNode imple
if (dirCount != 0 || count != 0) {
result = spaceAndThinSpace() +
(dirCount == 0
? VcsBundle.message("changes.nodetitle.changecount", count)
? VcsFrontendBundle.message("changes.nodetitle.changecount", count)
: count == 0
? VcsBundle.message("changes.nodetitle.directory.changecount", dirCount)
: VcsBundle.message("changes.nodetitle.directory.file.changecount", dirCount, count));
? VcsFrontendBundle.message("changes.nodetitle.directory.changecount", dirCount)
: VcsFrontendBundle.message("changes.nodetitle.directory.file.changecount", dirCount, count));
}
return result;
@@ -205,5 +193,4 @@ public abstract class ChangesBrowserNode<T> extends DefaultMutableTreeNode imple
renderer.append(spaceAndThinSpace() + parentPath, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
}
}
@@ -4,16 +4,12 @@ package com.intellij.vcs.impl.frontend.shelf.tree;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.BooleanGetter;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.changes.FilePathIconProvider;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.DirtyUI;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.speedSearch.SpeedSearchUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.JBInsets;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -94,19 +90,6 @@ public class ChangesBrowserNodeRenderer extends ColoredTreeCellRenderer {
//}
}
public void setIcon(@NotNull FilePath filePath, boolean isDirectory) {
if (isDirectory) {
setIcon(PlatformIcons.FOLDER_ICON);
return;
}
Icon icon = FilePathIconProvider.EP_NAME.computeSafeIfAny(provider -> provider.getIcon(filePath, myProject));
if (icon != null) {
setIcon(icon);
return;
}
setIcon(VcsUtil.getIcon(myProject, filePath));
}
public void setBackgroundInsets(@Nullable JBInsets backgroundInsets) {
myBackgroundInsets = backgroundInsets;
}
@@ -1,10 +1,10 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.impl.frontend.shelf.tree
import com.intellij.openapi.vcs.VcsBundle
import com.intellij.ui.SimpleTextAttributes
import com.intellij.util.FontUtil
import com.intellij.util.text.DateFormatUtil
import com.intellij.vcs.impl.frontend.VcsFrontendBundle
import com.intellij.vcs.impl.shared.rhizome.ShelvedChangeListEntity
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.Nls
@@ -14,7 +14,7 @@ class ShelvedChangeListNode(private val changeList: ShelvedChangeListEntity) : E
override fun render(renderer: ChangesBrowserNodeRenderer, selected: Boolean, expanded: Boolean, hasFocus: Boolean) {
var listName = changeList.description
if (listName.isBlank()) listName = VcsBundle.message("changes.nodetitle.empty.changelist.name")
if (listName.isBlank()) listName = VcsFrontendBundle.message("changes.nodetitle.empty.changelist.name")
if (changeList.isRecycled || changeList.isDeleted) {
renderer.appendTextWithIssueLinks(listName, SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES)
}
@@ -5,10 +5,10 @@ import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vcs.FileStatus
import com.intellij.openapi.vcs.VcsBundle
import com.intellij.ui.SimpleTextAttributes
import com.intellij.util.FontUtil
import com.intellij.util.PathUtil
import com.intellij.vcs.impl.frontend.VcsFrontendBundle
import com.intellij.vcs.impl.frontend.changes.findFileStatusById
import com.intellij.vcs.impl.shared.rhizome.ShelvedChangeEntity
import org.jetbrains.annotations.ApiStatus
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nls
class ShelvedChangeNode(val entity: ShelvedChangeEntity) : EntityChangesBrowserNode<ShelvedChangeEntity>(entity) {
override fun render(renderer: ChangesBrowserNodeRenderer, selected: Boolean, expanded: Boolean, hasFocus: Boolean) {
val path = entity.filePath
val directory = StringUtil.defaultIfEmpty(PathUtil.getParentPath(path), VcsBundle.message("shelve.default.path.rendering"))
val directory = StringUtil.defaultIfEmpty(PathUtil.getParentPath(path), VcsFrontendBundle.message("shelve.default.path.rendering"))
val fileName = StringUtil.defaultIfEmpty(PathUtil.getFileName(path), path)
val fileStatus = findFileStatusById(entity.fileStatus) ?: FileStatus.MODIFIED
renderer.append(fileName, SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, fileStatus.color))