1 11 12 package org.eclipse.pde.internal.ui.wizards.cheatsheet; 13 14 import org.eclipse.jface.dialogs.IDialogConstants; 15 import org.eclipse.jface.dialogs.TrayDialog; 16 import org.eclipse.pde.internal.ui.PDEUIMessages; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.layout.GridData; 19 import org.eclipse.swt.layout.GridLayout; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Control; 22 import org.eclipse.swt.widgets.Label; 23 import org.eclipse.swt.widgets.Shell; 24 import org.eclipse.swt.widgets.Text; 25 26 30 public class NewCategoryNameDialog extends TrayDialog { 31 32 private Text fNameText; 33 34 private String fNameTextValue; 35 36 39 public NewCategoryNameDialog(Shell shell) { 40 super(shell); 41 42 fNameText = null; 43 fNameTextValue = null; 44 } 45 46 49 protected Control createDialogArea(Composite parent) { 50 51 Composite composite = createUI(parent); 52 createListeners(); 53 updateUI(); 54 55 return composite; 56 } 57 58 61 private Composite createUI(Composite parent) { 62 Composite container = createUIContainer(parent); 64 createUIInstructionLabel(container); 66 createUINameField(container); 68 applyDialogFont(container); 70 71 return container; 72 } 73 74 77 private void createListeners() { 78 } 80 81 84 private void updateUI() { 85 } 87 88 92 private Composite createUIContainer(Composite parent) { 93 Composite composite = new Composite(parent, SWT.NONE); 94 GridLayout layout = new GridLayout(2, false); 95 layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); 96 layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); 97 layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); 98 layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); 99 composite.setLayout(layout); 100 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 101 102 return composite; 103 } 104 105 108 private void createUIInstructionLabel(Composite container) { 109 Label label = new Label(container, SWT.WRAP); 110 label.setText(PDEUIMessages.NewCategoryNameDialog_instructionLabel); 111 GridData data = new GridData(GridData.FILL_HORIZONTAL); 112 data.horizontalSpan = 2; 113 data.widthHint = 200; 114 label.setLayoutData(data); 115 } 116 117 120 private void createUINameField(Composite parent) { 121 createUINameLabel(parent); 123 createUINameText(parent); 125 } 126 127 130 private void createUINameLabel(Composite parent) { 131 Label label = new Label(parent, SWT.NONE); 132 label.setText(PDEUIMessages.NewCategoryNameDialog_name); 133 } 134 135 138 private void createUINameText(Composite parent) { 139 int style = SWT.BORDER; 140 fNameText = new Text(parent, style); 141 fNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 142 } 143 144 147 protected void okPressed() { 148 fNameTextValue = fNameText.getText(); 151 super.okPressed(); 152 } 153 154 157 public String getNameText() { 158 return fNameTextValue; 159 } 160 161 } 162 | Popular Tags |