
Středa srpen 31, 2005
NetBeans Quick Tip #11 - How to Save As...
There is no Save As... action in NetBeans. But there are (at least) two ways how to perform this action:
1. Copy and paste in projects view: Choose the file you want to save as something else and press Ctrl-C. Then go to the package right above this class and press Ctrl-V. Voila, a new file appears and you can rename it through Refactor->Rename. Not very elegant but works like Save As...
2. Second way is to download experimental refactorings from development update center. Then you can execute Refactor->Copy Class from context menu, choose new name and a new class is born. This way is definitely more elegant.
Both ways use refactoring, thus the new class remains compilable which I think is an added value over the usual Save As... action.

Úterý srpen 30, 2005
NetBeans on Vista with JDK6
Here's a screenshot from Chet - click for full size.
What do you think?
CVS or Subversion?
Here are results of the versioning system survey we did on December 2004. I wonder how much these numbers have changed since this survey, at that time CVS was used by approx. 80% of responders, while SVN was used by approx. 35% of them.
Some people think CVS is dead - so why to invest time and energy in the improvements? Well, SVN is obviously replacing CVS but a lot of people and companies still use CVS. It takes some time before SVN is offerred on sites like
sourceforge, so I believe CVS is still used today for more projects than SVN. This implies that good CVS support is important.
The ratio is going to change in the future and that's why we see creating SVN support with better IDE integration as a priority right after new CVS support is stabilized. In meanwhile, you can of course still use the usual SVN support in NetBeans. Not as fabulous as the new CVS... but we'll get there, it just takes time.

Pondělí srpen 29, 2005
Plug-in Development Support Improvements
This is very nice. Although it's a way how to make writing NetBeans plug-ins or application above NetBeans less exciting - less hacking is necessary, things will just work... etc. Wizards are not for 100% geeks, are they? :-)

Neděle srpen 28, 2005
A Cool Name
This is Yutaka Fukufuji who is a player of the national Japan hockey league. Try to say his name loud with English pronounciation. Now that he's in NHL the speakers might have some serious troubles with saying his name :-)

Sobota srpen 27, 2005
How We Do Usability Studies of NetBeans
Yesterday I went to see one of our usability studies. NetBeans UI group has arranged two days of usability testing of the development version of NetBeans with emphasis on it's editor. It was an exciting experience so I'd like to share some of my insights.
At first, how does it look like. There are two rooms - one with many LCDs, panels and audio-video technics. This is the operator room. The second room is almost empty, there is only a table with a computer, a chair and two cameras. This is for the person I'll call for lack of more appropriate terms as a victim of the study, who is observed and recorded. I'll definitely take a camera next time to make photos of the rooms, they're on Czech technical university (Sun
opened the lab there last year - see bottom of the article).
The operator speaks with the victim using by a microphone, he cannot hear us unless we press a button. We see and hear everything the user is doing and saying and see his screen which is recorded, too. We'll have a lot of material to study once we make videos out of this. The victims had 8 tasks to finish, they didn't have to do all of them. Some were rather of type "write a hello world!" and some included more advanced programming - e.g. rewriting of existing code.
We had a bunch of different people with different backgrounds, all experienced Java developers, some of them using Eclipse, some tried 3.x versions of NetBeans before and some used IDEs. How to recognize an Eclipse user? When he gets an error in the code he immediately clicks on the red "x" button in gutter and is irritated that he doesn't get assistance. The interesting part is that they do not learn from this experience and even they get a lightbulb as a hint elsewhere, they still click on the red sign. The only thing you can do when they click on the red "x" for 10th time is to laugh - I know this should be taken seriously, but I just could not help it (hopefully the victim cannot hear us). It's incredible to experience how much are people connected with their tools - they do lots of the tasks unconciously.
At the end each victim was thanked (it takes an hour or so) and interviewed. They also got a free t-shirt and a reasonable amount of money. One of the victims was really cool - he was happy about the t-shirt but was refusing to take any money. We were trying to persuade him - he did a good job... but he resisted so we had to keep it (we didn't spend it in the pub, honestly). The guy was so helpful that he has sent us an additional e-mail with what he forgot to tell us in the interview. What an amazing participation!
The results of the study will be published on netbeans.org, like the older ones (see usability reports on
ui.netbeans.org) once processed. I made some conclusions for myself about the editor:
- Developers rely on the IDE when writing and editing code in a large way - any extra assistence we can add is good.
- Probably the most crucial part is what I call the "write - get error - fix" cycle. That's typical for Java, you get errors like uncaught exception, missing import, missing cast, etc. all the time. The developers are becoming used to this assistence so features like editor hints are very important.
- Developers do not remember and do not want to remember details of Java APIs. They're too complex, so they rely a lot on code completion and built in javadoc. If they need to recover manually from an error the compiler is writing, some of them can hardly do so without the IDE. For example, there needs to be a functionality to add an additional exception into the try-catch block, which is added according to the error - developers don't remember which exceptions need to be caught and it's time consuming to look it up. Some of them almost cannot do this manually today!
- Number of exchanges of keyboard and mouse needs to be minimalized. Especially for fixing inline errors - we should not force users to use mouse to find out which error is there. We need to provide a facility to go over errors and fix them one by one from a selection of fixes using keyboard.
- Discoverability matters, especially if we want other users to use NetBeans. I've seen it too many times - the developer is searching for a feature, he is hovering above it, you want to shout at him: "just click there!"... but he doesn't find it, gives up and does it manually. This is not an issue if people are used to the IDE but if we want users of other IDEs to take advantage of NetBeans, we need to work on discoverability.
- We need to remove anything that obstructs developers, because such things are really frustrating. All automatic features (adding of brackets, quotes, etc.) are very useful but need to be non-obtrusive.
- Developers want to use their own way of formatting.
- Majority of developers are most productive if they don't have to think about the language. They just want to add their features and the IDE needs to do the language-related things automatically (handling exceptions, adding imports, templates - even for if() and while(), adding casts, ...). These features need to be offered instantly.
- Refactoring matters. Developers are becoming used to it and start to use it for even basic tasks like renaming a variable in a for cycle.
The participants who know NetBeans from 3.x versions were very much surprised how much NetBeans has improved and became more intuitive and good looking. They find work with the IDE as quite a pleasant experience - nobody was frustrated. But they would really welcome improvements in how the IDE helps write java code to make them more productive.
The results of the usability study will be filed into Issuezilla as concrete suggestions how to improve the editor. Bigger features/changes will be planned for next releases. I think this study was very useful and shows how important the productivity-related editor features are.
[Side remark] I was half a day out of the office and when I came back I found out that they've published my CVS flash demo on netbeans.org... things happen so fast lately it's really hard to be the first one to blog about the hottest news :-)

