SRADA-784: Save list of pages for trace collected in CLI.
authorMaria Guseva <m.guseva@samsung.com>
Thu, 16 Jun 2016 16:37:18 +0000 (19:37 +0300)
committerMaria Guseva <m.guseva@samsung.com>
Fri, 1 Jul 2016 08:24:04 +0000 (17:24 +0900)
For this CLIAction.getPageNames() has to be implemented properly as it is used
in Project.savePrimitive().

* CLIAction.getPageNames() - implemented.
* CLIAction.getCurrentTargetName() - new private method.
* CLIAction.setPageBySetting() - use new private method.
* UIAction.convertPageIDtoPageName() - removed from interface.
* PageInfoRegistry.convertPageIDtoPageName() - new method,
moved from GUIAction.convertPageIDtoPageName().

Conflicts:
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/GUIAction.java

Change-Id: I43386c26c0981c0b9c4c989dd9c388148bcb32a9

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/CLIAction.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/GUIAction.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/UIAction.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/PageInfoRegistry.java

index ccf285c..4964d15 100644 (file)
@@ -1,5 +1,6 @@
 package org.tizen.dynamicanalyzer.handlers;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -12,6 +13,7 @@ import org.tizen.dynamicanalyzer.setting.SettingDataManager;
 import org.tizen.dynamicanalyzer.setting.TargetData;
 import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
 import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
