Thursday December 07, 2006 Test Libraries Node for NetBeans Module Project
Tomas Musil (our QA specialist) yesterday contributed Test libraries node for NetBeans module project. It simplifies editing classpath for tests.Thanks to Tomas contribution, you don't need to edit project.xml for setting classpaths of tests manually. New test dependency can be added from popup of test libraries node.
Add Unit Test Dependency action shows Add dependency dialog.
The dialog has the same behaviour like dialog or adding module dependency. Test library dependency also contains customizer. It can be shown from popup of test library node.
Posted by xzajo ( Dec 07 2006, 10:19:36 AM CET ) Permalink Comments [8]
Few developers and me from NetBeans core team very often drink tea. We drink different kind of tea - green, yellow, black, pu erh, etc. Yesterday architect of our tea-team (the "enfant terrible") took pictures of us.
Who is on the picture? On the left side is sitting Milos Kleint. He develops Maven 2 plugin. Besides him is Martin Krauskopf. Martin is now working on debugger for JRuby. On the right side is laughing Radim Kubacki. He takes care of performance of NetBeans IDE.
Other developers are so kind to boil water.
Our editor VIP - Mila Metelka:
Retouche EXPERT - Tomas Zezula:
BTW he fixed me today bug.
Command Line Parsing API in NetBeans Platform
Jaroslav Tulach integrated Command Line Parsing API to NetBeans platform this week. The API was already tested in DVB Central project.
I wrote simple OptionProcessor in few minutes:
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.netbeans.api.sendopts.CommandException;
import org.netbeans.spi.sendopts.Env;
import org.netbeans.spi.sendopts.Option;
import org.netbeans.spi.sendopts.OptionProcessor;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
public class MyOptions extends OptionProcessor {
private static Option message = Option.requiredArgument(Option.NO_SHORT_NAME, "message");
public Set
The MyOptions processor is register in META-INF/sevices. The registration can by done by META-INF/services browser. The MyOptions provider display first parameter of -message parameter in message dialog box. For Example
./netbeans --message Helloshows Hello message. Posted by xzajo ( Sep 20 2006, 12:25:45 AM CEST ) Permalink Comments [10]
META-INF/services Browser for NBM project
Together with Jaroslav Tulach we are developing META-INF/services browser for NetBeans module project. In short META-INF services node was added to Important files node:
The META-INF services node has two children nodes:
<Exported Services> - services exported by module.
<All Services> - services from NetBeans platform and all modules in module suite.
Add New Service item. It shows Add Service dialog:

Class name text field. The class name of new service can be also selected in packages view. The package view will be shown after clicking on Browse button:

Delete menu item on service instance in All Services view.
Details about this feature are in issue #66606. We want to integrate it to Milestone 4 NetBeans build.
Run only tests which uses your code
NetBeans test distribution allows to run tests for modules which requires a specific module on runtime testing classpath. For Example you have built test distribution for 'org-openide-filesystems' and 'org-netbeans-modules-masterfs' NetBeans modules.
Use case 1: You want to run test with 'org-openide-filesystems' module on runtime testing classpath:
ant unit -Dtest.required.modules=org-openide-filesystems.jar -Dnetbeans.dest.dir=netbeans_installation_dir
It runs both modules - 'org-openide-modules-masterfs.jar' and 'org-openide-filesystems.jar'.
Use case 2: You want to run test with 'org-netbeans-modules-masterfs' module on runtime classpath:
ant unit -Dtest.required.modules=org-netbeans-modules-masterfs.jar -Dnetbeans.dest.dir=netbeans_installation_dir
It runs tests only for org-netbeans-modules-masterfs module because
org-netbeans-modules-masterfs module is not on runtime testing classpath of org-openide-filesystems module.
Posted by xzajo
( Sep 14 2006, 06:05:17 PM CEST )
Permalink
Comments [4]
Using velocity templates in NBM projects
Many people asked me how to use velocity template in their NetBeans module projects. So there is short example. Velocity libraries are wrapped to org-apache-velocity.nbm NetBeans module.
First time you need to install the module to NetBeans platform. Now we can start to write Velocity module. Add org-apache-velocity on classpath of module. Example class with generating code is below:
public class SimpleTemplate {
/** Write generated code to target document
*/
public static void apply(Writer t,String vmTemplate,Map beans) {
try {
VelocityContext context = VTResourceLoader.getContext();
for (Iterator bIt = beans.keySet().iterator() ; bIt.hasNext() ;) {
String name = (String)bIt.next();
Object bean = beans.get(name);
context.put(name, bean);
}
Template template = Velocity.getTemplate(vmTemplate);
if (t == null) {
throw new IllegalStateException(" no target defined ");
}
template.merge(context, t);
} catch (Exception e) {
Logger.getAnonymousLogger().log(Level.SEVERE,"Exception during generating templates",e);
}
}
}
The velocity template is present in velocity/templates folder of layer.xml :
<folder name="velocity">
<folder name="templates">
<file name="template.vm" url="Simple.vm"/>
</folder>
</folder>
public class SimpleBean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
template.vm example :
simple.name = $simple.nameWe can write action with body:
public void performAction() {
// TODO implement action body
InputOutput io = IOProvider.getDefault().getIO("template test",true);
Map map = new HashMap();
SimpleBean sb = new SimpleBean();
sb.setName("Text");
map.put("simple",sb);
SimpleTemplate.apply(io.getOut(),"template.vm",map);
}
It prints to output window transformed template:
simple.name = TextPosted by xzajo ( Sep 07 2006, 03:56:47 PM CEST ) Permalink Comments [6]
Test Dependencies of NetBeans Modules Moved to Project.xml
Test Dependencies of NetBeans module project are defined in nbproject/project.properties for previous versions of NetBeans.The test dependencies can be also added to project.xml for projects of NetBeans 6.x. The new variant is recommended. The test dependencies allows to define:
For migrating test dependencies from project.properties to project.xml was implemented fix-test-dependencies ant tasks in NetBeans module project. You can do it from command line:
cd your_nbm_project_dir ant fix-test-dependencies
GUI for adding/removing test dependencies has not yet been implemented. I hope it will be available early. It can by done only manually by editing project.xml file. The tags for test dependencies (defined in xml schema) are described below:
<test-dependencies>
<! -- Dependencies for a source root with tests: -->
<test-type>
<!--
Name of test type. Normally you will use 'unit'.
netbeans.org modules also support 'qa-functional' test-type.
-->
<name>unit</name>
<!-- A dependency on a module or its tests: -->
<test-dependency>
<!-- Identification of module our tests depend upon: -->
<code-name-base>org.netbeans.modules.java.project</code-name-base>
<!-- Include also transitive module dependencies of that module: -->
<recursive/>
<!-- Always available when running, but to include at compile time also: -->
<compile-dependency/>
<!-- To request the tests of that module, rather than itself: -->
<test/>
</test-dependency>
</test-type>
</test-dependencies>
For example you have three modules with code name bases A,B,C. A depends on B, B depends on C. You want to add test dependencies to unit test type of module D:
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>A</code-name-base>
</test-dependency>
</testtype>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>A</code-name-base>
<recursive/>
</test-dependency>
</testtype>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>A</code-name-base>
<compile-dependency/>
<recursive/>
</test-dependency>
</testtype>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>A</code-name-base>
<compile-dependency/>
<recursive/>
<test/>
</test-dependency>
</testtype>
Binary Test Distribution For NetBeans IDE
I'm finishing binary test distribution for NetBeans IDE. The test distribution won't be available for NetBeans 5.5 because it's too late to do it. The distribution will be available for NetBeans 6.0 build on download page, I hope. Quality Engineering team got idea to distribute NetBeans with its test binaries few years ago. We decided after a while to spend time to remove cvs dependencies on running tests and create files layout for test binaries.
To build test distribution is very simple now. You only need to checkout cvs files for NetBeans dev build, build ide and test distribution:
cvs co standard_nowww cd nbbuild ant ant build-test-dist -Dtest.fail.on.error=false
Ant needs more memory for building tests than is default value. So increase it by overring ANT_OPTS environment variable.
ANT_OPTS=-Xmx512mThe property
test.fail.on.error ignore compilation failures because few tests are still uncompilable. It is curious that some test are uncompilable. Why developer write tests if the test is uncompilable after a while. IMHO all the tests will have to be run daily if continuos integration is dream. I hope it will be solved as soon as possible.
The tests are built into nbbuild/build/testdist folder and packed to nbbuild/build/testdist.zip file. In the root folder of test distribution is short README.txt file. It contains description how to run tests. For example when you want to run all test(qa-functional and unit), you need only run ant :
ant all -Dnetbeans.dest.dir="${netbeans.home}"
The netbeans.dest.dir property contains directory with NetBeans installation. Te result of testrun is formated to html files. The html files are available in:
More details about binary test distribution are here.
Posted by xzajo ( Sep 01 2006, 02:32:17 PM CEST ) Permalink Comments [4]NetBeans 6.0 Milestone 2 build contains Floating windows feature. A window (TopComponent) can be undocked by dragging the window's title bar outside the NetBeans IDE. UI specification is available here. The specifacation also coontans few flash demos. For examle :
The feauture is also part of NetBeans platform. If you want to use it in your rich-client applications on top of the NetBeans Platform you need to rebuild it against NetBeans 6.0 M2 platform. I tried it for Paint Application tutorial. Screenshot is below.
Fullscreen mode in NetBeans platform
I've already blogged about fullscreen mode here. The fullscreen mode feature has been integrated into NetBeans 6.0 development daily builds.
It is very easy to add this feature to already written application based on NetBeans platform. If the application is compiled against NetBeans 6.0dev platform View|Full Screen menu item will be added automatically. Screenshot with NetBeans FeedReader in fullscreen mode is shown below.
The fullscreen mode works for JNLP application too.
Posted by xzajo ( Jul 12 2006, 11:13:14 PM CEST ) Permalink Comments [4]Netbeans met GWT and more GWT components
I wrote about my first experience with GWT in my last blog. Yesterday I experimented with GWT application in NetBeans. The new GWT plugin contains GWT project type. It is now easy build, run and debug GWT projects in NetBeans. The code completion with javadoc is also available. Tomas will publish his plugin early, I hope.
On http://gwt.components.googlepages.com/ are more GWT components. My favorite is
Auto-Completion Textbox. It allows to add Code completion to Texbox on web page.
The AutoCompleteTextBox component extends TextBox class. It adds to TextBox one new useful method:
public void setCompletionItems(CompletionItems items)The
CoompletionItems type is code completion provider:
public interface CompletionItems {
/**
* Returns an array of all completion items matching
* @param match The user-entered text all compleition items have to match
* @return Array of strings
*/
public String[] getCompletionItems(String match);
}
I wrote a simple application with AutoCompleteTextBox. The class with GWT EntryPoint is below. It shows code completion for names.
public class Main implements EntryPoint {
class NameCompletionItem implements CompletionItems {
public String[] getCompletionItems(String match) {
ArrayList list = new ArrayList();
String values[] = new String[]{"roumen","radim","xzajo","geertjan","lukas"};
String lowerMatch = match.toLowerCase();
for (int i = 0 ; i < values.length ; i++) {
String value = values[i];
if (value.startsWith(lowerMatch)) {
list.add(value);
}
}
String retVals [] = new String[list.size()];
for (int i = 0 ; i < list.size() ; i++) {
retVals[i] = (String) list.get(i);
}
return retVals;
}
}
public void onModuleLoad() {
AutoCompletionTexBox textBox = new AutoCompletionTexBox();
textBox.setCompletionItems(new NameCompletionItem());
RootPanel.get().add(textBox);
}
}
Conversion between ArrayList and array of Strings doesn't work on client side of GWT (Collection.toArray(Object[] array). The gwt compiler shows an error. Therefore I used the for loop. Screenshot with code completion in browser is below.
Jiri Skrivanek updated documentation how to use XTest framework in NetBeans IDE. XTest is extension of JUnit 3.x. It was designed to help develops tests for NetBeans platform. The flash demo is available here. Updated tutorial for XTest is on this page.
Many people in NetBeans asked me why not to switch to TestNG with annotations. To tell you truth xtest already has more features than TestNG now. Xtest has also few disadvantages. It is difficult to configure it. The authors of xtest never wrote tests. Only Jiri Skrivanek, the last owner, writes tests. Maybe he is the right person who fix problems with xtest.
Why we still use Xtest for testing NetBeans? There are few reasons:
Yesterday I was speaking with Stanislav Albrecht. He is working on fullscreen mode feature in NetBeans. He showed me it on Windows L&F. The feature has not finished yet. He need to implement full sreen mode feature also for others Look&Feels. But I was impressed. I use fullscreen mode in other application on my notebook. It saves workspace on my display. I can use it now also in NetBeans.
UI spec with flash demo for this feature is available on this page. Stanislav gave me a build with this feature for testing. I will show few screenshots. On the first screenshot is NetBeans in normal mode.
Two actions are highlighted in the screenshot. The first is in main menu. It shows NetBeans in full screen mode. The second is represented by icon in the right corner of window. It maximizes the window in NetBeans layout. The other windows are slided off - minimized by window sliding feature. I clicked on both actions. The result is on the screenshot below.
The main menu will be hidden in final version. This feature will be also available for application based on RCP. Developers don't need to change their applications. They only need to rebuild their applications with new NetBeans platform. The full screen action and maximize window button will be added automatically.
Posted by xzajo ( May 25 2006, 12:31:29 PM CEST ) Permalink Comments [11]Spellchecker for Javadoc plugin
Spellchecker module was added on nbextras.org update center this week. Author is Jan Lahoda. This module provides Spellchecker API. It underlines misspelled words in the editor, provides hints with possible fixes. Currently is implemented spellchecker for javadoc.
It will be useful if someone also implements spellchecker for HTML editor. Is there any volunteer?
Posted by xzajo ( Apr 27 2006, 01:10:55 PM CEST ) Permalink Comments [5]Preview Version of LaTeX for NetBeans 5.0
I am proud to announce testing version of Jan Lahoda's LaTeX for NetBeans 5.0 plugin. How to install
When all modules are successfully download and installed it is necessary to do two thinks :
Please give feedback to Jan Lahoda on users@latex.netbeans.org mailing list. To subscribe send mail to users-subscribe@latex.netbeans.org address.
Posted by xzajo ( Apr 07 2006, 11:26:04 AM CEST ) Permalink Comments [18]