SRADA-848: Fixed FlatFeature to work in CLI mode.
authorMaria Guseva <m.guseva@samsung.com>
Wed, 29 Jun 2016 02:36:46 +0000 (05:36 +0300)
committerMaria Guseva <m.guseva@samsung.com>
Thu, 30 Jun 2016 05:53:37 +0000 (14:53 +0900)
Moved all GUI-dependent initialization into separate setter method
setResources(). In case in CLI it does nothing.

Change-Id: I4bf390e4f7379ccc1e9680798f5266cdfd639cbe

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/setting/FlatFeature.java

index b00e81b..f7b643c 100644 (file)
@@ -30,6 +30,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.swt.graphics.Image;
+import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
 import org.tizen.dynamicanalyzer.nl.GLPageLabels;
@@ -42,179 +43,98 @@ public enum FlatFeature {
        CPU_USAGE(101, ConfigureLabels.FEATURE_NAME_CPU_USAGE,
                        ConfigureLabels.FEATURE_DESCRIPTION_CPU_USAGE,  // TODO: Check to use TimelineChartLables description
                        ConfigureLabels.FEATURE_PAGE_CPU_USAGE,
-                       TimelineChartLabels.CPU_CHART_TITLE,                    // TODO: Change symbol, text as new feature list
-                       ImageResources.FEATURE_CPU_FOCUS,
-                       ImageResources.FEATURE_CPU_NORMAL,
-                       ImageResources.FEATURE_CPU_DIM,
-                       ImageResources.FEATURE_CPU_OVER,
-                       ImageResources.FEATURE_CPU_SMALL_SEL),
+                       TimelineChartLabels.CPU_CHART_TITLE),                   // TODO: Change symbol, text as new feature list
+
        CPU_USAGE_PER_CORE(102, ConfigureLabels.FEATURE_NAME_CPU_USAGE_PER_CORE,
                        ConfigureLabels.FEATURE_DESCRIPTION_CPU_USAGE_PER_CORE,
                        ConfigureLabels.FEATURE_PAGE_CPU_USAGE_PER_CORE,
-                       TimelineChartLabels.CPU_CORE_CHART_TITLE,
-                       ImageResources.FEATURE_CPUCORE_FOCUS,
-                       ImageResources.FEATURE_CPUCORE_NORMAL,
-                       ImageResources.FEATURE_CPUCORE_DIM,
-                       ImageResources.FEATURE_CPUCORE_OVER,
-                       ImageResources.FEATURE_CPUCORE_SMALL_SEL),
+                       TimelineChartLabels.CPU_CORE_CHART_TITLE),
+
        CPU_FREQ_PER_CORE(103, ConfigureLabels.FEATURE_NAME_CPU_FREQ_PER_CORE,
                        ConfigureLabels.FEATURE_DESCRIPTION_CPU_FREQ_PER_CORE,
                        ConfigureLabels.FEATURE_PAGE_CPU_FREQ_PER_CORE,
-                       TimelineChartLabels.CPU_FREQUENCY_CHART_TITLE,
-                       ImageResources.FEATURE_CPUFREQ_FOCUS,
-                       ImageResources.FEATURE_CPUFREQ_NORMAL,
-                       ImageResources.FEATURE_CPUFREQ_DIM,
-                       ImageResources.FEATURE_CPUFREQ_OVER,
-                       ImageResources.FEATURE_CPUFREQ_SMALL_SEL),
+                       TimelineChartLabels.CPU_FREQUENCY_CHART_TITLE),
 
        // Group200 Memory
        SYSTEM_MEMORY(201, ConfigureLabels.FEATURE_NAME_FLAT_SYSTEM_MEMORY,
                        ConfigureLabels.FEATURE_DESCRIPTION_FLAT_SYSTEM_MEMORY,
                        ConfigureLabels.FEATURE_PAGE_FLAT_SYSTEM_MEMORY,
-                       TimelineChartLabels.SYSTEM_MEMORY_CHART_TITLE,
-                       ImageResources.FEATURE_MEM_SYSTEM_FOCUS,
-                       ImageResources.FEATURE_MEM_SYSTEM_NORMAL,
-                       ImageResources.FEATURE_MEM_SYSTEM_DIM,
-                       ImageResources.FEATURE_MEM_SYSTEM_OVER,
-                       ImageResources.FEATURE_MEM_SYSTEM_SMALL_SEL),
+                       TimelineChartLabels.SYSTEM_MEMORY_CHART_TITLE),
+
        PROCESS_MEMORY(202, ConfigureLabels.FEATURE_NAME_PROCESS_MEMORY,
                        ConfigureLabels.FEATURE_DESCRIPTION_PROCESS_MEMORY,
                        ConfigureLabels.FEATURE_PAGE_PROCESS_MEMORY,
-                       TimelineChartLabels.PROCESS_MEMORY_CHART_TITLE,
-                       ImageResources.FEATURE_MEM_PROCESS_FOCUS,
-                       ImageResources.FEATURE_MEM_PROCESS_NORMAL,
-                       ImageResources.FEATURE_MEM_PROCESS_DIM,
-                       ImageResources.FEATURE_MEM_PROCESS_OVER,
-                       ImageResources.FEATURE_MEM_PROCESS_SMALL_SEL),
+                       TimelineChartLabels.PROCESS_MEMORY_CHART_TITLE),
+
        MEMORY_ALLOC(203, ConfigureLabels.FEATURE_NAME_MEMORY_ALLOC,
                        ConfigureLabels.FEATURE_DESCRIPTION_MEMORY_ALLOC,
                        ConfigureLabels.FEATURE_PAGE_MEMORY_ALLOC,
-                       TimelineChartLabels.HEAP_CHART_TITLE,
-                       ImageResources.FEATURE_HEAPALLOC_FOCUS,
-                       ImageResources.FEATURE_HEAPALLOC_NORMAL,
-                       ImageResources.FEATURE_HEAPALLOC_DIM,
-                       ImageResources.FEATURE_HEAPALLOC_OVER,
-                       ImageResources.FEATURE_HEAPALLOC_SMALL_SEL),
+                       TimelineChartLabels.HEAP_CHART_TITLE),
 
        // Group300 File system
        DISK_IO(301, ConfigureLabels.FEATURE_NAME_DISK_IO,
                        ConfigureLabels.FEATURE_DESCRIPTION_DISK_IO,
                        ConfigureLabels.FEATURE_PAGE_DISK_IO,
-                       TimelineChartLabels.DISK_IO_CHART_TITLE,
-                       ImageResources.FEATURE_DISKIO_FOCUS,
-                       ImageResources.FEATURE_DISKIO_NORMAL,
-                       ImageResources.FEATURE_DISKIO_DIM,
-                       ImageResources.FEATURE_DISKIO_OVER,
-                       ImageResources.FEATURE_DISKIO_SMALL_SEL),
+                       TimelineChartLabels.DISK_IO_CHART_TITLE),
+
        FILE_ANALYSIS(302, ConfigureLabels.FEATURE_NAME_FILE,
                        ConfigureLabels.FEATURE_DESCRIPTION_FILE,
                        ConfigureLabels.FEATURE_PAGE_FILE,
-                       TimelineChartLabels.FILE_CHART_TITLE,
-                       ImageResources.FEATURE_FILE_FOCUS,
-                       ImageResources.FEATURE_FILE_NORMAL,
-                       ImageResources.FEATURE_FILE_DIM,
-                       ImageResources.FEATURE_FILE_OVER,
-                       ImageResources.FEATURE_FILE_SMALL_SEL),
+                       TimelineChartLabels.FILE_CHART_TITLE),
 
        // Group400 Graphics
        OPENGLES_ANALYSIS(401, ConfigureLabels.FEATURE_NAME_OPENGLES,
                        ConfigureLabels.FEATURE_DESCRIPTION_OPENGLES,
                        ConfigureLabels.FEATURE_PAGE_OPENGLES,
-                       GLPageLabels.GL_CHART_TITLE_FRAME_RATE,
-                       ImageResources.FEATURE_OPENGL_FOCUS,
-                       ImageResources.FEATURE_OPENGL_NORMAL,
-                       ImageResources.FEATURE_OPENGL_DIM,
-                       ImageResources.FEATURE_OPENGL_OVER,
-                       ImageResources.FEATURE_OPENGL_SMALL_SEL),
+                       GLPageLabels.GL_CHART_TITLE_FRAME_RATE),
 
        // Group500 Network
        NETWORK_IO(501, ConfigureLabels.FEATURE_NAME_NETWORK_IO,
                        ConfigureLabels.FEATURE_DESCRIPTION_NETWORK_IO,
                        ConfigureLabels.FEATURE_PAGE_NETWORK_IO,
-                       TimelineChartLabels.NETWORK_IO_CHART_TITLE,
-                       ImageResources.FEATURE_NETWORKIO_FOCUS,
-                       ImageResources.FEATURE_NETWORKIO_NORMAL,
-                       ImageResources.FEATURE_NETWORKIO_DIM,
-                       ImageResources.FEATURE_NETWORKIO_OVER,
-                       ImageResources.FEATURE_NETWORKIO_SMALL_SEL),
+                       TimelineChartLabels.NETWORK_IO_CHART_TITLE),
+
        NETWORK_ANALYSIS(502, ConfigureLabels.FEATURE_NAME_NETWORK,
                        ConfigureLabels.FEATURE_DESCRIPTION_NETWORK,
                        ConfigureLabels.FEATURE_PAGE_NETWORK,
-                       TimelineChartLabels.NETWORK_IO_CHART_TITLE,
-                       ImageResources.FEATURE_NETWORKTRAFFIC_FOCUS,
-                       ImageResources.FEATURE_NETWORKTRAFFIC_NORMAL,
-                       ImageResources.FEATURE_NETWORKTRAFFIC_DIM,
-                       ImageResources.FEATURE_NETWORKTRAFFIC_OVER,
-                       ImageResources.FEATURE_NETWORKTRAFFIC_SMALL_SEL),
+                       TimelineChartLabels.NETWORK_IO_CHART_TITLE),
 
        // Group600 UI
        UI_EVENT(601, ConfigureLabels.FEATURE_NAME_UI_EVENT,
                        ConfigureLabels.FEATURE_DESCRIPTION_UI_EVENT,
                        ConfigureLabels.FEATURE_PAGE_UI_EVENT,
-                       TimelineChartLabels.UI_EVENT_CHART_TITLE,
-                       ImageResources.FEATURE_UIEVENT_FOCUS,
-                       ImageResources.FEATURE_UIEVENT_NORMAL,
-                       ImageResources.FEATURE_UIEVENT_DIM,
-                       ImageResources.FEATURE_UIEVENT_OVER,
-                       ImageResources.FEATURE_UIEVENT_SMALL_SEL),
+                       TimelineChartLabels.UI_EVENT_CHART_TITLE),
+
        SCREENSHOT(602, ConfigureLabels.FEATURE_NAME_SCREENSHOT,
                        ConfigureLabels.FEATURE_DESCRIPTION_SCREENSHOT,
                        ConfigureLabels.FEATURE_PAGE_SCREENSHOT,
-                       TimelineChartLabels.SCREENSHOT_CHART_TITLE,
-                       ImageResources.FEATURE_SNAPSHOT_FOCUS,
-                       ImageResources.FEATURE_SNAPSHOT_NORMAL,
-                       ImageResources.FEATURE_SNAPSHOT_DIM,
-                       ImageResources.FEATURE_SNAPSHOT_OVER,
-                       ImageResources.FEATURE_SNAPSHOT_SMALL_SEL),
+                       TimelineChartLabels.SCREENSHOT_CHART_TITLE),
+
        UI_HIERARCHY_ANALYSIS(603, ConfigureLabels.FEATURE_NAME_UI_HIERARCHY,
                        ConfigureLabels.FEATURE_DESCRIPTION_UI_HIERARCHY,
                        ConfigureLabels.FEATURE_PAGE_UI_HIERARCHY,
-                       "UI Hierarchy", // TODO: Replace constant
-                       ImageResources.FEATURE_UIHV_FOCUS,
-                       ImageResources.FEATURE_UIHV_NORMAL,
-                       ImageResources.FEATURE_UIHV_DIM,
-                       ImageResources.FEATURE_UIHV_OVER,
-                       ImageResources.FEATURE_UIHV_SMALL_SEL),
+                       "UI Hierarchy"),        // TODO: Replace constant
 
        // Group700 Synchronization
        THREAD_ANALYSIS(701, ConfigureLabels.FEATURE_NAME_THREAD,
                        ConfigureLabels.FEATURE_DESCRIPTION_THREAD,
                        ConfigureLabels.FEATURE_PAGE_THREAD,
-                       ThreadPageLabels.THREAD_CHART_THREAD,   
-                       ImageResources.FEATURE_THREADACTIVITY_FOCUS,
-                       ImageResources.FEATURE_THREADACTIVITY_NORMAL,
-                       ImageResources.FEATURE_THREADACTIVITY_DIM,
-                       ImageResources.FEATURE_THREADACTIVITY_OVER,
-                       ImageResources.FEATURE_THREADACTIVITY_SMALL_SEL),
+                       ThreadPageLabels.THREAD_CHART_THREAD),
+
        SYNC_ANALYSIS(702, ConfigureLabels.FEATURE_NAME_SYNC,
                        ConfigureLabels.FEATURE_DESCRIPTION_SYNC,
                        ConfigureLabels.FEATURE_PAGE_SYNC,
-                       ThreadPageLabels.THREAD_CHART_SYNC,
-                       ImageResources.FEATURE_SYNC_FOCUS,
-                       ImageResources.FEATURE_SYNC_NORMAL,
-                       ImageResources.FEATURE_SYNC_DIM,
-                       ImageResources.FEATURE_SYNC_OVER,
-                       ImageResources.FEATURE_SYNC_SMALL_SEL),
+                       ThreadPageLabels.THREAD_CHART_SYNC),
 
        // Group800 Energy
        PERIPHERAL_STATUS(801, ConfigureLabels.FEATURE_NAME_PERIPHERAL_STATUS,
                        ConfigureLabels.FEATURE_DESCRIPTION_PERIPHERAL_STATUS,
                        ConfigureLabels.FEATURE_PAGE_PERIPHERAL_STATUS,
-                       TimelineChartLabels.DEVICE_CHART_TITLE, 
-                       ImageResources.FEATURE_DEVICE_FOCUS,
-                       ImageResources.FEATURE_DEVICE_NORMAL,
-                       ImageResources.FEATURE_DEVICE_DIM,
-                       ImageResources.FEATURE_DEVICE_OVER,
-                       ImageResources.FEATURE_DEVICE_SMALL_SEL),
+                       TimelineChartLabels.DEVICE_CHART_TITLE),
        POWER_ESTIMATION(802, ConfigureLabels.FEATURE_NAME_POWER_ESTIMATION,
                        ConfigureLabels.FEATURE_DESCRIPTION_POWER_ESTIMATION,
                        ConfigureLabels.FEATURE_PAGE_POWER_ESTIMATION,
-                       TimelineChartLabels.ENERGY_CHART_TITLE,
-                       ImageResources.FEATURE_CURRENT_FOCUS,
-                       ImageResources.FEATURE_CURRENT_NORMAL,
-                       ImageResources.FEATURE_CURRENT_DIM,
-                       ImageResources.FEATURE_CURRENT_OVER,
-                       ImageResources.FEATURE_CURRENT_SMALL_SEL);
+                       TimelineChartLabels.ENERGY_CHART_TITLE);
 
        private static final Map<Integer, FlatFeature> featureByIndex = new HashMap<Integer, FlatFeature>();
        private static final Map<String, FlatFeature> featureByName = new HashMap<String, FlatFeature>();
