SPTSDKUX-1919: Implemented new Screenshot preferences selection logic
authorDmitriy Nikiforov <d.nikiforov@partner.samsung.com>
Tue, 13 Sep 2016 10:08:33 +0000 (13:08 +0300)
committerMaria Guseva <m.guseva@samsung.com>
Tue, 20 Sep 2016 14:59:51 +0000 (17:59 +0300)
Added new FlatPreference - SCREENSHOT_ON_SCENE_TRANSITION, and it replaced
FlatFeature.SCREENSHOT in protocol configurations.

Now both screenshots on scene transition and periodical screenshots can be
enabled at the same time, but only if Screenshots feature is enabled. If
Screenshots feature is disabled then both preferences are also disabled. If
feature is enabled than at least one of screenshot prefences is enabled
(on attempt to disable both switches one of them toggles back on).

Refactoring changes:
  * Moved duplicated code to:
    - TimelineChartView.showScreenshotChart()
    - SettingDataManager.enableScreenshotFeature()
    - AnalyzerUtil.captureScreenshot()
  * Added PreferencesDialog.disableConfiguration()

Other changes:
  * All preferences will be disabled during tracing as they have no effect
    at that moment.
  * Analysis > Screenshot menu item is removed as it was very
    counter-intuitive.
  * 'Set as default' button is renamed to 'Reset to default'

Conflicts:
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/setting/TargetData.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/BaseView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java

Change-Id: I35f228fa467167ae269a454b7a8cb5386637eaaa

16 files changed:
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/control/StartTraceManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/PreferencesDialogLabels.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/PreferencesDialogLabels.properties
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/protocol/p30/ProtocolConfig30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/protocol/p30_uihv/ProtocolConfig30_UIHV.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/protocol/p40/ProtocolConfig40.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/protocol/p41/ProtocolConfig41.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/setting/FlatPreferences.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/setting/SettingDataManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/setting/TargetData.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/BaseView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/MenuBar.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/Toolbar.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/PreferencesDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java

index ae344c9..d242002 100755 (executable)
@@ -45,6 +45,7 @@ import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 import org.tizen.dynamicanalyzer.nl.MenuBarLabels;
 import org.tizen.dynamicanalyzer.project.Project;
+import org.tizen.dynamicanalyzer.setting.FlatFeature;
 import org.tizen.dynamicanalyzer.setting.FlatPreferences;
 import org.tizen.dynamicanalyzer.setting.SettingDataManager;
 import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
