In Eclipse when you press Command-Shift-R (Open Resource), you end up seeing the same resource a few times -- when it e.g. gets copied into a location in the workspace by your build tool (e.g. maven, ant).
I was looking for a solution for some time now and way playing with working sets for this purpose.
Rob Mayhew obviously has one:
http://robmayhew.com/eclipse-ignore-folder/
Now the "only" thing left to do is to mark those target directories as derived -- after each clean up of those folders.
Luckily there is a project dash in Eclipse that can use javascript to do this.
Someone on the net even wrote the right script
Wednesday, January 30, 2008
Sunday, January 13, 2008
Mac apps runtime config
Much of an application on a Mac is configured by a file called Info.plist. You can find the file when
you right click on an application and choose "Show packet content" and descend down in the Content folder.
Apple has a page about all the key/value pairs at http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html.
I was looking for a way to disable the dock icon and Main menu from a "StatusBarApp" (Apple calls them Agents IIUC). But without knowing the right terminology, this is hard to find :)
you right click on an application and choose "Show packet content" and descend down in the Content folder.
Apple has a page about all the key/value pairs at http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html.
I was looking for a way to disable the dock icon and Main menu from a "StatusBarApp" (Apple calls them Agents IIUC). But without knowing the right terminology, this is hard to find :)
Tuesday, January 08, 2008
Cocoa: Preferences - and Binding
Since Mac OS X 10.3 there is a new "Binding" mechanism. The idea behind this is to e.g. have an observer pattern for the enablement of GUI elements or to read and store preferences without coding. To use this, you need to pull the NSUserDefaultsController from the controller palette in InterfaceBuilder into your app. In the inspector for a field, you can then go to the "bindings" pane and bind the values (shown here for a NSTextField, but applies to other GUI elements like checkboxes as well):

Bind to: should be set to the NSUserDefaultsController. For the controller key, you can leave the values. Model key path finally contains the key in the preferences. Depending on the kind of GUI element, the right data type will be choosen automatically.
The technique of binding basically allows to provide a preferences panel without any (Objective-C) coding to set and store the values -- very nice.
It is still a good idea to provide defaults for the settings as described in the previous post.
Update: I just found a nice article from Apple describing all this as well.

