Trying to reuse the diff view at a different place

There already is the possibility e.g. in the VCS toolwindow's log tab to select a single file and open the diff window for it.

I'd like to try to place the contents of that window at a different place or in a different ui container, i.e. not in that modal window/dialog but say it in a splitpanels second place.

I can't seem however to understand how to get a hold on the component rendering that diff.

Any hints appreciated :)

0
8 comments

Do you mean, exactly same content? Why do you need it? (ex: it is possible to detach toolwindow into a separate window)

If you need your own diff view, you can use `com.intellij.diff.DiffManager#createRequestPanel`.
Also, see discussion in https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000508990-how-to-invoke-the-built-in-diff-action

0

I checked your link and found the sample usage at https://github.com/JetBrains/intellij-community/blob/master/java/java-impl/src/com/intellij/refactoring/extractMethod/SignatureSuggesterPreviewDialog.java, indeed this works for simple diffs.

But I was not precise anyway, so what I really want to achieve is to take the existing diff feature from the change lists for changes in the vcs, or as well the diff preview for local changes and instead of having a modal window (like the currend cmd+d or show diff action or show diff preview action) to place this very same thing somewhere else.

However I did not manage to grasp if ChangeViewDiffRequestProcessor and the like are my way to go. You said something about detaching? How would I do that?

0

To be even more precise, ideally I want to place the diff preview already available for local changes:

somehow into the log tab as well, e.g. like this:

 

0

If you want exactly same data, you can look at `com.intellij.openapi.vcs.changes.ui.ChangesListView` and `com.intellij.openapi.vcs.changes.ChangesViewManager`, where this component is implemented. 
Notable parts are building the tree with `TreeModelBuilder` and `MyChangeProcessor` for diff preview.
Also, you'll need `com.intellij.openapi.vcs.changes.ChangeListListener` to refresh tree on changes (ChangesViewManager is refreshed externally).

Detaching toolwindow: https://www.jetbrains.com/help/idea/tool-windows-viewing-modes.html

0

So, the idea is to have diff preview for commits in Log tab (not for local changes) ?

0

Related youtrack issue: https://youtrack.jetbrains.com/issue/IDEA-100234

Unfortunately, log tab is not pluggable.
You can still try to do this, but it'll require reflection and injecting into existing swing layouts, thus prone to be broken even in minor IDE releases. (So I am discouraging you from doing this)

Starting points (in case you ignore the warning and want to hack your way through):
`com.intellij.vcs.log.ui.frame.VcsLogChangesBrowser` (see `getDiffRequestProducer` / `showDiff` on how to get `DiffRequestChain`),
`com.intellij.diff.impl.CacheDiffRequestChainProcessor` (simpler version of `ChangeViewDiffRequestProcessor` - without synchronisation with selection in tree)
`com.intellij.vcs.log.ui.frame.MainFrame` (UI to embed into), 
`ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS)`, `VcsLogContentProvider.TAB_NAME` and `com.intellij.util.ContentUtilEx#findTabbedContent` to find the log window.


0

Understood, thanks for your guidance anyway.

Maybe IntelliJ 2018 considers https://youtrack.jetbrains.com/issue/IDEA-100234 :)

0

Please sign in to leave a comment.