- fTimeGraphViewer.setTimeGraphProvider(new TimeGraphPresentationProvider() {\r
- private static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$\r
- private static final String IDLE = "IDLE"; //$NON-NLS-1$\r
- private static final String BUSY = "BUSY"; //$NON-NLS-1$\r
- private static final String INTERRUPTED = "INTERRUPTED"; //$NON-NLS-1$\r
- private static final String RAISED = "RAISED"; //$NON-NLS-1$\r
- private static final String ACTIVE = "ACTIVE"; //$NON-NLS-1$\r
-\r
- @Override \r
- public String getStateTypeName() {\r
- return Messages.ResourcesView_stateTypeName;\r
- }\r
-\r
- @Override\r
- public String getEventName(ITimeEvent event) {\r
- if (event instanceof ResourcesEvent) {\r
- ResourcesEvent resourcesEvent = (ResourcesEvent) event;\r
- if (resourcesEvent.getType() == Type.CPU) {\r
- int currentThread = resourcesEvent.getValue();\r
- if (currentThread == 0) {\r
- return IDLE;\r
- } else {\r
- return BUSY;\r
- }\r
- } else if (resourcesEvent.getType() == Type.IRQ || resourcesEvent.getType() == Type.SOFT_IRQ) {\r
- int cpu = resourcesEvent.getValue();\r
- if (cpu == Attributes.SOFT_IRQ_RAISED) {\r
- return RAISED;\r
- }\r
- return ACTIVE;\r
- } else {\r
- return null;\r
- }\r
- }\r
- return UNKNOWN;\r
- }\r
-\r
- @Override\r
- public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
- \r
- Map<String, String> retMap = new HashMap<String, String>();\r
- if (event instanceof ResourcesEvent) {\r
-\r
- ResourcesEvent resourcesEvent = (ResourcesEvent) event;\r
-\r
- if (resourcesEvent.getType().equals(Type.IRQ) || resourcesEvent.getType().equals(Type.SOFT_IRQ)) {\r
- int cpu = resourcesEvent.getValue();\r
- if (cpu >= 0) {\r
- retMap.put(Messages.ResourcesView_attributeCpuName, String.valueOf(cpu));\r
- }\r
- }\r
- }\r
-\r
- return retMap;\r
- }\r
-\r
- @Override\r
- public StateItem[] getStateTable() {\r
- return new StateItem[] {\r
- new StateItem(new RGB(100, 100, 100), UNKNOWN),\r
- new StateItem(new RGB(200, 200, 200), IDLE),\r
- new StateItem(new RGB(0, 200, 0), BUSY),\r
- new StateItem(new RGB(200, 100, 100), INTERRUPTED),\r
- new StateItem(new RGB(200, 200, 0), RAISED),\r
- new StateItem(new RGB(200, 150, 100), ACTIVE)\r
- };\r
- }\r
-\r
- @Override\r
- public int getStateTableIndex(ITimeEvent event) {\r
- if (event instanceof ResourcesEvent) {\r
- ResourcesEvent resourcesEvent = (ResourcesEvent) event;\r
- if (resourcesEvent.getType() == Type.CPU) {\r
- int currentThread = resourcesEvent.getValue();\r
- if (currentThread == 0) {\r
- return 1; // IDLE\r
- } else {\r
- return 2; // BUSY\r
- }\r
- } else if (resourcesEvent.getType() == Type.IRQ || resourcesEvent.getType() == Type.SOFT_IRQ) {\r
- int cpu = resourcesEvent.getValue();\r
- if (cpu == Attributes.SOFT_IRQ_RAISED) {\r
- return 4; // RAISED\r
- }\r
- return 5; // ACTIVE\r
- } else {\r
- return -1; // NULL\r
- }\r
- }\r
- return 0; // UNKNOWN\r
- }\r
- });\r