Pátek srpen 26, 2005
Interesting Podcast with Sun's OSS Ombudsman
Here is a podcast with Sun's new opensource ombudsman, Simon Phipps. Very interesting.
Anyone from NetBeans volunteering for a podcast with me?
New CVS Support - Flash Demo
Here's my newest flash demo...
What's inside: improved CVS support, including
- integration with projects and refactoring
- editor annotations (to find out who broke your code)
- new colors and badges (for better overview)
- easily accessible actions (e.g. commit all on project or show all diffs)
- support for CVS over SSH
- ...see yourself
Feedback much appreciated!

Čtvrtek srpen 25, 2005
What Will Be the Next Version of NetBeans?
What is your opinion?
http://www.netbeans.org/servlets/ReadMsg?list=nbusers&msgNo=57150
5.0, I think. At least if I take a look at
this and that's not a complete list. There's Matisse, plug-in development support, new CVS, profiler, support for JBoss, Weblogic, Struts, JSF, new code completion, error stripe, editor hints, code templates, background scanning, many new refactorings, new Tools | Options, ant debugger, xml editor improvements, module manager, JSP and HTML palette... and other features I can't remember. Sounds rather like a major release to me.
Update: You can vote
here. You already know my recommendation... don't forget that besides engineering reasons there are also marketing reasons.
Java Thinks My Workstation is a Server
Thanks to Yarda I have found out that my W2100z workstation is considered by Java as a server on Linux. I've looked into the NetBeans startup log and indeed:
Java; VM; Vendor = 1.5.0_04; Java HotSpot(TM) Server VM 1.5.0_04-b05; Sun Microsystems Inc.
I obviously qualify for the
server criteria: I have 2 or more processors and 2 or more GB of memory on my workstation. So I've added the option -J-client to netbeans.conf and am curious if there is any noticable difference. According to the table I should not be able to start JVM in client mode on AMD64bit... but I can, at least according to the log. Hmm.
Code Templates in Dailies
Code Templates (aka live templates) were committed to trunk recently. Obviously this is not the most innovative feature to come with but one which is very useful. Code templates help you to write blocks of code easily, e.g. a for cycle. To invoke you can either use code completion (type in for and press Ctrl-Space) or abbreviations (type fori or forc and press Space).
You will also be able to define your own templates and we'll create a set of often used ones. More on this topic later on - once the functionality gets stabilized. Here's a screenshot:
As I've discussed in tram today with my colleague, editor features are important. Developers spend most of their time in editor so even small productivity boosts count.

