[5] | 1 | package de.ugoe.cs.swe.bnftools.ui.refactoring.rename;
|
---|
| 2 |
|
---|
| 3 | import org.eclipse.jface.wizard.IWizardPage;
|
---|
| 4 | import org.eclipse.ltk.core.refactoring.Refactoring;
|
---|
| 5 | import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
|
---|
| 6 | import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
|
---|
| 7 | import org.eclipse.swt.widgets.Composite;
|
---|
| 8 |
|
---|
| 9 | public class RenameRefactoringWizard extends RefactoringWizard {
|
---|
| 10 |
|
---|
| 11 | private RenameInputWizardPage wizardPage;
|
---|
| 12 | private String renameText = "";
|
---|
| 13 |
|
---|
| 14 | // ---------------------------------------------------------------------------
|
---|
| 15 |
|
---|
| 16 | public RenameRefactoringWizard(Refactoring refactoring, int flags) {
|
---|
| 17 | super(refactoring, flags);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | // ---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
| 22 | @Override
|
---|
| 23 | protected void addUserInputPages() {
|
---|
| 24 | wizardPage = new RenameInputWizardPage("Refactoring");
|
---|
| 25 | wizardPage.setRenameText(renameText);
|
---|
| 26 | addPage(wizardPage);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | // ---------------------------------------------------------------------------
|
---|
| 30 |
|
---|
| 31 | public void setRenameText(String s) {
|
---|
| 32 | renameText = s;
|
---|
| 33 | if (wizardPage != null)
|
---|
| 34 | wizardPage.setRenameText(s);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | // ---------------------------------------------------------------------------
|
---|
| 38 |
|
---|
| 39 | static class RenameInputWizardPage extends UserInputWizardPage {
|
---|
| 40 |
|
---|
| 41 | private RenamePageComposite composite;
|
---|
| 42 | private String renameText;
|
---|
| 43 |
|
---|
| 44 | public RenameInputWizardPage(String name) {
|
---|
| 45 | super(name);
|
---|
| 46 | setTitle("Rename Refactoring");
|
---|
| 47 | setDescription("Automated Refactoring to rename rule names, rule references etc."
|
---|
| 48 | + " with the possibility to automatically update references");
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | public void createControl(Composite parent) {
|
---|
| 52 | composite = new RenamePageComposite(parent, 0);
|
---|
| 53 | composite.getRenameText().setText(renameText);
|
---|
| 54 | composite.getRenameText().selectAll();
|
---|
| 55 | setControl(composite);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | public String getRenameText() {
|
---|
| 59 | return composite.getRenameText().getText();
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | public void setRenameText(String s) {
|
---|
| 63 | renameText = s;
|
---|
| 64 | if (composite != null)
|
---|
| 65 | composite.getRenameText().setText(renameText);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | @Override
|
---|
| 69 | public IWizardPage getNextPage() {
|
---|
| 70 | RenameRefactoring refactoring = (RenameRefactoring) getRefactoring();
|
---|
| 71 | if (refactoring != null) {
|
---|
| 72 | refactoring.setRenameText(getRenameText());
|
---|
| 73 | }
|
---|
| 74 | return super.getNextPage();
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | @Override
|
---|
| 78 | protected boolean performFinish() {
|
---|
| 79 | RenameRefactoring refactoring = (RenameRefactoring) getRefactoring();
|
---|
| 80 | if (refactoring != null) {
|
---|
| 81 | refactoring.setRenameText(getRenameText());
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | return super.performFinish();
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | }
|
---|