}
int messageLabelUnclippedHeight = messageLabel.computeSize(messageLabel.getSize().x - xTrim, SWT.DEFAULT, true).y;
boolean messageLabelClipped = messageLabelUnclippedHeight > messageLabel.getSize().y - yTrim;
if (messageLabel.getData() instanceof ToolTip) {
ToolTip toolTip = (ToolTip) messageLabel.getData();
toolTip.hide();
toolTip.deactivate();
messageLabel.setData(null);
}
if (messageLabelClipped) {
ToolTip tooltip = new ToolTip(messageLabel, ToolTip.NO_RECREATE, false) {
protected Composite createToolTipContentArea(Event event, Composite parent) {
Composite result = new Composite(parent, SWT.NONE);
result.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
result.setLayout(new GridLayout());
Text text = new Text(result, SWT.WRAP);
text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
text.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
text.setText(messageLabel.getText());
GridData gridData = new GridData();
gridData.widthHint = messageLabel.getSize().x;
text.setLayoutData(gridData);
Dialog.applyDialogFont(result);
return result;
}
public Point getLocation(Point tipSize, Event event) {
return messageLabel.getShell().toDisplay(messageLabel.getLocation());
}
};
messageLabel.setData(tooltip);
tooltip.setPopupDelay(0);
tooltip.activate();
}
}