1 11 package org.eclipse.jdt.internal.ui.refactoring; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.events.ModifyEvent; 15 import org.eclipse.swt.events.ModifyListener; 16 import org.eclipse.swt.layout.GridData; 17 import org.eclipse.swt.layout.GridLayout; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.Control; 20 import org.eclipse.swt.widgets.Label; 21 import org.eclipse.swt.widgets.Text; 22 23 import org.eclipse.jface.dialogs.IDialogSettings; 24 25 import org.eclipse.jdt.internal.corext.refactoring.tagging.IQualifiedNameUpdating; 26 27 import org.eclipse.jdt.internal.ui.refactoring.reorg.RenameRefactoringWizard; 28 29 public class QualifiedNameComponent extends Composite { 30 31 private Text fPatterns; 32 33 public QualifiedNameComponent(Composite parent, int style, final IQualifiedNameUpdating refactoring, IDialogSettings settings) { 34 super(parent, style); 35 GridLayout layout= new GridLayout(); 36 layout.marginWidth=0; layout.marginHeight= 0; 37 layout.numColumns= 2; 38 setLayout(layout); 39 Label label= new Label(this, SWT.NONE); 40 label.setText(RefactoringMessages.QualifiedNameComponent_patterns_label); 41 fPatterns= new Text(this, SWT.BORDER); 42 fPatterns.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 43 label= new Label(this, SWT.NONE); 44 label.setText(RefactoringMessages.QualifiedNameComponent_patterns_description); 45 GridData gd= new GridData(GridData.FILL_HORIZONTAL); 46 gd.horizontalSpan=2; 47 label.setLayoutData(gd); 48 String text= refactoring.getFilePatterns(); 49 if (text == null) 50 text= settings.get(RenameRefactoringWizard.QUALIFIED_NAMES_PATTERNS); 51 if (text != null) { 52 fPatterns.setText(text); 53 refactoring.setFilePatterns(text); 54 } 55 fPatterns.addModifyListener(new ModifyListener() { 56 public void modifyText(ModifyEvent e) { 57 refactoring.setFilePatterns(fPatterns.getText()); 58 } 59 }); 60 } 61 62 public void setEnabled(boolean enabled) { 63 super.setEnabled(enabled); 64 Control[] children= getChildren(); 65 for (int i= 0; i < children.length; i++) { 66 children[i].setEnabled(enabled); 67 } 68 } 69 70 public void savePatterns(IDialogSettings settings) { 71 settings.put(RenameRefactoringWizard.QUALIFIED_NAMES_PATTERNS, fPatterns.getText()); 72 } 73 } 74 | Popular Tags |