Bind to: should be set to the NSUserDefaultsController. For the controller key, you can leave the values. Model key path finally contains the key in the preferences. Depending on the kind of GUI element, the right data type will be choosen automatically.
The technique of binding basically allows to provide a preferences panel without any (Objective-C) coding to set and store the values -- very nice.
It is still a good idea to provide defaults for the settings as described in the previous post.
Update: I just found a nice article from Apple describing all this as well.
Friday, January 04, 2008
Cocoa: Preferences
Sometimes you want to save some user preferences for your app. Luckily there is good support for this in Mac OS X.
Perferences are key-value pairs that can be stored in the filesystem. The system works in multiple layers which means that if a key is not found in an upper layer, it will be searched in the layer below. Layers are: command line, application, global, language and default. This is means also that you don't need any additional code to see if a property is given on the command line or in the preferences etc - that is all transparent.
A good idea is to always provide the fallback values, so your code never needs to check if a preferences key is actually present or not.
Before your preferences show up in the Filesystem as user database under your choosen id, you have to fill the program id in Info.plist at:
With the XXX the prefernces store would be ~/Library/Preferences/XXX.plist
An easy approach to set up the defaults if you only have a few preferences items is:
If you have more than a few items, it is easier to provide a defaults file in the app bundle and load this instead:
After this is done, reading preference values is easy:
You might want to use the respective xxxForKey message depending on the type of preferences values.
Storing modified values is equally easy:
The documentation for NSUserDefaults states that it will store the modifications from time to time to the underlying filesystem object, but I found it better to explicitly call
Perferences are key-value pairs that can be stored in the filesystem. The system works in multiple layers which means that if a key is not found in an upper layer, it will be searched in the layer below. Layers are: command line, application, global, language and default. This is means also that you don't need any additional code to see if a property is given on the command line or in the preferences etc - that is all transparent.
A good idea is to always provide the fallback values, so your code never needs to check if a preferences key is actually present or not.
Before your preferences show up in the Filesystem as user database under your choosen id, you have to fill the program id in Info.plist at:
<key>CFBundleIdentifier</key>
<string>XXX</string>
With the XXX the prefernces store would be ~/Library/Preferences/XXX.plist
An easy approach to set up the defaults if you only have a few preferences items is:
NSUserDefaults *preferences = [[NSUserDefaults standardUserDefaults] retain];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:11] ,@"interval",
@"127.0.0.2" , @"targetAddr",
NO, @"logEvents",
@"osa:@shimoUp.aplescript", @"upScript",
@"osa:@shimoDown.aplescript", @"downScript",
nil ]; // terminate the list
[preferences registerDefaults:dict];
If you have more than a few items, it is easier to provide a defaults file in the app bundle and load this instead:
NSUserDefaults *preferences = [[NSUserDefaults standardUserDefaults] retain];
NSString *file = [[NSBundle mainBundle]
pathForResource:@"Defaults" ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:file];
[preferences registerDefaults:dict];
After this is done, reading preference values is easy:
NSString *someString = [preferences objectForKey:@"targetAddr"];
int interv = [preferences integerForKey:@"interval"];
You might want to use the respective xxxForKey message depending on the type of preferences values.
Storing modified values is equally easy:
[preferences setInteger:someInt forKey:@"interval"];
[preferences setObject:someString forKey:@"targetAddr"];
The documentation for NSUserDefaults states that it will store the modifications from time to time to the underlying filesystem object, but I found it better to explicitly call
[preferences synchronize] to trigger this.
Friday, December 28, 2007
Cocoa: Timed methods
Sometimes one wants to run a job a regular or scheduled times. One option would be to start a loop that runs until some abort condition is reached and that sleeps after the job is done. This is easily done, but has the big disadvantage to block the GUI while it is sleeping.
A better alternative is to set up a timer that calls you back from time to time. Cocoa offers the
It is actually easy to create the job. First you need to decide which method will be notified. In our example here it is
The code to set up the timer could then look like this:
So this one schedules the execution of the runIt method of the same class the timer is created in, to repeat every 10 seconds.
Simple.
To cancel the timer again, one just has to send it an invalidate method:
I was first experimenting with
A better alternative is to set up a timer that calls you back from time to time. Cocoa offers the
NSTimer class for this. It offers a wealth of methods to set up the timer and insert it into the RunLoop. The timer will then send from time to time a message to a method of your app that does the job.It is actually easy to create the job. First you need to decide which method will be notified. In our example here it is
- (void) runIt (with no arguments).The code to set up the timer could then look like this:
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector: @selector(runIt)
userInfo:nil
repeats: YES];
So this one schedules the execution of the runIt method of the same class the timer is created in, to repeat every 10 seconds.
Simple.
To cancel the timer again, one just has to send it an invalidate method:
[timer invalidate]I was first experimenting with
scheduledTimerWithTimeInterval:invocation:repeats: but for whatever reason it did not work, even if the timer said it is valid. But the above works well for me and is even easier.
Some Mac coding ... finally
I did some coding on Mac OS X lately. Basically the first time some real stuff besides just firing Xcode and InterfaceBuilder and closing them after some poking around.
At first it feels somewhat strange to code in Objective-C, given that I mostly did Java coding for the last five years, but then it feels good again. I am writing 'again' on purpose, as the whole programing is like it was over ten years ago on the NeXT.
I will try to put some stuff online, as I did fight against some obstacles and want to share the results.
At first it feels somewhat strange to code in Objective-C, given that I mostly did Java coding for the last five years, but then it feels good again. I am writing 'again' on purpose, as the whole programing is like it was over ten years ago on the NeXT.
I will try to put some stuff online, as I did fight against some obstacles and want to share the results.
Saturday, December 08, 2007
Small Applescript to make iTunes play
I recently put my Mac mini into a server room and am running it headless now.
As this one also has the iTunes library and the connection to the stereo, I was using VNC to connect to it and to start and stop iTunes. Of course that is cumbersome.
So I googled a little on "applescript" and "iTunes" and found this wonderful site.
Using the information on it I was able to come up with this script, that I saved as playTunes.scpt
It will play the contents of a playlist called "a_Ungespielt" if iTunes is paused and stop playing otherwise.
I can now just log into the mini and start/stop playing with "osascript playTunes.scpt".
As this one also has the iTunes library and the connection to the stereo, I was using VNC to connect to it and to start and stop iTunes. Of course that is cumbersome.
So I googled a little on "applescript" and "iTunes" and found this wonderful site.
Using the information on it I was able to come up with this script, that I saved as playTunes.scpt
tell application "iTunes"
if player state is paused then
play user playlist "a_Ungespielt"
return "Playing"
else
pause
return "Stopped"
end if
end tell
It will play the contents of a playlist called "a_Ungespielt" if iTunes is paused and stop playing otherwise.
I can now just log into the mini and start/stop playing with "osascript playTunes.scpt".
Saturday, December 01, 2007
Marlene is standing on her own

