1 /******************************************************************************* 2 * Copyright (c) 2011 Google, Inc. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Google, Inc. - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.wb.internal.core.model.property.table; 12 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.swt.widgets.Control; 15 import org.eclipse.swt.widgets.Shell; 16 import org.eclipse.wb.internal.core.model.property.Property; 17 18 /** 19 * Implementation of {@link PropertyTooltipProvider} for text. 20 * 21 * @author scheglov_ke 22 * @coverage core.model.property.table 23 */ 24 public abstract class PropertyTooltipTextProvider extends PropertyTooltipProvider { 25 //////////////////////////////////////////////////////////////////////////// 26 // 27 // PropertyTooltipProvider 28 // 29 //////////////////////////////////////////////////////////////////////////// 30 @Override 31 public Control createTooltipControl(Property property, 32 Composite parent, 33 int availableWidth, 34 IPropertyTooltipSite site) { 35 // prepare header and content 36 String header = null; 37 String content = null; 38 try { 39 // BEGIN ADT MODIFICATIONS 40 // was: header = property.getTitle(); 41 header = property.getName(); 42 // END ADT MODIFICATIONS 43 content = getText(property); 44 } catch (Throwable e) { 45 } 46 if (header == null || content == null) { 47 return null; 48 } 49 // create tooltip Control 50 return HtmlTooltipHelper.createTooltipControl(parent, header, content, 8); 51 } 52 53 @Override 54 public void show(Shell shell) { 55 // do nothing, Shell will be displayed when Browser will complete rendering 56 } 57 58 //////////////////////////////////////////////////////////////////////////// 59 // 60 // Text 61 // 62 //////////////////////////////////////////////////////////////////////////// 63 /** 64 * @return the text to show as tooltip. 65 */ 66 protected abstract String getText(Property property) throws Exception; 67 } 68