Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
c8422608 | 2 | * Copyright (c) 2005, 2012 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 | |
73005152 BH |
13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core; |
14 | ||
15 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC; | |
df0b8ff4 | 16 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences; |
3145ec83 | 17 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; |
73005152 BH |
18 | |
19 | /** | |
20 | * The message return graph node implementation.<br> | |
21 | * This class differs on the SynMessage 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> | |
c8422608 AM |
27 | * |
28 | * | |
73005152 | 29 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage SyncMessage for usage example |
df0b8ff4 | 30 | * @version 1.0 |
73005152 | 31 | * @author sveyrier |
c8422608 | 32 | * |
73005152 BH |
33 | */ |
34 | public class SyncMessageReturn extends SyncMessage { | |
35 | ||
df0b8ff4 BH |
36 | // ------------------------------------------------------------------------ |
37 | // Constants | |
38 | // ------------------------------------------------------------------------ | |
39 | /** | |
40 | * The graphNode ID | |
41 | */ | |
42 | public static final String SYNC_MESS_RET_TAG = "SyncMessageRet"; //$NON-NLS-1$ | |
c8422608 | 43 | |
df0b8ff4 BH |
44 | // ------------------------------------------------------------------------ |
45 | // Attributes | |
46 | // ------------------------------------------------------------------------ | |
73005152 BH |
47 | /** |
48 | * The associated message(the message it is the return). | |
49 | */ | |
eb63f5ff | 50 | protected SyncMessage fMessage = null; |
73005152 | 51 | |
df0b8ff4 BH |
52 | // ------------------------------------------------------------------------ |
53 | // Constractors | |
54 | // ------------------------------------------------------------------------ | |
c8422608 | 55 | |
df0b8ff4 BH |
56 | /** |
57 | * Default constructor | |
58 | */ | |
73005152 | 59 | public SyncMessageReturn() { |
eb63f5ff | 60 | fPrefId = ISDPreferences.PREF_SYNC_MESS_RET; |
73005152 BH |
61 | } |
62 | ||
df0b8ff4 BH |
63 | // ------------------------------------------------------------------------ |
64 | // Methods | |
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(SyncMessage parentMessage) { | |
eb63f5ff BH |
74 | fMessage = parentMessage; |
75 | fMessage.setMessageReturn(this); | |
73005152 BH |
76 | } |
77 | ||
78 | /** | |
79 | * Returns the syncMessage associated to this SyncMessageReturn | |
c8422608 | 80 | * |
73005152 BH |
81 | * @return the associated message |
82 | */ | |
83 | public SyncMessage getMessage() { | |
eb63f5ff | 84 | return fMessage; |
73005152 BH |
85 | } |
86 | ||
df0b8ff4 BH |
87 | /* |
88 | * (non-Javadoc) | |
89 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) | |
90 | */ | |
73005152 BH |
91 | @Override |
92 | public void draw(IGC context) { | |
df0b8ff4 | 93 | if (!isVisible()) { |
73005152 | 94 | return; |
df0b8ff4 | 95 | } |
c8422608 | 96 | |
3145ec83 BH |
97 | ISDPreferences pref = SDViewPref.getInstance(); |
98 | ||
73005152 BH |
99 | int oldStyle = context.getLineStyle(); |
100 | // Message return are dashed | |
101 | context.setLineStyle(context.getLineDotStyle()); | |
df0b8ff4 | 102 | // Draw it selected? |
73005152 | 103 | if (!isSelected()) { |
3145ec83 BH |
104 | context.setBackground(pref.getBackGroundColor(fPrefId)); |
105 | context.setForeground(pref.getForeGroundColor(fPrefId)); | |
73005152 BH |
106 | } |
107 | super.draw(context); | |
108 | // restore the context | |
109 | context.setLineStyle(oldStyle); | |
110 | } | |
111 | ||
df0b8ff4 BH |
112 | /* |
113 | * (non-Javadoc) | |
114 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage#getArrayId() | |
115 | */ | |
73005152 BH |
116 | @Override |
117 | public String getArrayId() { | |
118 | return SYNC_MESS_RET_TAG; | |
119 | } | |
120 | } |