diff --git a/bigbluebutton-client/src/conf/layout.xml b/bigbluebutton-client/src/conf/layout.xml index 8bf5a60012..24afcf8661 100644 --- a/bigbluebutton-client/src/conf/layout.xml +++ b/bigbluebutton-client/src/conf/layout.xml @@ -1,4 +1,4 @@ - + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/managers/LayoutManager.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/managers/LayoutManager.as index 86a9ab4cf2..e3f3561a34 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/managers/LayoutManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/managers/LayoutManager.as @@ -33,12 +33,12 @@ package org.bigbluebutton.modules.layout.managers import org.bigbluebutton.modules.layout.model.LayoutDefinition; public class LayoutManager extends EventDispatcher { - private var _layouts:Dictionary = new Dictionary(); + private var _layouts:Dictionary; private var _dispatcher:Dispatcher = new Dispatcher(); public function loadLayout(layoutUrl:String):void { var urlLoader:URLLoader = new URLLoader(); - urlLoader.addEventListener(Event.COMPLETE, handleComplete); + urlLoader.addEventListener(Event.COMPLETE, completeHandler); urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); var date:Date = new Date(); try { @@ -48,8 +48,10 @@ package org.bigbluebutton.modules.layout.managers } } - private function handleComplete(e:Event):void{ + public function completeHandler(e:Event):void { + LogUtil.debug("==================================> loaded"); var data:XML = new XML(e.target.data); + _layouts = new Dictionary(); for each (var n:XML in data.layout) { var layoutDefinition:LayoutDefinition = new LayoutDefinition(); layoutDefinition.load(n); @@ -68,6 +70,10 @@ package org.bigbluebutton.modules.layout.managers return _layouts; } + public function append(layoutDefinition:LayoutDefinition):void { + _layouts[layoutDefinition.name] = layoutDefinition; + } + public function getDefault():LayoutDefinition { for each (var value:LayoutDefinition in _layouts) { if (value.default_) @@ -79,5 +85,13 @@ package org.bigbluebutton.modules.layout.managers public function getLayout(name:String):LayoutDefinition { return _layouts[name]; } + + public function toXml():XML { + var xml:XML = ; + for each (var value:LayoutDefinition in _layouts) { + xml.appendChild(value.toXml()); + } + return xml; + } } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinition.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinition.as index b3152a61f5..cc886118da 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinition.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinition.as @@ -52,15 +52,15 @@ package org.bigbluebutton.modules.layout.model { return windows[name]; } - public function toXml():String { - var r:String = ""; + public function toXml():XML { + var xml:XML = ; + xml.@name = name; + if (default_) + xml.@default = true; for each (var value:WindowLayout in windows) { - r += "\n\t" + value.toXml(); + xml.appendChild(value.toXml()); } - r += "\n"; - return r; + return xml; } public function applyToCanvas(canvas:MDICanvas):void { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/WindowLayout.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/WindowLayout.as index e6aacf76e8..3808e28d72 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/WindowLayout.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/WindowLayout.as @@ -157,26 +157,36 @@ package org.bigbluebutton.modules.layout.model { } } - public function toAbsoluteXml(canvas:MDICanvas):String { - return ""; + public function toAbsoluteXml(canvas:MDICanvas):XML { + var xml:XML = ; + xml.@name = name; + if (minimized) + xml.@minimized = true; + else if (maximized) + xml.@maximized = true; + else { + xml.@width = int(width * canvas.width); + xml.@height = int(height * canvas.height); + xml.@x = int(x * canvas.width); + xml.@y = int(y * canvas.height); + } + return xml; } - public function toXml():String { - return ""; + public function toXml():XML { + var xml:XML = ; + xml.@name = name; + if (minimized) + xml.@minimized = true; + else if (maximized) + xml.@maximized = true; + else { + xml.@width = width; + xml.@height = height; + xml.@x = x; + xml.@y = y; + } + return xml; } } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/ToolbarComboBox.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/ToolbarComboBox.mxml index 462e66d04b..1f16ebd9a5 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/ToolbarComboBox.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/ToolbarComboBox.mxml @@ -39,6 +39,8 @@ import mx.controls.Alert; import mx.events.ResizeEvent; + import flash.net.FileReference; + import flexlib.mdi.managers.MDIManager; import flexlib.mdi.containers.MDICanvas; import flexlib.mdi.containers.MDIWindow; @@ -65,6 +67,12 @@ private var _previousLayout:int = -1; private var _defaultLayout:int = -1; private var _defaultLayoutTimer:Timer = new Timer(500, 1); + private var _customLayoutNumber:int = 0; + private var _firstTime:Boolean = true; + + private var ADD_LAYOUT:String = "Add layout to list"; + private var SAVE_LAYOUTS:String = "Save layouts to disk"; + private var LOAD_LAYOUTS:String = "Load layouts from disk"; private function init():void{ _mdiCanvas = getMdiCanvas(parent) as MDICanvas; @@ -108,6 +116,13 @@ private function populateComboBox(e:LayoutsLoadedEvent):void { _layouts = e.layouts; + updateComboBox(); + if (_firstTime) + applyDefaultLayout(); + _firstTime = false; + } + + private function updateComboBox():void { dataProvider.removeAll(); for each (var value:LayoutDefinition in _layouts.dict) { var item:Object = {label:value.name}; @@ -115,10 +130,27 @@ if (value.default_) _defaultLayout = dataProvider.getItemIndex(item); } - dataProvider.addItem({label:ResourceUtil.getInstance().getString('bbb.layout.copy')}); - applyDefaultLayout(); + dataProvider.addItem(null); + dataProvider.addItem({label:ADD_LAYOUT}); + dataProvider.addItem({label:SAVE_LAYOUTS}); + dataProvider.addItem({label:LOAD_LAYOUTS}); + //dataProvider.addItem({label:ResourceUtil.getInstance().getString('bbb.layout.copy')}); } + private function selectHandler(e:Event):void { + var file:FileReference = FileReference(e.target); + LogUtil.debug("==================================> loading"); + file.load(); + } + + private function completeHandler(e:Event):void { + LogUtil.debug("==================================> completeHandler"); + var loader:Loader = new Loader(); + loader.loadBytes(e.target.data); + addChild(loader); + _layouts.completeHandler(e); + } + private function applyDefaultLayout(event:TimerEvent = null):void { if (_defaultLayout != -1 && _mdiCanvas != null && selectedIndex != _defaultLayout) { selectedIndex = _defaultLayout; @@ -137,6 +169,8 @@ private function setupWindowListener(window:MDIWindow):void { window.addEventListener(MDIWindowEvent.RESIZE_START, invalidateLayout); window.addEventListener(MDIWindowEvent.DRAG_START, invalidateLayout); + window.addEventListener(MDIWindowEvent.MINIMIZE, invalidateLayout); + window.addEventListener(MDIWindowEvent.MAXIMIZE, invalidateLayout); } private function invalidateLayout(e:Event):void { @@ -153,15 +187,31 @@ } private function changeLayout(label:String):void { - if (label == ResourceUtil.getInstance().getString('bbb.layout.copy')) { + var file:FileReference; + if (label == ADD_LAYOUT) { + _customLayoutNumber += 1; + _layouts.append(LayoutDefinition.getLayout(_mdiCanvas, "Custom layout " + _customLayoutNumber)); + updateComboBox(); + prompt = ResourceUtil.getInstance().getString('bbb.layout.prompt'); + selectedIndex = -1; + } else if (label == SAVE_LAYOUTS) { + file = new FileReference(); + file.save(_layouts.toXml().toXMLString(), "layouts.xml"); + selectedIndex = _previousLayout; + } else if (label == LOAD_LAYOUTS) { + file = new FileReference(); + file.addEventListener(Event.SELECT, selectHandler); + file.addEventListener(Event.COMPLETE, completeHandler); + file.browse(); + selectedIndex = _previousLayout; + } else if (label == ResourceUtil.getInstance().getString('bbb.layout.copy')) { var name:String; if (_previousLayout != -1) name = dataProvider.getItemAt(_previousLayout).label; else name = "Custom layout"; - System.setClipboard(LayoutDefinition.getLayout(_mdiCanvas, name).toXml()); + System.setClipboard(LayoutDefinition.getLayout(_mdiCanvas, name).toXml().toXMLString()); Alert.show(ResourceUtil.getInstance().getString('bbb.layout.copied'), "", Alert.OK, this); - selectedIndex = _previousLayout; } else { _currentLayout = _layouts.getLayout(label); _currentLayout.applyToCanvas(_mdiCanvas);