From a992d7d54714ff8e8b033491281901f5f3a7bbcf Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Fri, 27 Jul 2012 18:23:43 +0000 Subject: [PATCH] - setup whiteboard model so that display will query it during redraws --- .../WhiteboardCanvasDisplayModel.as | 85 +++++++++++++++---- .../whiteboard/WhiteboardCanvasModel.as | 6 +- .../whiteboard/managers/WhiteboardManager.as | 5 ++ .../whiteboard/maps/WhiteboardEventMap.mxml | 6 +- .../modules/whiteboard/models/Page.as | 8 ++ .../modules/whiteboard/models/Presentation.as | 4 + .../whiteboard/models/WhiteboardModel.as | 7 +- .../whiteboard/services/MessageReceiver.as | 4 +- 8 files changed, 101 insertions(+), 24 deletions(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as index 445d99be80..127896753d 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as @@ -12,12 +12,14 @@ package org.bigbluebutton.modules.whiteboard import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; import flash.text.TextFormat; - import flash.ui.Keyboard; + import flash.ui.Keyboard; + import mx.collections.ArrayCollection; import mx.controls.TextInput; import mx.core.Application; import mx.core.UIComponent; - import mx.managers.CursorManager; + import mx.managers.CursorManager; + import org.bigbluebutton.common.IBbbCanvas; import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.core.managers.UserManager; @@ -40,12 +42,14 @@ package org.bigbluebutton.modules.whiteboard import org.bigbluebutton.modules.whiteboard.events.WhiteboardSettingResetEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate; import org.bigbluebutton.modules.whiteboard.models.Annotation; + import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel; import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas; /** * Class to handle displaying of received annotations from the server. */ public class WhiteboardCanvasDisplayModel { + public var whiteboardModel:WhiteboardModel; public var wbCanvas:WhiteboardCanvas; private var graphicList:Array = new Array(); @@ -54,8 +58,6 @@ package org.bigbluebutton.modules.whiteboard private var bbbCanvas:IBbbCanvas; private var width:Number; private var height:Number; - - public function drawGraphic(event:WhiteboardUpdate):void{ var o:Annotation = event.annotation; @@ -66,7 +68,10 @@ package org.bigbluebutton.modules.whiteboard drawShape(dobj, recvdShapes); } else { drawText(o, recvdShapes); - } + } + + var a2:Array = whiteboardModel.getAnnotations(); + LogUtil.debug("**** Number of annotations [" + a2.length + "]"); } @@ -151,10 +156,8 @@ package org.bigbluebutton.modules.whiteboard return tobj; } - /* adds a new TextObject that is suited for a presenter. For example, it will - be made editable and the appropriate listeners will be registered so that - the required events will be dispatched - */ + /* adds a new TextObject that is suited for a presenter. For example, it will be made editable and the appropriate listeners will be registered so that + the required events will be dispatched */ private function addPresenterText(o:Annotation):void { if(!isPresenter) return; var tobj:TextObject = calibrateNewTextWith(o); @@ -163,7 +166,7 @@ package org.bigbluebutton.modules.whiteboard tobj.autoSize = TextFieldAutoSize.LEFT; tobj.makeEditable(true); LogUtil.debug("Putting text object [" + tobj.getGraphicID() + "] in [" + tobj.x + "," + tobj.y + "]"); -// tobj.registerListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextListener, textObjSpecialListener); + tobj.registerListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextListener, textObjSpecialListener); wbCanvas.addGraphic(tobj); wbCanvas.stage.focus = tobj; graphicList.push(tobj); @@ -241,7 +244,7 @@ package org.bigbluebutton.modules.whiteboard var gobj:GraphicObject = graphicList.pop(); if(gobj.getGraphicType() == WhiteboardConstants.TYPE_TEXT) { (gobj as TextObject).makeEditable(false); -// (gobj as TextObject).deregisterListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextListener, textObjSpecialListener); + (gobj as TextObject).deregisterListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextListener, textObjSpecialListener); } wbCanvas.removeGraphic(gobj as DisplayObject); } @@ -308,6 +311,7 @@ package org.bigbluebutton.modules.whiteboard this.width = width; this.height = height; + // var an:Array = for (var i:int = 0; i < this.graphicList.length; i++){ redrawGraphic(this.graphicList[i] as GraphicObject, i); } @@ -347,16 +351,63 @@ package org.bigbluebutton.modules.whiteboard wbCanvas.addGraphic(dobj); graphicList[objIndex] = dobj; } else if(gobj.getGraphicType() == WhiteboardConstants.TYPE_TEXT) { - var origTobj:TextObject = gobj as TextObject; +// var origTobj:TextObject = gobj as TextObject; // wbCanvas.removeGraphic(origTobj); // origTobj.graphics.clear(); -// var tobj:TextObject = shapeFactory.makeTextObject(origTobj); - // tobj.setGraphicID(origTobj.getGraphicID()); - // tobj.status = origTobj.status; - // wbCanvas.addGraphic(tobj); - // graphicList[objIndex] = tobj; + // var tobj:TextObject = shapeFactory.makeTextObject(origTobj); +// tobj.setGraphicID(origTobj.getGraphicID()); +// tobj.status = origTobj.status; +// wbCanvas.addGraphic(tobj); +// graphicList[objIndex] = tobj; } } + + /* the following four methods are listeners that handle events that occur on TextObjects, such as text being typed, which causes the textObjTextListener + to send text to the server. */ + public function textObjSpecialListener(event:KeyboardEvent):void { + // check for special conditions + if(event.charCode == 127 || // 'delete' key + event.charCode == 8 || // 'bkspace' key + event.charCode == 13) { // 'enter' key + var sendStatus:String = TextObject.TEXT_UPDATED; + var tobj:TextObject = event.target as TextObject; + + // if the enter key is pressed, remove focus from the TextObject so that it is sent to the server. + if(event.charCode == 13) { + wbCanvas.stage.focus = null; + tobj.stage.focus = null; + return; + } +// sendTextToServer(sendStatus, tobj); + } + } + + public function textObjTextListener(event:TextEvent):void { + var sendStatus:String = TextObject.TEXT_UPDATED; + var tf:TextObject = event.target as TextObject; + LogUtil.debug("ID " + tf.getGraphicID() + " modified to " + tf.text); +// sendTextToServer(sendStatus, tf); + } + + public function textObjGainedFocusListener(event:FocusEvent):void { + var tf:TextObject = event.currentTarget as TextObject; + wbCanvas.stage.focus = tf; + tf.stage.focus = tf; +// currentlySelectedTextObject = tf; + var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_SELECTED); + e.data = tf; + wbCanvas.dispatchEvent(e); + } + + public function textObjLostFocusListener(event:FocusEvent):void { + var tf:TextObject = event.target as TextObject; +// sendTextToServer(TextObject.TEXT_PUBLISHED, tf); + LogUtil.debug("Text published to: " + tf.text); + var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_DESELECTED); + e.data = tf; + wbCanvas.dispatchEvent(e); + /* hide text toolbar because we don't want to show it if there is no text selected */ + } public function isPageEmpty():Boolean { return graphicList.length == 0; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as index 439991d93a..f4b6f48444 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as @@ -12,13 +12,11 @@ package org.bigbluebutton.modules.whiteboard import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; import flash.text.TextFormat; - import flash.ui.Keyboard; - + import flash.ui.Keyboard; import mx.controls.TextInput; import mx.core.Application; import mx.core.UIComponent; - import mx.managers.CursorManager; - + import mx.managers.CursorManager; import org.bigbluebutton.common.IBbbCanvas; import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.core.managers.UserManager; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/managers/WhiteboardManager.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/managers/WhiteboardManager.as index 43d450b12d..9d6097d039 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/managers/WhiteboardManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/managers/WhiteboardManager.as @@ -36,6 +36,7 @@ package org.bigbluebutton.modules.whiteboard.managers import org.bigbluebutton.modules.whiteboard.events.ToggleGridEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardButtonEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate; + import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel; import org.bigbluebutton.modules.whiteboard.views.WhiteboardButton; import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas; import org.bigbluebutton.modules.whiteboard.views.WhiteboardTextToolbar; @@ -43,6 +44,9 @@ package org.bigbluebutton.modules.whiteboard.managers public class WhiteboardManager { + /* Injected by Mate */ + public var whiteboardModel:WhiteboardModel; + private var globalDispatcher:Dispatcher; private var highlighterCanvas:WhiteboardCanvas; private var highlighterToolbar:WhiteboardToolbar; @@ -61,6 +65,7 @@ package org.bigbluebutton.modules.whiteboard.managers highlighterCanvas = new WhiteboardCanvas(); highlighterCanvas.model = model; highlighterCanvas.displayModel = displayModel; + displayModel.whiteboardModel = whiteboardModel; model.wbCanvas = highlighterCanvas; displayModel.wbCanvas = highlighterCanvas; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/maps/WhiteboardEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/maps/WhiteboardEventMap.mxml index ddaa099d30..21c729e014 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/maps/WhiteboardEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/maps/WhiteboardEventMap.mxml @@ -161,7 +161,11 @@ - + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Page.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Page.as index 8c5775c297..d3b411df70 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Page.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Page.as @@ -27,5 +27,13 @@ package org.bigbluebutton.modules.whiteboard.models public function get number():int { return _num; } + + public function getAnnotations():Array { + var a:Array = new Array(); + for (var i:int = 0; i < _annotations.length; i++) { + a.push(_annotations.getItemAt(i) as Annotation); + } + return a; + } } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Presentation.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Presentation.as index 8b27aff318..d07bbf7e2e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Presentation.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/Presentation.as @@ -18,6 +18,10 @@ package org.bigbluebutton.modules.whiteboard.models createPages(numPages); } + public function getAnnotations():Array { + return _currentPage.getAnnotations(); + } + private function createPages(numPages:int):void { LogUtil.debug("**** Creating presentation " + _id + " with pages [" + numPages + "]"); for (var i:int = 1; i <= numPages; i++) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/WhiteboardModel.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/WhiteboardModel.as index 1373be3c28..3abe652afc 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/WhiteboardModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/models/WhiteboardModel.as @@ -2,7 +2,8 @@ package org.bigbluebutton.modules.whiteboard.models { import flash.events.IEventDispatcher; - import mx.collections.ArrayCollection; + import mx.collections.ArrayCollection; + import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate; @@ -32,6 +33,10 @@ package org.bigbluebutton.modules.whiteboard.models } + public function getAnnotations():Array { + return _currentPresentation.getAnnotations(); + } + public function undo():void { _currentPresentation.undo(); _dispatcher.dispatchEvent(new WhiteboardDrawEvent(WhiteboardDrawEvent.UNDO)); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as index 73398c2b22..47f2e38ef0 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as @@ -11,8 +11,10 @@ package org.bigbluebutton.modules.whiteboard.services public class MessageReceiver implements IMessageListener { + /* Injected by Mate */ public var whiteboardModel:WhiteboardModel; - private var drawFactory:DrawObjectFactory; + + private var drawFactory:DrawObjectFactory; public function MessageReceiver() { drawFactory = new DrawObjectFactory();