Středa srpen 24, 2005
Is This NetBeans or Not?
This doesn't look like NetBeans Options dialog, does it? But it is - starting by today's build 200508241800.
Thanks Hanzi for your effort and great UI. Now my only wish is to finalize all the non-working parts... :-) Community, we'll need some help with finding out which important options are missing - see you in
NetCAT.

Úterý srpen 23, 2005
Using Relative Paths in Dependent Projects
I have crossed recently this issue: I have a project which depends on 3 other projects. Now I want to zip this project and open it on another computer. But then I get a message about broken project dependencies. The reason for this is that the paths to projects are stored as absolute so they don't work on another computer.
The solution is quite simple - you just need to move the definition of path of the dependent project from nbproject/private/private.properties to nbproject/project.properties and change the path to relative - e.g.:
project.DependentProject=/home/roman/projects/DependentProject
in private.properties is moved to project.properties and changed to:
project.DependentProject=../DependentProject
There is a good
FAQ entry from Jesse explaining all the possible cases. Obviously things are a bit different if you use version control system.
NetCAT Is Getting Close - And You're Invited!
In less than 14 days we will announce beginning of the new NetCAT program. This is an opportunity for members our community to get involved in finalizing the 4.2 release of NetBeans. You can find more info about the past NetCATs
here,
here and
here.
One of the changes I'm really happy about is that the coordinator of the NetCAT program will be Jiri Kovalsky. I think it's better that we have as a coordinator a person who is really involved in NetBeans project for a long time, actively communicates with our community and understands technical issues. He could not be a coordinator for 4.1 so I'm glad that he's back now.
We'll be announcing more info in next 14 days on netbeans.org, I just wanted to let you know we're preparing the program and this is an opportunity for you to tune up the features NetBeans developers are working on. The length of NetCAT is approx. 3 months and we'll appreciate your participation - it's important for us to get feedback about issues from real-life scenarios which we are not able to simulate in our environment.
The signup page for NetCAT will be announced on netbeans.org in next 14 days (I'll blog about it, too).
There will be many new features to try out... as for the hottest editor news I am now trying out the code templates (aka live templates) which will be commited to trunk during this week.

Pondělí srpen 22, 2005
Is Opensource DRM a Good Thing?
I was quite surprised how many people reacted on the news about DRM opensource project in a very positive way. All of my friends outside Sun who are involved in opensource projects think that DRM is an evil technology. Well, I guess the good news is that it at least it won't be proprietary so it will be harder for some software giants to control it which is a Good ThingTM.
My New Toy Is... a Processor Simulator
I'd like to show you two screenshots. Take a look at them and compare them (click to open maximized):

Original application

Ported to NetBeans platform
What I did is that I took the original application for simulation of processor and rewrote the GUI part in
2 days to work above NetBeans. I'm not done with it yet but the basic functionality is there. My impression is that the application got a really great look and somehow became professional-looking. The strange thing is that I didn't rewrite any of the components - the processor components are the same. I just reused NetBeans' components like editor, menu, toolbar and output window.
That were the changes in it's UI, but the more interesting part is which features I got for free from NetBeans, which the original application didn't have:
- Editor with search & replace, undo, redo, go to line, support for abbreviations and macros.
- Setting of keyboard shortcuts.
- Possibility to move windows, dock them, maximize editor and sliding windows.
- Automatic management of options in userdir.
- Customizable toolbars.
- Printing of source code.
- Output window with possibility of many windows opened, cleaning of output window, search, saving of output.
- Improved modularity of system, possibility to add additional features as modules, their uninstalling, updating and management of versions and dependencies.
- Availability of help window.
- Splashscreen, support for various look & feels, drag&drop functionality...
Now I have a question - do you know about an easier way of adding so many features in 2 days?! :-)
Ok, this is getting quite a marketing mambo-jumbo, I should not forget that I am an engineer... there are also some drawbacks:
- Increased start-up time (approx. 10 secs).
- Increased application size (+approx. 12 MB).
- Increased memory footprint (+approx. 10 MB).
However these drawbacks IMO are small compared to the set of functionality I gained for free. Programmer time is very expensive... and I wonder how many man-months it would take me to develop all the features I leveraged from NetBeans platform.

