SDM Lab 2: Introducing Papyrus (last updated 30/09/19)

This page gives brief notes and instructions on the guided lab session. I attempt to update it, but small details of the tools change from time to time and I've certainly missed some things (while trying to cover several versions). Be sure to listen in the lab!

Introduction

The main aim of this lab is to introduce the Papyrus plug-in to Eclipse. Today you will basically work individually, but you are welcome to discuss with your neighbours any time I'm not speaking: this is likely to be the quickest way to solve problems.

Documentation is... not the strongest aspect of the Papyrus project... but here is the official documentation page.

On DICE, from the Applications menu, pick Programming, then the latest available Eclipse Modeling (4.8, as I type). (There may be some automatic updating involved: this is normal, and should only happen this first time. Accept defaults.) From the menu, choose Help, then Install new software. Using Add, add the appropriate (to your Eclipse version) Papyrus Release Update Site which you can copy from the Papyrus site here. (That site talks about Help then Install modeling component, but that's outdated.) Select just the Papyrus option, ignoring the Releng and other options - some of those options lead to flakier software that will give you install problems, though feel free to experiment later. Wait while it installs the software - this will take a while. Eventually it will ask you whether you want to restart Eclipse; do so. You should now see that you have a New Papyrus Project option on the front page.

If you want to install Papyrus at home

That's a good idea: it should work on almost any platform. Download the Eclipse installer here, select the Eclipse Modeling Tools option when asked, then use the Papyrus Release Update Site as explained above. Remember, however, that in the Week 6 assessment you have to be able to use Papyrus on the standard DICE lab machines, so don't only use your home installation.

For purposes of the Week 6 assessment

When you go over this lab (and the same applies to the other labs), you should make sure you understand and remember how to use Papyrus to do the kind of thing we do in the lab. For example, in the assessment I might well say "Create a class diagram..." rather than "In the Model Explorer, right-click...".

Take your time! You want to not only get to the right model in the end, but understand what you did in the tool to get there, so that you can do it again easily. Feel free to explore, too.

We're going to work with the Paleo example: you may like to have the draft UML class diagram we came up with last week in front of you.

Conceptual class diagram

  1. Get Papyrus installed in your Eclipse as explained in the Introduction. If you run into weird problems raise your hand and listen hard...
  2. Switch to the Papyrus perspective. (Window, Perspective, Open Perspective, Other, choose Papyrus from the selector; or use the perspective shortcut icon near the top right.) Now you should have "Papyrus project" as an option under File, New.
  3. Create a new Papyrus project using UML, called paleo. Tick "A UML model with basic primitive types". Leave everything else at the default setting.
  4. In the Model Explorer, right-click Root Element, select New Diagram... Class Diagram.
  5. By dragging and dropping elements from the Palette on the right, reproduce the class diagram we created in class from the Paleo example. If you have ideas about how it could be improved, also create an improved version.

    Tip: If you get "A property with invalid text string found", delete the property in the Model Explorer and start again; enter the information about the property in the Properties window, not by typing into the diagram.

    Tip: the Model Explorer is often the most useful view. If you lose it, you can reopen it from the top menu, Window then Show View then Model Explorer. (If you don't see Model Explorer under that menu, pick Other and then search.)

  6. Lay out the diagram so that it is clearly readable. You might like to try the Diagram, Arrange, All menu option (later version: pick Arrange All from the right-click menu in the diagram pane), but you may not like its results... (2018 note: do NOT ever try this on a state diagram you care about.)
  7. Save your diagram as an image file by right-clicking in its window and choosing (File, then?) Save as image file. (For most purposes, you are better off saving the model itself, but of course images are needed for inclusion in documents.)
Things to discuss (ask me if they're not clear before we move on):

Java

In the package explorer, create a new Java project paleoJava, and (manually: we'll come back to code generation later in the course!) create Java classes corresponding to the class diagram you have just developed. Use the standard Java types for attributes, for now.

Next, suppose our conceptual class diagram is going to be used to support the development of a system in which the user, who is thinking of a food, will be asked questions in the appropriate sequence and finally told whether their food accords to the diet or not. For example, given the original paleo diagram, if the user is thinking of a fish, they will first be asked "Did it have a face?", they will answer Yes, and the system will tell them "It's paleo".

Add operations to the conceptual class diagram (as simply as possible: don't concern yourself with the user interface, just with the logic) to support this.

Add corresponding methods to your Java classes.

Sequence diagram

2018/19 note: currently, I find Papyrus' current sequence diagram interface rather delicate (so much so that I will not ask you to use it in the lab assessment). I'll attempt to show you in the lab how to make it work. To minimise confusion, I suggest you draw your sequence diagram on paper, before you try to put it into Papyrus. If you have time, feel free to experiment with alternatives such as WebSequenceDiagrams or maybe better sequencediagram.org.

Develop a sequence diagram to show the scenario mentioned above, where the user is thinking of a fish. Go on to think about more extended scenarios. Update your Java code to be consistent with the behaviour you show.

Remark: there's a Youtube video on sequence diagrams in Papyrus which you may find useful if you have trouble driving Papyrus... however, it's doing sequence diagrams in a particular kind of robustness analysis which I don't really recommend and it has a number of issues like talking about messages passing between "classes" when it means "objects", so be careful!

Activity diagram

Create an Activity Diagram, in the same model. You'll see there's one activity shown: if necessary, resize it, as your whole diagram will go inside here. Name it design diet: we're going to represent the business process of designing a new diet to be this year's craze.

To start with, model a simple process. Create an initial node. (Note that initial notes, final nodes, fork and join bars etc. are all under the same submenu in the palette, because they are all technically pseudostates: you may need to click on the small triangle to the left.) Then, using opaque actions, create actions for consult marketing, write book, write app, profit, and finally, a final node. Join these up in sequence using control flow edges.

Next, add some parallelism and some choice. Someone points out that the book and the app can both be written at the same time, and suggests that under certain circumstances it might be good to consult a nutrition expert as well as marketing. Revise your model to show appropriate parallelism and choice going on. Check that you understand the differences between decision, merge, fork and join nodes.

Remark: there's a youtube tutorial for activity diagrams in Papyrus. I didn't make it compulsory viewing because it's rather slow, but if you get stuck it might be useful! The other videos in the series are also worth considering (though they assume a particular development approach, and the way they use the term "robustness analysis" is a bit different from the way we use it in the course).


This page is maintained by Perdita Stevens (perdita@inf.ed.ac.uk)


Home : Teaching : Courses : Sdm 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh