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
This commit is contained in:
RafaFP 2016-01-27 21:51:41 +00:00
parent a340103fad
commit 480df6e90b
13 changed files with 200 additions and 5 deletions

View File

@ -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');
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

View File

@ -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

View File

@ -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

View File

@ -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)
{

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
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);
}
}
}

View File

@ -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 {

View File

@ -122,7 +122,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
</EventHandlers>
<EventHandlers type="{LayoutEvent.ADD_CURRENT_LAYOUT_EVENT}">
<MethodInvoker generator="{LayoutManager}" method="addCurrentLayoutToList" arguments="{event.layoutName}"/>
<MethodInvoker generator="{LayoutManager}" method="addCurrentLayoutToList" arguments="{event}"/>
</EventHandlers>
<EventHandlers type="{EventConstants.SWITCH_LAYOUT_REQ}">

View File

@ -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)

View File

@ -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();

View File

@ -30,14 +30,20 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
width="250"
title="{ResourceUtil.getInstance().getString('bbb.layout.window.name')}">
<mate:Listener type="{LayoutNameInUseEvent.LAYOUT_NAME_IN_USE_EVENT}" method="handleLayoutNameInUse"/>
<mx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import mx.managers.PopUpManager;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.util.i18n.ResourceUtil;
import org.bigbluebutton.modules.layout.events.LayoutEvent;
import org.bigbluebutton.modules.layout.events.LayoutNameInUseEvent;
private function addButton_clickHandler():void {
var e:LayoutEvent = new LayoutEvent(LayoutEvent.ADD_CURRENT_LAYOUT_EVENT);
@ -46,8 +52,14 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
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 <http://www.gnu.org/licenses/>.
<mx:TextInput id="textInput" restrict="a-zA-Z0-9 " maxChars="32" width="100%" text="{ResourceUtil.getInstance().getString('bbb.layout.combo.customName')}"/>
<mx:Button id="addButton" click="addButton_clickHandler()" enabled="{textInput.text.length > 0}" styleName="addLayoutButtonStyle" toolTip="{ResourceUtil.getInstance().getString('bbb.layout.addButton.toolTip')}"/>
</mx:HBox>
</mx:TitleWindow>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
Copyright (c) 2015 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 <http://www.gnu.org/licenses/>.
-->
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:mate="http://mate.asfusion.com/"
verticalScrollPolicy="off"
horizontalScrollPolicy="off"
horizontalAlign="center"
showCloseButton="true"
close="onCancelClicked()"
creationComplete="onCreationComplete()"
height="90"
width="300"
title="Overwrite Window">
<mx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import mx.managers.PopUpManager;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.util.i18n.ResourceUtil;
import org.bigbluebutton.modules.layout.events.LayoutEvent;
public var layoutNameOverwrite:String = "Overwrite Layout"
private function addButton_clickHandler():void {
var e:LayoutEvent = new LayoutEvent(LayoutEvent.ADD_CURRENT_LAYOUT_EVENT);
e.layoutName = layoutNameOverwrite;
e.overwrite = true;
var dispatcher:Dispatcher = new Dispatcher();
dispatcher.dispatchEvent(e);
PopUpManager.removePopUp(this);
}
private function cancelButton_clickHandler():void{
PopUpManager.removePopUp(this);
}
private function onCreationComplete():void {
cancelButton.setFocus();
}
private function onCancelClicked():void {
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<mx:Text text="{ResourceUtil.getInstance().getString('bbb.layout.overwriteText')}" width="100%" height="100%" />
<mx:Button id="cancelButton" click="cancelButton_clickHandler()" enabled="true" styleName="overwriteLayoutDenyStyle" toolTip="{ResourceUtil.getInstance().getString('bbb.layout.denyOverwrite.toolTip')}"/>
<mx:Button id="addButton" click="addButton_clickHandler()" enabled="true" styleName="overwriteLayoutConfirmStyle" toolTip="{ResourceUtil.getInstance().getString('bbb.layout.confirmOverwrite.toolTip')}"/>
</mx:HBox>
</mx:TitleWindow>