linux.ui: add a centralized registry of event styles.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 15 Nov 2016 19:53:31 +0000 (14:53 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 4 Apr 2017 19:42:48 +0000 (15:42 -0400)
This ensures that a state in the Control Flow view and the Resources
view will always be the same color. Also allows localizable help text.

Change-Id: I17cf2ad0e3bda0e254a1ee6d12df0aa96177647a
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/85091
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/META-INF/MANIFEST.MF
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/LinuxStyle.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/Messages.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/messages.properties [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowPresentationProvider.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/resources/ResourcesPresentationProvider.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesViewTest.java

index 38db698dd11f99969eb0d1ff57ece74fff4d4c13..2e41a9480b06211637a95938cc22e684496c6c6b 100644 (file)
@@ -27,6 +27,7 @@ Import-Package: com.google.common.annotations,
 Export-Package: org.eclipse.tracecompass.internal.analysis.os.linux.ui;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions;x-internal:=true,
  org.eclipse.tracecompass.internal.analysis.os.linux.ui.perspectives;x-internal:=true,
+ org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry;x-internal:=true,
  org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow;
   x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests,
    org.eclipse.tracecompass.analysis.os.linux.ui.tests,
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/LinuxStyle.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/LinuxStyle.java
new file mode 100644 (file)
index 0000000..a5f431c
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry;
+
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.RGBA;
+
+/**
+ * A Linux style
+ *
+ * @author Matthew Khouzam
+ */
+public enum LinuxStyle {
+
+    /**
+     * Unknown state for thread or CPU
+     */
+    UNKNOWN(Messages.LinuxStyles_unknown, new RGB(100, 100, 100), 0.33f),
+
+    /**
+     * Wait for an unknown reason
+     */
+    WAIT_UNKNOWN(Messages.LinuxStyles_wait, new RGB(200, 200, 200), 0.50f),
+
+    /**
+     * Wait to be scheduled back in
+     */
+    WAIT_BLOCKED(Messages.LinuxStyles_waitBlocked, new RGB(200, 200, 0), 0.50f),
+
+    /**
+     * Wait for the CPU to be available
+     */
+    WAIT_FOR_CPU(Messages.LinuxStyles_waitForCPU, new RGB(200, 100, 0), 0.50f),
+
+    /**
+     * CPU is idle
+     */
+    IDLE(Messages.LinuxStyles_idle, new RGB(200, 200, 200), 0.66f),
+
+    /**
+     * CPU or thread is in usermode
+     */
+    USERMODE(Messages.LinuxStyles_usermode, new RGB(0, 200, 0), 1.00f),
+
+    /**
+     * CPU or thread is in a system call
+     */
+    SYSCALL(Messages.LinuxStyles_systemCall, new RGB(0, 0, 200), 1.00f),
+
+    /**
+     * CPU is in an IRQ
+     */
+    INTERRUPTED(Messages.LinuxStyles_Interrupt, new RGB(200, 0, 100), 0.75f),
+
+    /**
+     * A Softirq or tasklet is raised
+     */
+    SOFT_IRQ_RAISED(Messages.LinuxStyles_softIrqRaised, new RGB(200, 200, 0), 1.00f),
+
+    /**
+     * CPU is in a softirq or tasklet
+     */
+    SOFT_IRQ(Messages.LinuxStyles_softrq, new RGB(200, 150, 100), 1.00f);
+
+    private final float fHeightFactor;
+    private RGBA fColor;
+    private String fLabel;
+
+    /**
+     * A Linux style
+     *
+     * @param label
+     *            The label of the style
+     * @param color
+     *            the color
+     * @param heightFactor
+     *            the hint of the height
+     */
+    private LinuxStyle(String label, RGB color, float heightFactor) {
+        this(label, new RGBA(color.red, color.green, color.blue, 255), heightFactor);
+    }
+
+    /**
+     * A Linux style
+     *
+     * @param label
+     *            the label of the style
+     * @param color
+     *            the color
+     * @param heightFactor
+     *            the hint of the height, between 0 and 1.0
+     */
+    private LinuxStyle(String label, RGBA color, float heightFactor) {
+        if (heightFactor > 1.0 || heightFactor < 0) {
+            throw new IllegalStateException("Height factor needs to be between 0 and 1.0, given hint : " + heightFactor); //$NON-NLS-1$
+        }
+        fLabel = label;
+        fColor = color;
+        fHeightFactor = heightFactor;
+    }
+
+    /**
+     * Get the label
+     *
+     * @return the label to display
+     */
+    public String getLabel() {
+        return fLabel;
+    }
+
+    /**
+     * Get the color
+     *
+     * @return the color to display
+     */
+    public RGBA getColor() {
+        return fColor;
+    }
+
+    /**
+     * Get the hint height, to be multiplied by the
+     *
+     * @return the heightHint
+     */
+    public float getHeightFactor() {
+        return fHeightFactor;
+    }
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/Messages.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/Messages.java
new file mode 100644 (file)
index 0000000..659546e
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages
+ *
+ * @author Matthew Khouzam
+ */
+public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry.messages"; //$NON-NLS-1$
+    /**
+     * Idle
+     */
+    public static String LinuxStyles_idle;
+    /**
+     * Irq
+     */
+    public static String LinuxStyles_Interrupt;
+    /**
+     * Softirq raised
+     */
+    public static String LinuxStyles_softIrqRaised;
+    /**
+     * Softirq
+     */
+    public static String LinuxStyles_softrq;
+    /**
+     * Syscall
+     */
+    public static String LinuxStyles_systemCall;
+    /**
+     * Unknown
+     */
+    public static String LinuxStyles_unknown;
+    /**
+     * User mode
+     */
+    public static String LinuxStyles_usermode;
+    /**
+     * Wait
+     */
+    public static String LinuxStyles_wait;
+    /**
+     * Wait blocked
+     */
+    public static String LinuxStyles_waitBlocked;
+    /**
+     * Wait for CPU
+     */
+    public static String LinuxStyles_waitForCPU;
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/messages.properties b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/registry/messages.properties
new file mode 100644 (file)
index 0000000..310b165
--- /dev/null
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright (c) 2017 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+LinuxStyles_idle=Idle
+LinuxStyles_Interrupt=Interrupt
+LinuxStyles_softIrqRaised=Soft Irq raised
+LinuxStyles_softrq=Soft Irq
+LinuxStyles_systemCall=System call
+LinuxStyles_unknown=Unknown
+LinuxStyles_usermode=Usermode
+LinuxStyles_wait=Wait
+LinuxStyles_waitBlocked=Wait blocked
+LinuxStyles_waitForCPU=Wait for CPU
index 14b087ab762f5eb87f8875652c45a3339a2616cc..5b0f6f373adbf053b0574bc3adb883b35a0308f2 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Map;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
@@ -28,6 +27,7 @@ import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
+import org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry.LinuxStyle;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
 import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
@@ -44,26 +44,32 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
 /**
  * Presentation provider for the control flow view
  */
 public class ControlFlowPresentationProvider extends TimeGraphPresentationProvider {
 
-    private enum State {
-        UNKNOWN        (new RGB(100, 100, 100)),
-        WAIT_UNKNOWN   (new RGB(200, 200, 200)),
-        WAIT_BLOCKED   (new RGB(200, 200, 0)),
-        WAIT_FOR_CPU   (new RGB(200, 100, 0)),
-        USERMODE       (new RGB(0,   200, 0)),
-        SYSCALL        (new RGB(0,     0, 200)),
-        INTERRUPTED    (new RGB(200,   0, 100));
-
-        public final RGB rgb;
+    private static final Map<Integer, StateItem> STATE_MAP;
+    private static final List<StateItem> STATE_LIST;
 
-        private State(RGB rgb) {
-            this.rgb = rgb;
-        }
+    private static StateItem createState(LinuxStyle style) {
+        return new StateItem(style.getColor().rgb, style.getLabel());
+    }
 
+    static {
+        ImmutableMap.Builder<Integer, StateItem> builder = new ImmutableMap.Builder<>();
+        builder.put(StateValues.PROCESS_STATUS_UNKNOWN, createState(LinuxStyle.UNKNOWN));
+        builder.put(StateValues.PROCESS_STATUS_RUN_USERMODE, createState(LinuxStyle.USERMODE));
+        builder.put(StateValues.PROCESS_STATUS_RUN_SYSCALL, createState(LinuxStyle.SYSCALL));
+        builder.put(StateValues.PROCESS_STATUS_INTERRUPTED, createState(LinuxStyle.INTERRUPTED));
+        builder.put(StateValues.PROCESS_STATUS_WAIT_BLOCKED, createState(LinuxStyle.WAIT_BLOCKED));
+        builder.put(StateValues.PROCESS_STATUS_WAIT_FOR_CPU, createState(LinuxStyle.WAIT_FOR_CPU));
+        builder.put(StateValues.PROCESS_STATUS_WAIT_UNKNOWN, createState(LinuxStyle.WAIT_UNKNOWN));
+        STATE_MAP = builder.build();
+        STATE_LIST = ImmutableList.copyOf(STATE_MAP.values());
     }
 
     /**
@@ -79,26 +85,16 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
         super(Messages.ControlFlowView_stateTypeName);
     }
 
-    private static State[] getStateValues() {
-        return State.values();
-    }
-
     @Override
     public StateItem[] getStateTable() {
-        State[] states = getStateValues();
-        StateItem[] stateTable = new StateItem[states.length];
-        for (int i = 0; i < stateTable.length; i++) {
-            State state = states[i];
-            stateTable[i] = new StateItem(state.rgb, state.toString());
-        }
-        return stateTable;
+        return STATE_LIST.toArray(new StateItem[STATE_LIST.size()]);
     }
 
     @Override
     public int getStateTableIndex(ITimeEvent event) {
         if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) {
             int status = ((TimeEvent) event).getValue();
-            return getMatchingState(status).ordinal();
+            return STATE_LIST.indexOf(getMatchingState(status));
         }
         if (event instanceof NullTimeEvent) {
             return INVISIBLE;
@@ -111,29 +107,14 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
         if (event instanceof TimeEvent) {
             TimeEvent ev = (TimeEvent) event;
             if (ev.hasValue()) {
-                return getMatchingState(ev.getValue()).toString();
+                return getMatchingState(ev.getValue()).getStateString();
             }
         }
         return Messages.ControlFlowView_multipleStates;
     }
 
-    private static State getMatchingState(int status) {
-        switch (status) {
-        case StateValues.PROCESS_STATUS_WAIT_UNKNOWN:
-            return State.WAIT_UNKNOWN;
-        case StateValues.PROCESS_STATUS_WAIT_BLOCKED:
-            return State.WAIT_BLOCKED;
-        case StateValues.PROCESS_STATUS_WAIT_FOR_CPU:
-            return State.WAIT_FOR_CPU;
-        case StateValues.PROCESS_STATUS_RUN_USERMODE:
-            return State.USERMODE;
-        case StateValues.PROCESS_STATUS_RUN_SYSCALL:
-            return State.SYSCALL;
-        case StateValues.PROCESS_STATUS_INTERRUPTED:
-            return State.INTERRUPTED;
-        default:
-            return State.UNKNOWN;
-        }
+    private static StateItem getMatchingState(int status) {
+        return STATE_MAP.getOrDefault(status, STATE_MAP.get(StateValues.PROCESS_STATUS_WAIT_UNKNOWN));
     }
 
     @Override
@@ -228,7 +209,8 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
 
                 /*
                  * Remove the "sys_" or "syscall_entry_" or similar from what we
-                 * draw in the rectangle. This depends on the trace's event layout.
+                 * draw in the rectangle. This depends on the trace's event
+                 * layout.
                  */
                 int beginIndex = 0;
                 ITmfTrace trace = entry.getTrace();
index c1c69e0f838bc049fbe6eef84cd90e5fc323c9e6..b02403ab0f161c2a1cd84b581fc0296d81451377 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Map;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
@@ -29,6 +28,7 @@ import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
+import org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry.LinuxStyle;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesEntry.Type;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -50,6 +50,9 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
 /**
  * Presentation provider for the Resource view, based on the generic TMF
  * presentation provider.
@@ -63,21 +66,24 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
     private Color fColorGray;
     private Integer fAverageCharWidth;
 
-    private enum State {
-        IDLE             (new RGB(200, 200, 200)),
-        USERMODE         (new RGB(  0, 200,   0)),
-        SYSCALL          (new RGB(  0,   0, 200)),
-        IRQ              (new RGB(200,   0, 100)),
-        SOFT_IRQ         (new RGB(200, 150, 100)),
-        IRQ_ACTIVE       (new RGB(200,   0, 100)),
-        SOFT_IRQ_RAISED  (new RGB(200, 200,   0)),
-        SOFT_IRQ_ACTIVE  (new RGB(200, 150, 100));
+    private static final Map<Integer, StateItem> STATE_MAP;
 
-        public final RGB rgb;
+    private static final List<StateItem> STATE_LIST;
 
-        private State(RGB rgb) {
-            this.rgb = rgb;
-        }
+    private static StateItem createState(LinuxStyle style) {
+        return new StateItem(style.getColor().rgb, style.getLabel());
+    }
+
+    static {
+        ImmutableMap.Builder<Integer, StateItem> builder = new ImmutableMap.Builder<>();
+        builder.put(StateValues.CPU_STATUS_IDLE, createState(LinuxStyle.IDLE));
+        builder.put(StateValues.CPU_STATUS_RUN_USERMODE, createState(LinuxStyle.USERMODE));
+        builder.put(StateValues.CPU_STATUS_RUN_SYSCALL, createState(LinuxStyle.SYSCALL));
+        builder.put(StateValues.CPU_STATUS_IRQ, createState(LinuxStyle.INTERRUPTED));
+        builder.put(StateValues.CPU_STATUS_SOFTIRQ, createState(LinuxStyle.SOFT_IRQ));
+        builder.put(StateValues.CPU_STATUS_SOFT_IRQ_RAISED, createState(LinuxStyle.SOFT_IRQ_RAISED));
+        STATE_MAP = builder.build();
+        STATE_LIST = ImmutableList.copyOf(STATE_MAP.values());
     }
 
     /**
@@ -87,36 +93,20 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
         super();
     }
 
-    private static State[] getStateValues() {
-        return State.values();
-    }
-
-    private static State getEventState(TimeEvent event) {
+    private static StateItem getEventState(TimeEvent event) {
         if (event.hasValue()) {
             ResourcesEntry entry = (ResourcesEntry) event.getEntry();
             int value = event.getValue();
 
             if (entry.getType() == Type.CPU) {
-                if (value == StateValues.CPU_STATUS_IDLE) {
-                    return State.IDLE;
-                } else if (value == StateValues.CPU_STATUS_RUN_USERMODE) {
-                    return State.USERMODE;
-                } else if (value == StateValues.CPU_STATUS_RUN_SYSCALL) {
-                    return State.SYSCALL;
-                } else if (value == StateValues.CPU_STATUS_IRQ) {
-                    return State.IRQ;
-                } else if (value == StateValues.CPU_STATUS_SOFTIRQ) {
-                    return State.SOFT_IRQ;
-                } else if (value == StateValues.CPU_STATUS_SOFT_IRQ_RAISED) {
-                    return State.SOFT_IRQ_RAISED;
-                }
+                return STATE_MAP.getOrDefault(value, STATE_MAP.get(StateValues.PROCESS_STATUS_UNKNOWN));
             } else if (entry.getType() == Type.IRQ) {
-                return State.IRQ_ACTIVE;
+                return STATE_MAP.get(StateValues.CPU_STATUS_IRQ);
             } else if (entry.getType() == Type.SOFT_IRQ) {
                 if (value == StateValues.CPU_STATUS_SOFT_IRQ_RAISED) {
-                    return State.SOFT_IRQ_RAISED;
+                    return STATE_MAP.get(StateValues.CPU_STATUS_SOFT_IRQ_RAISED);
                 }
-                return State.SOFT_IRQ_ACTIVE;
+                return STATE_MAP.get(StateValues.CPU_STATUS_SOFTIRQ);
             }
         }
         return null;
@@ -124,9 +114,9 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
 
     @Override
     public int getStateTableIndex(ITimeEvent event) {
-        State state = getEventState((TimeEvent) event);
+        StateItem state = getEventState((TimeEvent) event);
         if (state != null) {
-            return state.ordinal();
+            return STATE_LIST.indexOf(state);
         }
         if (event instanceof NullTimeEvent) {
             return INVISIBLE;
@@ -136,20 +126,14 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
 
     @Override
     public StateItem[] getStateTable() {
-        State[] states = getStateValues();
-        StateItem[] stateTable = new StateItem[states.length];
-        for (int i = 0; i < stateTable.length; i++) {
-            State state = states[i];
-            stateTable[i] = new StateItem(state.rgb, state.toString());
-        }
-        return stateTable;
+        return STATE_LIST.toArray(new StateItem[STATE_LIST.size()]);
     }
 
     @Override
     public String getEventName(ITimeEvent event) {
-        State state = getEventState((TimeEvent) event);
+        StateItem state = getEventState((TimeEvent) event);
         if (state != null) {
-            return state.toString();
+            return state.getStateString();
         }
         if (event instanceof NullTimeEvent) {
             return null;
@@ -174,7 +158,8 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
                 // Check for IRQ or Soft_IRQ type
                 if (entry.getType().equals(Type.IRQ) || entry.getType().equals(Type.SOFT_IRQ)) {
 
-                    // Get CPU of IRQ or SoftIRQ and provide it for the tooltip display
+                    // Get CPU of IRQ or SoftIRQ and provide it for the tooltip
+                    // display
                     int cpu = tcEvent.getValue();
                     if (cpu >= 0) {
                         retMap.put(Messages.ResourcesView_attributeCpuName, String.valueOf(cpu));
@@ -207,7 +192,8 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
                             /* Ignored */
                         }
                     } else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
-                        // In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
+                        // In SOFT_IRQ state get the SOFT_IRQ that caused the
+                        // interruption
                         int cpu = entry.getId();
 
                         try {
@@ -335,8 +321,9 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
                             } else if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {
                                 attribute = Attributes.SYSTEM_CALL;
                                 /*
-                                 * Remove the "sys_" or "syscall_entry_" or similar from what we
-                                 * draw in the rectangle. This depends on the trace's event layout.
+                                 * Remove the "sys_" or "syscall_entry_" or
+                                 * similar from what we draw in the rectangle.
+                                 * This depends on the trace's event layout.
                                  */
                                 ITmfTrace trace = entry.getTrace();
                                 if (trace instanceof IKernelTrace) {
index 5c5de886a474a3d9bfa61465e01baef7564a928f..603074a41829ddb4c38ded4fd1d6fe2e5a04304d 100644 (file)
@@ -96,7 +96,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
 
     @Override
     protected List<String> getLegendValues() {
-        return Arrays.asList("UNKNOWN", "WAIT_UNKNOWN", "WAIT_BLOCKED", "WAIT_FOR_CPU", "USERMODE", "SYSCALL", "INTERRUPTED");
+        return Arrays.asList("Unknown", "Usermode", "System call", "Interrupt", "Wait blocked", "Wait for CPU", "Wait");
     }
 
     @Override
@@ -107,7 +107,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
                 "Add Bookmark...", "Previous Marker", "Next Marker", SEPARATOR,
                 "Select Previous Process", "Select Next Process", "Zoom In", "Zoom Out", SEPARATOR,
                 "Hide Arrows", "Follow CPU Backward", "Follow CPU Forward",
-                "Go to previous event of the selected thread", "Go to next event of the selected thread" );
+                "Go to previous event of the selected thread", "Go to next event of the selected thread");
     }
 
     /**
@@ -252,7 +252,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
 
         SWTBotView viewBot = getViewBot();
-        SWTBotToolbarButton filterButton = viewBot .toolbarButton("Show View Filters");
+        SWTBotToolbarButton filterButton = viewBot.toolbarButton("Show View Filters");
         filterButton.click();
         fBot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive("Filter"));
         SWTBot bot = fBot.activeShell().bot();
@@ -425,7 +425,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
     }
 
     private void timeGraphIsReadyCondition(@NonNull TmfTimeRange selectionRange) {
-        IWorkbenchPart part = getViewBot() .getViewReference().getPart(false);
+        IWorkbenchPart part = getViewBot().getViewReference().getPart(false);
         fBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, selectionRange, selectionRange.getEndTime()));
     }
 }
index 5eef02fa8d4fdcc6a12ff323998b6cbef866c2a7..fc181b1d6a8d322cf1ce4734719ab4a76e50f243 100644 (file)
@@ -103,7 +103,7 @@ public class ResourcesViewTest extends KernelTimeGraphViewTestBase {
 
     @Override
     protected List<String> getLegendValues() {
-        return Arrays.asList("IDLE", "USERMODE", "SYSCALL", "IRQ", "SOFT_IRQ", "IRQ_ACTIVE", "SOFT_IRQ_RAISED", "SOFT_IRQ_ACTIVE");
+        return Arrays.asList("Idle", "Usermode", "System call", "Interrupt", "Soft Irq", "Soft Irq raised");
     }
 
     @Override
This page took 0.033334 seconds and 5 git commands to generate.