From 480df6e90b9571e96e8342e2d315b0e98f8be659 Mon Sep 17 00:00:00 2001 From: RafaFP Date: Wed, 27 Jan 2016 21:51:41 +0000 Subject: [PATCH] User can no longer create a custom layout that has the same name as any other layouts on his list. When a user tries to do so, he will be propted by a popup window to confirm the overwriting of the previous layout. If the user confirms this choice, then the previous layout will be removed and the new one takes it's place. If the user denies the overwriting then he will return to the naming window to change the name of the custom layout. refs #1825 --- .../branding/default/style/css/BBBDefault.css | 8 ++ .../css/assets/images/status_fail_16px.png | Bin 0 -> 416 bytes .../css/assets/images/status_success_16px.png | Bin 0 -> 487 bytes .../locale/en_US/bbbResources.properties | 3 + .../locale/pt_BR/bbbResources.properties | 3 + .../modules/layout/events/LayoutEvent.as | 1 + .../layout/events/LayoutNameInUseEvent.as | 37 +++++++++ .../modules/layout/managers/LayoutManager.as | 45 +++++++++- .../modules/layout/maps/LayoutEventMap.mxml | 2 +- .../layout/model/LayoutDefinitionFile.as | 9 ++ .../modules/layout/model/LayoutModel.as | 4 + .../layout/views/CustomLayoutNameWindow.mxml | 15 +++- .../modules/layout/views/OverwriteWindow.mxml | 78 ++++++++++++++++++ 13 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 bigbluebutton-client/branding/default/style/css/assets/images/status_fail_16px.png create mode 100644 bigbluebutton-client/branding/default/style/css/assets/images/status_success_16px.png create mode 100644 bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutNameInUseEvent.as create mode 100644 bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/OverwriteWindow.mxml diff --git a/bigbluebutton-client/branding/default/style/css/BBBDefault.css b/bigbluebutton-client/branding/default/style/css/BBBDefault.css index 867b85da80..3f5d30d621 100755 --- a/bigbluebutton-client/branding/default/style/css/BBBDefault.css +++ b/bigbluebutton-client/branding/default/style/css/BBBDefault.css @@ -985,6 +985,14 @@ Alert { icon: Embed('assets/images/ic_file_upload_16px.png'); } +.overwriteLayoutConfirmStyle{ + icon: Embed('assets/images/status_success_16px.png'); +} + +.overwriteLayoutDenyStyle{ + icon: Embed('assets/images/status_fail_16px.png'); +} + .broadcastLayoutButtonStyle { icon: Embed('assets/images/ic_send_16px.png'); } diff --git a/bigbluebutton-client/branding/default/style/css/assets/images/status_fail_16px.png b/bigbluebutton-client/branding/default/style/css/assets/images/status_fail_16px.png new file mode 100644 index 0000000000000000000000000000000000000000..9409038505c98f1ff4ea9d95ad14e0b54894b8b2 GIT binary patch literal 416 zcmV;R0bl-!P)H zK~y-)txd&SB=vx$LSk^S9rB)$b3PDKn=(5i)Zcv2bq-^bkk5sj6=s zR8=zb0Ul$GuT=&1hC!xAzQRdnuBxh&S2$_CqlUdB$xK!CBO<tg(;hIK(47!zJE#a$n(YltJXSi5%ih6S%-xRc%J{wg>-I z(|Co!u+uj71wP^_4kBV*RkwZrZ4>*cUNyrmafS~#zzf`uh)-3ubdfO!6P~nFy=#VT zT5pBdc#C6PSJeWmVV$Lg-hU@*7D20000< KMNUMnLSTZwb*=LN literal 0 HcmV?d00001 diff --git a/bigbluebutton-client/branding/default/style/css/assets/images/status_success_16px.png b/bigbluebutton-client/branding/default/style/css/assets/images/status_success_16px.png new file mode 100644 index 0000000000000000000000000000000000000000..89ed57c06f9256700b7bdc8f403e466c41174aef GIT binary patch literal 487 zcmVSV&ekSio`rcKD?!resfNpZ=iYmUf&Z!5Y82gYkGwtJT8Yi7}o^dIQ{%^jXqR0Ofg3 zv)N?1T<-RAck(<(5@lIpW@o@_;I5>nDWwu1#t0#V{ZMY!CUxD+ZkySAGrNj0T75Uh z2=F_^5W)#?U(zGs(%rw+Fz^yM2cElos^OFp0L`soCFuun4|ru}7m_wrRlNYtC0(X1 zVP-oRppj)6Wm#@Ioz5rVG0+D-R8{q^?wnFu)}7t`TF@th!GK<`$6~QywOW1c_xoRf zhrpSnXTBx&$KF?CKA+R=c6Xsk`Y7pvq>FaDT^<_ypoYWY&SW~BQWQmFKkcJGOO|E) d`BeW@zX0uQf-N~RL!1Br002ovPDHLkV1nL?)y@C_ literal 0 HcmV?d00001 diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index 4853b25dc3..117991bf6c 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -354,6 +354,9 @@ bbb.toolbar.video.toolTip.start = Share Your Webcam bbb.toolbar.video.toolTip.stop = Stop Sharing Your Webcam bbb.toolbar.video.unknownCameraName = Unknown Device bbb.layout.addButton.toolTip = Add the custom layout to the list +bbb.layout.confirmOverwrite.toolTip = Confirm overwriting of the layout +bbb.layout.denyOverwrite.toolTip = Deny overwriting of the layout +bbb.layout.overwriteText = Name already in use. Do you want to overwrite? bbb.layout.broadcastButton.toolTip = Apply Current Layout to All Viewers bbb.layout.combo.toolTip = Change Your Layout bbb.layout.loadButton.toolTip = Load layouts from a file diff --git a/bigbluebutton-client/locale/pt_BR/bbbResources.properties b/bigbluebutton-client/locale/pt_BR/bbbResources.properties index af45603ebd..148ce500d5 100755 --- a/bigbluebutton-client/locale/pt_BR/bbbResources.properties +++ b/bigbluebutton-client/locale/pt_BR/bbbResources.properties @@ -354,6 +354,9 @@ bbb.toolbar.video.toolTip.start = Transmitir sua câmera bbb.toolbar.video.toolTip.stop = Interromper compartilhamento da sua câmera bbb.toolbar.video.unknownCameraName = Dispositivo desconhecido bbb.layout.addButton.toolTip = Adicionar layout atual à lista +bbb.layout.confirmOverwrite.toolTip = Confirmar sobrescrita do layout +bbb.layout.denyOverwrite.toolTip = Negar sobrescrita do layout +bbb.layout.overwriteText = O nome já está em uso. Você quer sobrescrever? bbb.layout.broadcastButton.toolTip = Aplicar layout atual a todos os participantes bbb.layout.combo.toolTip = Modificar seu layout bbb.layout.loadButton.toolTip = Carregar layouts de um arquivo diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutEvent.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutEvent.as index 181f9db2a3..899935df15 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutEvent.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutEvent.as @@ -37,6 +37,7 @@ package org.bigbluebutton.modules.layout.events public static const INVALIDATE_LAYOUT_EVENT:String = 'INVALIDATE_LAYOUT_EVENT'; public var layoutName:String = ""; + public var overwrite:Boolean = false; public function LayoutEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutNameInUseEvent.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutNameInUseEvent.as new file mode 100644 index 0000000000..d7bccf6917 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/events/LayoutNameInUseEvent.as @@ -0,0 +1,37 @@ +/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). +* +* This program is free software; you can redistribute it and/or modify it under the +* terms of the GNU Lesser General Public License as published by the Free Software +* Foundation; either version 3.0 of the License, or (at your option) any later +* version. +* +* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along +* with BigBlueButton; if not, see . +* +*/ +package org.bigbluebutton.modules.layout.events +{ + import flash.events.Event; + import org.bigbluebutton.modules.layout.model.LayoutDefinitionFile; + + public class LayoutNameInUseEvent extends Event + { + public static const LAYOUT_NAME_IN_USE_EVENT:String = "LAYOUT_NAME_IN_USE_EVENT"; + + public var inUse:Boolean = false; + + public function LayoutNameInUseEvent(type:String = LAYOUT_NAME_IN_USE_EVENT) + { + trace("Layout name is already in use: Ask user if should overwrite"); + super(type,true,false); + } + + } +} 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 71eb03e177..ffcdde5e06 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/managers/LayoutManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/managers/LayoutManager.as @@ -19,6 +19,11 @@ package org.bigbluebutton.modules.layout.managers { import com.asfusion.mate.events.Dispatcher; + import flash.display.DisplayObject; + import mx.core.FlexGlobals; + import mx.core.IFlexDisplayObject; + import mx.managers.PopUpManager; + import org.bigbluebutton.util.i18n.ResourceUtil; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.TimerEvent; @@ -48,6 +53,7 @@ package org.bigbluebutton.modules.layout.managers import org.bigbluebutton.modules.layout.events.LockLayoutEvent; import org.bigbluebutton.modules.layout.events.LayoutFromRemoteEvent; import org.bigbluebutton.modules.layout.events.RemoteSyncLayoutEvent; + import org.bigbluebutton.modules.layout.events.LayoutNameInUseEvent; import org.bigbluebutton.modules.layout.events.SyncLayoutEvent; import org.bigbluebutton.modules.layout.model.LayoutDefinition; import org.bigbluebutton.modules.layout.model.LayoutDefinitionFile; @@ -55,6 +61,7 @@ package org.bigbluebutton.modules.layout.managers import org.bigbluebutton.modules.layout.model.LayoutModel; import org.bigbluebutton.modules.layout.model.WindowLayout; import org.bigbluebutton.util.i18n.ResourceUtil; + import org.bigbluebutton.modules.layout.views.OverwriteWindow; public class LayoutManager extends EventDispatcher { private static const LOG:String = "Layout::LayoutManager - "; @@ -135,17 +142,45 @@ package org.bigbluebutton.modules.layout.managers loader.loadFromLocalFile(); } - public function addCurrentLayoutToList(layoutName:String):void { + public function addCurrentLayoutToList(e:LayoutEvent):void { // Layout Name Window Popup calls this function var newLayout:LayoutDefinition; - if (layoutName != "") { - newLayout = LayoutDefinition.getLayout(_canvas, layoutName); + if (e.layoutName != "") { + newLayout = LayoutDefinition.getLayout(_canvas, e.layoutName); + + // This is true when the name given is already in use + // Or when the user picks a name from their preferred location + if(_layoutModel.hasLayout(e.layoutName)|| + e.layoutName == ResourceUtil.getInstance().getString('bbb.layout.name.defaultlayout')|| + e.layoutName == ResourceUtil.getInstance().getString('bbb.layout.name.videochat')|| + e.layoutName == ResourceUtil.getInstance().getString('bbb.layout.name.webcamsfocus')|| + e.layoutName == ResourceUtil.getInstance().getString('bbb.layout.name.presentfocus')){ + + if(!e.overwrite){ + var nameAlreadyInUse:LayoutNameInUseEvent = new LayoutNameInUseEvent(); + nameAlreadyInUse.inUse = true; + _globalDispatcher.dispatchEvent(nameAlreadyInUse); + + var overwriteWindow:OverwriteWindow; + overwriteWindow = OverwriteWindow(PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, OverwriteWindow, true)); + PopUpManager.centerPopUp(overwriteWindow); + overwriteWindow.layoutNameOverwrite = e.layoutName; + + return; + } + if(e.overwrite){ + _layoutModel.removeLayout(newLayout); + } + + } + } else { // if the user set the name empty newLayout = LayoutDefinition.getLayout(_canvas, ResourceUtil.getInstance().getString('bbb.layout.combo.customName')); newLayout.name += " " + (++_customLayoutsCount); } + _layoutModel.addLayout(newLayout); updateCurrentLayout(newLayout); broadcastLayouts(); @@ -155,6 +190,10 @@ package org.bigbluebutton.modules.layout.managers // this is to force LayoutCombo to update the current label redefineLayout.remote = true; _globalDispatcher.dispatchEvent(redefineLayout); + //EVENTO QUE FAZ FECHAR + var nameNotInUse:LayoutNameInUseEvent = new LayoutNameInUseEvent(); + nameNotInUse.inUse = false; + _globalDispatcher.dispatchEvent(nameNotInUse); } public function setCanvas(canvas:MDICanvas):void { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/maps/LayoutEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/maps/LayoutEventMap.mxml index a7328784a0..9e90e8935c 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/maps/LayoutEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/maps/LayoutEventMap.mxml @@ -122,7 +122,7 @@ with BigBlueButton; if not, see . - + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinitionFile.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinitionFile.as index 24d6bdb544..653d8de635 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinitionFile.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutDefinitionFile.as @@ -55,7 +55,16 @@ package org.bigbluebutton.modules.layout.model public function push(layoutDefinition:LayoutDefinition):void { _layouts.push(layoutDefinition); } + + public function splice(position:int):void{ + _layouts.splice(position,1); + } + public function indexOf(layoutDefinition:LayoutDefinition):int{ + return _layouts.indexOf(layoutDefinition); + } + + public function getDefault():LayoutDefinition { for each (var value:LayoutDefinition in _layouts) { if (value.defaultLayout) diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutModel.as b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutModel.as index e5b28b6bb9..466e1daa02 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/model/LayoutModel.as @@ -47,6 +47,10 @@ package org.bigbluebutton.modules.layout.model public function addLayout(layout: LayoutDefinition):void { _layouts.push(layout); } + + public function removeLayout(layout: LayoutDefinition):void{ + _layouts.splice(_layouts.indexOf(layout)); + } public function getLayoutNames():Array { if (_layouts == null) return new Array(); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/CustomLayoutNameWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/CustomLayoutNameWindow.mxml index 810ce21849..da52b472ce 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/CustomLayoutNameWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/CustomLayoutNameWindow.mxml @@ -30,14 +30,20 @@ with BigBlueButton; if not, see . width="250" title="{ResourceUtil.getInstance().getString('bbb.layout.window.name')}"> + + . } var dispatcher:Dispatcher = new Dispatcher(); dispatcher.dispatchEvent(e); + } - PopUpManager.removePopUp(this); + private function handleLayoutNameInUse(event:LayoutNameInUseEvent):void { + if(!event.inUse){ + PopUpManager.removePopUp(this); + }else{ + trace("The name is already in use, waiting for overwrite command or rename"); + } } private function onCreationComplete():void { @@ -64,4 +76,5 @@ with BigBlueButton; if not, see . + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/OverwriteWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/OverwriteWindow.mxml new file mode 100644 index 0000000000..68a66e4802 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/layout/views/OverwriteWindow.mxml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + +