Commit | Line | Data |
---|---|---|
73005152 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2005, 2006, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * $Id: SyncMessageReturn.java,v 1.2 2006/09/20 20:56:25 ewchan Exp $ | |
8 | * | |
9 | * Contributors: | |
10 | * IBM - Initial API and implementation | |
11 | * Bernd Hufmann - Updated for TMF | |
12 | **********************************************************************/ | |
13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC; | |
16 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences; | |
17 | ||
18 | /** | |
19 | * The message return graph node implementation.<br> | |
20 | * This class differs on the SynMessage class only on the drawing line style (dashed instead of plain line).<br> | |
21 | * Message return are generally associated to a message. This means, they are connected to the same lifelines than the | |
22 | * associated message but in the opposite direction and for a different event occurrence.<br> | |
23 | * <br> | |
24 | * WARNING: The association validity is not checked, it is not necessary to provide a valid association, not even needed | |
25 | * to set an association to drawn a message with a message return style.<br> | |
26 | * | |
27 | * | |
28 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage SyncMessage for usage example | |
29 | * @author sveyrier | |
30 | * | |
31 | */ | |
32 | public class SyncMessageReturn extends SyncMessage { | |
33 | ||
34 | /** | |
35 | * The associated message(the message it is the return). | |
36 | */ | |
37 | protected SyncMessage message = null; | |
38 | ||
39 | public static final String SYNC_MESS_RET_TAG = "SyncMessageRet"; //$NON-NLS-1$ | |
40 | ||
41 | public SyncMessageReturn() { | |
42 | prefId = ISDPreferences.PREF_SYNC_MESS_RET; | |
43 | } | |
44 | ||
45 | /** | |
46 | * Set the associated message (the message it is the return).<br> | |
47 | * Setting the association will activate the navigation in the default sequence diagram implementation to the | |
48 | * message when the user right click on this message return.<br> | |
49 | * | |
50 | * @param parentMessage the message to associate | |
51 | */ | |
52 | public void setMessage(SyncMessage parentMessage) { | |
53 | message = parentMessage; | |
54 | message.setMessageReturn(this); | |
55 | } | |
56 | ||
57 | /** | |
58 | * Returns the syncMessage associated to this SyncMessageReturn | |
59 | * | |
60 | * @return the associated message | |
61 | */ | |
62 | public SyncMessage getMessage() { | |
63 | return message; | |
64 | } | |
65 | ||
66 | @Override | |
67 | public void draw(IGC context) { | |
68 | if (!isVisible()) | |
69 | return; | |
70 | int oldStyle = context.getLineStyle(); | |
71 | // Message return are dashed | |
72 | context.setLineStyle(context.getLineDotStyle()); | |
73 | // Draw it selected?*/ | |
74 | if (!isSelected()) { | |
75 | context.setBackground(Frame.getUserPref().getBackGroundColor(prefId)); | |
76 | context.setForeground(Frame.getUserPref().getForeGroundColor(prefId)); | |
77 | } | |
78 | super.draw(context); | |
79 | // restore the context | |
80 | context.setLineStyle(oldStyle); | |
81 | } | |
82 | ||
83 | @Override | |
84 | public String getArrayId() { | |
85 | return SYNC_MESS_RET_TAG; | |
86 | } | |
87 | } |