How can i run plugin from startup in background?
Hello ,
It gonna be mine first plugin so everything is new for me,
I have successfully created a plugin which runs on some actions
but now what i want to do is run the plugin after IDE starts in background,
get the current opened file, add some icons on bar of line numbers and on click so some popup
also api to access notifier of IDE, can any one share link or show me path to move forward on my issues.
Thank you
请先登录再写评论。
>but now what i want to do is run the plugin after IDE starts in background,
com.intellij.openapi.components.ProjectComponent / ApplicationComponent
Will be called when project / application are opened/closed.
http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_components.html
>get the current opened file
com.intellij.openapi.fileEditor.FileEditorManager#getSelectedTextEditor
com.intellij.openapi.fileEditor.FileEditorManagerListener
ex: project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyEditorManagerListener());
But it's probably not what you want to do. Could you describe your use case in more detail?
>add some icons on bar of line numbers and on click so some popup
com.intellij.openapi.editor.markup.GutterIconRenderer
Ex:
http://www.jetbrains.org/intellij/sdk/docs/reference_guide/work_with_icons_and_images.html
http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/creating_an_action.html
>also api to access notifier of IDE
com.intellij.notification.Notification
ex: new Notification("SomeNotificationGroup", "Notification Title", "More text<br>with description", NotificationType.ERROR).notify(project);
http://www.jetbrains.org/intellij/sdk/docs/user_interface_components/notifications.html
Thank you aleksey for this help,
Can you provide me some help on accessing database to store data and api of VCS(GIT) like getting of current branch
>api of VCS(GIT) like getting of current branch
git4idea.repo.GitRepository
git4idea.commands.Git
4ex: GitUtil.getRepositoryManager(project).getRepositories(), GitRepository#getCurrentBranch
There are some VCS-agnostic APIs (mostly accessed via AbstractVcs class), but "current branch" and many others have no abstraction.
see: com.intellij.vcsUtil.VcsUtil#getVcsFor
Please, remember to add "<depends>Git4Idea</depends>" to plugin.xml if you rely on git4idea package. (to avoid confusing errors if this plugin is disabled)
>on accessing database to store data
Are you looking for access to DataGrip-related functionality, or just persisting plugin-related data on disk?
Just to store plugin related data ,
I hope there is key value pair kind of data store.
Thank you
>key value pair kind of data store.
com.intellij.openapi.components.PersistentStateComponent
http://www.jetbrains.org/intellij/sdk/docs/basics/persisting_state_of_components.html
Thank You very much Aleksey!