Neděle srpen 21, 2005
Interesting Essay from Paul Graham
I recommend reading
Paul's essay. I agree that meetings can waste a lot of time, blogging can be more effective than traditional marketing, people can do incredible amounts of work if they really like the job, more work is done at home than in the office (although working most of the time at home doesn't work IMO because of communication issues - good luck with that Paul) and being on time in the morning is not important for software people. The last part of the essay gets a bit utopistic, but the rest is a very interesting reading.
Weekend Partying in Prague
Yesterday a friend of mine got merried. She had a party in a pub on the Old Town Square, the famous one with the Orloj clock. It's also a place where well known Czech write Kafka was supposed to live (the funny thing about this is that there are quite a few places in Prague where they claim he lived - probably a good way how to attract tourists :-)
Anyway, the party was fun and we decided to something very stupid. All the boys took their belts from our trousers and we tied the bride by them. We carried her over several bars in Prague, all the tourists were staring at us, it really looked like if we captured her (she was quite loudly complaining about it, too). One of my friends had a problem with his trousers, while we were carrying the bride they were falling down. Which was another attraction for the shocked tourists.
The poor bride had to drink lots of alcohol, we drank chilli vodka and I thought I would scream when I drank it, it tastes... well... like vodka with a lot of chilli. Then we went to another bar where works a friend of us and got for her all kinds of exotic drinks. The funny thing is that for the whole time we did this, the husband didn't care - when we came back he was very calm about the whole thing :-)
We went dancing yesterday, I do not know from where I took the energy because I was dancing on Friday till morning. If you plan to visit Prague, I recommend to taste Prague's nightlife. In some clubs the atmosphere is very... hot... and the drinks are cheap if you come from west. A usual price of beer is less than 1 Euro or $1. Which is the reason why Prague is sometimes called the "fourth price category of Europe", the city center is full of foreigners who come here just to party.
Hacking NetBeans #5 - Boundling a Library with Your Module
Unless you're doing something very standard there is a probability you'll need to include an additional library with your module. At first it's a good idea to take a look if the library is not included with the IDE (in module/ext subdirs of individual clusters). In that case you can just declare dependence on the module which boundles the library and you're done.
However you probably won't be so lucky and you'll need to provide the library yourself. As I was told it's better to provide your library as a single module - this way others can then depend on this module if they need the library. Some useful info about this is
here. There is a new wizard in NetBeans Plug-in Modules | Library Wrapper Module Project which can do most of the job for you if you want to create a library wrapper module.
The other possibility is to add the library directly into your module which has an advantage that you provide single a nbm with everything. Create a subdirectory e.g. external and place the jar into it. It's a good idea to change the name of the jar, e.g. from mail.jar into mail-1.3.2.jar so that other people can find out what's its version easily.
In order to get the jar copied into your nbm, you need to add something like this to your build.xml:
<target name="netbeans-extra" depends="init">
<mkdir dir="${cluster}/modules/ext"/>
<copy todir="${cluster}/modules/ext">
<fileset dir="external">
<include name="mail-1.3.2.jar"/>
</fileset>
</copy>
</target>
This way you create a modules/ext subdir in your nbm and copy necessary libraries into it. You may need to get the library on classpath, so that it's visible for other modules. The classpath extensions are specified in project.xml like this:
<class-path-extension>
<runtime-relative-path>ext/mail-1.3.2.jar</runtime-relative-path>
<binary-origin>external/mail-1.3.2.jar</binary-origin>
</class-path-extension>
To add more jars to classpath just use additional class-path-extension tags. You get the same effect if you add the Class-Path: property into your manifest, but this method is deprecated - use project.xml for this purpose.
You will also need the IDE to recognize the jar, so that you can use code completion, methods called from the library don't get underlined as errors, etc. This is done by adding a property into the project.properties file:
cp.extra=\
external/library1.jar:\
external/library2.jar
Similar properties are used for tests - test.unit.cp.extra and test.qa-functional.cp.extra, so if the IDE doesn't recognize the API provided by the library, you're probably missing them.
Note that there are special requirements on libraries hosted on www.netbeans.org,
this document explains what needs to be done. The document explains everything necessary about scrambling and unscrambling, how to add a license to the nbm and few other legal topics (legal stuff is boring but you need to be correct).
I've been fighting quite a lot with adding a library to ant's classpath, this is a larger topic so it will deserve another post. Btw, if there's any area about module development you find fuzzy or underdocumented, let me know, I like finding out how things work. I can't guarantee that I will understand everything perfectly, but just writing about how things work for me might help other people out.

Sobota srpen 20, 2005
Innovation Certainly Happens Elsewhere

