[QUESTION] How to access version control log ui

I want to de-select or remove the highlight for a commit.

I know there is ae.getData(VcsLogDataKeys.VCS_LOG_UI) but that requires VcsLogHighlighter for the method removeHighlighter(). How do I get VcsLogHighlighter.

Also Im not sure if that Class is what I need in order to un-highlight a commit. Can someone help me please?

Thanks in advance

4 comments
Comment actions Permalink

Hi, Kenneth! In short, the answer to your question would be "you can not remove highlighting for a specific commit".

In details:

Under the "Gear" button, there is a submenu "Highlight" with 3 items: "My Commits", "Merge Commits", "Current Branch". My commits are bold, merge commits are grey, commits from current branch have blue background. Each of these items corresponds to a VcsLogHighlighter instance. Plugins are not supposed to remove them, and IDEA 15 does not even have the VcsLogUi.removeHighlighter method. So, if you want to somehow alter an appearance of a commit, currently there are two options:

  1. Turn a highlighter off completely with VcsLogUi.setHighlighterEnabled method. Actually, this method is designed to turn on and off your own highlighters, so you need to know the id (String) of the highlighter to disable (which can be found in our code of course, but it is not the part of API). I'd think twice before using this, since a user of your plugin can be really surprised if, for example, his commits will suddenly stop being bold without his desire.
  2. The second option is to write your own VcsLogHighlighter and register it via VcsLogHighlighterFactory. This allows to specify a style for individual commits. But it is not possible to remove the existing highlighting. For example, if the commit is already bold, you can not make it not bold. And also, VcsLogHighlighterFactory is not in API.

We did not have the need for un-highlighting some individual commits, so if you could describe a little bit more why you need this, it would be really helpful.

0
Comment actions Permalink

Hi Julia,

Thanks for the reply. Sorry I didn't check my Intellij forum notifications on my second Gmail account and forgot I posted this on the forum completely.

So my problem was the plugin I was developing was supposed to open all working copies of a commit and after it opened all the files in the file editor it would focus on the editor and not the log tab. But I wanted to handle the use case of a developer unintentionally pressing the custom shortcut a second time to open files from the same commit. In this situation the focus would be on the code editor and not the log tab (in my code) with the still highlighted commit, so it would return a 'please select a commit' message in the plugin code which is confusing as the developer/user can see that the commit is still highlighted.

Hope the explanation gives context to my question.

But saying all this, dont worry about the un-highlighting. I needed it for a plugin I was developing but didn't realise the plugin already exists natively out of the box, (F4 shortcut) for a commit.

My fault for not Googling about it but was a fun experience developing it with Java 8 for the first time nevertheless.

This is my Github plugin I submitted but withdrew after I knew it already existed. A bit embarrassing for sure haha.

Thanks so so much for the reply though, learned something either way :)

I might as well let you have a look if you are curious (hopefully). I did submit this plugin but withdrew it after I realised there was a native intellij feature already there.

https://github.com/ManiacViper/LazyDev.git  

Curious if you have a Github account I can follow? I want some inspiration for coding in my spare time and I don't mind getting it from a developer from Jetbrains (I assume).

0
Comment actions Permalink

Hi, Kenneth,

 

Thank you for explaining your use case. I think what you might want is to deselect the commit rather than unhighlight. We use term "highlight" for describing changing appearance of specific commits, for example we use bold text for commits made by current user, and blue background for commits in the current branch. Selected commit is a commit that user selects by clicking on it or using arrow buttons. 

 

But I do not think that deselecting a commit is appropriate for this case. You should rather implement update method in your action and check that log is available there. Like in GoToHashOrRefAction we check that a project, a log and a log ui is availabe in the context, and set action to be disabled and invisible if one of them is not. So the action can not be called when focus is not in the log. You can read this article, specifically "Setting up action’s visibility and availability" section explaining it in more details.

 

Also, note that getSelectedDetails method may return instances of LoadingDetails (without any useful information except hash). This happens because we do not keep all the details in memory (to many of them), but load them on demand. For your task you should use VcsDataKeys.SELECTED_CHANGES key that return the same changes as seen in changes view, they are already properly collected.

 

My github account is https://github.com/juliabeliaeva, you can follow if you'd like, but I can not guarantee it to be very inspirational:)

 

0
Comment actions Permalink

Hey Julia,

Nice one. Didn't check all the pre-existing Action classes like GoToHashOrRefAction. Very useful for what I'm doing.

Yes if the action can be disabled, that would be great. The article is useful, the update method may be the way to go for me.

Just need to think of another use for this plugin as opening working copy files in a commit already exists lol. :)

And talking about your Github account, 

JetSprinkler

has me inspired already! :)

Been thinking of Raspberry Pi or Arduino. 

0

Please sign in to leave a comment.