Translate

Tuesday, July 15, 2014

Opening a Java file with Class Viewer

One of the features of my latest version of Class Viewer is the ability to open a local Java file. The way it works is that you have the packages for your classes setup in ClassViewerConfig.xml as usual, but the Local option should be set to "Yes", where the case does not matter, if you wish to open files rather than go to javadocs.

Now if you double-click on a method in the Results pane, or click on the Documents button, the application will go find the Java file, relying on your classpath so that must be set properly, look into the file to find the line number of the method, and call your preferred text editor.

If your preferred text editor takes a line number argument then it will get the call and you should have the file opened to that line number. Which I think is really cool. Well, it's fun to me.

If your text editor does NOT take a line number argument when called, Class Viewer will open up a pop-up window telling you the line number of the method. But you tell Class Viewer whether it does or not, in ClassViewerConfig.xml, so if you say it does take a line number then it will try that call with the line number.

If your text editor just opens the Java file and doesn't go to the method, you can assume it doesn't take the line number argument, or you do not have it set to take a line number argument in the ClassViewerConfig.xml file. Remember editing that file is easily done with a text editor, which is how I always do it.

The default text editor in ClassViewerConfig.xml is gedit as I think that one is well-known and it does take a line number in the argument! So I consider it a recommended text editor. It takes the line number with a parameter which is "+". So a call is like gedit ExampleFile.java +151 to go to line number 151 in ExampleFile.java as an example. That parameter is set in the config file as well.

Was almost tempted to write my own text editor to add this capability and realized that was silly, when Class Viewer could just call one. I think applications have great potential in calling other applications.

Class Viewer started in that direction by calling the browser anyway, and it's natural to continue down that path.

It's just so simple to let the application do it.


James Harris

Post a Comment