From fb836156383e999430ae195c47a7fff088b17b40 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 2 Aug 2018 15:32:20 +0200
Subject: [PATCH] PluginManager extends AbstractGuiElement

---
 frontend-js/src/main/css/global.css           |  6 +++
 frontend-js/src/main/js/minerva.js            |  2 +-
 .../src/main/js/plugin/PluginManager.js       | 53 ++++++-------------
 .../src/test/js/gui/OptionsMenu-test.js       |  7 ++-
 .../src/test/js/plugin/PluginManager-test.js  |  2 +-
 5 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/frontend-js/src/main/css/global.css b/frontend-js/src/main/css/global.css
index 917e223e46..fc3b3c5126 100644
--- a/frontend-js/src/main/css/global.css
+++ b/frontend-js/src/main/css/global.css
@@ -425,6 +425,12 @@ table.minerva-window-drug-table td {
 }
 
 .minerva-plugin {
+    width: 300px;
+    max-width: 600px;
+    min-width: 150px;
+    height: 100%;
+    position: relative;
+    display: none;
 }
 
 .minerva-annotation-row-odd {
diff --git a/frontend-js/src/main/js/minerva.js b/frontend-js/src/main/js/minerva.js
index 3a7e83e4f4..5d9b6934f4 100644
--- a/frontend-js/src/main/js/minerva.js
+++ b/frontend-js/src/main/js/minerva.js
@@ -341,7 +341,7 @@ function create(params) {
 
     var pluginManager = new PluginManager({
       element: functions.getElementByClassName(element, "minerva-plugin"),
-      map: customMap,
+      customMap: customMap,
       project: params.getProject(),
       configuration: params.getConfiguration()
     });
diff --git a/frontend-js/src/main/js/plugin/PluginManager.js b/frontend-js/src/main/js/plugin/PluginManager.js
index 525af16e07..7d8eeb9e40 100644
--- a/frontend-js/src/main/js/plugin/PluginManager.js
+++ b/frontend-js/src/main/js/plugin/PluginManager.js
@@ -1,6 +1,6 @@
 "use strict";
 
-var ObjectWithListeners = require('../ObjectWithListeners');
+var AbstractGuiElement = require('../gui/AbstractGuiElement');
 var Plugin = require('./Plugin');
 var GuiUtils = require('../gui/leftPanel/GuiUtils');
 var GuiConnector = require('../GuiConnector');
@@ -12,14 +12,19 @@ var Promise = require("bluebird");
 // noinspection JSUnusedLocalSymbols
 var logger = require('../logger');
 
-
+/**
+ *
+ * @param options
+ * @param {HTMLElement} options.element
+ * @param {CustomMap} options.customMap
+ * @param {Configuration} options.configuration
+ * @param {Project} options.project
+ * @constructor
+ * @extends {AbstractGuiElement}
+ */
 function PluginManager(options) {
-  ObjectWithListeners.call(this);
+  AbstractGuiElement.call(this, options);
   var self = this;
-  self.setProject(options.project);
-  self.setMap(options.map);
-  self.setElement(options.element);
-  self.setConfiguration(options.configuration);
   self._plugins = [];
   self._pluginOnResizeHandlers = {};
 
@@ -33,32 +38,8 @@ function PluginManager(options) {
   });
 }
 
-PluginManager.prototype = Object.create(ObjectWithListeners.prototype);
-PluginManager.prototype.constructor = ObjectWithListeners;
-
-PluginManager.prototype.setProject = function (project) {
-  this._project = project;
-};
-PluginManager.prototype.setMap = function (map) {
-  this._map = map;
-};
-PluginManager.prototype.getMap = function () {
-  return this._map;
-};
-PluginManager.prototype.setElement = function (element) {
-  this._element = element;
-};
-PluginManager.prototype.getElement = function () {
-  return this._element;
-};
-
-PluginManager.prototype.setConfiguration = function (configuration) {
-  this._configuration = configuration;
-};
-
-PluginManager.prototype.getConfiguration = function () {
-  return this._configuration;
-};
+PluginManager.prototype = Object.create(AbstractGuiElement.prototype);
+PluginManager.prototype.constructor = AbstractGuiElement;
 
 PluginManager.prototype.getPlugins = function () {
   return this._plugins;
@@ -120,11 +101,7 @@ PluginManager.prototype.createTabForPlugin = function () {
   var tabData = self._tabData;
   var guiUtils = new GuiUtils(self.getConfiguration());
   if (tabData === undefined) {
-    self.getElement().style.width = "300px";
-    self.getElement().style.maxWidth = "600px";
-    self.getElement().style.minWidth = "150px";
-    self.getElement().style.height = "100%";
-    self.getElement().style.position = "relative";
+    $(self.getElement()).show();
     self._tabData = guiUtils.createTabDiv({element: self.getElement(), id: "plugin_tab"});
     tabData = self._tabData;
     $(tabData.element).css('position', 'absolute');
diff --git a/frontend-js/src/test/js/gui/OptionsMenu-test.js b/frontend-js/src/test/js/gui/OptionsMenu-test.js
index e10ca3ac30..7e51307df4 100644
--- a/frontend-js/src/test/js/gui/OptionsMenu-test.js
+++ b/frontend-js/src/test/js/gui/OptionsMenu-test.js
@@ -33,7 +33,12 @@ describe('OptionsMenu', function () {
     var pluginManager;
     return ServerConnector.getProject().then(function (project) {
 
-      pluginManager = new PluginManager({project: project});
+      pluginManager = new PluginManager({
+        project: project,
+        customMap: map,
+        element: div,
+        configuration: helper.getConfiguration()
+      });
       return menu.init();
     }).then(function () {
       menu.setPluginManager(pluginManager);
diff --git a/frontend-js/src/test/js/plugin/PluginManager-test.js b/frontend-js/src/test/js/plugin/PluginManager-test.js
index ab03699985..8a5e800a5b 100644
--- a/frontend-js/src/test/js/plugin/PluginManager-test.js
+++ b/frontend-js/src/test/js/plugin/PluginManager-test.js
@@ -14,7 +14,7 @@ describe('PluginManager', function () {
   var createParams = function () {
     var map = helper.createCustomMap();
     return {
-      map: map,
+      customMap: map,
       configuration: helper.getConfiguration(),
       element: testDiv
     };
-- 
GitLab