Wednesday, May 25, 2005

Making Open Type/Resource Dialogs respect current project

While I love the Eclipse Open Type/Resource dialogs they have a serious deficiency when it comes to working with multiple identical projects (e.g. different cvs branches)


For example, say I have 2 projects, P1 and P2 which are identical except from different cvs branches. If all I have open is P1/Foo.java and I go to open Bar.java, the Open Type dialog does not respect the fact that I'm currently working on P1, and I have to navigate to the right project within the dialog instead of simply hitting enter. This is not only a waste of time, its also very easy to mistakenly open/edit the wrong file!



I would much rather have the the default project selection be the same project as the project for the file I currently have focused. See the eclipse bug I have open on this issue.



Anyway, this problem annoyed me one time too many, so I ended up writing replacement dialogs that do the right thing. These are basically copies of the eclipse classes into my plugin with some tweaks - gotta love open source =). They'll be part of my sunshade plugin suite for the 3.1 release. The old dialogs will still be there, but you'll be able to map the old key bindings to my replacements if you wish. The Open Resource dialog replacement is intelligent and makes the default project selection be the current project, but you can navigate to other projects if you wish. On the other hand, Open Type Dialog limits the entire view to the current project - its seriously complex and I haven't dug in far enough to figure out how to get it to work like Open Resource does. Till then, I map ctrl-shift-t for OldOpenType, ctrl-shift-p for NewOpenProjectType, and ctrl-shift-r for NewOpenResource - you may like to do something similar.



I haven't checked them into CVS yet as I wanted to try and get OpenType working correctly. However, if you are as annoyed with the old behavior as I was, feel free to comment and I'll accelerate things. I'll probably submit a patch to eclipse as well, but who knows when that will be accepted, and I wanted to benefit from the new behavior now =)


Friday, May 20, 2005

Hosting your own domain (Part 1)

A quick HOWTO on the configuration of this site, and how I host my own domain over my cable modem to provide it.


This machine is actually my mythtv box which is serving dual pupose to host my domain. Seems to handle the load ok, but don't slashdot me or I'll miss my scifi channel. Actually, I'm more worried about my wife missing one her shows, that would truly be a disaster! ;)




Here is a basic description of my system. If you have a similar setup (or want one), then the rest of this article may prove useful. Its been a while since I set all this up, so I may be lacking some details. Feel free to correct me as needed, or suggest a better way to things.





  • Fedora Core 2

  • Apache 2.0.x

  • Tomcat 5.0.x (jdk 1.4.2.x)

  • Postfix SMTP/Dovecot IMAP/Squirrel WebMail

  • Pebble blog software 1.6.x





First you need to register a domain - I used GoDaddy to register mine, but any registrar should work just fine. The hardest part is coming up with a good name that hasn't already been taken.




Next you need someone to host your domain by providing DNS service for it. I use ZoneEdit because its free for up to 5 domains and does the job for me. A google search for "free dns service" will give you lots of choices. Once you sign up for an account, you need to create an entry for the domain name you chose above. The service should then tell you what DNS servers to use at the registrar for your domain (godaddy), so go back there and edit your domain to contain these DNS servers.





One pet peeve of mine is that the top level domain should resolve to the homepage rather than requiring the www prefix. Fortunately, this is the default behavior zoneedit, and it also defaults to adding a CName alias from www.yourdomain.com to yourdomain.com



Zoneedit also provides a mail service that will forward any address at your domain to a given email address. I prefer to host my own mail server (of course ;), so I disable this service and add a MX record from mydomain.com to mydomain.com. This way I can run my own SMTP/IMAP/Webmail servers. This may be too much for most sane people ;-)



You then need to setup any dynamic dns client to update your record in zoneedit whenever the IP address of your machine changes. I use ddclient on linux to do this, and it is setup as a daemon which checks every few minutes to see if the IP changes. This way I never have to worry about updating it manually because so long as my machine is on, zoneedit will have its correct IP. The custom part of my ddclient.conf config file looks like:


protocol=zoneedit1, \
server=www.zoneedit.com, \
login=myzoneeditlogin, \
password=somethingsecret \
yourdomain.com,yourotherdomain.com




At this point everything should be setup to resolve your domain name to your machine. However, it can take few days for zoneedit/godaddy/dns to do the initial sync up, so don't be alarmed if you can't resolve your domain name to your ip address right away.



Thats all for now. Part 2 will contain the configuration of my server software - apache/tomcat and postfix/dovecot/squirrelmail


Thursday, May 5, 2005

Testing/debugging code on the fly in eclipse


Sometimes its useful to be able to run a piece of code to see if it does what you want without having a test case for it.



Eclipse makes this easy to do with its Scrapbook Page feature. To create a Scrapbook Page, New (Ctrl-N) -> Java -> Java Run/Debug -> Scrapbook page. This brings up an editor into which you can add snippets of java code which you can then execute by selecting them, RC->Inspect/Display/Execute



But did you know you could also debug the code you are executing from a scrapbook? Since the scrapbook actually runs the code in a jvm running in a debugger, all you have to do is set breakpoints at the locations you care about. This makes it extremely easy for one to figure out if a utility method is doing what it should (but you should really write a test case ;), or inspect the execution of some javadoc deficient thirdparty code to figure out what it actually does before you make your code depend on it.