Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. 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">
<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.&nbsp;
Refactoring actions change the structure of your code without changing its
semantics (behavior). </p>
<ol>
  <li> In the Package Explorer view, select&nbsp;<em>junit.framework/TestCase.java</em>. 
  </li>
  <li> From its context menu, select&nbsp;<strong>Refactor &gt; Rename</strong>. </li>
  <li> In the&nbsp;<strong>New Name</strong> field on the Rename Compilation 
    Unit page, type &quot;<em>TestCase2</em>&quot;. 
    <p> <img src="images/rename_cu_dialog.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>Next</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.&nbsp;<p>Since renaming a compilation unit will affect the import
    statements in other compilation units, there are other compilation units
    affected by the change.&nbsp; These are shown in a list of changes in the
    preview pane. </p>
    <p> <img src="images/rename_cu_preview_dialog.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.&nbsp; You will
    typically accept all of the proposed changes. </li>
  <li> Click&nbsp;<strong>Finish</strong>  to accept all proposed changes. </li>
</ol>
<p>You have seen that a refactoring action can cause many changes in different
compilation units.&nbsp; These changes can be undone as a group.</p>
<ol>
  <li> In the menu bar, select&nbsp;<strong>Edit &gt; Undo Rename Compilation Unit</strong>. 
    <p> <img src="images/edit_undo_refactoring_menu.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>
<P class="nav_footer" id="nav_footer">Next Section: <A href="qs-10.htm">Moving and copying Java elements</A>
</P>
<img src="../images/ngrelc.png" alt="Related concepts" border="0" > 
<p> <a href="../concepts/concept-refactoring.htm">Refactoring support</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-wizard-refactorings.htm">Refactoring wizard</a><br>
  <a href="../reference/preferences/ref-preferences-java.htm">Java preferences</a> </p>

</body>
</html>

New to GrepCode? Check out our FAQ X