Wednesday, December 20, 2006

TBC: Name Completion with Ctrl+Space

Learned another TopBraid Composer trick: when filling out form fields, you can type Ctrl+Space bar to do name completion, very handy. Of course dragging and dropping classes into the slot areas works as well.

Probably lots more tips waiting for me if I read the manual one day...

Friday, December 15, 2006

HowTo: Remember Your Power Chord

Not a semantic tech topic, but a note to self on how to be a better computer user and save much pain and anguish. A coworker rescued me last night when I had left my laptop's power chord in the office when returning to my hotel. I've done this a number of times, the worst case undoubtedly in 2003 when I discovered at the airport that I had left my power cable behind and had no time to retrieve it before making a 3+ week international journey. A great friend who had a key to my house dashed off, found the chord (amongst many similar chords), sped off to the airport and saved the day. I thought that would be enough to teach me never to forget my chord again... it wasn't.

But now, I think I've hit upon a nearly fool proof way to always remember it:
Pack the chord first.
Pack the chord before you pack up the laptop.
The risk is then that you might get distracted before packing the laptop itself. The obviously too lite computer bag is sure to remind you, so risk mitigated.

Wednesday, December 13, 2006

Class Labels & Window Wrangling

Learned some new tricks with TopBraid Composer and Eclipse.

When you create a new class or subclass in TBC, at the bottom of the wizard window there will be rdfs:label under the "Property" column and an empty cell in the "Initial Value" column. Check the rdfs:label checkbox and in the "Initial Value" column put {name}. This sets the default value for future class creations as well. {name} will automagically copy the class name into the rdfs:label field after you click "Ok".

Somehow I managed to make my "Classes" window a tab of my "Navigator" window, and also managed to make my "Basket" window pane a tab within the pane to its left. Restoring the tab into a separate window pane is not intuitive. The way to do it is to hold down your left mouse button and drag the window to the edge of eclipse (left-right, or top-bottom) until a black arrow head appears. When this arrow head appears, you can release the mouse button and the window is returned as either a vertical split or horizontal split depending on where you dragged the window to. This also works in other places where you see tabs, such as for source files. Move a source tab in the same way and vertically split the pane, then seeing both windows side by side.

Friday, December 08, 2006

A Trisket, A Trasket, A Little Semantic Basket

Spent some time writing my first eclipse plug-in following the steps on the TopBraid Composer (TBC) Plug-in Development Guide, fun stuff! Plus I learned my new favorite eclipse command Ctrl+Shift+M which will automatically add the import for an unresolved class (keep your mouse over the class when hitting the sequence).

So I used the CreateInstanceAction skeleton and added my own JenaFu to find the resources I wanted from the loaded model, then printed the resources to System.out. It soon dawned on my that the snazier thing to do would be to send the resources to the "Basket" instead. Some inquiries to the TBC folks uncovered that the needed BasketView class was not exported from the jar in TBC 1.3, but they did export it in the 1.4 release that came out today. Thanks guys!

The tweaks needed:

import org.topbraidcomposer.ui.views.basket.BasketView;
:
IWorkbench wb = org.eclipse.ui.PlatformUI.getWorkbench();
IWorkbenchWindow wbw = wb.getActiveWorkbenchWindow();
IWorkbenchPage wbp = wbw.getActivePage();
:
try {
BasketView basket = (BasketView)wbp.showView("org.topbraidcomposer.ui.views.basket");
:
while (iter.hasNext) {
basket.add( (Resource)iter.next() );
}
:
}
catch(PartInitException ex) {
:
}

Some gotchas:

1) wb.getActiveWorkbenchWindow(); will return null if it is not invoked within a "UI Thread". So if these basket sending lines are in the "AbstractChange" class, or in another class that's called by the AbstractChange class, then you're in a UI Thread and it bombs.

2) code put after the TB.getSession().getChangeEngine().execute(change); will be executed before the line. Really.

3) you don't actually need the AbstractChange class and the corresponding TB...execute(change); line unless you've modified the loaded model.

4) if you do modify the model and want to send items to the basket, then invoke the TB...execute(change); line with an extra argument as per:

Runnable andThen = new Runnable() {
public void run() {
sendFoundStatementsToBasket();
}
};
TB.getSession().getChangeEngine().execute(change, andThen);

or with an anonymous runnable as the 2nd arg.