I want to create a plugin for IntelliJ Idea, which puts a little button into the status bar.
AFAIK the code for this must look like this:
final StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
final StatusBarWidget widget = new WordCounterWidget();
statusBar.addWidget(widget);
WordCounterWidget is the button I want to place into the status bar.
I tried to put it
None of this brought the expected result -- the button is not shown.
Is the above code for inserting a button (or anything else that can display text and is clickable) correct? If yes, where should I put it so that it's executed whenever a project is opened, re-opened, or created (the status bar widget should be visible all the time when there is a project open in Idea)?
The code is here .
Update 1: Tried to change the code of WordCounterServiceImpl to
public class WordCounterServiceImpl implements WordCounterService {
private final Project project;
public WordCounterServiceImpl(final Project project) {
this.project = project;
}
@Override
public void projectOpened() {
final StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
final StatusBarWidget widget = new WordCounterWidget();
statusBar.addWidget(widget);
}
}
The button is still not shown.
com.intellij.openapi.components.ProjectComponent#projectOpened
请参阅: https : //www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_components.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.