Archive for September, 2007

Displaying help in Wizards in Eclipse

Thursday, September 27th, 2007

I haven’t seen this full sequence written down anywhere (only in various partial fragments), so here it is for anyone who finds it useful. Here’s what you need to do if you want to add a Help button to your Eclipse wizard.

  1. In your wizard class, call setHelpAvailable(true).
  2. In your wizard page class, override performHelp() with code like this:
    public void performHelp() {
      PlatformUI.getWorkbench().getHelpSystem()
        .displayHelp(CONTEXT_ID);
    }
    
  3. CONTEXT_ID should be something like “.mywizardhelp”.
  4. Add a help context extension to your plugin. It should look something like:
    <extension
             id="com.wotsit.doodah.wizardhelp"
             point="org.eclipse.help.contexts">
          <contexts
                file="helpContexts.xml"
                />
       </extension>
    
  5. Create that helpContexts.xml file in the root of your plug-in. (It can be localised in fragments, incidentally). It should contain something like:
    <contexts>
          <context  id="wizardhelp">
            <description>Gets help about this wizard</description>
            <topic href="html/wizard.html"  label="My wizard help"/> 
            <topic href="html/toc.html"  label="General help"/>
      </context>
    </contexts>
    
  6. Finally, of course, create the help HTML itself (which you probably did already if you selected the easiest settings when creating your plug-in in the first place).

The bit I couldn’t find documented anywhere was the single line of code which ties it all together! So there might be a better way to do that, but it seems to work.

Numbering table rows in Word

Thursday, September 27th, 2007

Useful for test plans, etc.

Insert a field each time you want a number produced, with the formula “Seq XYZ”, where XYZ is any arbitrary label you want. (It won’t appear; it just gives a name to the sequence and ensures that each item with that name gets a unique number).

More advanced tips here.

UIQ3.1 SDK on Parallels

Thursday, September 27th, 2007

Back in November I was having difficulty getting the S60 3.1 SDK to run on Parallels. At that time I had access to some Symbian OS source code (through a contract) so was able to debug it. (Albeit not the S60 version, so hacking binaries was needed in the end.)

Now I’ve run into the same problem with the UIQ3.1 SDK, and my previous fix doesn’t quite work! And of course now I have no access to any source code to debug it. However I think I’ve found a fix that works.

Fortunately, my previous instructions contained enough pointless irrelevant information to enable me to figure out a fix this time round.

In short, here’s the change you need to make to your epoc32\release\winscw\udeb\ecust.dll binary.

0002e40: 0000 5959 5dc2 0400 b8bc 1041 00e9 ee5b  ..YY]......A...[
0002e50: 0000 5589 e56a ff68 9d2f 4000 64ff 3500  ..U..j.h./@.d.5.
0002e60: 0000 0064 8925 0000 0000 5053 5657 83ec  ...d.%....PSVW..
0002e70: 2851 b8cc cccc cc8d 7c24 04b9 0a00 0000  (Q......|$......
0002e80: f3ab 5989 4dbc c745 c000 c93d 006a 0fc7  ..Y.M..E...=.j..
0002e90: 45fc ffff ffff ff15 4042 4100 50c7 45fc  E.......@BA.P.E.
0002ea0: ffff ffff ff15 4442 4100 8d45 c450 c745  ......DBA..E.P.E
0002eb0: fcff ffff ffff 1548 4241 0083 f800 0f84  .......HBA......
0002ec0: a800 0000 8b45 c048 4848 4848 4848 4848  .....E.HHHHHHHHH
0002ed0: 4848 4848 4848 4848 4848 4848 4848 4848  HHHHHHHHHHHHHHHH

The reason the previous fix didn’t work is that the 84a8 instruction I suggested modifying previously no longer exists. Judging by the other stuff around (in particular the series of 4848484848…) this appears to be the same area of code, but no 84a8. Who knows why – maybe a new compiler version, or slightly changed code, or something.

Fortunately, though, in my previous post I’d noted that it was a loop over 4000000 iterations. 4000000 in hex is 0x3d0900. A bit further up (both in the old code and the new) we see 0009 3d00. Changing the digit before the 9 from a 0 into a c worked. It means the loop runs (many) more times, and therefore Parallels’ high-resolution timer is sufficient to distinguish the start and end of the loop.

(In fact, fiddling around with this number, I find that changing it from 4000000 to 8000000 is sufficient. You may experience differences…)

Yuck.

Zipping up directories from Java

Wednesday, September 26th, 2007

The standard Java libraries come with a convenient package for reading and creating Zip files (java.util.zip). The class representing a Zip file entry has a method isDirectory() which can tell you whether the entry is a directory.

Unfortunately there is no counterpart, setDirectory(), that can be used when you are creating a zip file.

Usually this doesn’t matter, because when you zip up a file and provide it with a path, the unzipper will create all the directories required to store the file in that path. The only problem, then, is if you need to store empty directories which contain no associated files.

Several solutions are found on the web for this, usually involving storing a slightly different type of filename. The Java API documentation itself suggests that any path ending in a slash will be regarded as a directory. None of these solutions work.

The reason none of them work is that there is actually a bit in the Zip file specification which is used to represent directories (in fact, the relevant bit of the Zip file structure is entitled ‘external attributes’ and is supposed to represent the DOS equivalents – set bit 4 to represent a directory). You can find PHP, etc. code on the web setting this field to 16 to represent directories. The Java zip classes simply don’t set that bit.

Solutions:

  • Use the zip library from Apache Commons, which does support these things.
  • Use the Zip comments field (or special filenames) to store metadata about the entries you put in your zip. This only works if you also control the unzipping process.

Eclipse in Ajax

Wednesday, September 12th, 2007

This is amazing. More details here.

Minor health and safety quirk

Tuesday, September 11th, 2007

I think I’ve found a bug in the health and safety rules.

These rules always say that you should adjust your working environment so that the top of your monitor is level with your eyes. Which I’d been doing – but I’d also been getting back pains.

What I hadn’t done is ensure that the top of the monitor is level with my eyes when my back is straight. So, my adjustments had involved altering the level of my monitor, but only to the level of my eyes when I was slumped in a presumably-unhealthy posture.

Arguably, since I wanted to believe that my monitor was at the correct level, I’d been slumping in order to comply with the rules. Only at a subconscious level though!

I have now put my monitor about 10 inches higher, which is definitely too far up, but I’ll see what effects it has and hopefully find a happy medium. I’m certainly finding my back is straighter – I am having to look up very high to see anything at all!

Google Earth Flight Sim

Sunday, September 2nd, 2007

Nothing to do with Macrobug…

But I’m pleased to see that the Google Earth built-in Flight Sim contains my old gliding club, Lasham, as one of its very select band of airports!