1 11 package org.eclipse.ui.forms; 12 13 import org.eclipse.jface.dialogs.TrayDialog; 14 import org.eclipse.jface.window.IShellProvider; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.layout.GridData; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.Label; 20 import org.eclipse.swt.widgets.Shell; 21 import org.eclipse.ui.forms.widgets.FormToolkit; 22 import org.eclipse.ui.forms.widgets.ScrolledForm; 23 import org.eclipse.ui.internal.forms.Messages; 24 25 46 47 public class FormDialog extends TrayDialog { 48 private FormToolkit toolkit; 49 50 56 public FormDialog(Shell shell) { 57 super(shell); 58 setShellStyle(getShellStyle() | SWT.RESIZE); 59 } 60 61 67 public FormDialog(IShellProvider parentShellProvider) { 68 super(parentShellProvider); 69 } 70 71 76 public boolean close() { 77 boolean rcode = super.close(); 78 toolkit.dispose(); 79 return rcode; 80 } 81 82 87 protected Control createDialogArea(Composite parent) { 88 toolkit = new FormToolkit(parent.getDisplay()); 89 ScrolledForm sform = toolkit.createScrolledForm(parent); 90 sform.setLayoutData(new GridData(GridData.FILL_BOTH)); 91 ManagedForm mform = new ManagedForm(toolkit, sform); 92 createFormContent(mform); 93 applyDialogFont(sform.getBody()); 94 return sform; 95 } 96 97 102 protected Control createButtonBar(Composite parent) { 103 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 104 Label sep = new Label(parent, SWT.HORIZONTAL|SWT.SEPARATOR); 108 sep.setLayoutData(gd); 109 Control bar = super.createButtonBar(parent); 110 return bar; 111 } 112 113 120 protected void createFormContent(IManagedForm mform) { 121 mform.getForm().setText(Messages.FormDialog_defaultTitle); 122 } 123 } 124 | Popular Tags |