@@ -288,7 +289,8 @@ public class StartTraceManager implements Runnable {
                        // start screenshot timer
                        FlatPreferences feature = FlatPreferences.SCREENSHOT_PERIODICALLY;                      
                        int value = SettingDataManager.INSTANCE.getOptionsPreferencesValue(feature);
-                       if (value > 0) {
+                       if (SettingDataManager.INSTANCE.getSelectedFlatFeatureSet().contains(FlatFeature.SCREENSHOT)
+                                       && value > 0) {
                                ScreenshotTimer.start(value);
                        }
                        setStageComplete(STAGE.CREATE_SCREENSHOT_TIMER);
index ce8e890..89ba285 100644 (file)
@@ -20,7 +20,7 @@ public class PreferencesDialogLabels extends NLS {
        public static String ON_SCENE_TRANSITION;
        public static String PERIODICALLY;
        
-       public static String SET_AS_DEFAULT;
+       public static String RESET_TO_DEFAULT;
        public static String TIME_UNIT_MS;
        public static String TIME_UNIT_S;
        
index ab8c875..7c2a1d8 100644 (file)
@@ -130,7 +130,6 @@ public enum ProtocolConfig30 implements IProtocolConfig {
                tempMap.put(FlatFeature.NETWORK_IO, new ProtocolConfig30[] { SYSTEM_NETWORK });
                tempMap.put(FlatFeature.NETWORK_ANALYSIS, new ProtocolConfig30[] { NETWORK_API_PROBE });
                tempMap.put(FlatFeature.UI_EVENT, new ProtocolConfig30[] { USER_EVENT });
-               tempMap.put(FlatFeature.SCREENSHOT, new ProtocolConfig30[] { SCREENSHOT });
                //tempMap.put(FlatFeature.UI_HIERARCHY_ANALYSIS, new ProtocolConfig30[] { UIHV });
                tempMap.put(FlatFeature.THREAD_ANALYSIS, new ProtocolConfig30[] { THREAD_API_PROBE, SYSTEM_THREAD_LOAD });
                tempMap.put(FlatFeature.PERIPHERAL_STATUS, new ProtocolConfig30[] { SYSTEM_DEVICE });
@@ -147,6 +146,7 @@ public enum ProtocolConfig30 implements IProtocolConfig {
                tempMap.put(FlatPreferences.FUNCTION_PROFILING, new ProtocolConfig30[] { FUNCTION_PROFILING });
                tempMap.put(FlatPreferences.SYSTEM_ALL_PROCESSES, new ProtocolConfig30[] { SYSTEM_PROCESSES_LOAD });
                tempMap.put(FlatPreferences.PROCESS_MEMORY, new ProtocolConfig30[] { SYSTEM_PROCESS });
+               tempMap.put(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, new ProtocolConfig30[] { SCREENSHOT });
 
                preferencesProtocolMap = Collections.unmodifiableMap(tempMap);
        }
index 6f310d1..d09527a 100644 (file)
@@ -134,7 +134,6 @@ public enum ProtocolConfig30_UIHV implements IProtocolConfig {
                tempMap.put(FlatFeature.NETWORK_IO, new ProtocolConfig30_UIHV[] { SYSTEM_NETWORK });
                tempMap.put(FlatFeature.NETWORK_ANALYSIS, new ProtocolConfig30_UIHV[] { NETWORK_API_PROBE });
                tempMap.put(FlatFeature.UI_EVENT, new ProtocolConfig30_UIHV[] { USER_EVENT });
-               tempMap.put(FlatFeature.SCREENSHOT, new ProtocolConfig30_UIHV[] { SCREENSHOT });
                tempMap.put(FlatFeature.UI_HIERARCHY_ANALYSIS, new ProtocolConfig30_UIHV[] { UI_HIERARCHY });
                tempMap.put(FlatFeature.THREAD_ANALYSIS, new ProtocolConfig30_UIHV[] { THREAD_API_PROBE, SYSTEM_THREAD_LOAD });
                tempMap.put(FlatFeature.PERIPHERAL_STATUS, new ProtocolConfig30_UIHV[] { SYSTEM_DEVICE });
@@ -151,6 +150,7 @@ public enum ProtocolConfig30_UIHV implements IProtocolConfig {
                tempMap.put(FlatPreferences.FUNCTION_PROFILING, new ProtocolConfig30_UIHV[] { FUNCTION_PROFILING });
                tempMap.put(FlatPreferences.SYSTEM_ALL_PROCESSES, new ProtocolConfig30_UIHV[] { SYSTEM_PROCESSES_LOAD });
                tempMap.put(FlatPreferences.PROCESS_MEMORY, new ProtocolConfig30_UIHV[] { SYSTEM_PROCESS });
+               tempMap.put(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, new ProtocolConfig30_UIHV[] { SCREENSHOT });
 
                preferencesProtocolMap = Collections.unmodifiableMap(tempMap);
        }
index 125602b..408a0a2 100644 (file)
@@ -137,6 +137,7 @@ public enum ProtocolConfig40 implements IProtocolConfig {
                                                                                                                                WEBAPP_STARTUP});
                tempMap.put(FlatPreferences.SYSTEM_ALL_PROCESSES, new ProtocolConfig40[] { SYSTEM_PROCESSES_LOAD });
                tempMap.put(FlatPreferences.PROCESS_MEMORY, new ProtocolConfig40[] { SYSTEM_PROCESS });
+               tempMap.put(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, new ProtocolConfig40[] { SCREENSHOT });
 
                preferencesProtocolMap = Collections.unmodifiableMap(tempMap);
        }
@@ -156,7 +157,6 @@ public enum ProtocolConfig40 implements IProtocolConfig {
                tempMap.put(FlatFeature.NETWORK_IO, new ProtocolConfig40[] { SYSTEM_NETWORK });
                tempMap.put(FlatFeature.NETWORK_ANALYSIS, new ProtocolConfig40[] { NETWORK_API_PROBE });
                tempMap.put(FlatFeature.UI_EVENT, new ProtocolConfig40[] { USER_EVENT });
-               tempMap.put(FlatFeature.SCREENSHOT, new ProtocolConfig40[] { SCREENSHOT });
                //tempMap.put(FlatFeature.UI_HIERARCHY_ANALYSIS, new ProtocolConfig40[] { UIHV });
                tempMap.put(FlatFeature.THREAD_ANALYSIS, new ProtocolConfig40[] { THREAD_API_PROBE, SYSTEM_THREAD_LOAD });
                tempMap.put(FlatFeature.PERIPHERAL_STATUS, new ProtocolConfig40[] { SYSTEM_DEVICE });
index 8669e73..5d82f33 100644 (file)
@@ -141,6 +141,7 @@ public enum ProtocolConfig41 implements IProtocolConfig {
                                                                                                                                WEBAPP_STARTUP});
                tempMap.put(FlatPreferences.SYSTEM_ALL_PROCESSES, new ProtocolConfig41[] { SYSTEM_PROCESSES_LOAD });
                tempMap.put(FlatPreferences.PROCESS_MEMORY, new ProtocolConfig41[] { SYSTEM_PROCESS });
+               tempMap.put(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, new ProtocolConfig41[] { SCREENSHOT });
 
                preferencesProtocolMap = Collections.unmodifiableMap(tempMap);
        }
@@ -160,7 +161,6 @@ public enum ProtocolConfig41 implements IProtocolConfig {
                tempMap.put(FlatFeature.NETWORK_IO, new ProtocolConfig41[] { SYSTEM_NETWORK });
                tempMap.put(FlatFeature.NETWORK_ANALYSIS, new ProtocolConfig41[] { NETWORK_API_PROBE });
                tempMap.put(FlatFeature.UI_EVENT, new ProtocolConfig41[] { USER_EVENT });
-               tempMap.put(FlatFeature.SCREENSHOT, new ProtocolConfig41[] { SCREENSHOT });
                tempMap.put(FlatFeature.UI_HIERARCHY_ANALYSIS, new ProtocolConfig41[] { UI_HIERARCHY });
                tempMap.put(FlatFeature.THREAD_ANALYSIS, new ProtocolConfig41[] { THREAD_API_PROBE, SYSTEM_THREAD_LOAD });
                tempMap.put(FlatFeature.PERIPHERAL_STATUS, new ProtocolConfig41[] { SYSTEM_DEVICE });
index bc12e72..5f0ff38 100644 (file)
@@ -12,6 +12,7 @@ public enum FlatPreferences {
        RECORDING(2004, 1, PreferencesDialogLabels.RECORDING),
        AUTO_STOP(2005, 0, PreferencesDialogLabels.AUTOSTOP_WHILE_REPLAYING),
        SCREENSHOT_PERIODICALLY(2006, 0, PreferencesDialogLabels.PERIODICALLY),
+       SCREENSHOT_ON_SCENE_TRANSITION(2007, 1, PreferencesDialogLabels.ON_SCENE_TRANSITION),
        FUNCTION_PROFILING(3001, 1, PreferencesDialogLabels.FUNCTION_PROFILING),
        APP_STARTUP(3002, 1, PreferencesDialogLabels.APP_STARTUP),
        WEB_FUNCTION_PROFILING(3003, 1, PreferencesDialogLabels.WEB_FUNCTION_PROFILING),
index 9f2606f..95cfc06 100644 (file)
@@ -47,12 +47,16 @@ import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.common.path.PathManager;
 import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
 import org.tizen.dynamicanalyzer.protocol.DebugLog;
 import org.tizen.dynamicanalyzer.protocol.IProtocolConfig;
 import org.tizen.dynamicanalyzer.protocol.Protocol;
 import org.tizen.dynamicanalyzer.protocol.UnknownProtocolException;
+import org.tizen.dynamicanalyzer.ui.page.BaseView;
+import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
 import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
 
 public enum SettingDataManager {
        INSTANCE;
@@ -963,4 +967,25 @@ public enum SettingDataManager {
                this.isNewSetting = isNewSetting;
        }
 
+       /**
+        * Enables Screenshot feature and adds corresponding chart on Timeline page.
+        *
+        * @param enable whether Screenshot feature should be enabled
+        */
+       public void enableScreenshotFeature(boolean enable) {
+               TargetData target = getConnectedTarget();
+               Set<String> targetChartList = getSelectedChartSet(target.getTargetName());
+               if (!targetChartList.contains(TimelineChartLabels.SCREENSHOT_CHART_TITLE)) {
+                       BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
+                       if (baseView.getTopComposite() instanceof TimelinePage) {
+                               TimelinePage timelinePage = (TimelinePage) baseView.getTopComposite();
+                               timelinePage.getTimelineChartView().showScreenshotChart(enable);
+
+                               if (enable)
+                                       target.addSelectedFlatFeature(FlatFeature.SCREENSHOT.getName());
+                               else
+                                       target.removeSelectedFeature(FlatFeature.SCREENSHOT.getName());
+                       }
+               }
+       }
 }
index a44ba13..b40100b 100644 (file)
@@ -116,6 +116,8 @@ public class TargetData {
                FlatFeature feature = FlatFeature.getFlatFeature(featureName);
                if (!this.selectedFlatFeatureList.contains(feature)) {
                        this.selectedFlatFeatureList.add(feature);
+               if (feature == FlatFeature.SCREENSHOT)
+                       SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, 1);
                }
        }
 
index 8be3dc9..1bd321e 100644 (file)
@@ -46,46 +46,23 @@ import org.eclipse.ui.part.ViewPart;
 import org.tizen.dynamicanalyzer.annotation.UIMethod;
 import org.tizen.dynamicanalyzer.callback.ExecutionCallbackManager;
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.DAResult;
 import org.tizen.dynamicanalyzer.common.DAResult.ErrorCode;
 import org.tizen.dynamicanalyzer.common.DAState;
 import org.tizen.dynamicanalyzer.common.PreWindowShellCloseCallback;
 import org.tizen.dynamicanalyzer.common.path.PathManager;
-import org.tizen.dynamicanalyzer.communicator.DACommunicator;
 import org.tizen.dynamicanalyzer.communicator.DeviceManager;
 import org.tizen.dynamicanalyzer.communicator.IDECommunicator;
-import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
 import org.tizen.dynamicanalyzer.control.SideWorker;
 import org.tizen.dynamicanalyzer.handlers.CommandAction;
-import org.tizen.dynamicanalyzer.handlers.CommonAction;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
-import org.tizen.dynamicanalyzer.setting.FlatFeature;
-import org.tizen.dynamicanalyzer.setting.SettingConstants;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.setting.TargetData;
 import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
-import org.tizen.dynamicanalyzer.ui.file.FilePage;
-import org.tizen.dynamicanalyzer.ui.hierarchy.HierarchyPage;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-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.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
-import org.tizen.dynamicanalyzer.ui.thread.ThreadPage;
-import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
 import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.ui.toolbar.setting.FlatFeatureDialog;
 import org.tizen.dynamicanalyzer.ui.toolbar.setting.PreferencesDialog;
 import org.tizen.dynamicanalyzer.ui.toolbar.setting.TargetDialog;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.ui.widgets.SearchDialog;
 import org.tizen.dynamicanalyzer.util.CommonUtil;
 import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
@@ -94,7 +71,6 @@ import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
 import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAPageComposite;
 import org.tizen.dynamicanalyzer.widgets.da.view.DATabComposite;
-import org.tizen.dynamicanalyzer.widgets.scale.DAScale;
 import org.tizen.dynamicanalyzer.workbench.LayoutManager;
 
 public class BaseView extends ViewPart {
@@ -162,29 +138,7 @@ public class BaseView extends ViewPart {
                                        }
                                        MenuBar.getInstance().getViewDetail().notifyListeners(SWT.Selection, new Event());
                                } else if(e.keyCode == SWT.F9) {
-                                       if(DAState.isRunning()) {
-                                               TargetData target = SettingDataManager.INSTANCE.getConnectedTarget();
-                                               Set<String> targetChartList = SettingDataManager.INSTANCE.getSelectedChartSet(target
-                                                               .getTargetName());
-                                               if(!targetChartList.contains(TimelineChartLabels.SCREENSHOT_CHART_TITLE)) {
-                                                       BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
-                                                       if(baseView.getTopComposite() instanceof TimelinePage) {
-                                                               TimelinePage timelinePage = (TimelinePage)baseView.getTopComposite();
-                                                               timelinePage.getTimelineChartView().addScreenshotChart();
-                                                               target.addSelectedFlatFeature(FlatFeature.SCREENSHOT.getName());
-                                                       }
-                                               }
-                                       }
-                                       
-                                       try {
-                                               if (!DACommunicator.captureScreenshot().isSuccess()) {
-                                                       Logger.error("Failed to capture screenshot");
-                                               }
-                                       } catch (InterruptedException ex) {
-                                               Logger.warning("Interrupted during send screenshot message");
-                                       } catch (UnsupportedProtocolException ex) {
-                                               Logger.warning("Message to capture screenshot is not supported by communicator");
-                                       }
+                                       AnalyzerUtil.captureScreenshot();
                                } else if(e.keyCode == SWT.F5) {
                                        if(DAState.isStartable() && Toolbar.INSTANCE.getStartButton().getState() == DACustomButton.STATE_NORMAL) { //start trace
                                                Toolbar.INSTANCE.clearMarkerTimeList();
index acd8dbb..09755ce 100644 (file)
@@ -40,8 +40,6 @@ import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.DAState;
 import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.common.path.PathManager;
-import org.tizen.dynamicanalyzer.communicator.DACommunicator;
-import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
 import org.tizen.dynamicanalyzer.handlers.CommandAction;
 import org.tizen.dynamicanalyzer.handlers.CommonAction;
 import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
@@ -159,12 +157,7 @@ public class MenuBar {
 
                MenuItem analyzeTarget = new MenuItem(analyzeMenu, SWT.PUSH);
                analyzeTarget.setText(MenuBarLabels.ANALYZE_TARGET);
-               analyzeTarget.addSelectionListener(anlysisMenuListener);                
-
-               MenuItem analyzeScreenshot = new MenuItem(analyzeMenu, SWT.PUSH);
-               analyzeScreenshot.setText(MenuBarLabels.ANALYZE_SCREENSHOT);
-               analyzeScreenshot.addSelectionListener(anlysisMenuListener);
-               analyzeScreenshot.setEnabled(false);
+               analyzeTarget.addSelectionListener(anlysisMenuListener);
 
                MenuItem analyzePreferences = new MenuItem(analyzeMenu, SWT.PUSH);
                analyzePreferences.setText(MenuBarLabels.ANALYZE_PREFENCES);
@@ -320,16 +313,6 @@ public class MenuBar {
                        } else if (menuName.equals(MenuBarLabels.ANALYZE_TARGET)) {
                                TargetDialog targetDialog = new TargetDialog(currentShell);
                                targetDialog.open();
-                       } else if (menuName.equals(MenuBarLabels.ANALYZE_SCREENSHOT)) {
-                               try {
-                                       if (!DACommunicator.captureScreenshot().isSuccess()) {
-                                               Logger.error("Failed to capture screenshot");
-                                       }
-                               } catch (InterruptedException e) {
-                                       Logger.warning("Interrupted during send screenshot message");
-                               } catch (UnsupportedProtocolException e) {
-                                       Logger.warning("Message to capture screenshot is not supported by communicator");
-                               }
                        } else if (menuName.equals(MenuBarLabels.ANALYZE_PREFENCES)) {
                                PreferencesDialog preferencesDialog = new PreferencesDialog(currentShell);
                                preferencesDialog.open();
@@ -521,7 +504,6 @@ public class MenuBar {
                        ArrayList<DAChartBoard> chartboards = new ArrayList<DAChartBoard>();
                        ArrayList<DAChartBoardManager> boardMannagers = new ArrayList<DAChartBoardManager>();
                        ArrayList<DAScale> scales = new ArrayList<DAScale>();
-                       int[] zoom_vals = { 0, 0, 0, 0, 0 };
 
                        int index = 0;
                        double chartDiv = 3;
index 7bcdf93..c1ea306 100644 (file)
@@ -467,13 +467,21 @@ public class TimelineChartView extends DAViewComposite {
                        }
                }
        }
-       
-       public void addScreenshotChart() {
+
+       /**
+        * Shows or hides Screenshot chart depending on {@code show} argument.
+        *
+        * @param show whether Screenshot should be shown
+        */
+       public void showScreenshotChart(boolean show) {
                List<TimelineChart> chartList = timelineChartManager.getChartList();
                for(int i = 0; i < chartList.size(); i++){
                        TimelineChart timelineChart = chartList.get(i);
                        if(timelineChart.getChartName().equals(TimelineChartLabels.SCREENSHOT_CHART_TITLE)) {
-                               chartBoard.showItem(i);
+                               if (show)
+                                       chartBoard.showItem(i);
+                               else
+                                       chartBoard.hideItem(i);
                                break;
                        }
                }
index e60dcf4..7ec83a0 100644 (file)
@@ -32,7 +32,6 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Point;
@@ -54,7 +53,6 @@ import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.communicator.DACommunicator;
 import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
 import org.tizen.dynamicanalyzer.communicator.DeviceManager;
-import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.control.ApplistManager;
 import org.tizen.dynamicanalyzer.handlers.CommandAction;
@@ -62,7 +60,6 @@ import org.tizen.dynamicanalyzer.handlers.CommonAction;
 import org.tizen.dynamicanalyzer.handlers.ReplayManager;
 import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
 import org.tizen.dynamicanalyzer.nl.UserErrorWarningLabels;
 import org.tizen.dynamicanalyzer.project.AppInfo;
 import org.tizen.dynamicanalyzer.project.PackageInfo;
@@ -73,9 +70,7 @@ import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.setting.Feature;
-import org.tizen.dynamicanalyzer.setting.FlatFeature;
 import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.setting.TargetData;
 import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
 import org.tizen.dynamicanalyzer.ui.common.explorer.DeviceExplorerDialog;
 import org.tizen.dynamicanalyzer.ui.file.FileChartView;
@@ -614,29 +609,7 @@ public enum Toolbar {
 
                        @Override
                        public void handleClickEvent(DACustomButton button) {
-                               if(DAState.isRunning()) {
-                                       TargetData target = SettingDataManager.INSTANCE.getConnectedTarget();
-                                       Set<String> targetChartList = SettingDataManager.INSTANCE.getSelectedChartSet(target
-                                                       .getTargetName());
-                                       if(!targetChartList.contains(TimelineChartLabels.SCREENSHOT_CHART_TITLE)) {
-                                               BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
-                                               if(baseView.getTopComposite() instanceof TimelinePage) {
-                                                       TimelinePage timelinePage = (TimelinePage)baseView.getTopComposite();
-                                                       timelinePage.getTimelineChartView().addScreenshotChart();
-                                                       target.addSelectedFlatFeature(FlatFeature.SCREENSHOT.getName());
-                                               }
-                                       }
-                               }
-                               
-                               try {
-                                       if (!DACommunicator.captureScreenshot().isSuccess()) {
-                                               Logger.error("Failed to capture screenshot");
-                                       }
-                               } catch (InterruptedException e) {
-                                       Logger.warning("Interrupted during send screenshot message");
-                               } catch (UnsupportedProtocolException e) {
-                                       Logger.warning("Message to capture screenshot is not supported by communicator");
-                               }
+                               AnalyzerUtil.captureScreenshot();
                        }
                });
 
index ecefa4f..05db102 100644 (file)
@@ -49,6 +49,7 @@ import org.tizen.dynamicanalyzer.nl.WidgetLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.setting.FlatFeature;
 import org.tizen.dynamicanalyzer.setting.FlatPreferences;
 import org.tizen.dynamicanalyzer.setting.SettingDataManager;
 import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
@@ -63,6 +64,7 @@ import org.tizen.dynamicanalyzer.widgets.da.base.DAMessageBox;
 
 public class PreferencesDialog extends DAMessageBox {
        private static boolean opened = false;
+       private static boolean screenshotFeatureEnabled = false;
        private ScrolledComposite scrolledComp = null;
        private Composite buttonContentsComp = null;
        final private int DIALOG_HEIGT = 500;
@@ -83,6 +85,7 @@ public class PreferencesDialog extends DAMessageBox {
        private DACustomCombo systemRateCombo = null;
        private DACustomCombo functionRateCombo = null;
        private DACustomCombo screenshotRateCombo = null;
+       private Button okButton;
 
        public PreferencesDialog(Shell parentShell) {
                super(parentShell);
@@ -154,6 +157,8 @@ public class PreferencesDialog extends DAMessageBox {
                buttonContentsComp.setLayoutData(compData);
                buttonContentsComp.setBackground(ColorResources.WHITE);
 
+               screenshotFeatureEnabled = SettingDataManager.INSTANCE.getSelectedFlatFeatureSet().contains(FlatFeature.SCREENSHOT);
+
                drawPreferenceCom();
 
                initComboBoxes();
@@ -162,6 +167,10 @@ public class PreferencesDialog extends DAMessageBox {
 
                setSelectedOptions();
 
+               // Disable configuration preferences if DAState is RUNNING
+               if (DAState.isRunning())
+                       disableConfiguration();
+
                opened = true;
                ShortCutManager.getInstance().setEnabled(!opened);
                shell.open();
@@ -221,12 +230,6 @@ public class PreferencesDialog extends DAMessageBox {
                        // Source view
                        createLabel(generalView, PreferencesDialogLabels.SOURCE_VIEW, 2);
                        sourceviewtoggle = createToggleButton(generalView);
-                       sourceviewtoggle.addClickListener(new DACustomButtonClickEventListener() {
-                               @Override
-                               public void handleClickEvent(DACustomButton button) {
-                                       MenuBar.getInstance().setSourceView(sourceviewtoggle.isToggled());
-                               }
-                       });
 
                        // System sampling rate
                        createLabel(generalView, PreferencesDialogLabels.SYSTEM_SAMPLIING_RATE, 2);
@@ -271,13 +274,25 @@ public class PreferencesDialog extends DAMessageBox {
                        periodicallyToggle.addClickListener(new DACustomButtonClickEventListener() {
                                @Override
                                public void handleClickEvent(DACustomButton button) {
-                                       screenshotRateCombo.setEnabled(periodicallyToggle.isToggled());
+                                       boolean toggled = periodicallyToggle.isToggled();
+                                       screenshotRateCombo.setEnabled(toggled);
+                                       if (!toggled && !onSceneTransitionToggle.isToggled())
+                                               onSceneTransitionToggle.setToggled(true);
                                }
                        });
 
                        // On scene transition
                        createLabel(screenshotView, PreferencesDialogLabels.ON_SCENE_TRANSITION, 2);
                        onSceneTransitionToggle = createToggleButton(screenshotView);
+                       onSceneTransitionToggle.addClickListener(new DACustomButtonClickEventListener() {
+                               @Override
+                               public void handleClickEvent(DACustomButton button) {
+                                       if (!periodicallyToggle.isToggled() && !onSceneTransitionToggle.isToggled()) {
+                                               periodicallyToggle.setToggled(true);
+                                               screenshotRateCombo.setEnabled(true);
+                                       }
+                               }
+                       });
                }
 
                scrolledComp.setContent(baseCom);
@@ -306,7 +321,7 @@ public class PreferencesDialog extends DAMessageBox {
        }
 
        private void drawButtonCom() {
-               Button okButton = new Button(buttonContentsComp, SWT.NONE);
+               okButton = new Button(buttonContentsComp, SWT.NONE);
                FormData buttonData = new FormData();
                buttonData.top = new FormAttachment(0, 15);
                buttonData.right = new FormAttachment(100, -15);
@@ -353,16 +368,16 @@ public class PreferencesDialog extends DAMessageBox {
                        }
                });
 
-               Button setAsDefaultButton = new Button(buttonContentsComp, SWT.NONE);
+               Button resetToDefaultButton = new Button(buttonContentsComp, SWT.NONE);
                buttonData = new FormData();
                buttonData.top = new FormAttachment(0, 15);
                buttonData.right = new FormAttachment(cancelButton, -8);
-               buttonData.width = 100;
+               buttonData.width = 115;
                buttonData.height = 30;
-               setAsDefaultButton.setLayoutData(buttonData);
-               setAsDefaultButton.setFont(FontResources.DIALOG_BUTTON_FONT);
-               setAsDefaultButton.setText(PreferencesDialogLabels.SET_AS_DEFAULT);
-               setAsDefaultButton.addSelectionListener(new SelectionListener() {
+               resetToDefaultButton.setLayoutData(buttonData);
+               resetToDefaultButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+               resetToDefaultButton.setText(PreferencesDialogLabels.RESET_TO_DEFAULT);
+               resetToDefaultButton.addSelectionListener(new SelectionListener() {
 
                        @Override
                        public void widgetDefaultSelected(SelectionEvent arg0) {
@@ -370,7 +385,7 @@ public class PreferencesDialog extends DAMessageBox {
 
                        @Override
                        public void widgetSelected(SelectionEvent arg0) {
-                               setToDefault();
+                               resetToDefault();
                                scrolledComp.setFocus();
                        }
                });
@@ -392,20 +407,30 @@ public class PreferencesDialog extends DAMessageBox {
                value = SettingDataManager.INSTANCE.getOptionsPreferencesValue(FlatPreferences.FUNCTION_SAMPLING_RATE);
                functionRateCombo.setText(String.valueOf(value));
 
-               value = SettingDataManager.INSTANCE.getOptionsPreferencesValue(FlatPreferences.SCREENSHOT_PERIODICALLY);
-               if (value != 0) {
-                       periodicallyToggle.setToggled(true);
-                       screenshotRateCombo.setEnabled(true);
-                       screenshotRateCombo.setText(String.valueOf(value));
+               if (screenshotFeatureEnabled) {
+                       value = SettingDataManager.INSTANCE.getOptionsPreferencesValue(FlatPreferences.SCREENSHOT_PERIODICALLY);
+                       boolean enabled = (value != 0);
+
+                       periodicallyToggle.setToggled(enabled);
+                       periodicallyToggle.setButtonEnabled(true);
+                       screenshotRateCombo.setEnabled(enabled);
+                       if (enabled)
+                               screenshotRateCombo.setText(String.valueOf(value));
+
+                       enabled = SettingDataManager.INSTANCE.isOptionsSelectedPrefereces(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION);
+                       onSceneTransitionToggle.setToggled(enabled);
+                       onSceneTransitionToggle.setButtonEnabled(true);
                } else {
                        periodicallyToggle.setToggled(false);
+                       periodicallyToggle.setButtonEnabled(false);
                        screenshotRateCombo.setEnabled(false);
-               }
 
-               // TODO handle 'On scene transition' toggle
+                       onSceneTransitionToggle.setToggled(false);
+                       onSceneTransitionToggle.setButtonEnabled(false);
+               }
        }
 
-       private void setToDefault() {
+       private void resetToDefault() {
                int value = FlatPreferences.SOURCE_VIEW.getDefaultValue();
                if (value == 1) {
                        sourceviewtoggle.setToggled(true);
@@ -419,19 +444,19 @@ public class PreferencesDialog extends DAMessageBox {
                value = FlatPreferences.FUNCTION_SAMPLING_RATE.getDefaultValue();
                functionRateCombo.setText(String.valueOf(value));
 
-               value = FlatPreferences.SCREENSHOT_PERIODICALLY.getDefaultValue();
-               if (value != 0) {
-                       periodicallyToggle.setToggled(true);
-                       screenshotRateCombo.setEnabled(true);
+               if (screenshotFeatureEnabled) {
+                       value = FlatPreferences.SCREENSHOT_PERIODICALLY.getDefaultValue();
 
-                       screenshotRateCombo.setText(String.valueOf(value));
-               } else {
-                       periodicallyToggle.setToggled(false);
-                       screenshotRateCombo.select(0);
-                       screenshotRateCombo.setEnabled(false);
-               }
+                       boolean periodically = (value != 0);
+
+                       periodicallyToggle.setToggled(periodically);
+                       screenshotRateCombo.setEnabled(periodically);
+                       if (periodically)
+                               screenshotRateCombo.setText(String.valueOf(value));
 
-               // TODO handle 'On scene transition' toggle
+                       value = FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION.getDefaultValue();
+                       onSceneTransitionToggle.setToggled(value != 0);
+               }
        }
 
        private DACustomExtendButton createFoldingButton(Composite parent, String text) {
@@ -445,7 +470,7 @@ public class PreferencesDialog extends DAMessageBox {
                foldingbutton.setBackground(ColorResources.DIALOG_CONTENT_BACKGROUND);
                foldingbutton.setButtonFont(FontResources.DIALOG_CONTENTS_BOLD_FONT);
 
-               RowData rowData = new RowData(100, CONTROL_HEIGHT);
+               RowData rowData = new RowData(200, CONTROL_HEIGHT);
                foldingbutton.setLayoutData(rowData);
 
                return foldingbutton;
@@ -494,11 +519,9 @@ public class PreferencesDialog extends DAMessageBox {
        }
 
        private void applyPreferenceData() {
-               if (sourceviewtoggle.isToggled()) {
-                       SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SOURCE_VIEW, 1);
-               } else {
-                       SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SOURCE_VIEW, 0);
-               }
+               boolean sourceViewEnabled = sourceviewtoggle.isToggled();
+               MenuBar.getInstance().setSourceView(sourceViewEnabled);
+               SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SOURCE_VIEW, sourceViewEnabled ? 1 : 0);
 
                String ratestring = systemRateCombo.getText();
                try {
@@ -518,20 +541,21 @@ public class PreferencesDialog extends DAMessageBox {
                        return;
                }
                
+               int rate = 0;
                if (periodicallyToggle.isToggled()) {
-                       int rate = 1;
                        ratestring = screenshotRateCombo.getText();
                        try {
                                rate = Integer.parseInt(ratestring);
                        } catch (Exception ex) {
                                return;
                        }
-                       SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SCREENSHOT_PERIODICALLY, rate);
-               } else {
-                       SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SCREENSHOT_PERIODICALLY, 0);
                }
+               SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SCREENSHOT_PERIODICALLY, rate);
 
-               // TODO handle 'On scene transition' toggle
+               if (onSceneTransitionToggle.isToggled())
+                       SettingDataManager.INSTANCE.addOptionsSelectedPreference(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, 1);
+               else
+                       SettingDataManager.INSTANCE.deleteOptionsSelectedPreference(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION);
        }
 
        private DACustomCombo makeDACustomCombo(Composite parent, String unit) {
@@ -623,4 +647,15 @@ public class PreferencesDialog extends DAMessageBox {
                        });
                }
        }
+
+       /**
+        * Disables configuration controls that have no effect during tracing.
+        */
+       private void disableConfiguration() {
+               systemRateCombo.setEnabled(false);
+               functionRateCombo.setEnabled(false);
+               periodicallyToggle.setButtonEnabled(false);
+               screenshotRateCombo.setEnabled(false);
+               onSceneTransitionToggle.setButtonEnabled(false);
+       }
 }
index d2422f2..b04c0e8 100644 (file)
@@ -58,7 +58,10 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.handlers.IHandlerService;
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DAState;
 import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.project.BinaryInfo;
 import org.tizen.dynamicanalyzer.project.ProcessInformation;
@@ -548,4 +551,25 @@ public class AnalyzerUtil {
        public static void setPlatformSDK() {
                AnalyzerManager.setPlatformSDK(SettingDataManager.INSTANCE.isPlatformDA());
        }
+
+       /**
+        * Captures screenshot on target and shows Screenshot chart if it is not
+        * shown yet.
+        */
+       public static void captureScreenshot() {
+               if (!DAState.isRunning())
+                       return;
+
+               SettingDataManager.INSTANCE.enableScreenshotFeature(true);
+
+               try {
+                       if (!DACommunicator.captureScreenshot().isSuccess()) {
+                               Logger.error("Failed to capture screenshot");
+                       }
+               } catch (InterruptedException ex) {
+                       Logger.warning("Interrupted during send screenshot message");
+               } catch (UnsupportedProtocolException ex) {
+                       Logger.warning("Message to capture screenshot is not supported by communicator");
+               }
+       }
 }