Find component on appStarting from AppLifecycleListener

Answered

How would I achieve something like this from the appStarting method implemented by the AppLifecycleListener interface?

I find a StartupActivity a bit too late for my code execution :(

Simple example: 

UIUtil.findComponentOfType(ideComponent, JMenuBar.class)

Thanks in advance

3 comments
Comment actions Permalink

What feature do you want to build exactly?

0
Comment actions Permalink

Simple example to better understand my problem.

Lets say I create rainbow menu titles (every menuItem a different color). I use a startUpActivity, find the appropriate type component (with findComponentOfType) and patch it with a color.

Problem: The default colored titles would be shown first --> project opens --> new styling gets applied. Would look nicer to have this styling applied on application startup to prevent a switch from old to new. The menubar is visible on startup, so I assume it can accessed. 

I use the IDE as a parent component to find components, but since AppLifecycleListener doest have a method that provides me with a project (to access the IDE component) I have no idea what other parent component I can use (retrieve from code) in order to start a search.

Component ideComponent = WindowManager.getInstance().getIdeFrame(project).getComponent;
UIUtil.findComponentOfType(ideComponent, class)

 

0
Comment actions Permalink

Peter,

The getIdeFrame method allows passing null as a project parameter:

public abstract @Nullable IdeFrame getIdeFrame(@Nullable Project project);

If so, another approach is used for obtaining the IdeFrame instance.
Check the WindowManagerImpl class for more details.

0

Please sign in to leave a comment.