1 11 package org.eclipse.jdt.internal.ui.refactoring.reorg; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.events.SelectionAdapter; 15 import org.eclipse.swt.events.SelectionEvent; 16 import org.eclipse.swt.layout.GridData; 17 import org.eclipse.swt.widgets.Button; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.Label; 20 21 import org.eclipse.ltk.core.refactoring.Refactoring; 22 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 23 import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; 24 25 import org.eclipse.jdt.internal.corext.refactoring.rename.RenamePackageProcessor; 26 27 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 28 import org.eclipse.jdt.internal.ui.JavaPluginImages; 29 import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages; 30 import org.eclipse.jdt.internal.ui.util.RowLayouter; 31 32 33 public class RenamePackageWizard extends RenameRefactoringWizard { 34 35 public RenamePackageWizard(Refactoring refactoring) { 36 super(refactoring, 37 RefactoringMessages.RenamePackageWizard_defaultPageTitle, 38 RefactoringMessages.RenamePackageWizard_inputPage_description, 39 JavaPluginImages.DESC_WIZBAN_REFACTOR_PACKAGE, 40 IJavaHelpContextIds.RENAME_PACKAGE_WIZARD_PAGE); 41 } 42 43 protected RenameInputWizardPage createInputPage(String message, String initialSetting) { 44 return new RenamePackageInputWizardPage(message, IJavaHelpContextIds.RENAME_PACKAGE_WIZARD_PAGE, initialSetting) { 45 protected RefactoringStatus validateTextField(String text) { 46 return validateNewName(text); 47 } 48 }; 49 } 50 51 private static class RenamePackageInputWizardPage extends RenameInputWizardPage { 52 53 private Button fRenameSubpackages; 54 public RenamePackageInputWizardPage(String message, String contextHelpId, String initialValue) { 55 super(message, contextHelpId, true, initialValue); 56 } 57 58 protected void addAdditionalOptions(Composite composite, RowLayouter layouter) { 59 fRenameSubpackages= new Button(composite, SWT.CHECK); 60 fRenameSubpackages.setText(RefactoringMessages.RenamePackageWizard_rename_subpackages); 61 boolean subpackagesSelection= getBooleanSetting(RenameRefactoringWizard.PACKAGE_RENAME_SUBPACKAGES, getRenamePackageProcessor().getRenameSubpackages()); 62 fRenameSubpackages.setSelection(subpackagesSelection); 63 getRenamePackageProcessor().setRenameSubpackages(subpackagesSelection); 64 fRenameSubpackages.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 65 fRenameSubpackages.addSelectionListener(new SelectionAdapter(){ 66 public void widgetSelected(SelectionEvent e) { 67 getRenamePackageProcessor().setRenameSubpackages(fRenameSubpackages.getSelection()); 68 69 RefactoringStatus status= validateTextField(getText()); 70 if (status == null) 71 status= new RefactoringStatus(); 72 setPageComplete(status); 73 } 74 }); 75 layouter.perform(fRenameSubpackages); 76 77 Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); 78 separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 79 layouter.perform(separator); 80 } 81 82 public void dispose() { 83 if (saveSettings() && fRenameSubpackages.isEnabled()) 84 saveBooleanSetting(RenameRefactoringWizard.PACKAGE_RENAME_SUBPACKAGES, fRenameSubpackages); 85 super.dispose(); 86 } 87 88 private RenamePackageProcessor getRenamePackageProcessor() { 89 return (RenamePackageProcessor) ((RenameRefactoring) getRefactoring()).getProcessor(); 90 } 91 } 92 } 93 | Popular Tags |