Yet another calendar widget

I needed a good calendar widget, so I took a look around. There are quite a few calendar widgets out there for Eclipse, but none of them did quite what I wanted. I looked at modifying one to better suit my requirements, but it turned out to be a lot harder than I had hoped. Naturally, I saw this as an opportunity to build my own.

I have to admit that there’s another reason for building my own: I really wanted to. I was in a mood to build a widget and this seemed as good a thing to build as any. I built the widget using standard SWT stuff. The initial implementation is derived from code contributed by Bahadir Yagan in bug 19945, however little of the original implementation remains.

Here’s what it looks like:

The calendar can be used either directly or as a drop-down. I spent a lot of time trying to get it work right with the keyboard; so the tab and arrow keys work the way that I think you’d expect. I’m sure that there’s more that it needs to do, and so I welcome your feedback. At very least, I need to do a little consolidation and commenting; while I like to think that my code is self documenting, I’m pretty sure that it’s not…

If you’re interested in taking a look, you can access it from here:

:pserver:anonymous@dev.eclipse.org:/cvsroot/org.eclipse
www/evangelism/samples/datepicker/code/org.eclipse.swt.extensions.datepicker

There’s a Main class included that demonstrates the operation of the widget.

One thing that I’ve been thinking about lately is ICU support. The current implementation doesn’t use ICU4J. Instead, I just used the standard Java classes to figure out how to build the calendar. My next step is to convert it over to use ICU4J and try to sort out how to handle arbitrary calendars (and there does seem to be a lot of them). The big challenge for me is that I know very little about other calendars. Okay… I know nothing about other calendars. If you’re curious to see what I’m talking about, browse the hierarchy for com.ibm.icu.util.Calendar to see all the different subclasses (each supporting a different calendar).

Assuming that I’m smart enough to sort this out (Maria is helping, so there’s a good chance that something good will come from this) I’ll let you know how it works out.

This entry was posted in Uncategorized. Bookmark the permalink.

7 Responses to Yet another calendar widget

  1. Eugene Kuleshov says:

    Are you planning to submit your work as a patch to that bug report? I wonder if your implementation is working within forms toolkit and on non windows platforms, especially that keyboard handling you implemented…I saw that Mylar implemented their own widget and for compatibility reasons had to use popup dialod.

  2. Jesper S Møller says:

    ICU4J is one thing, if you are planning on becoming a calendar geek, check out the Calendar FAQ: http://www.tondering.dk/claus/calendar.html

  3. Jeroen says:

    @jesper:At first I thought: “There’s actually been research done into calendars? How weird is…” *click click* “Wow!!”I got it bookmarked now, tnx for the link.@Wayne:What are the requirements of your widget? Still working on Eclipse 3.0.1 here. *sob* We have to do loads of date input here as well, so it would be nice to show something handy and pretty like this to the users. Which leads to my last question. Is it ready for prime time?

  4. Wayne says:

    I built it using Eclipse 3.2. I’m not sure if it’ll work in Eclipse 3.1, but I don’t see anything that should prevent it working; I’d be very appreciative if you could test it.As for the ready-for-primetime question… I think it’s close. However, I’m the only one using it so far, so I reserve answering until I hear back from a few more thoughts.

  5. Aaron Digulla says:

    Two suggestions:1. The year should be a text field. Imagine you have to enter “1936” or “1605”; that would be 70 or 400 clicks!2. Turn the month into a combobox (just two clicks instead of up to 11).

  6. Wayne says:

    @aaron: Thanks for the input. An entry field for the year could work. I’m not sure about the month, though… a combo box inside a dropdown feels a little odd. I’ll see what I can put together.

  7. Pingback: Laptop

Leave a comment