1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.analysis
.graph
.ui
.criticalpath
.view
;
12 import org
.eclipse
.jdt
.annotation
.Nullable
;
13 import org
.eclipse
.swt
.graphics
.RGB
;
14 import org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
;
15 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.StateItem
;
16 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.TimeGraphPresentationProvider
;
17 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
18 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.TimeEvent
;
21 * Presentation provider for the critical path view
23 * @author Geneviève Bastien
25 public class CriticalPathPresentationProvider
extends TimeGraphPresentationProvider
{
28 * The enumeration of possible states for the view
30 public static enum State
{
31 /** Worker is running */
32 RUNNING (new RGB(0x33, 0x99, 0x00)),
33 /** Worker is interrupted */
34 INTERRUPTED (new RGB(0xff, 0xdc, 0x00)),
35 /** Worker has been preempted */
36 PREEMPTED (new RGB(0xc8, 0x64, 0x00)),
37 /** Worker waiting on a timer */
38 TIMER (new RGB(0x33, 0x66, 0x99)),
39 /** Worker is blocked, waiting on a device */
40 BLOCK_DEVICE (new RGB(0x66, 0x00, 0xcc)),
41 /** Worker is waiting for user input */
42 USER_INPUT (new RGB(0x5a, 0x01, 0x01)),
43 /** Worker is waiting on network */
44 NETWORK (new RGB(0xff, 0x9b, 0xff)),
45 /** Worker is waiting for an IPI */
46 IPI (new RGB(0x66, 0x66, 0xcc)),
47 /** Any other reason */
48 UNKNOWN (new RGB(0x40, 0x3b, 0x33));
50 /** RGB color associated with a state */
53 private State (RGB rgb
) {
59 public String
getStateTypeName() {
60 return Messages
.getMessage(Messages
.CriticalFlowView_stateTypeName
);
64 public StateItem
[] getStateTable() {
65 StateItem
[] stateTable
= new StateItem
[State
.values().length
];
66 for (int i
= 0; i
< stateTable
.length
; i
++) {
67 State state
= State
.values()[i
];
68 stateTable
[i
] = new StateItem(state
.rgb
, state
.toString());
74 public int getStateTableIndex(@Nullable ITimeEvent event
) {
75 if (event
instanceof TimeEvent
&& ((TimeEvent
) event
).hasValue()) {
76 return ((TimeEvent
) event
).getValue();
81 private static State
getMatchingState(int status
) {
86 return State
.INTERRUPTED
;
88 return State
.PREEMPTED
;
92 return State
.BLOCK_DEVICE
;
94 return State
.USER_INPUT
;
100 return State
.UNKNOWN
;
105 public String
getEventName(@Nullable ITimeEvent event
) {
106 if (event
instanceof TimeEvent
) {
107 TimeEvent ev
= (TimeEvent
) event
;
109 return NonNullUtils
.nullToEmptyString(getMatchingState(ev
.getValue()));
112 return Messages
.getMessage(Messages
.CriticalFlowView_multipleStates
);