+import org.tizen.dynamicanalyzer.ui.page.PageInfoRegistry;
 import org.tizen.dynamicanalyzer.util.Logger;
 
 public class CLIAction implements UIAction {
@@ -78,14 +80,8 @@ public class CLIAction implements UIAction {
 
        @Override
        public List<String> getPageNames() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       @Override
-       public List<String> convertPageIDtoPageName(List<String> pageIDs) {
-               // TODO Auto-generated method stub
-               return null;
+               return new ArrayList<String>(
+                               PageInfoRegistry.getPageNamesByTarget(getCurrentTargetName()));
        }
 
        @Override
@@ -109,9 +105,20 @@ public class CLIAction implements UIAction {
 
        @Override
        public void setPageBySetting() {
-               TargetData target = SettingDataManager.INSTANCE.getConnectedTarget();
-               final String targetName = target.getTargetName();
+               final String targetName = getCurrentTargetName();
                DataManagerRegistry.createDataManagersByTarget(targetName);
        }
 
+       /**
+        * Get name(serial) of currently selected target.
+        * @return target name(serial)
+        */
+       private String getCurrentTargetName() {
+               String targetName = null;
+               TargetData target = SettingDataManager.INSTANCE.getConnectedTarget();
+               if (target != null)
+                       targetName = target.getTargetName();
+               return targetName;
+       }
+
 }
index a16c4d8..f7b0354 100644 (file)
@@ -26,7 +26,6 @@
 
 package org.tizen.dynamicanalyzer.handlers;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -38,31 +37,19 @@ import org.eclipse.swt.widgets.Shell;
 import org.tizen.dynamicanalyzer.common.DALogExport;
 import org.tizen.dynamicanalyzer.common.DAResult;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.nl.SummaryLabels;
 import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.setting.SettingConstants;
 import org.tizen.dynamicanalyzer.setting.SettingDataManager;
 import org.tizen.dynamicanalyzer.setting.TargetData;
 import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
-import org.tizen.dynamicanalyzer.ui.file.FilePage;
-import org.tizen.dynamicanalyzer.ui.hierarchy.HierarchyPage;
 import org.tizen.dynamicanalyzer.ui.info.appStartup.AppStartupView;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.kernel.KernelPage;
-import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
-import org.tizen.dynamicanalyzer.ui.network.NetworkPage;
-import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
 import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
-import org.tizen.dynamicanalyzer.ui.summary.leaks.LeakView;
+import org.tizen.dynamicanalyzer.ui.page.PageInfoRegistry;
 import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfilingView;
-import org.tizen.dynamicanalyzer.ui.thread.ThreadPage;
 import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
 import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceView;
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
@@ -211,47 +198,12 @@ public class GUIAction implements UIAction {
        public List<String> getPageNames() {
                BaseView bv = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
                List<String> idList = bv.getMainTab().getViewIDList();
-               List<String> nameList = convertPageIDtoPageName(idList);
+               List<String> nameList = PageInfoRegistry.convertPageIDtoPageName(idList);
 
                return nameList;
        }
 
        @Override
-       public List<String> convertPageIDtoPageName(List<String> pageIDs) {
-               List<String> pageNameList = new ArrayList<String>();
-
-               for (int i = 0; i < pageIDs.size(); i++) {
-                       if (pageIDs.get(i).equals(TimelinePage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_TIME_LINE);
-                       } else if (pageIDs.get(i).equals(ThreadPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_THREAD);
-                       } else if (pageIDs.get(i).equals(NetworkPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_NETWORK);
-                       } else if (pageIDs.get(i).equals(FilePage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_FILE);
-                       } else if (pageIDs.get(i).equals(GLPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_OPENGL);
-                       } else if (pageIDs.get(i).equals(UIPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_UI);
-                       } else if (pageIDs.get(i).equals(KernelPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_KERNEL);
-                       } else if (pageIDs.get(i).equals(InteractivePage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_INTERACTIVE);
-                       } else if (pageIDs.get(i).equals(SummaryPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_SUMMARY);
-                       } else if (pageIDs.get(i).equals(HierarchyPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_HIERARCHY);
-                       } else if (pageIDs.get(i).equals(MemoryPage.pageID)) {
-                               pageNameList.add(SettingConstants.PAGE_NAME_MEMORY);
-                       } else {
-                               Logger.error("Unknown page ID");
-                       }
-               }
-
-               return pageNameList;
-       }
-
-       @Override
        public void setUIElements(Project project) {
                setPages(project.getPageTabList());
                setCharts(project.getTimelineChartList());
index bfdd1c1..2a9f281 100644 (file)
@@ -95,14 +95,6 @@ public interface UIAction {
        List<String> getPageNames();
 
        /**
-        * Convert ids of tab pages to corresponding tab pages names.
-        *
-        * @param pageIDs list of page ids.
-        * @return list of page names.
-        */
-       List<String> convertPageIDtoPageName(List<String> pageIDs);
-
-       /**
         * Set UI elements to be shown to user.
         *
         * @param project {@link Project} where to load list of UI elements from
index 64cf77b..c32a865 100644 (file)
@@ -73,6 +73,7 @@ import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenShotDBTable;
 import org.tizen.dynamicanalyzer.ui.kernel.data.ContextDataDBTable;
 import org.tizen.dynamicanalyzer.ui.network.data.NetworkAPIDBManager;
 import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLAPIDBTableManager;
+import org.tizen.dynamicanalyzer.ui.page.PageInfoRegistry;
 import org.tizen.dynamicanalyzer.ui.thread.db.ThreadDataDBTable;
 import org.tizen.dynamicanalyzer.ui.timeline.UIEventDBTable;
 import org.tizen.dynamicanalyzer.util.CommonUtil;
@@ -991,7 +992,7 @@ public class Project {
                } else {
                        // if there is 'pageTabList' in primitive section
                        // convert it to current name list
-                       List<String> pageNames = UIActionHolder.getUIAction().convertPageIDtoPageName(Arrays.asList(pageTabList));
+                       List<String> pageNames = PageInfoRegistry.convertPageIDtoPageName(Arrays.asList(pageTabList));
                        pageTabList = pageNames.toArray(new String[0]);
                }
 
index b35d472..09bb9cf 100644 (file)
@@ -265,4 +265,44 @@ public class PageInfoRegistry {
                return selectedPageSet;
        }
 
+       /**
+        * Convert ids of tab pages to corresponding tab pages names.
+        *
+        * @param pageIDs list of page ids.
+        * @return list of page names.
+        */
+       public static List<String> convertPageIDtoPageName(List<String> pageIDs) {
+               List<String> pageNameList = new ArrayList<String>();
+
+               // TODO replace if-else with selection from preliminarily prepared map
+               for (int i = 0; i < pageIDs.size(); i++) {
+                       if (pageIDs.get(i).equals(TimelinePage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_TIME_LINE);
+                       } else if (pageIDs.get(i).equals(ThreadPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_THREAD);
+                       } else if (pageIDs.get(i).equals(NetworkPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_NETWORK);
+                       } else if (pageIDs.get(i).equals(FilePage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_FILE);
+                       } else if (pageIDs.get(i).equals(GLPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_OPENGL);
+                       } else if (pageIDs.get(i).equals(UIPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_UI);
+                       } else if (pageIDs.get(i).equals(KernelPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_KERNEL);
+                       } else if (pageIDs.get(i).equals(InteractivePage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_INTERACTIVE);
+                       } else if (pageIDs.get(i).equals(SummaryPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_SUMMARY);
+                       } else if (pageIDs.get(i).equals(HierarchyPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_HIERARCHY);
+                       } else if (pageIDs.get(i).equals(MemoryPage.pageID)) {
+                               pageNameList.add(SettingConstants.PAGE_NAME_MEMORY);
+                       } else {
+                               Logger.error("Unknown page ID");
+                       }
+               }
+               return pageNameList;
+       }
+
 }