I am about to finish reading the book
Innovation Happens Elsewhere. It's one of the less readable books which you want to finish reading anyway because the content is very interesting. I apologize if any of the two authors reads this (they're from Sun so it's possible) but I can't help myself, I have to push myself to read the next page, because the content is hard to digest. On the other hand it's full of very interesting ideas so I never gave up so far.
The book is about using opensource as a business strategy. There are many concrete examples how Sun is using opensource as a business strategy. I recommend the book to anyone who wants to find out what are the motives behind Sun doing lots of opensource (especially to those who are suspicious about them :-)
I find the book very good in demystifying opensource - that was probably the most interesting part for me, to see what all kinds of myths exist out there. There exist too many misconceptions like for example "opensource can be used to get outside developers do the job for you for no cost" and the book explains why these ideas are wrong and what works. There is also a very good explanation of all kinds of opensource licences and the reasons why they were created, including useful information like which licences are compatible and which kinds of project they fit the most.
The other interesting thing is that NetBeans is used very often through the whole book as an example of successfull opensource project. It's especially interesting to read about what the authors think works well and what doesn't in a project like NetBeans. Many of the used NetBeans examples are correct, but there's one which is wrong.
We've used at NetBeans before I joined the project for a some time quite intensively the UI mailing list to discuss all issues around UI of NetBeans. This is referred in the book as an example of succesfull design done in public. Unfortunately user interface is an area where it is almost impossible to reach a concensus if too many people are involved. Everybody has his own, a bit different and strong opinion how the UI should look like. While discussing code, application design or it's individual features is very useful if it's done on public mailing lists (look at openide, nbdev or nbusers), discussing UI is not very practical, because lots of the threads just lead nowhere.
The reason why NetBeans 4.0 and 4.1 have great UI is that there was a small dedicated team which was doing the redesign (kudos to them). I do not think that we would get a good result if the UI was designed by hundreds of people - it's better to have few dedicated proffesionals. One of the most important properties of UI is it's consistence and this is something what cannot be really reached if everybody has a slightly different opinion.
So I recommend the book to anyone who wants to find out more about functioning of opensource projects, especially of those which are sponsored by Sun (NetBeans, OpenOffice, Jini, JXTA and some of the Apache projects are the most widely discussed). Java is discussed in the book as well, including reasoning why compatibility is important and how that influences the choice of licences and development model.
I think we at NetBeans have what to learn from the book - there's always what to improve. I'll be glad to lend this book, so if you're from NetBeans or Sun feel free to visit me in my office to get it.
P.S. Ja jsem asi fakt grafoman :-)

Pátek srpen 19, 2005
netbeans.org Under Maintenance Today
CollabNet, who host netbeans.org, will take the site down for a period
of 15 minutes for scheduled maintenance this Friday the 19th August, at
19:00 GMT. All services (http, cvs, email) will be unavailable during
the outage. No mail will be lost.
Don't panic!
The Best Resource to Find Out About New Features
Probably the best page with a short summary of new features is
What's new in Q-Build. Lukas created it as a Q-Build coordinator and now it's a ... privilege ... for every other coordinator to contribute to this page. So make sure to
check it out.
Yesterday we've tested the newest Q-Build candidate. There were many new features added recently as we're getting close to the feature freeze date. There is a new Tomcat customizer, more Refactorings, new Module Manager (including module uninstall!), Camel Case code completion, Debugger improvements, Error Stripe for JSPs, HTML and JSP palette with common components, basic Struts support, Weblogic plug-in, Server UI improvements and JUnit output window redesign.
You'll see short descriptions of these features once the new Q-Build is promoted. If you are really anxious and want to try these features out, they are in daily build - but I recommend to wait for Mr. Q because he's more stable. We of course welcome your contributions in form of reported bugs in
Issuezilla (patches or bugfixes are even more welcome and encouraged!).
You can expect a few more exceptions these days due to the large amount of new code committed, but don't worry, there's a long stabilization phase in front of us before the release. And you'll have a possibility to join the NetCat program to help us tune these new features up.

