| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2005, 2013 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; |
| 14 | |
| 15 | import java.util.ArrayList; |
| 16 | import java.util.Arrays; |
| 17 | import java.util.List; |
| 18 | |
| 19 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
| 20 | import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; |
| 21 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; |
| 22 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage; |
| 23 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessageReturn; |
| 24 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage; |
| 25 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ExecutionOccurrence; |
| 26 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame; |
| 27 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode; |
| 28 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange; |
| 29 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline; |
| 30 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Metrics; |
| 31 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SDTimeEvent; |
| 32 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage; |
| 33 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor; |
| 34 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl.ColorImpl; |
| 35 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; |
| 36 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.TimeEventComparator; |
| 37 | import org.eclipse.swt.SWT; |
| 38 | import org.eclipse.swt.accessibility.ACC; |
| 39 | import org.eclipse.swt.accessibility.Accessible; |
| 40 | import org.eclipse.swt.accessibility.AccessibleAdapter; |
| 41 | import org.eclipse.swt.accessibility.AccessibleControlAdapter; |
| 42 | import org.eclipse.swt.accessibility.AccessibleControlEvent; |
| 43 | import org.eclipse.swt.accessibility.AccessibleEvent; |
| 44 | import org.eclipse.swt.events.DisposeEvent; |
| 45 | import org.eclipse.swt.events.DisposeListener; |
| 46 | import org.eclipse.swt.events.FocusEvent; |
| 47 | import org.eclipse.swt.events.FocusListener; |
| 48 | import org.eclipse.swt.events.KeyEvent; |
| 49 | import org.eclipse.swt.events.MouseEvent; |
| 50 | import org.eclipse.swt.events.TraverseEvent; |
| 51 | import org.eclipse.swt.events.TraverseListener; |
| 52 | import org.eclipse.swt.graphics.Color; |
| 53 | import org.eclipse.swt.graphics.GC; |
| 54 | import org.eclipse.swt.graphics.Image; |
| 55 | import org.eclipse.swt.widgets.Composite; |
| 56 | import org.eclipse.swt.widgets.Control; |
| 57 | import org.eclipse.swt.widgets.Display; |
| 58 | |
| 59 | /** |
| 60 | * <p> |
| 61 | * The time compression bar implementation. |
| 62 | * </p> |
| 63 | * |
| 64 | * @version 1.0 |
| 65 | * @author sveyrier |
| 66 | */ |
| 67 | public class TimeCompressionBar extends ScrollView implements DisposeListener { |
| 68 | |
| 69 | // ------------------------------------------------------------------------ |
| 70 | // Attributes |
| 71 | // ------------------------------------------------------------------------ |
| 72 | |
| 73 | /** |
| 74 | * The listener list |
| 75 | */ |
| 76 | protected List<ITimeCompressionListener> fListenerList = null; |
| 77 | /** |
| 78 | * The current frame displayed. |
| 79 | */ |
| 80 | protected Frame fFrame = null; |
| 81 | /** |
| 82 | * List of time events. |
| 83 | */ |
| 84 | protected List<SDTimeEvent> fNodeList = null; |
| 85 | /** |
| 86 | * The minimum time delta. |
| 87 | */ |
| 88 | protected ITmfTimestamp fMinTime = new TmfTimestamp(); |
| 89 | /** |
| 90 | * The maximum time delta. |
| 91 | */ |
| 92 | protected ITmfTimestamp fMaxTime = new TmfTimestamp(); |
| 93 | /** |
| 94 | * The current zoom value. |
| 95 | */ |
| 96 | protected float fZoomValue = 1; |
| 97 | /** |
| 98 | * The tooltip to display. |
| 99 | */ |
| 100 | protected DrawableToolTip fTooltip = null; |
| 101 | /** |
| 102 | * Array of colors for displaying wight of time deltas. |
| 103 | */ |
| 104 | protected ColorImpl[] fColors; |
| 105 | /** |
| 106 | * The accessible object reference. |
| 107 | */ |
| 108 | protected Accessible fAccessible = null; |
| 109 | /** |
| 110 | * The focused widget reference. |
| 111 | */ |
| 112 | protected int fFocusedWidget = -1; |
| 113 | /** |
| 114 | * The sequence diagram view reference. |
| 115 | */ |
| 116 | protected SDView view = null; |
| 117 | /** |
| 118 | * The current lifeline. |
| 119 | */ |
| 120 | protected Lifeline fLifeline = null; |
| 121 | /** |
| 122 | * The current start event value. |
| 123 | */ |
| 124 | protected int fLifelineStart = 0; |
| 125 | /** |
| 126 | * The current number of events. |
| 127 | */ |
| 128 | protected int fLifelineNumEvents = 0; |
| 129 | /** |
| 130 | * The Current color of range to display. |
| 131 | */ |
| 132 | protected IColor fLifelineColor = null; |
| 133 | /** |
| 134 | * The next graph node y coordinate. |
| 135 | */ |
| 136 | protected int fNextNodeY = 0; |
| 137 | /** |
| 138 | * The previous graph node y coordinate. |
| 139 | */ |
| 140 | protected int fPrevNodeY = 0; |
| 141 | |
| 142 | // ------------------------------------------------------------------------ |
| 143 | // Constructors |
| 144 | // ------------------------------------------------------------------------ |
| 145 | /** |
| 146 | * Standard constructor |
| 147 | * |
| 148 | * @param parent The parent composite |
| 149 | * @param s The style bits |
| 150 | */ |
| 151 | public TimeCompressionBar(Composite parent, int s) { |
| 152 | super(parent, s | SWT.NO_BACKGROUND, false); |
| 153 | setVScrollBarMode(ScrollView.ALWAYS_OFF); |
| 154 | setHScrollBarMode(ScrollView.ALWAYS_OFF); |
| 155 | fListenerList = new ArrayList<ITimeCompressionListener>(); |
| 156 | fColors = new ColorImpl[10]; |
| 157 | fColors[0] = new ColorImpl(Display.getDefault(), 255, 229, 229); |
| 158 | fColors[1] = new ColorImpl(Display.getDefault(), 255, 204, 204); |
| 159 | fColors[2] = new ColorImpl(Display.getDefault(), 255, 178, 178); |
| 160 | fColors[3] = new ColorImpl(Display.getDefault(), 255, 153, 153); |
| 161 | fColors[4] = new ColorImpl(Display.getDefault(), 255, 127, 127); |
| 162 | fColors[5] = new ColorImpl(Display.getDefault(), 255, 102, 102); |
| 163 | fColors[6] = new ColorImpl(Display.getDefault(), 255, 76, 76); |
| 164 | fColors[7] = new ColorImpl(Display.getDefault(), 255, 51, 51); |
| 165 | fColors[8] = new ColorImpl(Display.getDefault(), 255, 25, 25); |
| 166 | fColors[9] = new ColorImpl(Display.getDefault(), 255, 0, 0); |
| 167 | super.addDisposeListener(this); |
| 168 | |
| 169 | fAccessible = getViewControl().getAccessible(); |
| 170 | |
| 171 | fAccessible.addAccessibleListener(new AccessibleAdapter() { |
| 172 | @Override |
| 173 | public void getName(AccessibleEvent e) { |
| 174 | // Case toolTip |
| 175 | if (e.childID == 0) { |
| 176 | if (fTooltip != null) { |
| 177 | e.result = fTooltip.getAccessibleText(); |
| 178 | } |
| 179 | } else if (e.childID == 1) { |
| 180 | createFakeTooltip(); |
| 181 | e.result = fTooltip.getAccessibleText(); |
| 182 | } |
| 183 | } |
| 184 | }); |
| 185 | |
| 186 | fAccessible.addAccessibleControlListener(new AccessibleControlAdapter() { |
| 187 | @Override |
| 188 | public void getFocus(AccessibleControlEvent e) { |
| 189 | if (fFocusedWidget == -1) { |
| 190 | e.childID = ACC.CHILDID_SELF; |
| 191 | } |
| 192 | else { |
| 193 | e.childID = fFocusedWidget; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | @Override |
| 198 | public void getRole(AccessibleControlEvent e) { |
| 199 | switch (e.childID) { |
| 200 | case ACC.CHILDID_SELF: |
| 201 | e.detail = ACC.ROLE_CLIENT_AREA; |
| 202 | break; |
| 203 | case 0: |
| 204 | e.detail = ACC.ROLE_TOOLTIP; |
| 205 | break; |
| 206 | case 1: |
| 207 | e.detail = ACC.ROLE_LABEL; |
| 208 | break; |
| 209 | default: |
| 210 | break; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | @Override |
| 215 | public void getState(AccessibleControlEvent e) { |
| 216 | e.detail = ACC.STATE_FOCUSABLE; |
| 217 | if (e.childID == ACC.CHILDID_SELF) { |
| 218 | e.detail |= ACC.STATE_FOCUSED; |
| 219 | } else { |
| 220 | e.detail |= ACC.STATE_SELECTABLE; |
| 221 | if (e.childID == fFocusedWidget) { |
| 222 | e.detail |= ACC.STATE_FOCUSED | ACC.STATE_SELECTED | ACC.STATE_CHECKED; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | }); |
| 227 | |
| 228 | getViewControl().addTraverseListener(new LocalTraverseListener()); |
| 229 | |
| 230 | addTraverseListener(new LocalTraverseListener()); |
| 231 | |
| 232 | getViewControl().addFocusListener(new FocusListener() { |
| 233 | @Override |
| 234 | public void focusGained(FocusEvent e) { |
| 235 | redraw(); |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public void focusLost(FocusEvent e) { |
| 240 | redraw(); |
| 241 | } |
| 242 | }); |
| 243 | } |
| 244 | |
| 245 | // ------------------------------------------------------------------------ |
| 246 | // Methods |
| 247 | // ------------------------------------------------------------------------ |
| 248 | |
| 249 | /** |
| 250 | * Sets the focus widget |
| 251 | * |
| 252 | * @param newFocusShape widget reference to set |
| 253 | */ |
| 254 | void setFocus(int newFocusShape) { |
| 255 | fFocusedWidget = newFocusShape; |
| 256 | if (fFocusedWidget == -1) { |
| 257 | getViewControl().getAccessible().setFocus(ACC.CHILDID_SELF); |
| 258 | } else { |
| 259 | getViewControl().getAccessible().setFocus(fFocusedWidget); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Sets the current frame. |
| 265 | * |
| 266 | * @param theFrame The frame to set |
| 267 | */ |
| 268 | public void setFrame(Frame theFrame) { |
| 269 | fFrame = theFrame; |
| 270 | fMinTime = fFrame.getMinTime(); |
| 271 | fMaxTime = fFrame.getMaxTime(); |
| 272 | } |
| 273 | |
| 274 | @Override |
| 275 | protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) { |
| 276 | if (fFrame == null) { |
| 277 | return; |
| 278 | } |
| 279 | fNodeList = new ArrayList<SDTimeEvent>(); |
| 280 | int messageArraysStep = 1; |
| 281 | |
| 282 | if ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * fZoomValue < Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1) { |
| 283 | messageArraysStep = Math.round(Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1 / ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * fZoomValue)); |
| 284 | } |
| 285 | |
| 286 | int firstVisible = fFrame.getFirstVisibleSyncMessage(); |
| 287 | if (firstVisible > 0) { |
| 288 | firstVisible = firstVisible - 1; |
| 289 | } |
| 290 | for (int i = firstVisible; i < fFrame.syncMessageCount(); i = i + messageArraysStep) { |
| 291 | SyncMessage m = fFrame.getSyncMessage(i); |
| 292 | if (m.hasTimeInfo()) { |
| 293 | SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), m); |
| 294 | fNodeList.add(t); |
| 295 | if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) { |
| 296 | break; |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | firstVisible = fFrame.getFirstVisibleSyncMessageReturn(); |
| 302 | if (firstVisible > 0) { |
| 303 | firstVisible = firstVisible - 1; |
| 304 | } |
| 305 | for (int i = firstVisible; i < fFrame.syncMessageReturnCount(); i = i + messageArraysStep) { |
| 306 | SyncMessage m = fFrame.getSyncMessageReturn(i); |
| 307 | if (m.hasTimeInfo()) { |
| 308 | SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), m); |
| 309 | fNodeList.add(t); |
| 310 | if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) { |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | firstVisible = fFrame.getFirstVisibleAsyncMessage(); |
| 317 | if (firstVisible > 0) { |
| 318 | firstVisible = firstVisible - 1; |
| 319 | } |
| 320 | for (int i = firstVisible; i < fFrame.asyncMessageCount(); i = i + messageArraysStep) { |
| 321 | AsyncMessage m = fFrame.getAsyncMessage(i); |
| 322 | if (m.hasTimeInfo()) { |
| 323 | SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), m); |
| 324 | fNodeList.add(t); |
| 325 | t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), m); |
| 326 | fNodeList.add(t); |
| 327 | if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) { |
| 328 | break; |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | firstVisible = fFrame.getFirstVisibleAsyncMessageReturn(); |
| 334 | if (firstVisible > 0) { |
| 335 | firstVisible = firstVisible - 1; |
| 336 | } |
| 337 | for (int i = firstVisible; i < fFrame.asyncMessageReturnCount(); i = i + messageArraysStep) { |
| 338 | AsyncMessageReturn m = fFrame.getAsyncMessageReturn(i); |
| 339 | if (m.hasTimeInfo()) { |
| 340 | SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), m); |
| 341 | fNodeList.add(t); |
| 342 | t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), m); |
| 343 | fNodeList.add(t); |
| 344 | if (m.getY() * fZoomValue > getContentsY() + getVisibleHeight()) { |
| 345 | break; |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | List<SDTimeEvent> executionOccurrencesWithTime = fFrame.getExecutionOccurrencesWithTime(); |
| 351 | if (executionOccurrencesWithTime != null) { |
| 352 | fNodeList.addAll(executionOccurrencesWithTime); |
| 353 | } |
| 354 | |
| 355 | SDTimeEvent[] temp = fNodeList.toArray(new SDTimeEvent[fNodeList.size()]); |
| 356 | Arrays.sort(temp, new TimeEventComparator()); |
| 357 | fNodeList = Arrays.asList(temp); |
| 358 | |
| 359 | Image dbuffer = null; |
| 360 | GC gcim = null; |
| 361 | try { |
| 362 | dbuffer = new Image(getDisplay(), getClientArea().width, getClientArea().height); |
| 363 | } catch (Exception e) { |
| 364 | Activator.getDefault().logError("Error creating image", e); //$NON-NLS-1$ |
| 365 | } |
| 366 | gcim = new GC(dbuffer); |
| 367 | for (int i = 0; i < fNodeList.size() - 1; i++) { |
| 368 | SDTimeEvent m1 = fNodeList.get(i); |
| 369 | SDTimeEvent m2 = fNodeList.get(i + 1); |
| 370 | |
| 371 | if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) { |
| 372 | BaseMessage mes1 = (BaseMessage) m1.getGraphNode(); |
| 373 | BaseMessage mes2 = (BaseMessage) m2.getGraphNode(); |
| 374 | if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) { |
| 375 | continue; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | fMinTime = fFrame.getMinTime(); |
| 380 | fMaxTime = fFrame.getMaxTime(); |
| 381 | ITmfTimestamp minMaxdelta = fMaxTime.getDelta(fMinTime); |
| 382 | double gr = (minMaxdelta.getValue()) / (double) 10; |
| 383 | |
| 384 | ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(fMinTime); |
| 385 | long absDelta = Math.abs(delta.getValue()); |
| 386 | |
| 387 | ColorImpl color; |
| 388 | if (gr != 0) { |
| 389 | int colIndex = Math.round((float) (absDelta / gr)); |
| 390 | if (colIndex < fColors.length && colIndex > 0) { |
| 391 | color = fColors[colIndex - 1]; |
| 392 | } else if (colIndex <= 0) { |
| 393 | color = fColors[0]; |
| 394 | } else { |
| 395 | color = fColors[fColors.length - 1]; |
| 396 | } |
| 397 | } else { |
| 398 | color = fColors[0]; |
| 399 | } |
| 400 | |
| 401 | if (color.getColor() instanceof Color) { |
| 402 | gcim.setBackground((Color) color.getColor()); |
| 403 | } |
| 404 | int y1 = ((GraphNode) m1.getGraphNode()).getY(); |
| 405 | int y2 = ((GraphNode) m2.getGraphNode()).getY(); |
| 406 | if (m1.getGraphNode() instanceof AsyncMessage) { |
| 407 | AsyncMessage as = (AsyncMessage) m1.getGraphNode(); |
| 408 | if (as.getEndTime() == m1.getTime()) { |
| 409 | y1 += as.getHeight(); |
| 410 | } |
| 411 | } |
| 412 | if (m2.getGraphNode() instanceof AsyncMessage) { |
| 413 | AsyncMessage as = (AsyncMessage) m2.getGraphNode(); |
| 414 | if (as.getEndTime() == m2.getTime()) { |
| 415 | y2 += as.getHeight(); |
| 416 | } |
| 417 | } |
| 418 | if (m1.getGraphNode() instanceof ExecutionOccurrence) { |
| 419 | |
| 420 | ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode(); |
| 421 | if (m1.getEvent() == eo.getEndOccurrence()) { |
| 422 | y1 += eo.getHeight(); |
| 423 | } |
| 424 | |
| 425 | if (m2.getGraphNode() instanceof ExecutionOccurrence) { |
| 426 | |
| 427 | ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode(); |
| 428 | if (m2.getEvent() == eo2.getEndOccurrence()) { |
| 429 | y2 += eo2.getHeight(); |
| 430 | } |
| 431 | |
| 432 | } |
| 433 | } |
| 434 | gcim.fillRectangle(contentsToViewX(0), contentsToViewY(Math.round(y1 * fZoomValue)), 10, Math.round((y2 - y1) * fZoomValue) + 1); |
| 435 | if (messageArraysStep == 1) { |
| 436 | Color backupColor = gcim.getForeground(); |
| 437 | gcim.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); |
| 438 | gcim.drawRectangle(contentsToViewX(0), contentsToViewY(Math.round(y1 * fZoomValue)), 9, Math.round((y2 - y1) * fZoomValue)); |
| 439 | gcim.setForeground(backupColor); |
| 440 | } |
| 441 | } |
| 442 | if (getViewControl().isFocusControl() || isFocusControl()) { |
| 443 | gcim.drawFocus(contentsToViewX(0), contentsToViewY(Math.round(fPrevNodeY * fZoomValue)), contentsToViewX(10), Math.round((fNextNodeY - fPrevNodeY) * fZoomValue)); |
| 444 | } |
| 445 | try { |
| 446 | gc.drawImage(dbuffer, 0, 0, getClientArea().width, getClientArea().height, 0, 0, getClientArea().width, getClientArea().height); |
| 447 | } catch (Exception e) { |
| 448 | Activator.getDefault().logError("Error drawing image", e); //$NON-NLS-1$ |
| 449 | } |
| 450 | gcim.dispose(); |
| 451 | if (dbuffer != null) { |
| 452 | dbuffer.dispose(); |
| 453 | } |
| 454 | gc.dispose(); |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * Checks for focus of children. |
| 459 | * |
| 460 | * @param children |
| 461 | * Control to check |
| 462 | * @return true if child is on focus else false |
| 463 | */ |
| 464 | protected boolean checkFocusOnChilds(Control children) { |
| 465 | if (children instanceof Composite) { |
| 466 | Control[] child = ((Composite) children).getChildren(); |
| 467 | for (int i = 0; i < child.length; i++) { |
| 468 | if (child[i].isFocusControl()) { |
| 469 | return true; |
| 470 | } |
| 471 | checkFocusOnChilds(child[i]); |
| 472 | } |
| 473 | } |
| 474 | return false; |
| 475 | } |
| 476 | |
| 477 | @Override |
| 478 | public boolean isFocusControl() { |
| 479 | Control[] child = getChildren(); |
| 480 | for (int i = 0; i < child.length; i++) { |
| 481 | if (child[i].isFocusControl()) { |
| 482 | return true; |
| 483 | } |
| 484 | checkFocusOnChilds(child[i]); |
| 485 | } |
| 486 | return false; |
| 487 | } |
| 488 | |
| 489 | @Override |
| 490 | protected void contentsMouseMoveEvent(MouseEvent event) { |
| 491 | if (fTooltip != null) { |
| 492 | fTooltip.hideToolTip(); |
| 493 | } |
| 494 | super.contentsMouseMoveEvent(event); |
| 495 | if (!isFocusControl() || getViewControl().isFocusControl()) { |
| 496 | Control[] child = getParent().getChildren(); |
| 497 | for (int i = 0; i < child.length; i++) { |
| 498 | if (child[i].isFocusControl()) { |
| 499 | break; |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | setFocus(-1); |
| 504 | } |
| 505 | |
| 506 | @Override |
| 507 | protected void contentsMouseHover(MouseEvent e) { |
| 508 | if (fTooltip == null) { |
| 509 | fTooltip = new DrawableToolTip(this); |
| 510 | } |
| 511 | if (fFrame != null) { |
| 512 | setFocus(0); |
| 513 | for (int i = 0; i < fNodeList.size() - 1; i++) { |
| 514 | SDTimeEvent m1 = fNodeList.get(i); |
| 515 | SDTimeEvent m2 = fNodeList.get(i + 1); |
| 516 | |
| 517 | if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) { |
| 518 | BaseMessage mes1 = (BaseMessage) m1.getGraphNode(); |
| 519 | BaseMessage mes2 = (BaseMessage) m2.getGraphNode(); |
| 520 | if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) { |
| 521 | continue; |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | int y1 = ((GraphNode) m1.getGraphNode()).getY(); |
| 526 | int y2 = ((GraphNode) m2.getGraphNode()).getY(); |
| 527 | |
| 528 | if (m1.getGraphNode() instanceof AsyncMessage) { |
| 529 | AsyncMessage as = (AsyncMessage) m1.getGraphNode(); |
| 530 | if (as.getEndTime() == m1.getTime()) { |
| 531 | y1 += as.getHeight(); |
| 532 | } |
| 533 | } |
| 534 | if (m2.getGraphNode() instanceof AsyncMessage) { |
| 535 | AsyncMessage as = (AsyncMessage) m2.getGraphNode(); |
| 536 | if (as.getEndTime() == m2.getTime()) { |
| 537 | y2 += as.getHeight(); |
| 538 | } |
| 539 | } |
| 540 | if (m1.getGraphNode() instanceof ExecutionOccurrence) { |
| 541 | ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode(); |
| 542 | if (m1.getEvent() == eo.getEndOccurrence()) { |
| 543 | y1 += eo.getHeight(); |
| 544 | } |
| 545 | |
| 546 | if (m2.getGraphNode() instanceof ExecutionOccurrence) { |
| 547 | |
| 548 | ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode(); |
| 549 | if (m2.getEvent() == eo2.getEndOccurrence()) { |
| 550 | y2 += eo2.getHeight(); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | int m1Y = Math.round(y1 * fZoomValue); |
| 555 | int m2Y = Math.round(y2 * fZoomValue); |
| 556 | if ((m1Y < e.y) && (m2Y >= e.y)) { |
| 557 | ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()); |
| 558 | fTooltip.showToolTip(delta, fMinTime, fMaxTime); |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | setFocus(0); |
| 563 | } |
| 564 | |
| 565 | @Override |
| 566 | protected void contentsMouseExit(MouseEvent e) { |
| 567 | if (fTooltip != null) { |
| 568 | fTooltip.hideToolTip(); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | @Override |
| 573 | protected void contentsMouseUpEvent(MouseEvent event) { |
| 574 | selectTimeDelta(event.y, 0); |
| 575 | setFocus(); |
| 576 | super.contentsMouseUpEvent(event); |
| 577 | } |
| 578 | |
| 579 | /** |
| 580 | * Force the time compression bar to highlight the event occurrences between |
| 581 | * the two given messages. The event occurrences are highlighted on the |
| 582 | * first message's end lifeline |
| 583 | * |
| 584 | * @param mes1 |
| 585 | * the first message |
| 586 | * @param mes2 |
| 587 | * the second message |
| 588 | */ |
| 589 | public void highlightRegion(BaseMessage mes1, BaseMessage mes2) { |
| 590 | BaseMessage localMes1 = mes1; |
| 591 | BaseMessage localMes2 = mes2; |
| 592 | |
| 593 | if (fFrame == null) { |
| 594 | return; |
| 595 | } |
| 596 | if (!(localMes1 instanceof ITimeRange)) { |
| 597 | return; |
| 598 | } |
| 599 | if (!(localMes2 instanceof ITimeRange)) { |
| 600 | return; |
| 601 | } |
| 602 | ITimeRange t1 = (ITimeRange) localMes1; |
| 603 | ITimeRange t2 = (ITimeRange) localMes2; |
| 604 | |
| 605 | ITmfTimestamp time1 = t1.getStartTime(); |
| 606 | ITmfTimestamp time2 = t2.getStartTime(); |
| 607 | int event1 = localMes1.getEventOccurrence(); |
| 608 | int event2 = localMes2.getEventOccurrence(); |
| 609 | |
| 610 | if (localMes1 instanceof AsyncMessage) { |
| 611 | AsyncMessage as = (AsyncMessage) localMes1; |
| 612 | time1 = as.getEndTime(); |
| 613 | event1 = as.getEndOccurrence(); |
| 614 | } |
| 615 | if (localMes2 instanceof AsyncMessage) { |
| 616 | AsyncMessage as = (AsyncMessage) localMes2; |
| 617 | if (as.getEndOccurrence() > as.getStartOccurrence()) { |
| 618 | time1 = as.getEndTime(); |
| 619 | event1 = as.getEndOccurrence(); |
| 620 | } else { |
| 621 | time1 = as.getStartTime(); |
| 622 | event1 = as.getStartOccurrence(); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | if (event1 > event2) { |
| 627 | BaseMessage tempMes = localMes2; |
| 628 | localMes2 = localMes1; |
| 629 | localMes1 = tempMes; |
| 630 | |
| 631 | t1 = (ITimeRange) localMes1; |
| 632 | t2 = (ITimeRange) localMes2; |
| 633 | |
| 634 | time1 = t1.getStartTime(); |
| 635 | time2 = t2.getStartTime(); |
| 636 | event1 = localMes1.getEventOccurrence(); |
| 637 | event2 = localMes2.getEventOccurrence(); |
| 638 | |
| 639 | if (localMes1 instanceof AsyncMessage) { |
| 640 | AsyncMessage as = (AsyncMessage) localMes1; |
| 641 | time1 = as.getEndTime(); |
| 642 | event1 = as.getEndOccurrence(); |
| 643 | } |
| 644 | if (localMes2 instanceof AsyncMessage) { |
| 645 | AsyncMessage as = (AsyncMessage) localMes2; |
| 646 | if (as.getEndOccurrence() > as.getStartOccurrence()) { |
| 647 | time1 = as.getEndTime(); |
| 648 | event1 = as.getEndOccurrence(); |
| 649 | } else { |
| 650 | time1 = as.getStartTime(); |
| 651 | event1 = as.getStartOccurrence(); |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | ITmfTimestamp minMaxdelta = fMaxTime.getDelta(fMinTime); |
| 657 | double gr = (minMaxdelta.getValue()) / (double) 10; |
| 658 | |
| 659 | ITmfTimestamp delta = time2.getDelta(time1).getDelta(fMinTime); |
| 660 | long absDelta = Math.abs(delta.getValue()); |
| 661 | |
| 662 | int colIndex = 0; |
| 663 | if (gr != 0) { |
| 664 | colIndex = Math.round((float) (absDelta / gr)); |
| 665 | if (colIndex >= fColors.length) { |
| 666 | colIndex = fColors.length - 1; |
| 667 | } else if (colIndex < 0) { |
| 668 | colIndex = 0; |
| 669 | } |
| 670 | } else { |
| 671 | colIndex = 0; |
| 672 | } |
| 673 | for (int j = 0; j < fListenerList.size(); j++) { |
| 674 | ITimeCompressionListener list = fListenerList.get(j); |
| 675 | if (localMes1.getEndLifeline() != null) { |
| 676 | list.deltaSelected(localMes1.getEndLifeline(), event1, event2 - event1, fColors[colIndex]); |
| 677 | } else if (localMes2.getStartLifeline() != null) { |
| 678 | list.deltaSelected(localMes2.getStartLifeline(), event1, event2 - event1, fColors[colIndex]); |
| 679 | } else { |
| 680 | list.deltaSelected(localMes1.getStartLifeline(), event1, event2 - event1, fColors[colIndex]); |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | /** |
| 686 | * Force the time compression bar to highlight the event occurrences between the two given messages. The event |
| 687 | * occurrences are highlighted on the first message's end lifeline |
| 688 | * |
| 689 | * @param mes1 the first message |
| 690 | * @param mes2 the second message |
| 691 | */ |
| 692 | public void highlightRegionSync(final BaseMessage mes1, final BaseMessage mes2) { |
| 693 | getDisplay().syncExec(new Runnable() { |
| 694 | @Override |
| 695 | public void run() { |
| 696 | highlightRegion(mes1, mes2); |
| 697 | } |
| 698 | }); |
| 699 | } |
| 700 | |
| 701 | @Override |
| 702 | public void scrollBy(int x, int y) { |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * Sets the zoom value. |
| 707 | * |
| 708 | * @param value The zoom value to set. |
| 709 | */ |
| 710 | public void setZoom(float value) { |
| 711 | fZoomValue = value; |
| 712 | redraw(); |
| 713 | } |
| 714 | |
| 715 | /** |
| 716 | * Adds a listener to the time compression listener list to be notified about selected deltas. |
| 717 | * |
| 718 | * @param listener The listener to add |
| 719 | */ |
| 720 | public void addTimeCompressionListener(ITimeCompressionListener listener) { |
| 721 | if (!fListenerList.contains(listener)) { |
| 722 | fListenerList.add(listener); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * Removes a time compression listener. |
| 728 | * |
| 729 | * @param listener The listener to remove. |
| 730 | */ |
| 731 | public void removeSelectionChangedListener(ITimeCompressionListener listener) { |
| 732 | fListenerList.remove(listener); |
| 733 | } |
| 734 | |
| 735 | @Override |
| 736 | public void widgetDisposed(DisposeEvent e) { |
| 737 | if (fTooltip != null) { |
| 738 | fTooltip.dispose(); |
| 739 | } |
| 740 | super.removeDisposeListener(this); |
| 741 | for (int i = 0; i < fColors.length; i++) { |
| 742 | fColors[i].dispose(); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | @Override |
| 747 | protected void keyPressedEvent(KeyEvent event) { |
| 748 | if (fTooltip != null) { |
| 749 | fTooltip.hideToolTip(); |
| 750 | } |
| 751 | if (!isFocusControl() || getViewControl().isFocusControl()) { |
| 752 | Control[] child = getParent().getChildren(); |
| 753 | for (int i = 0; i < child.length; i++) { |
| 754 | if (child[i].isFocusControl()) { |
| 755 | // getViewControl().setFocus(); |
| 756 | break; |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | setFocus(-1); |
| 761 | |
| 762 | boolean top = false; |
| 763 | if (fNextNodeY == 0) { |
| 764 | top = true; |
| 765 | } |
| 766 | if ((fFrame != null) && (fNextNodeY == 0)) { |
| 767 | for (int i = 0; i < fNodeList.size() - 1 && i < 1; i++) { |
| 768 | SDTimeEvent m1 = fNodeList.get(i); |
| 769 | SDTimeEvent m2 = fNodeList.get(i + 1); |
| 770 | if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) { |
| 771 | BaseMessage mes1 = (BaseMessage) m1.getGraphNode(); |
| 772 | BaseMessage mes2 = (BaseMessage) m2.getGraphNode(); |
| 773 | if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) { |
| 774 | continue; |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | int y1 = ((GraphNode) m1.getGraphNode()).getY(); |
| 779 | int y2 = ((GraphNode) m2.getGraphNode()).getY(); |
| 780 | if (m1.getGraphNode() instanceof AsyncMessage) { |
| 781 | AsyncMessage as = (AsyncMessage) m1.getGraphNode(); |
| 782 | if (as.getEndTime() == m1.getTime()) { |
| 783 | y1 += as.getHeight(); |
| 784 | } |
| 785 | } |
| 786 | if (m2.getGraphNode() instanceof AsyncMessage) { |
| 787 | AsyncMessage as = (AsyncMessage) m2.getGraphNode(); |
| 788 | if (as.getEndTime() == m2.getTime()) { |
| 789 | y2 += as.getHeight(); |
| 790 | } |
| 791 | } |
| 792 | if (m1.getGraphNode() instanceof ExecutionOccurrence) { |
| 793 | ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode(); |
| 794 | if (m1.getEvent() == eo.getEndOccurrence()) { |
| 795 | y1 += eo.getHeight(); |
| 796 | } |
| 797 | |
| 798 | if (m2.getGraphNode() instanceof ExecutionOccurrence) { |
| 799 | |
| 800 | ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode(); |
| 801 | if (m2.getEvent() == eo2.getEndOccurrence()) { |
| 802 | y2 += eo2.getHeight(); |
| 803 | } |
| 804 | } |
| 805 | } |
| 806 | fPrevNodeY = Math.round(y1 * fZoomValue); |
| 807 | fNextNodeY = Math.round(y2 * fZoomValue); |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | if (fLifeline != null) { |
| 812 | for (int j = 0; j < fListenerList.size(); j++) { |
| 813 | ITimeCompressionListener list = fListenerList.get(j); |
| 814 | list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | if (event.keyCode == SWT.ARROW_DOWN) { |
| 819 | if (!top) { |
| 820 | selectTimeDelta(fNextNodeY + 1, 1); |
| 821 | } else { |
| 822 | selectTimeDelta(fPrevNodeY + 1, 1); |
| 823 | } |
| 824 | setFocus(1); |
| 825 | } else if (event.keyCode == SWT.ARROW_UP) { |
| 826 | selectTimeDelta(fPrevNodeY - 1, 2); |
| 827 | setFocus(1); |
| 828 | } else if (event.keyCode == SWT.ARROW_RIGHT) { |
| 829 | selectTimeDelta(fPrevNodeY, 1); |
| 830 | setFocus(1); |
| 831 | } |
| 832 | super.keyPressedEvent(event); |
| 833 | } |
| 834 | |
| 835 | /** |
| 836 | * Selects the time delta for given delta y coordinate and direction. |
| 837 | * |
| 838 | * @param dy The delta in y coordinate. |
| 839 | * @param direction 0 no direction, 1 = down, 2 = up |
| 840 | */ |
| 841 | protected void selectTimeDelta(int dy, int direction) { |
| 842 | SDTimeEvent lastM1 = null; |
| 843 | SDTimeEvent lastM2 = null; |
| 844 | int lastY1 = 0; |
| 845 | int lastY2 = 0; |
| 846 | boolean done = false; |
| 847 | if (fFrame != null) { |
| 848 | for (int i = 0; i < fNodeList.size() - 1; i++) { |
| 849 | SDTimeEvent m1 = fNodeList.get(i); |
| 850 | SDTimeEvent m2 = fNodeList.get(i + 1); |
| 851 | if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) { |
| 852 | BaseMessage mes1 = (BaseMessage) m1.getGraphNode(); |
| 853 | BaseMessage mes2 = (BaseMessage) m2.getGraphNode(); |
| 854 | if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) { |
| 855 | continue; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | int y1 = ((GraphNode) m1.getGraphNode()).getY(); |
| 860 | int y2 = ((GraphNode) m2.getGraphNode()).getY(); |
| 861 | if (m1.getGraphNode() instanceof AsyncMessage) { |
| 862 | AsyncMessage as = (AsyncMessage) m1.getGraphNode(); |
| 863 | if (as.getEndTime() == m1.getTime()) { |
| 864 | y1 += as.getHeight(); |
| 865 | } |
| 866 | } |
| 867 | if (m2.getGraphNode() instanceof AsyncMessage) { |
| 868 | AsyncMessage as = (AsyncMessage) m2.getGraphNode(); |
| 869 | if (as.getEndTime() == m2.getTime()) { |
| 870 | y2 += as.getHeight(); |
| 871 | } |
| 872 | } |
| 873 | if (m1.getGraphNode() instanceof ExecutionOccurrence) { |
| 874 | ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode(); |
| 875 | if (m1.getEvent() == eo.getEndOccurrence()) { |
| 876 | y1 += eo.getHeight(); |
| 877 | } |
| 878 | |
| 879 | if (m2.getGraphNode() instanceof ExecutionOccurrence) { |
| 880 | ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode(); |
| 881 | if (m2.getEvent() == eo2.getEndOccurrence()) { |
| 882 | y2 += eo2.getHeight(); |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | int m1Y = Math.round(y1 * fZoomValue); |
| 887 | int m2Y = Math.round(y2 * fZoomValue); |
| 888 | |
| 889 | if ((m1Y < dy) && (m2Y > dy) || (!done && m2Y > dy && direction == 1 && lastM1 != null) || (!done && m1Y > dy && direction == 2 && lastM1 != null)) { |
| 890 | if (m1Y > dy && direction == 2) { |
| 891 | m1 = lastM1; |
| 892 | m2 = lastM2; |
| 893 | m1Y = lastY1; |
| 894 | m2Y = lastY2; |
| 895 | } |
| 896 | done = true; |
| 897 | fPrevNodeY = m1Y; |
| 898 | fNextNodeY = m2Y; |
| 899 | ITmfTimestamp minMaxdelta = fMaxTime.getDelta(fMinTime); |
| 900 | double gr = (minMaxdelta.getValue()) / (double) 10; |
| 901 | |
| 902 | ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(fMinTime); |
| 903 | long absDelta = Math.abs(delta.getValue()); |
| 904 | |
| 905 | int colIndex = 0; |
| 906 | if (gr != 0) { |
| 907 | colIndex = Math.round((float) (absDelta / gr)); |
| 908 | if (colIndex >= fColors.length) { |
| 909 | colIndex = fColors.length - 1; |
| 910 | } else if (colIndex < 0) { |
| 911 | colIndex = 0; |
| 912 | } |
| 913 | } else { |
| 914 | colIndex = 0; |
| 915 | } |
| 916 | if (m1.getGraphNode() instanceof BaseMessage) { |
| 917 | BaseMessage mes1 = (BaseMessage) m1.getGraphNode(); |
| 918 | if (mes1.getEndLifeline() != null) { |
| 919 | fLifeline = mes1.getEndLifeline(); |
| 920 | fLifelineStart = m1.getEvent(); |
| 921 | fLifelineNumEvents = m2.getEvent() - m1.getEvent(); |
| 922 | fLifelineColor = fColors[colIndex]; |
| 923 | } else if (m2.getGraphNode() instanceof BaseMessage && ((BaseMessage) m2.getGraphNode()).getStartLifeline() != null) { |
| 924 | fLifeline = ((BaseMessage) m2.getGraphNode()).getStartLifeline(); |
| 925 | fLifelineStart = m1.getEvent(); |
| 926 | fLifelineNumEvents = m2.getEvent() - m1.getEvent(); |
| 927 | fLifelineColor = fColors[colIndex]; |
| 928 | } else { |
| 929 | fLifeline = mes1.getStartLifeline(); |
| 930 | fLifelineStart = m1.getEvent(); |
| 931 | fLifelineNumEvents = m2.getEvent() - m1.getEvent(); |
| 932 | fLifelineColor = fColors[colIndex]; |
| 933 | } |
| 934 | } else if (m1.getGraphNode() instanceof ExecutionOccurrence) { |
| 935 | if (m2.getGraphNode() instanceof ExecutionOccurrence) { |
| 936 | ExecutionOccurrence eo = (ExecutionOccurrence) m2.getGraphNode(); |
| 937 | fLifeline = eo.getLifeline(); |
| 938 | fLifelineStart = m1.getEvent(); |
| 939 | fLifelineNumEvents = m2.getEvent() - m1.getEvent(); |
| 940 | fLifelineColor = fColors[colIndex]; |
| 941 | } else { |
| 942 | ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode(); |
| 943 | fLifeline = eo.getLifeline(); |
| 944 | fLifelineStart = m1.getEvent(); |
| 945 | fLifelineNumEvents = m2.getEvent() - m1.getEvent(); |
| 946 | fLifelineColor = fColors[colIndex]; |
| 947 | } |
| 948 | } |
| 949 | for (int j = 0; j < fListenerList.size(); j++) { |
| 950 | ITimeCompressionListener list = fListenerList.get(j); |
| 951 | list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor); |
| 952 | } |
| 953 | break; |
| 954 | } |
| 955 | lastM1 = m1; |
| 956 | lastM2 = m2; |
| 957 | lastY1 = m1Y; |
| 958 | lastY2 = m2Y; |
| 959 | } |
| 960 | } |
| 961 | } |
| 962 | |
| 963 | /** |
| 964 | * Creates a fake tool tip. |
| 965 | */ |
| 966 | protected void createFakeTooltip() { |
| 967 | if (fTooltip == null) { |
| 968 | fTooltip = new DrawableToolTip(this); |
| 969 | } |
| 970 | |
| 971 | if (fFrame != null) { |
| 972 | setFocus(0); |
| 973 | for (int i = 0; i < fNodeList.size() - 1; i++) { |
| 974 | SDTimeEvent m1 = fNodeList.get(i); |
| 975 | SDTimeEvent m2 = fNodeList.get(i + 1); |
| 976 | |
| 977 | if ((SDViewPref.getInstance().excludeExternalTime()) && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) { |
| 978 | BaseMessage mes1 = (BaseMessage) m1.getGraphNode(); |
| 979 | BaseMessage mes2 = (BaseMessage) m2.getGraphNode(); |
| 980 | if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) { |
| 981 | continue; |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | int y1 = ((GraphNode) m1.getGraphNode()).getY(); |
| 986 | int y2 = ((GraphNode) m2.getGraphNode()).getY(); |
| 987 | |
| 988 | if (m1.getGraphNode() instanceof AsyncMessage) { |
| 989 | AsyncMessage as = (AsyncMessage) m1.getGraphNode(); |
| 990 | if (as.getEndTime() == m1.getTime()) { |
| 991 | y1 += as.getHeight(); |
| 992 | } |
| 993 | } |
| 994 | if (m2.getGraphNode() instanceof AsyncMessage) { |
| 995 | AsyncMessage as = (AsyncMessage) m2.getGraphNode(); |
| 996 | if (as.getEndTime() == m2.getTime()) { |
| 997 | y2 += as.getHeight(); |
| 998 | } |
| 999 | } |
| 1000 | if (m1.getGraphNode() instanceof ExecutionOccurrence) { |
| 1001 | ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode(); |
| 1002 | if (m1.getEvent() == eo.getEndOccurrence()) { |
| 1003 | y1 += eo.getHeight(); |
| 1004 | } |
| 1005 | |
| 1006 | if (m2.getGraphNode() instanceof ExecutionOccurrence) { |
| 1007 | |
| 1008 | ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode(); |
| 1009 | if (m2.getEvent() == eo2.getEndOccurrence()) { |
| 1010 | y2 += eo2.getHeight(); |
| 1011 | } |
| 1012 | } |
| 1013 | } |
| 1014 | int m1Y = Math.round(y1 * fZoomValue); |
| 1015 | int m2Y = Math.round(y2 * fZoomValue); |
| 1016 | if ((m1Y < fPrevNodeY + 1) && (m2Y >= fPrevNodeY + 1)) { |
| 1017 | ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()); |
| 1018 | fTooltip.showToolTip(delta, fMinTime, fMaxTime); |
| 1019 | fTooltip.hideToolTip(); |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | /** |
| 1026 | * Traverse Listener implementation. |
| 1027 | */ |
| 1028 | protected static class LocalTraverseListener implements TraverseListener { |
| 1029 | @Override |
| 1030 | public void keyTraversed(TraverseEvent e) { |
| 1031 | if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) { |
| 1032 | e.doit = true; |
| 1033 | } |
| 1034 | } |
| 1035 | } |
| 1036 | } |