Marlene is growing well. She is eight months old now and since three weeks, she is able to sit up on her own. She is not yet able to crawl on arms and legs, but she is already moving around quite a bit.
Today she was for the first time able to stand up on her own by holding the bars of her bed and pulling herself up. She was totally happy and excited - as we have been as well
Wednesday, November 21, 2007
Oracle surprise
I was hunting an issue where inserting an empty string (not null in Java, but with String.lenght()==0) resulted in a constraint violation exception. The column was a varchar2 one and indeed marked as not null.
I asked some people that should know (including a former DBA) and everyone told me that "" != null - always.
Digging around I found the following in an Oracle manual:
So in this case "" == null.
It is ok if one knows it and one can work around, but it came as surprise to me and others.
I asked some people that should know (including a former DBA) and everyone told me that "" != null - always.
Digging around I found the following in an Oracle manual:
Note: Oracle Database currently treats a character value with a length of zero as null. However, this may not continue to be true in future releases, and Oracle recommends that you do not treat empty strings the same as nulls.
So in this case "" == null.
It is ok if one knows it and one can work around, but it came as surprise to me and others.
Tuesday, November 20, 2007
Broken ixus
About one and a half years ago I bought myself a Canon Digital Ixus i Zoom. After two weks, the camera was broken, as the lens protection lids were just lying in the lens tube. I had the camera sent to Canon and they repaired it on warranty.
The camera worked well - until recently when I had the same issue again. Googling around indicated that this time the repair would be expensive.

After the camera was just lying around, I thougt "why don't I just remove the broken parts and try if it works again?"
Here is what worked for me.
I take no responsability whatsoever if your camera breaks, you hurt yourself or your dog runs away.
Continue reading at your own risk
So I took tweezers to try to remove them. As this was not soo easy I shaked the lens tube a bit and found out that I could just remove the cover.
The next image shows the parts that fell out

This closeup of the front shows an axis (red), a slider (green) and a hole (blue)

Put the one cover thingy with the hole marked in red on the axis and the hole marked in green on the slidrer. The teeth must be facing the hole marked in blue. Then put the other thingy in place with its little axis in the hole marked in blue and the teeth mathing those of the other one.

The result should look like in the next picture:

Or when you switch the camera on:

Now it is time to clip the grey plastic ring back on. There is basically only one way to do it right:

After that put the metal tube/front cover back on it and carefully apply some preasure to it. Volia the result:
The camera worked well - until recently when I had the same issue again. Googling around indicated that this time the repair would be expensive.

After the camera was just lying around, I thougt "why don't I just remove the broken parts and try if it works again?"
Here is what worked for me.
I take no responsability whatsoever if your camera breaks, you hurt yourself or your dog runs away.
Continue reading at your own risk
So I took tweezers to try to remove them. As this was not soo easy I shaked the lens tube a bit and found out that I could just remove the cover.
The next image shows the parts that fell out

This closeup of the front shows an axis (red), a slider (green) and a hole (blue)

Put the one cover thingy with the hole marked in red on the axis and the hole marked in green on the slidrer. The teeth must be facing the hole marked in blue. Then put the other thingy in place with its little axis in the hole marked in blue and the teeth mathing those of the other one.

The result should look like in the next picture:

Or when you switch the camera on:

Now it is time to clip the grey plastic ring back on. There is basically only one way to do it right:

After that put the metal tube/front cover back on it and carefully apply some preasure to it. Volia the result:
Wednesday, November 14, 2007
Hyperic and Red Hat cooperate
Red Hat / JBoss built the JBoss ON 1.x product on the base of code from Hyperic. Now the two companies
are going to collaborate on that.
Why do I write that? Because I am part of the JBossON team :)
are going to collaborate on that.
Why do I write that? Because I am part of the JBossON team :)
Friday, October 12, 2007
Use == for Enum comparision
I was recently running FindBugs over some Java5 based code and found some places where FindBugs was complaining that two Objects compared with
Closer inspection showed that this have been Enums in most cases. The IDEs did not warn here and maunal code inspection also does not directly show the issue.
Luckily with enums, you can use