Čtvrtek srpen 18, 2005
Hacking NetBeans #4 - Create Your Own Options
One of the things you'll probably want to do if you're writing your plug-in is to have your own options. NetBeans can take care of their lifecycle - they are loaded on IDE startup and if changed they are saved to the userdir. You have probably noticed the small dialog which appears when you close IDE, saving options of all modules is one of the actions performed. So the IDE takes care about management of your options - you don't have to write quite a lot of code which is already a part of NetBeans.
How to add your options? As usual, you'll have to start with the layer.xml file:
<folder name="Services">
<file name="org-netbeans-modules-mymodule-MyModuleSettings.settings" url="MyModuleSettings.xml" />
</folder>
This way you add to the folder Services a settings file, which is the MyModuleSettings.xml file in the same directory as your layer.xml. The MyModuleSettings.xml specifies the class which will be used for options of your module:
<?xml version="1.0"?>
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
<module name="org.netbeans.modules.mymodule"/>
<instanceof class="org.openide.util.SharedClassObject"/>
<instanceof class="org.openide.options.SystemOption"/>
<instanceof class="org.netbeans.modules.mymodule.MyModuleSettings"/>
<instance class="org.netbeans.modules.mymodule.MyModuleSettings"/>
</settings>
The MyModuleSettings.xml files specifies the class which will be instanciated when your options are needed. This class extends the SystemOption class. As specified in xml file, it is located in org/netbeans/modules/mymodule/MyModuleSettings.java. The class has a special format:
public class MyModuleSettings extends SystemOption {
// unique serial number for serialization
static final long serialVersionUID = 34343534534534573L;
// the names of options you'll use
public static final String PROP_HOSTNAME = "hostname";
public static final String PROP_PORT = "port";
// initialization method
protected void initialize () {
// calles SystemOption's initialize
super.initialize();
// default values
putProperty(PROP_HOSTNAME, "localhost", true);
putProperty(PROP_PORT, "4976", true);
}
// this method serializes the options
public void writeExternal (ObjectOutput out) throws IOException {
out.writeObject(getProperty(PROP_HOSTNAME));
out.writeObject(getProperty(PROP_PORT));
}
// this method deserializes the options
private void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
putProperty(PROP_HOSTNAME, in.readObject(), true);
putProperty(PROP_PORT, in.readObject(), true);
}
// readable name of options
public String displayName() {
return "My Module's Options";
}
// help context
public HelpCtx getHelpCtx () {
return new HelpCtx(MyModuleSettings.class);
}
// set Hostname Option
public void setHostname(String hostname) {
putProperty(PROP_HOSTNAME, hostname, true);
}
// get Hostname Option
public String getHostname() {
return (String) getProperty(PROP_HOSTNAME);
}
// set Port Option
public void setPort(Integer port) {
putProperty(PROP_PORT, host, true);
}
// get Port Option
public Integer getPort() {
return (Integer) getProperty(PROP_PORT);
}
}
This is basicly all you need to make the options work - whatever you write using setXXX method will be saved to the userdir (all options need to be serializable objects). Your module can read the options by calling the getXXX methods and they're loaded. You can create this way as many options as you want (but keep in mind it's better to keep the number of options small - we know what we are talking about). As you know, things get always complex, one of the first things you'll need to support various versions. But that's mostly solved by just writing to the first position an Integer with version and add a switch to decide what to do according to this version.
So this code handles reading and writing of options, but you'll probably also want them to be displayed. To do that, you need at first to create a beaninfo class, which will add additional information to your options. The name of the beaninfo class is always name of your class + BeanInfo.
public class MyModuleSettingsBeanInfo extends SimpleBeanInfo {
public PropertyDescriptor[] getPropertyDescriptors() {
try {
PropertyDescriptor hostname =
new PropertyDescriptor("hostname", MyModuleSettings.class);
hostname.setDisplayName("Hostname");
hostname.setShortDescription("This option sets the hostname.");
PropertyDescriptor port =
new PropertyDescriptor("port", MyModuleSettings.class);
port.setDisplayName("Port");
port.setShortDescription("This option sets the port.");
return new PropertyDescriptor[] {hostname, port};
} catch (IntrospectionException ie) {
System.err.println("Introspection exception thrown: "+ie);
return null;
}
}
public Image getIcon(int type) {
if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
return Utilities.loadImage(
"/org/netbeans/modules/mymodule/MyModuleIcon16.gif");
} else {
return null;
}
}
}
This way you set the names of the options and their descriptions, displayed in Tools | Options. You also specify an icon which is displayed in the panel. The last missing piece is wiring these options into the UI. Again, we'll use our favourite layer.xml file:
<folder name="UI">
<folder name="Services">
<folder name="IDEConfiguration">
<folder name="ServerAndExternalToolSettings">
<file name="org-netbeans-modules-mymodule-MyModuleSettings.shadow">
<attr name="originalFile" stringvalue="Services/org-netbeans-modules-mymodule-MyModuleSettings.settings"/>
</file>
</folder>
</folder>
</folder>
</folder>
Yes, the options in Tools | Options are created like this, simply via definitions in xml files. This part defines that your options will be displayed in IDE Configuration | Server And External Tools Settings. The .shadow is actually a link the original xml settings file which specifies the class implementing your Options.
And that's it - your plug-in is now plugged into Tools | Options.

Středa srpen 17, 2005
NetBeans on a World Tour
I've just found out from our marketing team (might be a surprise but I'm not from marketing, I'm an engineer) that NetBeans will go on a world tour. The first stop is
Java China on 12th Semptember. I do not know what the other stops are, but once I'll find out then I'll share the news.
This is the logo we'll use for the tour:
A hint to our marketing team: you could use somebody who sings about NetBeans on the world tour, wouldn't you? Ok, I know, the people would run away if it was me.
Update: Just found out that the other stops are: Toronto, Singapore, Madrid, Sao Paulo and some other bigger cities around the globe are being discussed as well. I especially look forward to the report from Brazil, whose developer community is so enthusiastic about Java (as seen on Java One).

