if (tree.getItemCount() == 0) {
return;
}
int indent = SideBar.END_INDENT ? tree.getClientArea().width - 1 : 0;
TreeItem treeItem = tree.getItem(new Point(indent, mousePos.y));
if (treeItem == null) {
return;
}
mdiEntry = (MdiEntry) treeItem.getData("MdiEntry");
if (mdiEntry == null) {
return;
}
Rectangle itemBounds = treeItem.getBounds();
Point relPos = new Point(mousePos.x, mousePos.y - itemBounds.y);
String sToolTip = getToolTip(relPos);
if (sToolTip == null || sToolTip.length() == 0) {
return;
}
lastRelMouseHoverPos = relPos;
Display d = tree.getDisplay();
if (d == null)
return;
// We don't get mouse down notifications on trim or borders..
toolTipShell = new Shell(tree.getShell(), SWT.ON_TOP);
toolTipShell.addListener(SWT.Dispose, new Listener() {
public void handleEvent(Event event) {
UIUpdaterSWT.getInstance().removeUpdater(SideBarToolTips.this);
}
});
FillLayout f = new FillLayout();
try {
f.marginWidth = 3;
f.marginHeight = 1;
} catch (NoSuchFieldError e) {
/* Ignore for Pre 3.0 SWT.. */
}
toolTipShell.setLayout(f);
toolTipShell.setBackground(d.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
toolTipLabel = new Label(toolTipShell, SWT.WRAP);
toolTipLabel.setForeground(d.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
toolTipLabel.setBackground(d.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
toolTipLabel.setText(sToolTip.replaceAll("&", "&&"));
// compute size on label instead of shell because label
// calculates wrap, while shell doesn't
Point size = toolTipLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (size.x > 600) {
size = toolTipLabel.computeSize(600, SWT.DEFAULT, true);
}
size.x += toolTipShell.getBorderWidth() * 2 + 2;
size.y += toolTipShell.getBorderWidth() * 2;
try {
size.x += toolTipShell.getBorderWidth() * 2 + (f.marginWidth * 2);
size.y += toolTipShell.getBorderWidth() * 2 + (f.marginHeight * 2);
} catch (NoSuchFieldError e) {
/* Ignore for Pre 3.0 SWT.. */
}
Point pt = tree.toDisplay(mousePos.x, mousePos.y);
Rectangle displayRect;
try {
displayRect = tree.getMonitor().getClientArea();
} catch (NoSuchMethodError e) {
displayRect = tree.getDisplay().getClientArea();