| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> |
| <title> Renaming Java elements </title> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| </head> |
| <body> |
| <h1> Renaming Java elements </h1> |
| <p> In this section, you will rename a Java element using refactoring. |
| Refactoring actions change the structure of your code without changing its |
| semantic behavior. </p> |
| <ol> |
| <li> In the Package Explorer view, select <em>junit.framework.TestCase.java</em>. |
| </li> |
| <li> From its context menu, select <strong>Refactor > Rename</strong>. </li> |
| <li> In the <strong>New Name</strong> field on the Rename Compilation |
| Unit page, type "<em>TestCase2</em>". |
| <p> <img src="../images/qs-38.png" alt="Rename refactoring wizard"> |
| </p> |
| </li> |
| <li> To preview the changes that will be made as a result of renaming the |
| class, press <strong>Preview ></strong>. |
| </li> |
| <li> The workbench analyzes the proposed change and presents you with a preview |
| of the changes that would take place if you rename this |
| resource. <p>Since renaming a compilation unit will affect the import |
| statements in other compilation units, there are other compilation units |
| affected by the change. These are shown in a list of changes in the |
| preview pane. </p> |
| <p> <img src="../images/qs-39.png" alt="Refactoring wizard preview page"> |
| </p> |
| </li> |
| <li> On the Refactoring preview page, you can scroll through the proposed |
| changes and select or deselect changes, if necessary. You will |
| typically accept all of the proposed changes. </li> |
| <li> Click <strong>OK</strong> to accept all proposed changes. </li> |
| </ol> |
| <p>You have seen that a refactoring action can cause many changes in different |
| compilation units. These changes can be undone as a group.</p> |
| <ol> |
| <li> In the menu bar, select <strong>Edit > Undo Rename TestCase.java |
| to TestCase2.java</strong>. |
| <p> <img src="../images/qs-40.png" alt="Refactor menu"> |
| </p> |
| </li> |
| <li> The refactoring changes are undone, and the workbench returns to its previous |
| state. You can undo refactoring actions right up until you change and save |
| a compilation unit, at which time the refactoring undo buffer is cleared. |
| </li> |
| </ol> |
| <img src="../images/ngrelc.png" alt="Related concepts" border="0" > |
| <p> <a href="../concepts/concepts-9.htm">Refactoring support</a> </p> |
| <p> <img src="../images/ngrelt.png" alt="Related tasks" border="0" > |
| </p> |
| <p> <a href="../tasks/tasks-80.htm">Refactoring</a><br> |
| <a href="../tasks/tasks-92.htm">Renaming a compilation unit</a><br> |
| <a href="../tasks/tasks-82.htm">Refactoring without preview</a><br> |
| <a href="../tasks/tasks-83.htm">Refactoring with preview</a><br> |
| <a href="../tasks/tasks-84.htm">Previewing refactoring changes</a><br> |
| <a href="../tasks/tasks-100.htm">Undoing a refactoring operation</a><a href="../tasks/tasks-100.htm"></a> |
| </p> |
| <p> <img src="../images/ngrelr.png" alt="Related reference" border="0" > |
| </p> |
| <p> <a href="../reference/ref-menu-refactor.htm">Refactoring actions</a><br> |
| <a href="../reference/ref-117.htm">Refactoring wizard</a><br> |
| <a href="../reference/ref-13.htm">Java preferences</a> </p> |
| |
| </body> |
| </html> |
| |