private void updatePresenceOfItem(TreeItem item, RosterEntry entry,
Presence presence) {
item.setImage(GOIMIcons.getImageForPresence(entry, presence));
int extensions = 0;
TreeEditor editor = getEditor(item, false);
if (presence != null) {
Iterator iterator = presence.getExtensions();
if (editor != null)
if (editor.getEditor() == null) {
System.err.println("editor.getEditor() is null !! "
+ this.getClass().toString());
} else {
for (Control control : ((Composite) editor.getEditor())
.getChildren())
control.dispose();
}
while (iterator.hasNext()) {
PacketExtension ex = (PacketExtension) iterator.next();
if (ex instanceof IGameExtension) {
extensions++;
if (editor == null)
editor = getEditor(item, true);
final IGameExtension gameEx = (IGameExtension) ex;
final GOIMGameItem game = gameEx.getGameItem();
final GameExtensionProxy proxy = gameEx.getGameExtension();
// final InetSocketAddress target = gameEx.getDestination();
Label label = new Label((Composite) editor.getEditor(),
SWT.NULL);
// Button label = new
// Button((Composite)editor.getEditor(),SWT.PUSH);
try {
label.setImage(proxy.getIcon().createImage());
} catch(SWTError error) {
error.printStackTrace();
// Since we still want the user to know about the error .. i throw an exception for now ..
throw new RuntimeException("An SWT Error occurred during setting game icon",error);
}
label.setToolTipText(proxy.getTooltipText(game, gameEx));
System.out.println("Addin label with image: " + proxy.icon
+ ": " + label.computeSize(-1, -1));
// label.setEnabled(true);
// label.setText("Muh");
label.setLayoutData(new RowData(16,16));
if (game != null) {
label.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
//System.out.println("mouseup");
proxy.execute(game, gameEx);
}
});
label.setFocus();
} else {
label.setToolTipText("Game not installed: "
+ label.getToolTipText());
}
((Composite) editor.getEditor()).layout(true, true);
((Composite) editor.getEditor()).pack(true);
editor.minimumWidth = editor.getEditor().getSize().x;
editor.layout();
}
}
}
if (extensions < 1 && editor != null) {
editor.getEditor().dispose();
editor.dispose();
item.setData("editor",null);
}
contactList.redraw();
}