Over a million developers have joined DZone.

JCite Support in NetBeans IDE

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

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 AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.

Topics:

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

{{ parent.tldr }}

{{ parent.urlSource.name }}