Úterý srpen 16, 2005
I'm not the Only One Singing about Software
Check
this out. Richard Stallman himself! More
here.
What Can Project Jackpot Bring to NetBeans?
Tom Ball is currently in Prague and today he had a session about
Project Jackpot. You may have heard about this technology, Tom presented it on Java One. I thought I would share some of the interesting things I've learned today.
Jackpot can be used to analyze source code and search for patterns. Then, it can transform the source code to get improvements. A typical usage is to search for some ugly code constructions and replace them by something nicer. So it serves for a kind of code analysis combined with code refactoring.
Now what's really cool is that you can specify patterns you want to find/replace. So you can for instance write a pattern which will search for all unnecessary casts and removes them. The first question you'll have is: "but how safe is it?". Jackpot creates a fully attributed AST tree from the sources, so it will never produce something uncompilable. The changes it does are very local. There are other things which help protect the code including a fully customizable pretty printer used not to break the formatting.
Here's a simple example, let's have a piece of code like this:
String message = "";
message = ex.toString();
return message;
Obviously, you can get the same functionality if you do:
return ex.toString();
You can use Jackpot to detect such patterns and to make such corrections. So you can improve the readability of the code, performance and get rid of some ugly constructions (another example - transforming difficult boolean expressions into simple ones).
The good news is that this technology will be in future integrated into NetBeans. Obviously, it's something nontrivial, we will have to come up with a good library of rules... and we'll definitely meet many obstacles. But once it's there, I can imagine many possibilities how to leverage it. The nice thing about opensource is that you never know what can come, NetBeans community may find a usage of such technology Tom has never thought of.
There used to be a time when people were saying about NetBeans that we are not very innovative. If I take a look today at Matisse, J2ME features (the visual designer rocks), EJB 3.0, Profiler,... now Jackpot... well, it feels good for a change. And more will come (there are some long-term features I'm not allowed to blog about).
P.S. Just noticed that basic Struts support was commited to trunk. But haven't tried it yet. The build gods are not with us lately. We'll have to pray more.
P.P.S. The build gods have heard our prayers because I've just received an e-mail with link to the build of new q-build candidate.
Update: Here's an explanation of my comment "long-term features I'm not allowed to blog about" - I am not allowed to blog about some features Sun is considering to opensource as contributions to netbeans.org. I cannot publish the details about them until it happens.
NetBeans in the Gaming Area
Quote: "All existing Java3D NIO-based-multiplayer WW1 flightsims that are sourceforge projects today are developed with NetBeans!". This really gives me a better sleep :-)

Pondělí srpen 15, 2005
History Was not My Favourite Subject at School...
... but this history is kind of interesting. Inspired by
Michal's entry I'd like to share this:

Jun 2000
More of history here:
Dec 2000,
Dec 2001,
Apr 2001,
Oct 2001,
2002,
2003,
2004,
Today. What a progress...

