Thursday, October 4, 2007

OOPSLA 07'

If you want to learn eclipse plug-in development, we are giving a tutorial at OOPSLA 2007 in Montreal. The tutorial is called "Developing plug-ins and applications on eclipse platform", it's number 49, on Thursday afternoon. There are still places available and the registration is almost over so hurry up. Together with Amir Kirsh, we will have a beautiful presentation, comprehensive eighty page long companion and breathtaking demos. We will cover GEF, RCP, SWT and jFace, all this on the new eclipse 3.3.

It will be fun, so you are all welcome.

See ya there.

Tuesday, August 21, 2007

Oh, I just want it to work as, you know, in Explorer

"I mean, is it too much to ask" said my product manager. All she wanted is to be able to rename an element in the tree viewer we have in our application. "Just like in Windows Explorer", she said.

Right.

In Explorer, when you click an element and then click it again, after some time, an in place editor is opened allowing you to rename the file or directory. But if you click fast enough, the system recognizes this as double click and performs the associated operation (i.e. opens a file or enters a directory). We wanted to do the same in our tree control.

At first it looked easy, the Internet is full of examples of how to add an in place editor to the SWT Tree control. However, problems began when we tried to determine when the editor should be activated. It should be when the same element is selected twice in a row, but not it should not happen when the element is double clicked.

Now, I have to admit, I am a little confused since there are two different types of events. There is a Selection event, which can handle both single and double click operations. There is also a MouseDown event, which also can be used for this purpose. In addition it is possible to monitor events that occur in the jFace TreeViewer or the underlying SWT Tree control itself. Very confusing.

First attempts left us with buggy, inconsistent behavior, nowhere near our Explorer ideal. We had problems with activation, the double click still activated the editor. We also had different problems with TRAVERSE_ESCAPE event due to the fact that we did not know how to correctly handle FocusOut. It was really frustrating.

I would like to present a solution which seems to satisfy all our requirements, though I admit it is not a peak of beauty. It does seem to work, however, which in our line of business is a plus.

The solution is based on a single SelectionListener implementation attached directly to the Tree which handles both single and double clicks (through widgetSelected and widgetDefaultSelected methods). In addition we remember the last selected element and whenever a double click is recognized we raise a special flag. The purpose of this flag is to avoid entering the editor in case an already selected element is double clicked.

Each time widgetSelected is called, it updates the last selected element and then waits for about half a second. It then checks whether a double click flag is up, and if it is not, opens the rename editor. After the editor exits, the flag is reset.

I really hope there is a better and shorter solution which provides the same functionality, I did not check Eclipse 3.3 yet, I hope it is there. In any case, if you need this solution add comment with your email and I will send you the source. It will also be available for download from here as a part of the new RadView Reporter. Look for version 10, it should be there in about two weeks. You will be able to find this code in the TemplatesView class.

Sunday, August 12, 2007

Would you trust them?

Several days ago Steve Jobs announced a new line of iMac computers, beautifully designed, thinner than ever, great products for those who care. Not only are they a better value than the old ones, but the 17" model was replaced by the 20" one for the same price. Clearly no one in his own mind would buy an old iMac today, wouldn't he?

Not in the opinion of this, large (by local standards), computer store chain, here in Israel, who keeps advertising and selling old iMacs on their site without a word of warning. I am really interested whether one of those was sold these days. I bet there weren't any, since Apple users are generally perceived as an knowledgeable and updated bunch.

Yet, if this obsolete piece of machinery sits happily there on the site, then what could we say about less celebrated computer related products. Hard drives, cameras, computer monitors? Would it be nice to buy a 22" display just to find out that a better model is already out for the same price. Not keeping the site updated, just teaches the consumer not to trust this store and its site and always double check everything.

Clearly not a reputation you want to have.

Friday, June 29, 2007

Weird behavior

