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