I am currently at the move to write an IntelliJ plugin. I want to be able to store/restore a set of tabs to switch between different tab sessions (comparable to browser plugins like Session Manager or Session Buddy).
Therefore i need basically three types of actions:
- Read open tabs (which file and editor is used?)
- Store that information persistently as a tab session
- Open tabs of selected session and close all others
I looked at the available actions: IdeActions.java - it seems that there is not what i am searching for. But maybe i am looking at the wrong place. Can anyone tell me if what's i am trying to achieve is possible and give me some pointers in the right direction?
Update
I succesfully created the plugin and it's available at Github: http://alp82.github.com/idea-tabsession/
It is available in the official plugin repository: Tab Session.
Update 2
Here is a follow-up question regarding splitted windows: Retrieving and setting split window settings
Update 2017
I discontinue support for this plugin because IDEA already supports that feature. You can save and load contexts easily as shown here: https://github.com/alp82/idea-tabsession#discontinued
Update
The plugin is up and ready and can be downloaded in IDEA -> Settings -> Plugins. Source code is available at: https://github.com/alp82/idea-tabsession
Short Answer
To read which tabs are open right now, use the
EditorFactory
andFileDocumentManager
Singletons:To open tabs use the
FileEditorManager
singleton (files
being a String Array of canonical paths):Long Answer
Prerequisites
Checkout IDEA Community Edition sources to any folder:
Configure IDEA SDK and create plugin
Plugin Structure
After you have created your plugin you need to edit your plugin.xml located in the META-INF folder. Modify the
id
,name
anddescription
.We need a configuration file for persistant storage. Create a
mystorage.xml
file in yoursrc
folder. It's now time to create the needed files:SessionComponent.java (create it with the
Add Project Component
wizard to automatically create the needed xml settings):We also need the storage class:
The component class should have an entry in your plugin.xml like this one:
The component class offers all needed functionality, but is never be used. Therefore, we need actions to perform loading and saving:
Save.java:
Load.java:
Aaand... Action!
Last thing we need is the user interface to select those actions. Simply put this in your
plugin.xml
:Plugin Deployment
The basic functionality is ready. I will add support for multiple sessions and some other neat stuff before deploying this plugin and releasing it to the open-source community. Link will be posted here, when it's online.