1 11 17 package org.eclipse.pde.internal.ui.editor.plugin.rows; 18 import org.eclipse.pde.core.plugin.IPluginModelBase; 19 import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; 20 import org.eclipse.pde.internal.ui.editor.IContextPart; 21 import org.eclipse.pde.internal.ui.editor.text.PDETextHover; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.swt.widgets.Display; 25 import org.eclipse.ui.forms.events.HyperlinkAdapter; 26 import org.eclipse.ui.forms.events.HyperlinkEvent; 27 import org.eclipse.ui.forms.widgets.FormToolkit; 28 import org.eclipse.ui.forms.widgets.Hyperlink; 29 30 public abstract class ReferenceAttributeRow extends TextAttributeRow { 31 32 public ReferenceAttributeRow(IContextPart part, ISchemaAttribute att) { 33 super(part, att); 34 } 35 36 42 protected void createLabel(Composite parent, FormToolkit toolkit) { 43 if(!part.isEditable()) 44 { super.createLabel(parent, toolkit); 45 return; 46 } 47 48 Hyperlink link = toolkit.createHyperlink(parent, getPropertyLabel(), 49 SWT.NULL); 50 link.addHyperlinkListener(new HyperlinkAdapter() { 51 public void linkActivated(HyperlinkEvent e) { 52 if (!isReferenceModel()) { 53 openReference(); 54 } else { 55 Display.getCurrent().beep(); 56 } 57 } 58 }); 59 PDETextHover.addHoverListenerToControl(fIC, link, this); 60 } 61 62 protected boolean isReferenceModel() { 63 return ((IPluginModelBase) part.getPage().getModel()) 64 .getUnderlyingResource() != null; 65 } 66 67 protected abstract void openReference(); 68 69 } 70 | Popular Tags |