Adding Text to a custom Action version compatibility issue for 2024.2 and 2024.3

Answered

Hi Team,

Currently I am facing an issue regarding custom implementation of AnAction class

The issue is caused when I am trying to show text in my custom action.
and due to change in plugin libraries in 2024.2 and 2024.3 version,  my plugin is unable to support both of them but I am forced to support any one of the version

for 2024.2 Custom action implementation is  :

public class Action extends AnAction {

  public Action(String text, Icon icon) {
    super(text, StringUtils.EMPTY, icon);
  }

  @Override
  public void actionPerformed(@NotNull AnActionEvent e) {
      doSomething();
  }

 @Override
 public boolean displayTextInToolbar() {
   return true;
 }

  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.putClientProperty(ActionUtil.SHOW_TEXT_IN_TOOLBAR, true);
  }

  @Override
  public @NotNull ActionUpdateThread getActionUpdateThread() {
    return ActionUpdateThread.EDT;
  }
}

for 2024.3 implementation is like:

public class Action extends AnAction {

  public Action(String text, Icon icon) {
    super(text, StringUtils.EMPTY, icon);
  }

  @Override
  public void actionPerformed(@NotNull AnActionEvent e) {
      doSomething();
  }

  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.putClientProperty(ActionUtil.SHOW_TEXT_IN_TOOLBAR, true);
  }

  @Override
  public @NotNull ActionUpdateThread getActionUpdateThread() {
    return ActionUpdateThread.EDT;
  }
}

So based on the above implementation if i opt for 2024.2 version
I am overriding displayTextInToolbar() method but the same gets depriciated in 2024.3

if I opt for 2024.3 and override update() method 
I am unable to use ActionUtil.SHOW_TEXT_IN_TOOLBAR because this is not available on the previous version

Is there any other way around this?

 

0
4 comments

Hi,

Please use displayTextInToolbar() in your case and migrate to SHOW_TEXT_IN_TOOLBAR when your lowest supported version contains it.

Deprecation doesn't mean that the method mustn't be used. There will be a transition period before it is removed from the API.

0

Hi Karol,

Thanks for the information.

0

Hi Karol,

The IDE versions that my plugin supports is 242 and above

I have one more question, for my current implementation I have used SHOW_TEXT_IN_TOOLBAR and found an workaround to avoid the NoSuchFeildError but when my plugin is submitted for compatibility verification, I got the following warnings
 

 

So if I roll back to the deprecated method displayTextInToolbar() and submit it again for verification, I should be getting this method is deprecated and marked for removal warning, so the deprecated warning that will be occurring is it something that I have to fix it before the release or can it be consider in the future when my plugin supports 243 and above  and can I implement the deprecated method and submit it for release?

0

Hi,

You don't need to fix it to release the plugin. It can be fixed later when your plugin's minimal supported version contains the new API.

0

Please sign in to leave a comment.