1 11 12 package org.eclipse.pde.internal.ui.editor.plugin.rows; 13 14 import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; 15 import org.eclipse.pde.internal.ui.PDEUIMessages; 16 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; 17 import org.eclipse.pde.internal.ui.editor.IContextPart; 18 import org.eclipse.swt.SWT; 19 import org.eclipse.swt.events.SelectionAdapter; 20 import org.eclipse.swt.events.SelectionEvent; 21 import org.eclipse.swt.layout.GridData; 22 import org.eclipse.swt.widgets.Button; 23 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.ui.forms.widgets.FormToolkit; 25 26 30 public abstract class ButtonAttributeRow extends ReferenceAttributeRow { 31 32 36 public ButtonAttributeRow(IContextPart part, ISchemaAttribute att) { 37 super(part, att); 38 } 39 40 public void createContents(Composite parent, FormToolkit toolkit, int span) { 41 super.createContents(parent, toolkit, span); 42 if(part.isEditable()) 43 { Button button = toolkit.createButton(parent, PDEUIMessages.ReferenceAttributeRow_browse, SWT.PUSH); 44 button.addSelectionListener(new SelectionAdapter() { 45 public void widgetSelected(SelectionEvent e) { 46 if (!isReferenceModel()) 47 browse(); 48 } 49 }); 50 } 52 } 53 54 protected GridData createGridData(int span) { 55 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 56 gd.widthHint = 20; 57 gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT; 58 return gd; 59 } 60 61 protected abstract void browse(); 62 63 } 64 | Popular Tags |