Just a small little change in habits, but it helps a lot.
equals() are not of the same type.Closer inspection showed that this have been Enums in most cases. The IDEs did not warn here and maunal code inspection also does not directly show the issue.
Luckily with enums, you can use
== to compare them. And then it gets obvious:
Just a small little change in habits, but it helps a lot.
JIRAClient is cool
Recently we at JBoss® received licenses for JIRAClient. It is a cool desktop app (written in Java) that serves as a frontent to Atlassians JIRA bugtracking sytem. One of the nicest features here is offline mode: JIRAClient is ablw to download issues to its local database, so you can work offline and upload changes later on.
The staff at Almworks is very responsive in the forums and also open to suggestions.
If you are using JIRA on an daily basis, then you should definitively check out JIRAClient.
The staff at Almworks is very responsive in the forums and also open to suggestions.
If you are using JIRA on an daily basis, then you should definitively check out JIRAClient.
Thursday, October 11, 2007
pg_stat_activity is your friend
PgAdmin for postgres has a nice feature called "Server status". It is great if you sit in front of a GUI.
But if you want to do some remote work or tell a customer to report that server status, it is not quite the right thing.
But at the end, pgAdmin is only doing
This will show you all client connections together with the command they are currently executing.
But if you want to do some remote work or tell a customer to report that server status, it is not quite the right thing.
But at the end, pgAdmin is only doing
select * from pg_stat_activity order by procpid;
This will show you all client connections together with the command they are currently executing.
Tuesday, September 11, 2007
NPE due to autoboxing
One of the nice features of Java 5 is autoboxing. I guess everyone remembers the hassle of calling
Now can you guess what the following code does when you call
Yeah, it is throwing a
Unfortunately it seems like FindBugs and other tools are not (yet) able to detect this (actually in my test code, FindBugs was not even able to detect the NPE in teh explicit call).
Integer.intValue() to convert from Integer to int.Now can you guess what the following code does when you call
FB.foo()?
public class FB
{
public void foo()
{
int x;
x = bar();
System.out.println("X is " + x);
}
public Integer bar()
{
return null;
}
}
Yeah, it is throwing a
NullPointerException in the assignment x = bar() because bar() is returning null and the implicit bar().intValue() is thus throwing the NPE. Without autoboxing, this is much more evident.Unfortunately it seems like FindBugs and other tools are not (yet) able to detect this (actually in my test code, FindBugs was not even able to detect the NPE in teh explicit call).
Monday, August 13, 2007
x2svg new release 1.2beta1
Project x2svg just released a new version, 1.2-beta1
Changes are
* Documentation updates
* Changed handling of the property file. See properties.html.
* Fixed a bug where the directory path of the input was appended to the output if only a directory was given for output conversion (x2svg-Bugs-1770327)
* The gui no longer silently swallows errors (x2svg-Bugs-1771512)
* Comments can be added to a diagram e.g. stating the input file or user (x2svg-FR-1770604)
* Improved XSD handling. Recursions are handled and a big Schema from @work can now be parsed. Inheritance is honored.
* Fix for: "The DTDParser was going into an endless loop" (x2svg-Bugs-1766097).
* Added a test suite.
It can be downloaded from the sourceforge download pages at:
http://sourceforge.net/project/showfiles.php?group_id=199130&package_id=236217&release_id=531824
Changes are
* Documentation updates
* Changed handling of the property file. See properties.html.
* Fixed a bug where the directory path of the input was appended to the output if only a directory was given for output conversion (x2svg-Bugs-1770327)
* The gui no longer silently swallows errors (x2svg-Bugs-1771512)
* Comments can be added to a diagram e.g. stating the input file or user (x2svg-FR-1770604)
* Improved XSD handling. Recursions are handled and a big Schema from @work can now be parsed. Inheritance is honored.
* Fix for: "The DTDParser was going into an endless loop" (x2svg-Bugs-1766097).
* Added a test suite.
It can be downloaded from the sourceforge download pages at:
http://sourceforge.net/project/showfiles.php?group_id=199130&package_id=236217&release_id=531824
Saturday, August 11, 2007
Sleepless in Stuttgart - Part III
Over two month have now passed since my last post.
Both Kids are doing fine. Marlene is much more moving around (but still not crawling).
Around six weeks ago we've implemented the 8-o-clock rule for Orlando and since that time we have our evenings back to us.
The rule is very basic: "Orlando is in bed at 8pm and daddy and mommy are out until the next morning". Actually we have tried this several times in the past, but never really succeeded. The big difference now is that he has an analog clock in his room, so he can directly see if the big needle is already at the top and little one on the eight or not. When he is in bed before eight, we still have some time for reading. If he is in late, it is relatively easy to point him to the clock and tell him that it is late now. That system really works well for us.
End of June we did a short trip to the Bodensee (Lake of Constance) where we had a good time altogether. We were staying at a farm with lots of toys for children. Unfortunately Orlando was the only German kid at his age (there was a French girl), so we still were his major friends for playing). Next time we do such a trip, we will try to convince friends to come with us, so that the kids can go playing on their own.
I am having my second month of Elternzeit and am currently discussing the implementation of that with the regional agency, as the law seems to allow to take the Elternzeit only on the n-th month of birth of the child. So if the child is born on 15th of a month, you can only take Elternzeit from a 15th to a 14th on the next month, but not e.g. from 1st to 31th. Unfortunately I didn't know that :-/ Well lets see, what comes ...
Both Kids are doing fine. Marlene is much more moving around (but still not crawling).
Around six weeks ago we've implemented the 8-o-clock rule for Orlando and since that time we have our evenings back to us.
The rule is very basic: "Orlando is in bed at 8pm and daddy and mommy are out until the next morning". Actually we have tried this several times in the past, but never really succeeded. The big difference now is that he has an analog clock in his room, so he can directly see if the big needle is already at the top and little one on the eight or not. When he is in bed before eight, we still have some time for reading. If he is in late, it is relatively easy to point him to the clock and tell him that it is late now. That system really works well for us.
End of June we did a short trip to the Bodensee (Lake of Constance) where we had a good time altogether. We were staying at a farm with lots of toys for children. Unfortunately Orlando was the only German kid at his age (there was a French girl), so we still were his major friends for playing). Next time we do such a trip, we will try to convince friends to come with us, so that the kids can go playing on their own.
I am having my second month of Elternzeit and am currently discussing the implementation of that with the regional agency, as the law seems to allow to take the Elternzeit only on the n-th month of birth of the child. So if the child is born on 15th of a month, you can only take Elternzeit from a 15th to a 14th on the next month, but not e.g. from 1st to 31th. Unfortunately I didn't know that :-/ Well lets see, what comes ...
XO review by a 12 year old
This blog entry contains a review of the XO (the One Laptop Per Child, OLPC) machine.
Interesting read. I wish I could get my hands onto one as well
Interesting read. I wish I could get my hands onto one as well
Must sees in Stuttgart (?)
As you know I am a regular qyper since end of last year. Recently I got asked by another qyper from outside Germany what are the must sees in Stuttgart.
Well, the first solution to this would be to just select the entries with 5 stars. But this still leaves a big chunk of things.
So this is a very subjective list of must sees from my point of view. All urls refer to qype entries:
- TV-Tower: This is located on the top of one of the surrounding hills and was the first all concrete TV-tower in the world. You have a great view from up there. You can get there with Subway U7 from main station.
- Killesberg (+ tower) it is a nice parc with a cool tower there as well. You can get there via U7 as well (in the other direction). When you are up there and are into architecture, then you should also go and see the Weissenhofsiedlung or on Qype
- The Zacke also gives nice views over Stuttgart. Tickets for public transport are vaid here as well.
- The Königsstraße is the main shopping mile and starts at the main station. When you walk this pedestrian zone, you pass by at the châteaus , the new Kunstmuseum (this entry only describes the bar, but the picture shows what to expect) This link is better: http://www.kunstmuseum-stuttgart.de/de/index2.php
Then of course as the City of Mercedes and Porsche there are museums as well:
- Porsche Museum (currently in construction, but the old one is not far away.
- Mercedes Benz Museum
There are plenty more things to see. Check out the Qype listing for Stuttgart
Well, the first solution to this would be to just select the entries with 5 stars. But this still leaves a big chunk of things.
So this is a very subjective list of must sees from my point of view. All urls refer to qype entries:
- TV-Tower: This is located on the top of one of the surrounding hills and was the first all concrete TV-tower in the world. You have a great view from up there. You can get there with Subway U7 from main station.
- Killesberg (+ tower) it is a nice parc with a cool tower there as well. You can get there via U7 as well (in the other direction). When you are up there and are into architecture, then you should also go and see the Weissenhofsiedlung or on Qype
- The Zacke also gives nice views over Stuttgart. Tickets for public transport are vaid here as well.
- The Königsstraße is the main shopping mile and starts at the main station. When you walk this pedestrian zone, you pass by at the châteaus , the new Kunstmuseum (this entry only describes the bar, but the picture shows what to expect) This link is better: http://www.kunstmuseum-stuttgart.de/de/index2.php
Then of course as the City of Mercedes and Porsche there are museums as well:
- Porsche Museum (currently in construction, but the old one is not far away.
- Mercedes Benz Museum
There are plenty more things to see. Check out the Qype listing for Stuttgart
Monday, July 30, 2007
Gui for x2svg
Hi,
project x2svg just released a new version that now contains a simple graphical user interface.
You can download it from Sourceforge.
project x2svg just released a new version that now contains a simple graphical user interface.
You can download it from Sourceforge.
Subscribe to:
Posts (Atom)