MagicDraw Tutorials
MagicDraw Tutorials
version 16.8
No Magic, Inc.
2010
All material contained herein is considered proprietary information owned by No Magic, Inc. and is not to be
shared, copied, or reproduced by any means. All information copyright 1998-2010 by No Magic, Inc. All Rights
Reserved
CONTENTS
MAGICDRAW BASICS 5
STEP #1 Create a class diagram 5
STEP #2 Create a new class element in diagram 7
STEP #3 Create package element in diagram 10
STEP #4 Create new class element from browser 12
STEP #5 Draw relationships 13
STEP #6 Presentation options 15
STEP #7 Browser options 16
DATA PARTITIONING 53
STEP #1 Export a new Module 53
STEP #2 Open module as a new project 55
STEP #3 Reload the module 56
2. In the diagrams toolbar, click on the Class Diagram button . The Create Diagram dialog
box appears.
3. In the Type Class Diagram Name field, enter the name of the new class diagram or leave the
default name.
4. From the package tree, select the package where to contain the diagram (default is Data) or
create the new one by clicking the Create Owner button and choosing Package from the list.
5. Click OK. The diagram is created and the diagram pane appears.
1. In the diagram toolbar, click the Class button . Click again on the diagram pane in order to
place the class. Type the name for a class. Click anywhere on the diagram pane to close the
class title line.
2. The class that you see on the diagram pane is only the class symbol. All the class data are con-
tained in the Browser. You can see that the class Customer has been created in the browser
when you have drawn it on the diagram pane.
3. Double click on a class. The Class Specification dialog box appears. It contains various fea-
tures of a class. For more detailed information about this dialog box, see MagicDraw Help.
4. Select the Documentation/Hyperlinks group, add some documentation about this class. Click
Close.
3. Right-click on a class to access its shortcut menu. Choose the Select in Containment Tree
command.
4. The class name becomes marked by dark blue fill in the Browser tree.
2. A new class in the package will appear in the Browser tree. Name the class Ticket.
3. Select the class in Browser and drag it onto the Diagram pane into the package.
1. In the diagram toolbar, click on the Association button . Connect the two classes with this
path. If it is allowed to draw the link from one element to another, a blue border appears around
it.
NOTE You can draw some paths by clicking handler buttons on the class
symbol.
in the toolbar.
3. Double click on the path. The Association Specification dialog box appears.
NOTE: For more detailed information about this dialog box, see MagicDraw
Help
4. In the Name field, enter the path name owns. Click Close.
5. Drag the association name link around and leave it on the diagram pane. Select the link. From
the main toolbar, using a special Reset Labels Positions button , put the path’s name
into place.
NOTE: The same action can be performed using handler on the link.
and click the Fill Color. Choose a color and click on it. The class fill color has been changed.
Note: If not all symbol editing buttons are displayed on the diagram toolbar,
from the toolbar shortcut menu, select the Expert Mode check box.
2. Click on Text Color. Choose a color and click on it. The class text color has been changed.
3. Click on an association to select it. Go to symbol editing toolbar and click Line Color. Choose a
color and click on it. The association line color has been changed.
3. Zoom in/out the picture by dragging the slider of the sliding scale to over/under 100% or zoom
in/out the picture by dragging the blue border around the diagram in Zoom window.
NOTE: To add slider to the Zoom tab, from the Options main menu, choose
Environment and in the opened dialog box, Browser group, select the
Show diagram zoom slider check box.
This guide contains step-by-step instructions, showing how to create a sequence diagram.
For creating a sequence diagram, an example of the Magic Test system will be given.
Figure 2 -- The Change Password sequence diagram, lifeline with Instructor type
ii. In the same way in the sequence diagram create lifelines for the LoginDialog, SystemAccessManager, Pro-
fileManager, InstructorProfile elements.
iii. You can display Image instead of lifeline shape. To change the lifeline representation on the diagram pane:
1. On the diagram pane from the lifeline shortcut menu select Symbol(s) Properties. The Prop-
erties dialog opens.
2. Change the Show Stereotypes property to Shape Image.
3. Change the same property for the rest of lifelines.
Figure 4 -- The Change Password sequence diagram - images displayed instead of Lifeline shapes
1. Click the Message button and draw message from Instructor to LoginDialog.
2. Type in message name as Type in new password twice.
1. Click the Alternatives button and draw alternatives fragmetn from LoginDialog
to InstructorProfile.
2. Click on empty brackets and type in equals = = true.
1. Click the Call Message button and draw message from LoginDialog to Sys-
temAccessManager.
A particular java source code file will be used to show how java reverse to sequence diagram is performed -
extracted src.zip file from java home directory.
4. In the Add Files tree, select java file and add it to the Set list. Click OK. Class source files is
added to the java set in Browser.
5. From the java source file shortcut menu, choose Reverse, define reverse options and click OK.
A new model with packages and classes will be created in the project.
• The same wizard can be opened from the Diagrams main menu by choosing Diagram
Wizards command, from the Tools main menu, choosing Model Visualizer, or from the
method shortcut menu in the Browser, choosing the Reverse Implementation command.
3. In the Step 1, specify the name of the sequence diagram and select the package, where this
diagram will be created. By default, name of the class and method will be given to the sequence
diagram. For example: Class.Method implementation. Click Next.
4. In the Step 2, select method (operation), which will be displayed in the sequence diagram.
Specify the Java source file, if this file cannot be found automatically. Click Next.
5. In the Step 3, select other referenced classes, which you want to be displayed in the diagram.
Click Next.
Select the Analyze and split long expressions in diagram check box if expression contains
calls and cannot be displayed as call message. Then every call will be shown as separate call
message with temporary variable initialization.
Select the Create reply message check box, if you want to display reply message for every call
message.
Select the Wrap messages text check box and specify the maximum message text length in
pixels, to wrap longer message.
6. In the Step 4, specify the presentation style for elements in created diagram.
3. The Sequence Diagram from Java Source Wizard appears. Following instruction in Step 2,
define wizard options and click Finish. Additional new elements, which define the selected
method, are added to the sequence diagram.
Diagrams may have a set of different types of elements. For example, in the class diagram you may draw pack-
ages and classes. All those elements can be colored in the same color that you chose for your views. To make
diagrams more clear, you may color elements of different types with their own color.
An example of two implementation diagrams, created in one project, will be used in this tutorial.
2. Choose the color you wish to be assigned to the element. Click OK.
3. In the Properties dialog box, click OK. The colors of the selected shapes will be changed.
NOTE If you want to make the selected color as default for the newly created
shapes, in the Properties dialog box select the Make Default check
box.
2. In the General Project Options tree, expand the Shapes section and select the Component
element.
2. Change the Fill Color and Pen Color properties values, by clicking the ’...’ button. The Color
dialog box appears. Submit changes.
3. In the Project Options dialog box click the Apply button. The Select Diagrams dialog box
appears.
NOTE! Only Implementation diagrams are displayed in this list, because prop-
erties were extended by this type of diagram only.
4. Select the Java Files diagram and click OK. The Select Properties to Apply dialog box
appears. By default, all properties are added to the Selected list.
NOTE! To apply not all properties, use the ‘< ‘ button and move irrelevant
properties to the All list. Only selected properties existing in the
Selected list will be applied.
5. To submit changes and close dialog boxes, click OK. Changes were made to component ele-
ments but only in Java Files implementation diagram.
2. You may choose an existing stereotype from the tree or add a new one from the metaclass
shortcut menu, by choosing New and then Stereotype. The Select Package dialog box opens:
3. Select package, where newly created stereotype will be saved and click OK. Type the name of
the stereotype in the Browser.
4. Press Enter, double-click or from the stereotype shortcut menu, choose Specification. The
Stereotype Specification dialog box opens.
NOTE: GIF, JPG, JPEG, SVG, PNG, and MDICO files are attachable.
TIP You can suppress attributes and operations using a smart manipula-
tion feature. Select a class and click on the buttons with ‘minus’ sign.
NOTE This functionality is available in Standard, Professional, Architect, and Enterprise editions only.
For starting work with a data partitioning, from the MagicDraw installation directory, samples folder, case stud-
ies subfolder, open the Inventory Control System.xml.zip project.
2. Select the Static View package and drag it to the newly created package. A class diagram with
all contained elements now is an inner element of the Inventory Control System package.
3. From the Inventory Control System package shortcut menu, choose Modules, and then
choose Export Module. The Export Module dialog box appears.
4. The Selected packages list shows, which package will be exported as a module. Click OK.
NOTE If you want to check for dependencies and module you are exporting
depends on external project elements, the Package Dependencies
dialog box appears. Using this dialog box, solve errors. Then you will
be able to export module.
5. The Save dialog box appears. Select the destination directory, where you want to save the proj-
ect module, type the file name Static View and click Save. The name of the module appears in
the Browser, near the package name.
NOTE The exported module is not editable after exportation. If you want to
make some changes, from the module shortcut menu, choose Mod-
ules, and then choose Import Module. The module will be merged
with a project model.
check box. In the Diagram pane, press CTRL+ALT+A. A new attribute is added to the class.
Type the name for the attribute Name. Add one more attribute, name it Address.
NOTE Code Engineering is available in Professional, Architect and Enterprise editions only.
Three classes, presenting the system for controlling the luggage storage in an aircraft will be used in this tuto-
rial:
• Luggage – represents a piece of luggage;
• LuggageCompartment – represents the luggage compartment of an aircraft during a flight;
• FlightSegment – represents a flight segment.
3. Open the Add Data from Model tab and from the All Data list to the Set list, add the selected
classes.
4. Click OK.
/**
* @(#) LuggageCompartment.java
*/
public class LuggageCompartment
{
private float maxWeight;
private Vector pieces;
private float weight = 0.0F;
/**
* Check a piece of luggage
*/
protected void checkLuggage( Luggage piece )
{
}
/**
* Constructor
*/
protected LuggageCompartment( float maxWeight )
{
}
}
/**
* @(#) FlightSegment.java
*/
public class FlightSegment
{
protected LuggageCompartment luggage;
/**
* Check a piece of luggage
*/
protected void checkLuggage( Luggage piece )
{
}
}
3. In the Add Files tab, select the created LuggageException.java code file and add this file to the
Set files list.
2. Define options of the reverse and click OK. A new class element is added to the project and
class symbol appears on the Diagram pane.
2. Generate the code to the Luggage class element from the set. Open the generated code file.
The additional lines are added according to the new created subclasses.
/**
* @(#) Luggage.java
*/
public class Luggage
{
private float weight;
/**
* Return the weight of this piece of luggage in kg.
*/
protected float getWeight( )
{
return 0;
}
public class NormalLuggage extends Luggage
{
}
public class DangerousLuggage extends Luggage
{
}
}
NOTE Code Engineering is available in Professional, Architect and Enterprise editions only.
TIP! To add data for generation, you can drag–and–drop elements to the
created set in the Browser tree.
2. The generated source will be opened for editing. Edit source and save changes.
NOTE! If you have only a source code and want to create a model, from the
newly created code engineering set shortcut menu, choose Edit. Add
files you wish to reverse from your hard disk to the set, in the Round
Trip Set dialog box, the Add Files tab.
TIP! You may reverse the desired files using the Quick Reverse option:
from the Tools menu, choose Quick Reverse, select a language and
select a files you want to reverse.
NOTE Integration with CVS is available in Professional, Architect and Enterprise editions only.
NOTE Grouped directories, that contain subfolders with the together related
files are called modules.
5. Click OK.
2. In the CVS Root field, enter the path of the CVS repository, which stores a complete copy of all
the files and directories that are under version control.
3. In the Module name field, enter the path where the module is stored.
4. In the Local folder field enter the path of the local folder where the module will be saved on
checkout action.
• You may select the Prune empty directories check box, if you want automatically
remove empty folders when you update a module.
• For checking out only the last project version, select the Reset sticky tags check
box.
• If you don’t want to check out the subdirectories, select the Non-recursive check
box.
5. Click OK.
• If the project is saved as XML.ZIP format, select the Add as binary data [-kb] check box.
NOTE: Project is committed to the CVS server every time after saving it, if the
option Commit Project to CVS After Saving is selected in the Envi-
ronment Options dialog box, CVS pane
2. In the Log message field, type the message about the project that can be important for other
users.
3. Click OK.
• If the Reset sticky tags check box is selected, the last version of the project that is
on the server will be updated. If no check box is selected, you will be informed that
project is already opened but you can reload it and loose changes.
• Type the tag or version number you want to update to the Retrieve rev./tag/branch
field (it becomes enabled when the Reset sticky tags check box is cleared). You
may click the ‘…’ button and in the Revision dialog box choose the desirable
version.
2. Click OK.
2. To login to the server as administrator, in the Login and Password fields, type “Administrator”.
In the Teamwork Server Name text box, enter the server name and port.
3. If you want every time when starting MagicDraw to connect to the server, select the Auto
Login to Server check box.
4. Click OK. On the status bar the note ”Logged in as: Administrator” appears. The Administrator
has administrator’s permissions (all available permissions) and is allowed to create new users.
2. To add a new user, click the Add button. The Edit User dialog box appears.
3. Enter the login, name, and password for the user. Click OK. A new user is created.
4. In the Edit Users dialog box, Permissions list, set specific permissions for the user by select-
ing corresponding check boxes.
5. The More>> button allows to set permissions for the users on particular projects. If there are
teamwork projects available, you can set permissions for the users on these projects.
6. When all users are added and permissions are set, click Close.
2. Select from the existing teamwork projects or add a new project using the Add button. When
adding a new project, the Project Name dialog box appears. Enter the name for a new project
or leave the default one. Click OK.
3. In the Permissions list, set project permissions for the users. Click Close.
2. Enter the user login, password, and teamwork server name. Click OK.
2. Look at the Browser tree. The items in the Browser tree are blank and they can be read, but no
editing is allowed. A user may add new elements and edit only those elements that he/she has
locked for editing.
NOTE! If you have some elements locked for editing, the list of them is displayed in the Locked
Elements tab. Select elements if you want to unlock them after committing project.
If your project uses some local modules, list of them is displayed in the Local Modules tab.
The Locked Modules tab displays list of modules, which are locked in this project.
3. Click Commit.
4. After committing the diagram for the first time, it becomes read-only and it is blank in the
Browser tree.
2. In the Browser tree, appears a name of a user who has locked the class diagram for editing.
3. To lock any class from a diagram for edit, from its shortcut menu, choose the Lock Class for
Edit command and then Lock for Edit.
4. Perform some changes for a class. Click CTRL+K to commit changes. The diagram that was
edited once again does not become read-only, and it is left editable for the user who has locked
it.
5. In order to unlock the diagram, in the Browser tree, from the class diagram shortcut menu,
choose the Unlock command and then Unlock.
NOTE! If you select the Discard Changes command, you may unlock a diagram and discard any
changes that were made by the user who has locked the diagram.
6. In the same way classes and other elements of a diagram are unlocked.
This guide contains step-by-step instructions, showing how to create a basic XML schema model (and then
generate the schema from this model) from scratch.
Value button. In the Select Elemets dialog, select http://system/ namespace and add it to the
list by clicking Add.
9. Such a model will result (after code generation) in schema like this:
3. Type the id name for new attribute. Double-click to open the Property Specification dialog box
and assign integer type in the Type field.
4. Select mailType element and from the shortcut menu, choose Stereotype. Apply <<XSDse-
quence>> stereotype for this element. This will enable inner element creation for complex type.
5. Right-click on the type again and from the shortcut menu, choose XML Schema and then New
XSDelement. Name this element as e-mail. In the same manner, add another element, named
envelope .
8. It is possible to put the name of the element on the appropriate end of the association relation.
Draw composition between mailsType and mailType, add a name and assign <<XSDele-
ment>> stereotype to the association end. From the end shortcut menu, choose Edit Name
and then on the diagram pane, type mail.
9. After code generation, this model will result in the following source code::
3. Double-click the bodyType element to open its Specification dialog box. Select the Tags tab
and in the <<XSDSequence>> branch add new tagged value “1” for sequenceOrder tag.
4. Repeat the same action for attachmentType element, just add tagged value “2”.
5. Such model after all these actions is created:
2. From the created code engineering set shortcut menu, choose Edit. Open the Add Data from
Model tab in the Round Trip Set dialog box. From the All Data list to the Set list, add XML
Schema elements for code generation. Click OK.
3. From the code engineering set shortcut menu, choose Generate. The Code Generation
Options dialog box opens:
4. Specify Output Directory for source code and click OK. The schema.xsd file containing XML
Schema code will be generated there.