3ac93854112eac5c909a6e0edffce2da5946903d
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / AsyncMessageReturn.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
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 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
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.preferences.ISDPreferences;
17 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
18
19 /**
20 * The message return graph node implementation.<br>
21 * This class differs on the AsynMessage class only on the drawing line style (dashed instead of plain line).<br>
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>
27 *
28 *
29 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage AsyncMessage for usage example
30 * @version 1.0
31 * @author sveyrier
32 *
33 */
34 public class AsyncMessageReturn extends AsyncMessage {
35
36 // ------------------------------------------------------------------------
37 // Constants
38 // ------------------------------------------------------------------------
39 /**
40 * The grahNode ID constant
41 */
42 public static final String ASYNC_MESS_RET_TAG = "AsyncMessageRet"; //$NON-NLS-1$
43
44 // ------------------------------------------------------------------------
45 // Attributes
46 // ------------------------------------------------------------------------
47 /**
48 * The corresponding asynchronous message.
49 */
50 protected AsyncMessage fMessage;
51
52 // ------------------------------------------------------------------------
53 // Constructors
54 // ------------------------------------------------------------------------
55 /**
56 * Default constructor.
57 */
58 public AsyncMessageReturn() {
59 fPrefId = ISDPreferences.PREF_ASYNC_MESS_RET;
60 }
61
62 // ------------------------------------------------------------------------
63 // Methods
64 // ------------------------------------------------------------------------
65
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>
70 *
71 * @param parentMessage the message to associate
72 */
73 public void setMessage(AsyncMessage parentMessage) {
74 fMessage = parentMessage;
75 }
76
77 /*
78 * (non-Javadoc)
79 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
80 */
81 @Override
82 public void draw(IGC context) {
83 if (!isVisible()) {
84 return;
85 }
86
87 ISDPreferences pref = SDViewPref.getInstance();
88
89 fPrefId = ISDPreferences.PREF_ASYNC_MESS_RET;
90 int oldStyle = context.getLineStyle();
91 // Message return are dashed
92 context.setLineStyle(context.getLineDotStyle());
93 if (!isSelected()) {
94 context.setBackground(pref.getBackGroundColor(fPrefId));
95 context.setForeground(pref.getForeGroundColor(fPrefId));
96 }
97 super.draw(context);
98 // restore the context
99 context.setLineStyle(oldStyle);
100 }
101
102 /*
103 * (non-Javadoc)
104 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage#getArrayId()
105 */
106 @Override
107 public String getArrayId() {
108 return ASYNC_MESS_RET_TAG;
109 }
110 }
This page took 0.031782 seconds and 5 git commands to generate.