1 11 package org.eclipse.ltk.internal.ui.refactoring.history; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.layout.GridData; 15 import org.eclipse.swt.widgets.Composite; 16 import org.eclipse.swt.widgets.Control; 17 import org.eclipse.swt.widgets.Label; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.swt.widgets.Text; 20 21 import org.eclipse.jface.dialogs.Dialog; 22 import org.eclipse.jface.dialogs.IDialogConstants; 23 24 29 public final class EditRefactoringDetailsDialog extends Dialog { 30 31 32 private String fDetails= ""; 34 35 private Text fDetailsField; 36 37 38 private final String fMessage; 39 40 41 private final String fTitle; 42 43 55 public EditRefactoringDetailsDialog(final Shell shell, final String title, final String message, final String details) { 56 super(shell); 57 fTitle= title; 58 fMessage= message; 59 if (details == null) 60 fDetails= ""; else 62 fDetails= details; 63 } 64 65 68 protected void buttonPressed(final int id) { 69 if (id == IDialogConstants.OK_ID) 70 fDetails= fDetailsField.getText(); 71 else 72 fDetails= null; 73 super.buttonPressed(id); 74 } 75 76 79 protected void configureShell(final Shell shell) { 80 super.configureShell(shell); 81 if (fTitle != null) 82 shell.setText(fTitle); 83 } 84 85 88 protected void createButtonsForButtonBar(final Composite parent) { 89 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); 90 createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); 91 fDetailsField.setFocus(); 92 if (fDetails != null) { 93 fDetailsField.setText(fDetails); 94 fDetailsField.selectAll(); 95 } 96 } 97 98 101 protected Control createDialogArea(final Composite parent) { 102 initializeDialogUnits(parent); 103 final Composite composite= (Composite) super.createDialogArea(parent); 104 if (fMessage != null) { 105 final Label label= new Label(composite, SWT.WRAP); 106 label.setText(fMessage); 107 final GridData data= new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); 108 data.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); 109 label.setLayoutData(data); 110 label.setFont(parent.getFont()); 111 } 112 fDetailsField= new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); 113 final GridData data= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); 114 data.heightHint= convertHeightInCharsToPixels(8); 115 fDetailsField.setLayoutData(data); 116 applyDialogFont(composite); 117 return composite; 118 } 119 120 125 public String getDetails() { 126 return fDetails; 127 } 128 } 129 | Popular Tags |