[ANN] OpenInIDEA Plugin version 0.5.1

Hello IDEA fans,

I have just released the first version of the OpenInIDEA plugin. This plugin allows opening a Java or other file in the IDE by double clicking on the file in Windows explorer. The way the plugin works is not too complicated:

The plugin consists of a client and a server component, both included in the OpenInIDEA.jar archive which is installed in the normal plugin directory (typically via the plugin manager).

The server component is a Java Thread started by the OpenInIdeaPlugin (which is the a ProjectComponent registered for the plugin). This Thread listens on a configurable port for requests from the client.

The client is a standalone Java application whose main() method takes the path of a file and basically sends this path to the server which in turn attempts to open it.

Now, the user can use the file association mechanism of the operating system to "open" files having a certain extension (e.g. ".java") with the plugin's client application. Also, depending on the OS, a context menu entry of the file browser can be configured which attempts to "open" ANY file with the client application.

In order to ease the creation of these file associations, the plugin contains a "helper" class which creates Windows batch files for setting up the necessary registry entries. This helper class will also create .ico files from IDEA's file type icons that may be linked to the file types.

These .bat and .ico files will be created in the etc subdirectory of the plugin's base directory, i.e. the subdirectory named OpenInIDEA of whereever the plugin manager installs plugins.

THE BATCH FILES CREATED COME WITH NO WARRANTY AND ARE USED AT THE USER'S OWN RISK. IN PARTICULAR, THEY MAY OVERRIDE EXISTING REGISTRY SETTINGS THAT YOU MAY WANT TO BACKUP BEFORE EXECUTING THE SCRIPTS!

MOREOVER, THE FILE ASSOCIATIONS WILL CAUSE THE FILES TO BE OPENED WITH THE IDEA JRE AND THE OpenInIDEA.jar ARCHIVE IN THE CLASSPATH. BOTH THESE SETTINGS MAY BECOME INVALID WHEN YOU DELETE OR MOVE YOUR IntelliJ IDEA INSTALLATION, SO THE ASSOCIATION MAY STOP WORKING THEN!

As mentioned above, the current version is the first public release, and the plugin's state is probably not more than late alpha. There are a number of issues with this release that I would like to see solved but will probably need some help from you:

1. The helper class use to set up the registry scripts is available for Windows machines only

I have neither access to Unix or Mac computers (or at least machines running IntelliJ IDEA), and much less knowledge of how (and even if at all) file associations work on these operating systems. I would appreciate any hint or sample files from you experts here.

2. The registry scripts for Windows may not be optimal

First, as mentioned above, the scripts do not create a backup of possibly already existing registry entries before setting up the association with the OpenInIDEA client application. I am also not an expert on the reg program; anybody with more knowlegde might help me on that. Also, there may be issues with user access rights on Windows involved that may have to be taken into consideration.
Secondly, the etc subdirectory of the plugins base directory may not be an ideal place for putting the batch files; if you have any alternative suggestions, please let me know.

3. The license situation regarding the .ico files is unclear (to me)

IANAL, so I am not sure whether the use of IDEA's file type icons (they are converted into the .ico files by a third party library) is in compliance with IDEA's licenses. If there are any problems, please let me know; in that case I will remove that part of the plugin.

4. IDEA is not getting focus after opening a file

Even though the run() method of the OpenFile class includes a call to JFrame.requestFocus(), the IDEA button in the task bar only rarely does in fact flash after a file has been opened. Maybe someone from JetBrains can give me a clue why (and how to improve the behavior)?

5. OpenInIDEA cannot handle files of unknown type

When I developed the plugin, I was of course looking at its "closest cousin", the DragNDrop plugin. This plugin manages to associate files of unknown types with the "text" file type temporarily. I tried to do this as well, (by calling FileTypeManager.associateExtension()), but I always got IDEA assertion errors telling me "Write access is allowed inside write-action only"). Can someone tell me how to avoid this?

6. Project selection is rather fragile

If the client asks the server to open a file, then the server will first check whether there is exactly one project opened in which case it will go ahead and open it. In the case where multiple projects are active, it will send a list of the projects' URLs back to the client which will then bring up a popup menu from which the user can select the correct project.
This approach is a bit problematic as I currently see no way of forcing this popup menu to be displayed in the foreground (and much less remain there). I have thought about shifting this selection process entirely to the server instead. Any comments or suggestions?

7. Project selection popup menu is placed at fixed location

Related to the previous issue is the fact that I wasn't able to place the popup menu for the project selection next to the current mouse position since I could not determine that position (note that the popup is produces outside of any Swing Window or Frame context, so I would have been interested in obtaining the mouse position relative to the screen, and have no idea how to achieve that).

Aside from all these issues, there are a few minor things such as some more configuration options, additional documentation, screenshots and such, but I would prefer to get some of the above issues fixed first.

As you can see, there is still plenty of room for improvements. The plugin is licensed under the Apache License, so you can (and are cordially invited to) contribute to it. I have placed the sources in the SVN repository at googlecode; the home page of the project is http://code.google.com/p/openinidea
Unfortunately, my company firewall does not let me upload files to googlecode, so I won't be able to put the documentation there until I get home. However, you will get the sources as part of the installed plugin (to be found in OpenInIDEA/src).

I hope you will enjoy testing the plugin and give me plenty of feedback!

Best regards,
Jens

2 comments

For point 5, you need to wrap whatever you're doing in a Runnable and then have IDEA invoke it for you:

ApplicationManager.getApplication().runWriteAction(new Runnable()
{
public void run()
{
// your logic
}
}

Similarly, there is also a
ApplicationManager.getApplication().runReadAction(Runnable) method.

Note that you can also use the Computable interface in place of Runnable.

HTH,
Steve

0

Thanks, this is changed in version 0.5.2.

Best regards,
Jens

0

Please sign in to leave a comment.