Over a million developers have joined DZone.

JCite Support in NetBeans IDE

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

With JCite, you ensure that two sources are synchronized with each other. In my case, I'm interested in synchronizing the code referenced in tutorials I write with Java code in sample applications. I learned about all the things involved with JCite at Devoxx, from the guy who created JCite, Peter Arrenbrecht.

Simply put, in a template of a tutorial I have this, in the place where I'd like a snippet of code to be:

[jc:org.wordapp.word.engine.WordEngineTopComponent:---fragment] 

Then, in the class referred to above, I have the snippet I need surrounded as follows:

// ---fragment
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String s = text.getText();
    s = s.toUpperCase();
    text.setText(s);
}
// ---fragment

Then I run the JCite executable, with the arguments -i (input, i.e., the template file), -o (output, i.e., the actual tutorial in the actual folder where I'll check it into the repository), and -sp (source path, i.e., the path to the "src" folder in the sample project where the code snippet above is found).

I've created a small plugin for NetBeans IDE that automates most of this:

What you see above is a new type of file, i.e., with a "jcite" extension, which has specific properties shown in the Properties window, which opens in the HTML editor, and which has a specific menu item for running JCite, using the properties in the Properties window.

Now I'm working on code completion for the placeholder in the template file, which will let you complete the path to the file you're referencing and you'll also be able to use a hyperlink to open that file:

 

 

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}