List of usage examples for org.eclipse.jface.window ToolTip hide
public void hide()
From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.java
License:Open Source License
/** * Re-layout the labels for the new message. * //from w ww. j ava2s .c om * @param forceLayout * <code>true</code> to force a layout of the shell */ private void layoutForNewMessage(boolean forceLayout) { int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); // If there are no images then layout as normal if (errorMessage == null && messageImage == null) { setImageLabelVisible(false); setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing); } else { messageImageLabel.setVisible(true); bottomFillerLabel.setVisible(true); leftFillerLabel.setVisible(true); /** * Note that we do not use horizontalSpacing here as when the * background of the messages changes there will be gaps between the * icon label and the message that are the background color of the * shell. We add a leading space elsewhere to compendate for this. */ FormData data = new FormData(); data.left = new FormAttachment(0, H_GAP_IMAGE); data.top = new FormAttachment(titleLabel, verticalSpacing); messageImageLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(messageImageLabel, 0); data.left = new FormAttachment(0, 0); data.bottom = new FormAttachment(messageLabel, 0, SWT.BOTTOM); data.right = new FormAttachment(messageImageLabel, 0, SWT.RIGHT); bottomFillerLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(messageImageLabel, 0, SWT.TOP); data.left = new FormAttachment(0, 0); data.bottom = new FormAttachment(messageImageLabel, 0, SWT.BOTTOM); data.right = new FormAttachment(messageImageLabel, 0); leftFillerLabel.setLayoutData(data); FormData messageLabelData = new FormData(); messageLabelData.top = new FormAttachment(titleLabel, verticalSpacing); messageLabelData.right = new FormAttachment(titleImageLabel); messageLabelData.left = new FormAttachment(messageImageLabel, 0); messageLabelData.height = messageLabelHeight; if (titleImageLargest) messageLabelData.bottom = new FormAttachment(titleImageLabel, 0, SWT.BOTTOM); messageLabel.setLayoutData(messageLabelData); } if (forceLayout) { getShell().layout(); } else { // Do not layout before the dialog area has been created // to avoid incomplete calculations. if (dialogArea != null) workArea.getParent().layout(true); } 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(); } }