Editing Classes and Interfaces

You can edit a class or interface directly on the diagram using the in-place editor, updating the code in the Editor, or using the Properties view for the element. A read-only class or interface cannot be edited, and is shown on the diagram with a lock symbol . To edit a class or interface, choose one of the following methods:

Using the Diagram, UML Navigator, or UML Explorer views:

  1. Select the class or interface.


  2. Edit the fields in the Properties view as necessary.

NB: The Properties view is open by default. If it is closed, select Window > Show View > Properties from the menubar to reopen it.

Using the Editor:

  1. Right click on the class or interface in the Diagram view or UML Navigator view.


  2. From the context menu, select Open. The *.java file displays in the Editor.


  3. Make the desired changes in the Editor. The changes are reflected in the Diagram view.

To set visibility for a class or interface:

  1. In the Diagram view, right click on the class or interface.


  2. Select Modifiers from the context menu.


  3. Choose either Public or Package Local.

To set Abstract or Final for a class or interface:

  1. From the Diagram view, right click on the class or interface.


  2. Select Modifiers from the context menu.


  3. Choose either Final or Abstract.


    NB: Setting a class modifier to Abstract italicizes the class name on the diagram.

Using Drag and Drop

You can physically move a class or interface into another package by using drag and drop. Using drag and drop automatically updates the package statement for the class or interface. If you have two classes with an association link and move one of the classes to another package, the changes are refactored to reflect the linked class's new package.

Using Override Methods

You can quickly add operations from an interface to an implementing class by using the Override Methods command.

To add operations from an interface to an implementing class:

  1. Click the Generalization/Implementation Link button on the diagram toolbar.


  2. Click the class element.


  3. Drag the link to the interface element.


  4. Drop when the interface element is highlighted.


  5. Right click on the class element, and select Override Methods from the context menu. The Override Methods dialog displays.


  6. Select the methods from the interface that you wish to add to the implementation class.


  7. Click OK.

Extending and Implementing Classes and Interfaces

Use the Properties view or the Generalization/Implementation Link button to extend a class or implement an interface. A generalization/implementation link displays between the two elements for classes/interfaces located in the same package or diagram. However, for classes/interfaces residing in different packages, the base class name displays in the upper right corner of the corresponding class. You must use the Properties view to designate a base class if the base class (or interface) resides in a different package than the extending/implementing class.

A class may implement more than one interface. To show this on the diagram, draw Generalization/Implementation links from the class to each interface. You may also indicate this by updated the implements property for the class in the properties view.

To choose an extending class or implement an interface using the Properties view:

  1. Right click on the class.


  2. In the Properties view, select the extends field or implements field.


  3. Click the selection dialog button . The Selection dialog displays.


  4. In the Model elements tab, select the class or interface, and click Add.


  5. Click OK.

Renaming Classes and Interfaces

To rename a class or interface, choose from one of the following methods:

Using the context menu:

  1. Right click on the class or interface.


  2. Select Rename from the context menu.


  3. Enter the new name.


  4. Click Enter, or click in the diagram to apply the changes.

Using the Properties view:

  1. From the menubar, select Window > Show View > Properties.


  2. Select the class or interface.


  3. Edit the name field in the Properties view.


  4. Press Enter to apply the changes.

Using in-place editing:

  1. In the Diagram view, double click the element's name to enable in-place editing.


  2. Enter the new name.


  3. Click Enter or click in the diagram to apply the changes.