@@ -232,6 +152,8 @@ public enum FlatFeature {
        private int overheadRanking = 0;
 
        static {
+               setResources();
+
                for (FlatFeature feature : FlatFeature.values()) {
                        int index = feature.getIndex();
                        String name = feature.getName();
@@ -240,13 +162,128 @@ public enum FlatFeature {
                }
        }
 
-       private FlatFeature(int index, String name, String description, String page, String chart,
-                                               Image focusImg, Image normalImg, Image dimImg, Image overImg, Image smallImg) {
+       private static void setResources() {
+               //In case of CLI do nothing
+               if (Global.isCLIMode()) return;
+               CPU_USAGE.setResources(
+                               ImageResources.FEATURE_CPU_FOCUS,
+                               ImageResources.FEATURE_CPU_NORMAL,
+                               ImageResources.FEATURE_CPU_DIM,
+                               ImageResources.FEATURE_CPU_OVER,
+                               ImageResources.FEATURE_CPU_SMALL_SEL);
+               CPU_USAGE_PER_CORE.setResources(
+                               ImageResources.FEATURE_CPUCORE_FOCUS,
+                               ImageResources.FEATURE_CPUCORE_NORMAL,
+                               ImageResources.FEATURE_CPUCORE_DIM,
+                               ImageResources.FEATURE_CPUCORE_OVER,
+                               ImageResources.FEATURE_CPUCORE_SMALL_SEL);
+               CPU_FREQ_PER_CORE.setResources(
+                               ImageResources.FEATURE_CPUFREQ_FOCUS,
+                               ImageResources.FEATURE_CPUFREQ_NORMAL,
+                               ImageResources.FEATURE_CPUFREQ_DIM,
+                               ImageResources.FEATURE_CPUFREQ_OVER,
+                               ImageResources.FEATURE_CPUFREQ_SMALL_SEL);
+               SYSTEM_MEMORY.setResources(
+                               ImageResources.FEATURE_MEM_SYSTEM_FOCUS,
+                               ImageResources.FEATURE_MEM_SYSTEM_NORMAL,
+                               ImageResources.FEATURE_MEM_SYSTEM_DIM,
+                               ImageResources.FEATURE_MEM_SYSTEM_OVER,
+                               ImageResources.FEATURE_MEM_SYSTEM_SMALL_SEL);
+               PROCESS_MEMORY.setResources(
+                               ImageResources.FEATURE_MEM_PROCESS_FOCUS,
+                               ImageResources.FEATURE_MEM_PROCESS_NORMAL,
+                               ImageResources.FEATURE_MEM_PROCESS_DIM,
+                               ImageResources.FEATURE_MEM_PROCESS_OVER,
+                               ImageResources.FEATURE_MEM_PROCESS_SMALL_SEL);
+               MEMORY_ALLOC.setResources(
+                               ImageResources.FEATURE_HEAPALLOC_FOCUS,
+                               ImageResources.FEATURE_HEAPALLOC_NORMAL,
+                               ImageResources.FEATURE_HEAPALLOC_DIM,
+                               ImageResources.FEATURE_HEAPALLOC_OVER,
+                               ImageResources.FEATURE_HEAPALLOC_SMALL_SEL);
+               DISK_IO.setResources(
+                               ImageResources.FEATURE_DISKIO_FOCUS,
+                               ImageResources.FEATURE_DISKIO_NORMAL,
+                               ImageResources.FEATURE_DISKIO_DIM,
+                               ImageResources.FEATURE_DISKIO_OVER,
+                               ImageResources.FEATURE_DISKIO_SMALL_SEL);
+               FILE_ANALYSIS.setResources(
+                               ImageResources.FEATURE_FILE_FOCUS,
+                               ImageResources.FEATURE_FILE_NORMAL,
+                               ImageResources.FEATURE_FILE_DIM,
+                               ImageResources.FEATURE_FILE_OVER,
+                               ImageResources.FEATURE_FILE_SMALL_SEL);
+               OPENGLES_ANALYSIS.setResources(
+                               ImageResources.FEATURE_OPENGL_FOCUS,
+                               ImageResources.FEATURE_OPENGL_NORMAL,
+                               ImageResources.FEATURE_OPENGL_DIM,
+                               ImageResources.FEATURE_OPENGL_OVER,
+                               ImageResources.FEATURE_OPENGL_SMALL_SEL);
+               NETWORK_IO.setResources(
+                               ImageResources.FEATURE_NETWORKIO_FOCUS,
+                               ImageResources.FEATURE_NETWORKIO_NORMAL,
+                               ImageResources.FEATURE_NETWORKIO_DIM,
+                               ImageResources.FEATURE_NETWORKIO_OVER,
+                               ImageResources.FEATURE_NETWORKIO_SMALL_SEL);
+               NETWORK_ANALYSIS.setResources(
+                               ImageResources.FEATURE_NETWORKTRAFFIC_FOCUS,
+                               ImageResources.FEATURE_NETWORKTRAFFIC_NORMAL,
+                               ImageResources.FEATURE_NETWORKTRAFFIC_DIM,
+                               ImageResources.FEATURE_NETWORKTRAFFIC_OVER,
+                               ImageResources.FEATURE_NETWORKTRAFFIC_SMALL_SEL);
+               UI_EVENT.setResources(
+                               ImageResources.FEATURE_UIEVENT_FOCUS,
+                               ImageResources.FEATURE_UIEVENT_NORMAL,
+                               ImageResources.FEATURE_UIEVENT_DIM,
+                               ImageResources.FEATURE_UIEVENT_OVER,
+                               ImageResources.FEATURE_UIEVENT_SMALL_SEL);
+               SCREENSHOT.setResources(
+                               ImageResources.FEATURE_SNAPSHOT_FOCUS,
+                               ImageResources.FEATURE_SNAPSHOT_NORMAL,
+                               ImageResources.FEATURE_SNAPSHOT_DIM,
+                               ImageResources.FEATURE_SNAPSHOT_OVER,
+                               ImageResources.FEATURE_SNAPSHOT_SMALL_SEL);
+               UI_HIERARCHY_ANALYSIS.setResources(
+                               ImageResources.FEATURE_UIHV_FOCUS,
+                               ImageResources.FEATURE_UIHV_NORMAL,
+                               ImageResources.FEATURE_UIHV_DIM,
+                               ImageResources.FEATURE_UIHV_OVER,
+                               ImageResources.FEATURE_UIHV_SMALL_SEL);
+               THREAD_ANALYSIS.setResources(
+                               ImageResources.FEATURE_THREADACTIVITY_FOCUS,
+                               ImageResources.FEATURE_THREADACTIVITY_NORMAL,
+                               ImageResources.FEATURE_THREADACTIVITY_DIM,
+                               ImageResources.FEATURE_THREADACTIVITY_OVER,
+                               ImageResources.FEATURE_THREADACTIVITY_SMALL_SEL);
+               SYNC_ANALYSIS.setResources(
+                               ImageResources.FEATURE_SYNC_FOCUS,
+                               ImageResources.FEATURE_SYNC_NORMAL,
+                               ImageResources.FEATURE_SYNC_DIM,
+                               ImageResources.FEATURE_SYNC_OVER,
+                               ImageResources.FEATURE_SYNC_SMALL_SEL);
+               PERIPHERAL_STATUS.setResources(
+                               ImageResources.FEATURE_DEVICE_FOCUS,
+                               ImageResources.FEATURE_DEVICE_NORMAL,
+                               ImageResources.FEATURE_DEVICE_DIM,
+                               ImageResources.FEATURE_DEVICE_OVER,
+                               ImageResources.FEATURE_DEVICE_SMALL_SEL);
+               POWER_ESTIMATION.setResources(
+                               ImageResources.FEATURE_CURRENT_FOCUS,
+                               ImageResources.FEATURE_CURRENT_NORMAL,
+                               ImageResources.FEATURE_CURRENT_DIM,
+                               ImageResources.FEATURE_CURRENT_OVER,
+                               ImageResources.FEATURE_CURRENT_SMALL_SEL);
+       }
+
+       private FlatFeature(int index, String name, String description, String page, String chart) {
                this.index = index;
                this.name = name;
                this.description = description;
                this.page = page;
                this.chart = chart;
+       }
+
+       private void setResources(Image focusImg, Image normalImg, Image dimImg, Image overImg, Image smallImg) {
                this.focusImg = focusImg;
                this.normalImg = normalImg;
                this.dimImg = dimImg;