Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
df0b8ff4 | 2 | * Copyright (c) 2005, 2006 IBM Corporation and others. |
73005152 BH |
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 | |
73005152 BH |
7 | * |
8 | * Contributors: | |
9 | * IBM - Initial API and implementation | |
10 | * Bernd Hufmann - Updated for TMF | |
11 | **********************************************************************/ | |
12 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core; | |
13 | ||
14 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC; | |
df0b8ff4 | 15 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences; |
73005152 BH |
16 | |
17 | /** | |
18 | * The message return graph node implementation.<br> | |
df0b8ff4 | 19 | * This class differs on the AsynMessage class only on the drawing line style (dashed instead of plain line).<br> |
73005152 BH |
20 | * Message return are generally associated to a message. This means, they are connected to the same lifelines than the |
21 | * associated message but in the opposite direction and for a different event occurrence.<br> | |
22 | * <br> | |
23 | * WARNING: The association validity is not checked, it is not necessary to provide a valid association, not even needed | |
24 | * to set an association to drawn a message with a message return style.<br> | |
25 | * | |
26 | * | |
27 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage AsyncMessage for usage example | |
df0b8ff4 | 28 | * @version 1.0 |
73005152 BH |
29 | * @author sveyrier |
30 | * | |
31 | */ | |
32 | public class AsyncMessageReturn extends AsyncMessage { | |
33 | ||
df0b8ff4 BH |
34 | // ------------------------------------------------------------------------ |
35 | // Constants | |
36 | // ------------------------------------------------------------------------ | |
37 | /** | |
38 | * The grahNode ID constant | |
39 | */ | |
73005152 BH |
40 | public static final String ASYNC_MESS_RET_TAG = "AsyncMessageRet"; //$NON-NLS-1$ |
41 | ||
df0b8ff4 BH |
42 | // ------------------------------------------------------------------------ |
43 | // Attributes | |
44 | // ------------------------------------------------------------------------ | |
45 | /** | |
46 | * The corresponding asynchronous message. | |
47 | */ | |
48 | protected AsyncMessage message; | |
49 | ||
50 | // ------------------------------------------------------------------------ | |
51 | // Constructors | |
52 | // ------------------------------------------------------------------------ | |
53 | /** | |
54 | * Default constructor. | |
55 | */ | |
73005152 BH |
56 | public AsyncMessageReturn() { |
57 | prefId = ISDPreferences.PREF_ASYNC_MESS_RET; | |
58 | } | |
59 | ||
df0b8ff4 BH |
60 | // ------------------------------------------------------------------------ |
61 | // Methods | |
62 | // ------------------------------------------------------------------------ | |
63 | ||
73005152 BH |
64 | /** |
65 | * Set the associated message (the message it is the return).<br> | |
66 | * Setting the association will activate the navigation in the default sequence diagram implementation to the | |
67 | * message when the user right click on this message return.<br> | |
68 | * | |
69 | * @param parentMessage the message to associate | |
70 | */ | |
71 | public void setMessage(AsyncMessage parentMessage) { | |
72 | message = parentMessage; | |
73 | } | |
74 | ||
df0b8ff4 BH |
75 | /* |
76 | * (non-Javadoc) | |
77 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) | |
78 | */ | |
73005152 BH |
79 | @Override |
80 | public void draw(IGC context) { | |
df0b8ff4 | 81 | if (!isVisible()) { |
73005152 | 82 | return; |
df0b8ff4 | 83 | } |
73005152 BH |
84 | prefId = ISDPreferences.PREF_ASYNC_MESS_RET; |
85 | int oldStyle = context.getLineStyle(); | |
86 | // Message return are dashed | |
87 | context.setLineStyle(context.getLineDotStyle()); | |
88 | if (!isSelected()) { | |
89 | context.setBackground(Frame.getUserPref().getBackGroundColor(prefId)); | |
90 | context.setForeground(Frame.getUserPref().getForeGroundColor(prefId)); | |
91 | } | |
92 | super.draw(context); | |
93 | // restore the context | |
94 | context.setLineStyle(oldStyle); | |
95 | } | |
96 | ||
df0b8ff4 BH |
97 | /* |
98 | * (non-Javadoc) | |
99 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getArrayId() | |
100 | */ | |
73005152 BH |
101 | @Override |
102 | public String getArrayId() { | |
103 | return ASYNC_MESS_RET_TAG; | |
104 | } | |
105 | } |