Yesterday I was working on final graphics of our new Eclipse RCP based application (http://www.webload.org/ ). Among the icons, we have asked the designers to prepare an application window icons, which are set in the branding section of product configuration. The designers did a great job, the icon looks excellent.

But when we tried to put it in place, we have discovered that the dialog is only able to accept GIF format, nothing else.


The designers, have supplied the icons in the PNG format, clearly a much better suited for graphical work. I have asked them to convert the icons to GIF, and they said, "OK, which background would you like?". I didn't know. I said, well, I kinda need it transparent, to look good in the different versions of windows and in the Alt + Tab window, is that possible? They said "yes, it is". However, they said, there are no transparency levels, it is all or nothing. So, the icon looks pretty awful, especially when switching between applications.

Clearly I was not satisfied. I pointed at the eclipse icon, which looked great and asked them to make ours in the same way. The said that it could not be done with GIF and offered me a bet if I could find that icon in eclipse installation and show it to them. They sounded confident enough, so instead of taking the bet I have downloaded a small utility that can look into JARs and looked for all images called "eclipse" in the installation directory. I found quite a few GIFs, but none of them was what I was looking for. On the other hand, I found quite a lot PNGs, just like designers have said. I was very glad I did not take that bet but I still had a problem. How would I put PNG into a field that only accepts GIFs. One of the designers suggested that I put it there nonetheless. I was skeptical but decided to do it. It has produced an ugly warning, but, amazingly, it worked. The icon worked exactly as required.

Needless to say I was looking a little stupid, I also felt bad for eclipse, after all - what is that? I did not manage to find a good explanation for this strange behavior so far. Why would this dialog only allow to put GIF images and not PNG images that work much better. I will try to investigate this further and keep you posted but if by any chance you know the answer, or you know an already open bug on the subject please tell me.





























Thursday, June 28, 2007

iDay tribute


This days I am a little confused. What will it be, the long tail or the fat head?

The long tail sounds smart, insightful. One of those, "did you know" things. Fat head sounds simple and powerful, you are the best in the world and you get four times more than the next guy. What are you doing now? Quit it and go be the best in the world.

So which will it be?

Well, both, of course. Be the head and use the tail. Just like Apple does today with iPods (the head) and iTunes (the tail). But though both are smart ways to make money, the head has something that the tail doesn't. Romance.

Now, as I write these lines, there are people sleeping in the street. There are people, sleeping in the streets of New York. People sleeping in the streets, with little tents and blankets. Waiting for iPhone, to arrive three days from now.

It's not a gadget, it's not a product, it's a dream. It's a romantic dream of red eyed high tech workers and amateur tech lovers, consumers and engineers. You see, now that's a product. It can do this, it can do that, it's amazing. It's something worth waiting for, for three days in the street. That's what this is.

It's a dream about doing something right. Right now. Will it work well right from the start, maybe not. But we dream it will.

It's an epic launch. Will it sell? Who cares. Windows 95 launch was a blast. Did it sell? It did. So what. Was it a great product, probably, at the time, I don’t remember. What do I think of it now? It sucks.

So what is it about. It's about hype. And today, hype is global. It's about inspiration. It's about watching the commercial, and wishing there were more like it. More dreams.

It's about lifestyle. It's about what you think about when someone around says "simple", "clean", "white".

It's not about tomorrow. It's about today.

It's about winners. It's about being the best in the world. It's about big fat head.

I choose the head.

Friday, April 20, 2007

Dear computer, please tell me why...

It might sound like a regular customer service rant.

Yesterday my wife and I went to a large supermarket near the house. Among other things we have bought three bottles of juice that had a special price, something like "take three and get 40% discount". I am not a great believer in discounts so naturally, when we approached the cashier, the only thing that really interested me was to make sure we get it.


As expected, once the purchase was complete, we found out that the computer did not give us the discount on the juice. I would be actually surprised if it did since the complexity of these, so called, discounts is just too large to be practical. It would take a supercomputer to track them all. Without going into technicalities let’s just say that Jurassic Park failed for the same reason.

Of course, we asked: “Why?”

Now, cashiers in those kind of places are caught in constant crossfire between bosses and customers. They have to enforce the random policies invented by the store managers and at the same time patiently explain them to the angry customers that argue with it. Of course the woman at the register did not know why the computer missed the discount in this particular case. She did not invent it and she did not program it into the system. What could she do?

It was at this point that the giant usability problem in this whole system became painfully obvious to me and the poor people stuck behind me in the line for whole ten minutes. This system was not designed to answer the question why? The cashier had nothing she could do with all this complex, full-of-colorful-buttons, vertical-shaky-touch-screen piece of junk. It was of no help at all. In fact, she had only two good old fashioned choices. She could either call the manager or get up and go across the floor to the shelf to see with her own eyes what was written on that bloody label.

Well, since it was never about the money, we closed the account as it is, right before the raging mob behind us managed to get hold of their lawyers. Later, I went to the store management and got my couple of dollars worth of discount back by proving them I was right and they were wrong and we went home happy, to sleep off the heavy headache.

Now we get to the point.

The point is that we were wrong. The very small letters on the discount label stated that it was for “some blah blah card holder only” and we didn’t have that specific blah blah card in the first place. So we were not actually supposed to get this discount and the computer was right after all. It just could not explain it to us, the cashier or the store manager. As a result we all have wasted lots of time and nerves because the computer could not answer the question why?

Deeper analysis of the situation shows that it is as simple as one, two, and three.

One. All these discounts, sales, cards, rules and policies are too complex for any man to grasp. They can only be upheld by complex dynamic computer systems like the one we have seen in that store.

Two. People dealing with these systems are tired cashiers with sore finger from touching the screen all day from one end and angry, suspicious customers, tired from constantly checking, arguing and eventually returning products that were not priced as they expected because they failed to read some small letters somewhere or made a mistake in some complex percent calculation on the other.

Three, and the most important. The system is not designed to explain its rules to the user. It can make a decision but it can’t explain why it made it.

Back in time, moment of sale, customer asks a question, the clerk pushes the “Why?” button, screen comes up. “Dear Sir, the discount for juice is for: 1. Card holders only 2. That bought over this amount 3. And wear a black tie. You were rejected for 1. not having a card. Please be more careful next time and have a nice day”. And if the customer does not believe it, it will show the exact scan of the label that appeared on that shelf so that the customer can be sure he talks about the same sale.

How cool would that be.

Have a nice day indeed.

Tuesday, March 13, 2007

Guess What Happened

I will start with an old haiku which seems painfully appropriate for the moment:

Three things are certain:
Death, taxes, and lost data.
Guess which has occurred.

It all happened so quickly. I have created a new project in Eclipse to add some minor library to the prototype application I have been writing for three days. Since my projects sit outside the workspace, I had to uncheck this little checkbox suggesting me to put a new project in default location and type the new location (a directory not far from there) by myself.

For some strange reason, when you uncheck this box, the text field with the directory path becomes empty so despite the fact that the directory I needed was just beside the one that is already written there by default I had to switch to explorer, copy and paste the path manually into the field.

This is where I erred. After pasting the directory, I forgot that this was the path of the directory where all my projects resided, the parent directory - not the directory of the new project I wanted to create. Before I realized that I hit OK, and there it was - my new project created in the projects parent directory instead of a nice little directory of its own.

Well, I suppose these things happen, said I when I realized my mistake, I will just delete that project and create a new one in the correct directory. So I said, and pressed the "delete" button.

But this story is not about me, it's about Eclipse. After I pressed that button, Eclipse inconspicuously asked me whether I wanted to remove the project from the workspace only or delete its contents as well, all that with straight, poker face, calm as a frozen lake. I thought "why would I need to keep contents of an empty, just created, project in the wrong location" so I hit "delete contents" - and that was exactly what Eclipse did.

He deleted the contents of the entire directory, all three meaningless files that were created with the new plugin project and ALL SUBDIRECTORIES WITH ALL MY OTHER PROJECTS as well.

It was almost too easy. BOOM - everything was gone.

I know what you are thinking so NO - I did not have a backup, NO - it was not in a source control and NO - I did not have anyone to blame. Three days of work, were gone. Eclipse does not have any Recycle Bin and I did not have a good recovery software installed, and I only have one logical drive - so if I would install one I would risk accidentally overwriting the very data I was trying to rescue. The irony tends to get thick in situations like these.

It looked hopeless, but I know you are waiting for the happy ending, so here it comes.

Once, in one obscure Eclipse conference, I heard that there is such a thing called "local history" in Eclipse 3.2, and that in that history they save all the files you work on so you can go back and undo some changes that you have done and compare previous versions. Lucky for me, this history is saved in the workspace .metadata directory that was not deleted during the accident. After a few minutes I have found it, a bunch of tiny little files with long meaningless names, just lying there happily, each holding a class full of my precious code.

It only took three hours of scraping around to restore 90 percent of the code I have written, and I filled in the rest - so in almost no time I had all my stuff back in good working condition, even better, as in some cases I found bugs while reviewing the code and looking for the changes.

Now for the moral.

First, do backup, do use source control and don't be an idiot.

Second, be extra careful with what you DELETE with Eclipse. Eclipse has it's own file system underneath, so everything it deletes does not go to the Windows recycle bin, or any other place you can salvage it from. This is just plain barbaric. Even my browser has a trash can, in case I accidentally close a tab I did not yet bookmark.

Third, just for the sake of emergencies. Find, try and buy a good piece of software that restores deleted files and keep it installed on your computer at all times. It might save you some nerves one day or another.

And last, listen carefully in conferences, you never know what might save your day next time :)