List of usage examples for org.eclipse.jface.window ToolTip show
public void show(Point location)
From source file:org.activiti.designer.property.extension.field.CustomPropertyDataGridField.java
License:Apache License
private void createHeader() { if (dataGridAnnotation.orderable()) { // Empty label for the header of order column final CLabel orderColumnLabel = factory.createCLabel(dataGridControl, "", SWT.WRAP); }//w ww .ja v a 2s. com // Create a row with headers for (final FieldInfo fieldInfo : gridFields) { final Property propertyAnnotation = fieldInfo.getPropertyAnnotation(); Composite headerGroup = factory.createFlatFormComposite(dataGridControl); final GridLayout headerLayout = new GridLayout(2, false); headerGroup.setLayout(headerLayout); final CLabel headerLabel = factory.createCLabel(headerGroup, propertyAnnotation.displayName()); GridData headerLabelData = new GridData(); headerLabelData.grabExcessHorizontalSpace = true; headerLabelData.horizontalAlignment = GridData.FILL; headerLabel.setLayoutData(headerLabelData); headerLabel.setFont(PropertyCustomServiceTaskSection.boldFont); final Help help = getHelpAnnotation(); if (help != null) { final Button propertyHelp = factory.createButton(headerGroup, "", SWT.BUTTON1); propertyHelp.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP)); GridData headerButtonData = new GridData(); headerButtonData.horizontalAlignment = SWT.END; headerLabel.setLayoutData(headerButtonData); // create a tooltip final ToolTip tooltip = new FormToolTip(propertyHelp, String.format("Help for field %s", propertyAnnotation.displayName().equals("") ? fieldInfo.getFieldName() : propertyAnnotation.displayName()), help.displayHelpShort(), help.displayHelpLong()); tooltip.setHideOnMouseDown(false); propertyHelp.addMouseListener(new MouseListener() { @Override public void mouseUp(MouseEvent e) { } @Override public void mouseDown(MouseEvent e) { tooltip.show(new Point(0, 0)); } @Override public void mouseDoubleClick(MouseEvent e) { } }); } final GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; headerGroup.setLayoutData(gridData); } if (dataGridAnnotation.orderable()) { // Empty label for the header of the two ordering columns final CLabel upColumnLabel = factory.createCLabel(dataGridControl, "", SWT.WRAP); final CLabel downColumnLabel = factory.createCLabel(dataGridControl, "", SWT.WRAP); } // Empty label for the header of the final column final CLabel finalColumnLabel = factory.createCLabel(dataGridControl, "", SWT.WRAP); }
From source file:org.eclipse.ui.internal.handlers.SpyHandler.java
License:Open Source License
/** * @param control//from w ww . j a va 2 s . c o m * @param offset * @param contributionInfo */ protected void doShowTooltip(Control control, Point offset, final ContributionInfo contributionInfo) { ToolTip toolTip = new ToolTip(control, ToolTip.NO_RECREATE, true) { protected Composite createToolTipContentArea(Event event, Composite parent) { // Create the content area Composite composite = new Composite(parent, SWT.NONE); Color fg = parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); Color bg = parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); composite.setForeground(fg); composite.setBackground(bg); Text text = new Text(composite, SWT.READ_ONLY); text.setForeground(fg); text.setBackground(bg); String info = NLS.bind(ContributionInfoMessages.ContributionInfo_ContributedBy, contributionInfo.getElementType(), contributionInfo.getBundleId()); text.setText(info); GridLayoutFactory.fillDefaults().margins(2, 2).generateLayout(composite); return composite; } }; toolTip.setHideOnMouseDown(false); toolTip.setHideDelay(3000); toolTip.show(offset); }