Adding Types to Class Diagrams

There are several ways to add types to a class diagram.

Adding Types by Dragging

Types (ie classes, interfaces, enums) may be added to a diagram by dragging them in from the Package Explorer, Project Explorer, Type Hierarchy or the Navigator in the Resource Perspective.

It is best to deselect the Link with Editor button while dragging types onto a diagram to avoid Eclipse assuming you want to edit the code and opening source editors.

As a type is dragged over a diagram the mouse cursor will indicate if it is suitable for dropping. The reasons why a drop would be disallowed are:

A multiple selection of types can be added to a diagram, or a parent (for example a package) of types can be added. The cursor will indicate a valid drop state if there is at least one suitable type among the selection. Groups of newly added classes are laid out automatically.

Adding Types by Context Menu

Right clicking on a node in the Eclipse Package Explorer tree reveals a menu option Add to current class diagram situated off the AgileJ menu. This action works in exactly the same way as a drag, adding types to the active diagram.

Adding Related Classes

A right click on a type in a diagram reveals options to add related types. Selecting any of these options scans the Java model for qualifying types and adds them to the diagram.

A right-click on the type label of a field reveals the option to add the field's type to the diagram.

A right-click on the return type label of a method (String in this case) reveals the option to add the type String to the diagram.

Controlling Bulk Addition of Types

There are many ways to add types to a diagram, for example: dragging from the package explorer or using the Add Supertypes context menu. Since it is often difficult to anticipate how many types will be added there are thresholds which control AgileJ's response. If you attempt to add a large number (200 or more) of types to a diagram in one go, the addition will be aborted. This prevents accidental addition of a large number of types which would take a long time to process and probably not result in a meaningful class diagram.

For type additions below the large threshold the dialog below offers you an opportunity to apply a filter to thin down the number of types before you add them.

Multi-Drop dialog

If you want to check the number of types contained beneath a node in the package explorer use the Count Classes action which shows a total of all types which exist beneath that node.

Count Classes

Removing Types

Select any collection of types on a diagram then press the delete key to remove them. You can also right click on the diagram and select Remove selected Types.

Notes:

Copyright © AgileJ Ltd. All rights reserved.