Refactoring
IBM WebSphere Portlet Factory offers extended support for refactoring through the Project Explorer and the Java Package Explorer. Refactoring through the Project Explorer is recommended because when you move or rename a resource in Project Explorer, all internal references are reconciled. This is not the case if you attempt refactoring in the standard Navigator.
Renaming resources
We can rename a folder, a model, or a profile set.
To rename a folder, model, or profile set from the Project Explorer, follow these steps:
- Select the folder, model, or profile set.
- Choose Refactor | Rename either by right clicking the resource and then selecting from the resulting popup menu, or by clicking the resource and choosing Refactor | Rename from the main menu.
- Enter the new name in the Rename Resource dialog.
- Click Preview to display a list of the changes that will occur if you rename the selected item. In some cases, the renaming will affect multiple resources. These resources are listed in the Preview screen. We can elect not to update one or more of the resources in the list but to update the others, though typically you would not do this.
- Click OK to complete the renaming or Cancel> to cancel the renaming. If you click OK, the name of the item you selected is changed and references to other resources are reconciled.
To rename a resource in the Model Navigator, right click the resource, choose Rename from the resulting popup, and enter the new name.
Renaming a Builder or profile entry
We can rename Builders and profile entries and, in some cases, we can edit their definitions as well. You do this from the Outline after opening a model or profile set in either the Project Explorer or the Model Navigator.
Another point to consider before renaming a Builder or profile entry is this: In reconciling references, the renaming process internally performs a simple text search for those references. If, for example, you have a Builder named Page2 and another named Page20, and you rename Page2 to Pagex, references to both Page2 and Page20 will be found. In order to weed out references to Page20, we need to preview the changes that the renaming would make (by clicking >Next), deselecting the items that you do not want to change.
To rename a profile entry or Builder call, follow these steps:
- Display the Outline window by choosing Window | Show View | Other, then choose General | Outline, and then click OK.
- Open the model containing the Builder that you want to rename (or the profile set whose profile entry you want to rename) by right clicking on the model (or profile set) in the Project Explorer or Model Navigator tree and clicking Open in the resulting popup. Opening the model (or profile set) populates the Outline.
- Right click the item in the Outline that you want to rename, and then select Rename from the resulting popup.
- Enter the new name in the Builder call rename (or Profile entry rename) dialog.
- If the Next button is enabled, click it to display a list of the changes that will occur if you rename the selected item. In some cases, the renaming will affect multiple resources. These resources are listed in the Rename screen. We can elect not to update one or more of the resources in the list but to update the others, though typically you would not do this.
- Click Finish to complete the renaming, or click Cancel to cancel the renaming.
Moving resources
We can change the location in which a folder appears in the project tree in Project Explorer or Model Navigator. Note: When you have a resource open that references the folder that you want to move, the change will not be reflected until you reopen the resource. The same condition applies when you rename a folder.
To move an item in the Project Explorer tree, follow these steps:
- Right click the resource and choose Refactor | Move from the resulting popup menu.
- Click the folder to which you want to move the resource in the resulting dialog box, and then click OK.
Alternatively,
- Click the resource and choose Refactor | Move from the main menu.
- Click the folder to which you want to move the resource in the resulting dialog box, and then click OK.
To move a resource in the Model Navigator, right click the resource, choose Move from the resulting popup, click the folder to which you want to move the resource in the resulting dialog box, and then click OK.