Sobota srpen 13, 2005
I've Recorded a NetBeans Song :-)
This is going to be fun... I've recorded a NetBeans song:
Download / Play Roumen's NetBeans Song
Looking forward to your comments :-) Here's the text:
Somebody once told me the world is gonna roll me
I haven't got sharp tool in the shed
She was looking kind of weird once her splashscreen has appeared
With few rays of the light on her forehead
Well the bugs keep coming and they won't stop coming
Deadlines all tight and I hit the ground running
Didn't make sense not to live for fun
Your brain gets smart but your head gets dumb
So much to code so much to see
So what's wrong with that SWT
You'll never know if you don't go
You'll never shine if you don't glow
[Chorus:]
Hey now, try NetBeans, get your game on, go play
Hey now, try NetBeans, get your code done, get paid
And all that glitters is gold
Only shooting stars break the mold
It's a cool tool and they say it gets better
It's bundled up now so just go and get her
And the geekest men need to differ
Judging by the features that we all know that glitter
The market we're in is getting pretty thin
The waters getting hot and you cannot be dim
My world's on fire how about yours
That's the way I like it and I never get bored
[Chorus:]
Hey now, try NetBeans, get your game on, go play
Hey now, try NetBeans, get your code done, get paid
And all that glitters is gold
Only shooting stars break the mold
Somebody once asked what I need to finish tasks
I said there's only one tool in my head
He said yeap what a concept
I could use a single tool myself
And we could all use a little change
Well the bugs keep coming and they don't stop coming
Deadlines all tight and I hit the ground running
Didn't make sense not to live for fun
Your head gets dumb but your tool is smart
So much to code so much to see
Got rid of that ugly SWT
You'll never know if you don't go
You'll never shine if you don't glow
[Chorus:]
Hey now, try NetBeans, get your game on, go play
Hey now, try NetBeans, get your code done, get paid
And all that glitters is gold
Only shooting stars break the mold
Ok, here's the text in Czech as well... some of the original sentences from Shrek are harder to translate (I don't claim I understand them perfectly btw so any corrections are welcome). Anyway, here it is:
Nekdo mi jednou rek', ze me svet prevalcuje,
nemam totiz ostej tool v kulne.
Vypadala trochu divne kdyz se ukazala jeji splashscreena
s nekolika paprsky svetla na cele.
Jo, bugy prichazej a neprestanou chodit,
dedlajny jsou tesny a ja padam na hubu za behu.
Nedavalo smysl nezit pro legraci,
tvuj mozek je chytrej, ale hlava je hloupa.
Tolik kodu napsat a tolik toho poznat,
tak co je spatne s tim SWT?
Nepoznas dokud neodejdes,
nezazaris dokud nesvitis.
[Sbor:]
Hej ty, zkus NetBeans, zacni svou hru a hraj si.
Hej ty, zkus NetBeans, napis svuj kod a dostan zaplaceno.
Vse co se trpyti je zlato,
jen letajici hvezdy zmeni stare zvyky.
Je to cool tool a rikaj' ze je cim dal lepsi,
je ted zabundlovenej tak jdi a sezen si ji (tady se nic nerymovalo).
A nejvetsi geekove se musi lisit,
soudim podle featur, ktere se vsem trpyti.
Trh ve kterym jsme se hodne zmensuje,
vody jsou horke a nemuzes byt hloupy (take znamena v seru).
Muj svet je na ohni, jak je na tom tvuj,
takhle se mi to libi a nikdy me to nezacne nudit.
[Sbor:]
Hej ty, zkus NetBeans, zacni svou hru a hraj si.
Hej ty, zkus NetBeans, napis svuj kod a dostan zaplaceno.
Vse co se trpyti je zlato,
jen letajici hvezdy zmeni stare zvyky.
Nekdo se me jednou zeptal, co potrebuju na dokonceni ukolu.
Rek' jsem ze mam jen jeden tool na mysli.
On rek': teda, to je koncept.
Taky bych moh' pouzivat jediny tool.
A vsem by se nam hodila mala zmena.
Jo, bugy prichazej a neprestanou chodit,
dedlajny jsou tesny a ja padam na hubu za behu.
Nedavalo smysl nezit pro legraci,
tvoje hlava je hloupa ale tvuj tool je chytrej.
Tolik kodu napsat a tolik toho poznat,
zbavil jsem se toho osklivyho SWT.
Nepoznas dokud neodejdes,
nezazaris dokud nesvitis.
[Sbor:]
Hej ty, zkus NetBeans, zacni svou hru a hraj si.
Hej ty, zkus NetBeans, napis svuj kod a dostan zaplaceno.
Vse co se trpyti je zlato,
jen letajici hvezdy zmeni stare zvyky.

Pátek srpen 12, 2005
Hacking NetBeans #3 - Registering Files in Default Filesystem
Last time I blogged about executing ant tasks from the IDE. It was done in an ugly way - by generating a temporary ant script for execution. A nicer way is to use an existing ant script, which will be placed somewhere in the module's jar.
But the question is: how to access a xml file which is located somewhere inside my module? Or any other arbitrary file?
Well, you need to register this file in NetBeans layered filesystem. To achieve this, add something like this to the layer.xml file:
<folder name="Services">
<folder name="MyModule">
<file name="my_script.xml" url="resources/copy_script.xml"/>
</folder>
</folder>
By this I am declaring, that the export_script.xml file is located in resources/export_script.xml inside my module. This path is relative to the path of the layer.xml files. So these files are:
org/netbeans/modules/mymodule/layer.xml
org/netbeans/modules/mymodule/resources/copy_script.xml
I also declare that my module can find the xml file in Services/MyModule/copy_script.xml on the default NetBeans filesystem. To access the file, I use:
FileObject sfo = Repository.getDefault().getDefaultFileSystem().findResource("Services/MyModule/my_script.xml");
Now that I have a reference to the FileObject of the xml file I can do
something useful with it. I can e.g. convert it to a regular file by using FileUtil.toFile(sfo). To execute the ant script you can use
my previous example but you will need to copy the ant script to the disk at first and call RunTarget() method on a FileObject which resides on disk.
Confused about NetBeans filesystems and the layer.xml file? I was, too. A good and short reading is
here from Tim. You can also use the
sysfs plug-in to explore the default filesystem. It's full of surprises :-)