From 20cf9e7c6f09a4ea02f8cb6eff5d16fa00e7db41 Mon Sep 17 00:00:00 2001
From: pkupczyk <pkupczyk>
Date: Tue, 13 May 2014 07:37:59 +0000
Subject: [PATCH] SSDM-274 : Javascript-based Microscopy Data Viewer -
 synchronizing parameters for different data sets done

SVN: 31490
---
 .../components/imageviewer/AbstractWidget.js  | 24 +++++++++++++++++++
 .../imageviewer/ChannelChooserWidget.js       | 12 ++++------
 .../ChannelStackMatrixChooserWidget.js        | 14 ++++-------
 .../ChannelStackSeriesChooserView.js          |  2 +-
 .../ChannelStackSeriesChooserWidget.js        | 18 ++++++--------
 .../imageviewer/ImageParametersWidget.js      | 14 ++++-------
 .../imageviewer/MovieButtonsWidget.js         | 12 ++++------
 .../imageviewer/ResolutionChooserWidget.js    | 10 +++-----
 8 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js
index 00d2bbe30a9..7e2100fa8b6 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js
@@ -46,6 +46,30 @@ define([ "jquery", "components/common/ListenerManager" ], function($, ListenerMa
 			}
 		},
 
+		getState : function() {
+			if (!this.state) {
+				this.state = {};
+			}
+			this.doGetState(this.state);
+			return this.state;
+		},
+
+		setState : function(state) {
+			if (state) {
+				if (!this.state) {
+					this.state = {};
+				}
+				$.extend(this.state, state);
+				this.doSetState(this.state);
+			}
+		},
+
+		doGetState : function(state) {
+		},
+
+		doSetState : function(state) {
+		},
+
 		getView : function() {
 			return this.view;
 		},
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js
index 68cd9e35591..bf6b212aa42 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js
@@ -16,18 +16,14 @@ define([ "jquery", "components/imageviewer/AbstractWidget", "components/imagevie
 			this.setChannels(channels);
 		},
 
-		getState : function() {
-			var state = {};
+		doGetState : function(state) {
 			state.selectedChannel = this.getSelectedChannel();
 			state.selectedMergedChannels = this.getSelectedMergedChannels();
-			return state;
 		},
 
-		setState : function(state) {
-			if (state) {
-				this.setSelectedChannel(state.selectedChannel);
-				this.setSelectedMergedChannels(state.selectedMergedChannels);
-			}
+		doSetState : function(state) {
+			this.setSelectedChannel(state.selectedChannel);
+			this.setSelectedMergedChannels(state.selectedMergedChannels);
 		},
 
 		getSelectedChannel : function() {
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js
index 5ec6f87f57a..f670e728efc 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js
@@ -21,20 +21,16 @@ define([ "jquery", "components/imageviewer/AbstractWidget", "components/imagevie
 			}
 		},
 
-		getState : function() {
-			var state = {};
+		doGetState : function(state) {
 			state.timePointButtonsState = this.getTimePointButtonsWidget().getState();
 			state.selectedTimePoint = this.getSelectedTimePoint();
 			state.selectedDepth = this.getSelectedDepth();
-			return state;
 		},
 
-		setState : function(state) {
-			if (state) {
-				this.getTimePointButtonsWidget().setState(state.timePointButtonsState);
-				this.setSelectedTimePoint(state.selectedTimePoint);
-				this.setSelectedDepth(state.selectedDepth);
-			}
+		doSetState : function(state) {
+			this.getTimePointButtonsWidget().setState(state.timePointButtonsState);
+			this.setSelectedTimePoint(state.selectedTimePoint);
+			this.setSelectedDepth(state.selectedDepth);
 		},
 
 		getTimePoints : function() {
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserView.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserView.js
index 5607a989730..4a140f77fff 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserView.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserView.js
@@ -19,7 +19,7 @@ define([ "jquery", "bootstrap", "bootstrap-slider", "components/imageviewer/Abst
 			var thisView = this;
 
 			this.panel.append(this.createSliderWidget());
-			this.panel.append(this.controller.getButtonsWidget().render());
+			this.panel.append(this.controller.getChannelStackButtonsWidget().render());
 
 			this.refresh();
 
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js
index 640355ec3ad..5557d781dd5 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js
@@ -21,18 +21,14 @@ define([ "jquery", "components/imageviewer/AbstractWidget", "components/imagevie
 			}
 		},
 
-		getState : function() {
-			var state = {};
-			state.buttonsWidget = this.getButtonsWidget().getState();
+		doGetState : function(state) {
+			state.channelStackButtonsWidget = this.getChannelStackButtonsWidget().getState();
 			state.selectedChannelStackIndex = this.getSelectedChannelStackIndex();
-			return state;
 		},
 
-		setState : function(state) {
-			if (state) {
-				this.getButtonsWidget().setState(state.buttonsWidget);
-				this.setSelectedChannelStackIndex(state.selectedChannelStackIndex);
-			}
+		doSetState : function(state) {
+			this.getChannelStackButtonsWidget().setState(state.getChannelStackButtonsWidget);
+			this.setSelectedChannelStackIndex(state.selectedChannelStackIndex);
 		},
 
 		getChannelStacks : function() {
@@ -95,13 +91,13 @@ define([ "jquery", "components/imageviewer/AbstractWidget", "components/imagevie
 
 			if (this.getSelectedChannelStackId() != channelStackId) {
 				this.selectedChannelStackId = channelStackId;
-				this.getButtonsWidget().setSelectedFrame(this.getSelectedChannelStackIndex());
+				this.getChannelStackButtonsWidget().setSelectedFrame(this.getSelectedChannelStackIndex());
 				this.refresh();
 				this.notifyChangeListeners();
 			}
 		},
 
-		getButtonsWidget : function() {
+		getChannelStackButtonsWidget : function() {
 			if (this.buttonsWidget == null) {
 				var thisWidget = this;
 
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageParametersWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageParametersWidget.js
index fcbd6226d86..d58f1ddb0f6 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageParametersWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageParametersWidget.js
@@ -18,20 +18,16 @@ define([ "jquery", "components/imageviewer/AbstractWidget", "components/imagevie
 			this.imageResolutions = imageResolutions;
 		},
 
-		getState : function() {
-			var state = {};
+		doGetState : function(state) {
 			state.channelChooserState = this.getChannelChooserWidget().getState();
 			state.resolutionChooserState = this.getResolutionChooserWidget().getState();
 			state.channelStackChooserState = this.getChannelStackChooserWidget().getState();
-			return state;
 		},
 
-		setState : function(state) {
-			if (state) {
-				this.getChannelChooserWidget().setState(state.channelChooserState);
-				this.getResolutionChooserWidget().setState(state.resolutionChooserState);
-				this.getChannelStackChooserWidget().setState(state.channelStackChooserState);
-			}
+		doSetState : function(state) {
+			this.getChannelChooserWidget().setState(state.channelChooserState);
+			this.getResolutionChooserWidget().setState(state.resolutionChooserState);
+			this.getChannelStackChooserWidget().setState(state.channelStackChooserState);
 		},
 
 		getChannelChooserWidget : function() {
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js
index 4444583bffe..633189813a9 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js
@@ -116,18 +116,14 @@ define([ "jquery", "components/imageviewer/AbstractView", "components/imageviewe
 			this.selectedFrame = 0;
 		},
 
-		getState : function() {
-			var state = {};
+		doGetState : function(state) {
 			state.selectedFrame = this.getSelectedFrame();
 			state.selectedDelay = this.getSelectedDelay();
-			return state;
 		},
 
-		setState : function(state) {
-			if (state) {
-				this.setSelectedFrame(state.selectedFrame);
-				this.setSelectedDelay(state.selectedDelay);
-			}
+		doSetState : function(state) {
+			this.setSelectedFrame(state.selectedFrame);
+			this.setSelectedDelay(state.selectedDelay);
 		},
 
 		play : function() {
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js
index 29bb0f6bafd..7020719b30d 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js
@@ -16,16 +16,12 @@ define([ "jquery", "components/imageviewer/AbstractWidget", "components/imagevie
 			this.setResolutions(resolutions);
 		},
 
-		getState : function() {
-			var state = {};
+		doGetState : function(state) {
 			state.selectedResolution = this.getSelectedResolution();
-			return state;
 		},
 
-		setState : function(state) {
-			if (state) {
-				this.setSelectedResolution(state.selectedResolution);
-			}
+		doSetState : function(state) {
+			this.setSelectedResolution(state.selectedResolution);
 		},
 
 		getSelectedResolution : function() {
-- 
GitLab