More fixes of static analysis warnings for UML2SD
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / SyncMessageReturn.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
4 *
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
15
16 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
17 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
18 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
19
20 /**
21 * The message return graph node implementation.<br>
22 * This class differs on the SynMessage class only on the drawing line style (dashed instead of plain line).<br>
23 * Message return are generally associated to a message. This means, they are connected to the same lifelines than the
24 * associated message but in the opposite direction and for a different event occurrence.<br>
25 * <br>
26 * WARNING: The association validity is not checked, it is not necessary to provide a valid association, not even needed
27 * to set an association to drawn a message with a message return style.<br>
28 *
29 *
30 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage SyncMessage for usage example
31 * @version 1.0
32 * @author sveyrier
33 *
34 */
35 public class SyncMessageReturn extends SyncMessage {
36
37 // ------------------------------------------------------------------------
38 // Constants
39 // ------------------------------------------------------------------------
40 /**
41 * The graphNode ID
42 */
43 public static final String SYNC_MESS_RET_TAG = "SyncMessageRet"; //$NON-NLS-1$
44
45 // ------------------------------------------------------------------------
46 // Attributes
47 // ------------------------------------------------------------------------
48 /**
49 * The associated message(the message it is the return).
50 */
51 protected SyncMessage fMessage = null;
52
53 // ------------------------------------------------------------------------
54 // Constractors
55 // ------------------------------------------------------------------------
56
57 /**
58 * Default constructor
59 */
60 public SyncMessageReturn() {
61 fPrefId = ISDPreferences.PREF_SYNC_MESS_RET;
62 }
63
64 // ------------------------------------------------------------------------
65 // Methods
66 // ------------------------------------------------------------------------
67 /**
68 * Set the associated message (the message it is the return).<br>
69 * Setting the association will activate the navigation in the default sequence diagram implementation to the
70 * message when the user right click on this message return.<br>
71 *
72 * @param parentMessage the message to associate
73 */
74 public void setMessage(SyncMessage parentMessage) {
75 fMessage = parentMessage;
76 fMessage.setMessageReturn(this);
77 }
78
79 /**
80 * Returns the syncMessage associated to this SyncMessageReturn
81 *
82 * @return the associated message
83 */
84 public SyncMessage getMessage() {
85 return fMessage;
86 }
87
88 /*
89 * (non-Javadoc)
90 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
91 */
92 @Override
93 public void draw(IGC context) {
94 if (!isVisible()) {
95 return;
96 }
97
98 ISDPreferences pref = SDViewPref.getInstance();
99
100 int oldStyle = context.getLineStyle();
101 // Message return are dashed
102 context.setLineStyle(context.getLineDotStyle());
103 // Draw it selected?
104 if (!isSelected()) {
105 context.setBackground(pref.getBackGroundColor(fPrefId));
106 context.setForeground(pref.getForeGroundColor(fPrefId));
107 }
108 super.draw(context);
109 // restore the context
110 context.setLineStyle(oldStyle);
111 }
112
113 /*
114 * (non-Javadoc)
115 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage#getArrayId()
116 */
117 @Override
118 public String getArrayId() {
119 return SYNC_MESS_RET_TAG;
120 }
121 }
This page took 0.035364 seconds and 6 git commands to generate.