Index: lams_central/web/lams_authoring.swf =================================================================== diff -u -r04425a2cd9dd2555c09c36a7988fdc0c728fcb8a -r36ff08f56e379e802a469ff880b947b2d36c6908 Binary files differ Index: lams_central/web/lams_authoring_library.swf =================================================================== diff -u -r656a20d4a2f71279ce04fa6aff8b13989e150395 -r36ff08f56e379e802a469ff880b947b2d36c6908 Binary files differ Index: lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/cv/ValidationIssuesDialog.as =================================================================== diff -u -rd7823922f404944822957e6c051bc0f1335a76de -r36ff08f56e379e802a469ff880b947b2d36c6908 --- lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/cv/ValidationIssuesDialog.as (.../ValidationIssuesDialog.as) (revision d7823922f404944822957e6c051bc0f1335a76de) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/authoring/cv/ValidationIssuesDialog.as (.../ValidationIssuesDialog.as) (revision 36ff08f56e379e802a469ff880b947b2d36c6908) @@ -1,184 +1,208 @@ -/*************************************************************************** - * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) - * ============================================================= - * License Information: http://lamsfoundation.org/licensing/lams/2.0/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2.0 - * as published by the Free Software Foundation. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * http://www.gnu.org/licenses/gpl.txt - * ************************************************************************ - */ - -import org.lamsfoundation.lams.authoring.cv.*; -import org.lamsfoundation.lams.authoring.*; -import org.lamsfoundation.lams.common.util.* -import org.lamsfoundation.lams.common.dict.* -import org.lamsfoundation.lams.common.style.* -import org.lamsfoundation.lams.common.ui.* -import org.lamsfoundation.lams.common.* - -import mx.controls.* -import mx.utils.* -import mx.managers.* -import mx.events.* - -/* -* -* @author DC -* @version 0.1 -* @comments Shows validation issues in a datagrid -* -*/ -class org.lamsfoundation.lams.authoring.cv.ValidationIssuesDialog extends MovieClip{ - - private var MARGIN = 5; - private var _canvasModel:CanvasModel; - private var _canvasController:CanvasController; - private var _validationIssues:Object; - - //References to components + clips - private var _container:MovieClip; //The container window that holds the dialog. Will contain any init params that were passed into createPopUp - - private var validationIssues_dgd:DataGrid; - private var done_btn:Button; - - private var fm:FocusManager; - private var _tm:ThemeManager; - private var toolDisplayName_lbl:Label; - - - //Defined so compiler can 'see' events added at runtime by EventDispatcher - private var dispatchEvent:Function; - public var addEventListener:Function; - public var removeEventListener:Function; - - - /** - * Constructor - */ - function ValidationIssuesDialog(){ - Debugger.log('Constructor',Debugger.GEN,'ValidationIssuesDialog','ValidationIssuesDialog'); - _tm = ThemeManager.getInstance(); - //Set up this class to use the Flash event delegation model - EventDispatcher.initialize(this); - - //let it wait one frame to set up the components. - MovieClipUtils.doLater(Proxy.create(this,init)); - - } - - public function init():Void{ - _canvasModel = _container.canvasModel; - _canvasController = _container.canvasController; - _validationIssues = _container.validationIssues; - - _canvasModel.addEventListener('viewUpdate',this); - - _container.addEventListener('click',this); - //get focus manager + set focus , focus manager is available to all components through getFocusManager - fm = _container.getFocusManager(); - fm.enabled = true; - validationIssues_dgd.setFocus(); - - setStyles(); - done_btn.label = Dictionary.getValue('ld_val_done'); - - //set up handlers - //TODO connect to the controller - validationIssues_dgd.addEventListener("change",this); - done_btn.addEventListener("click",this); - - //set the 1st colum a bit smaller - validationIssues_dgd.dataProvider = _validationIssues; - validationIssues_dgd.removeAllColumns(); - - validationIssues_dgd.columnNames = ["Activity", "Issue"]; - - validationIssues_dgd.getColumnAt(0).headerText = Dictionary.getValue("ld_val_activity_column"); - validationIssues_dgd.getColumnAt(0).width = 110; - - validationIssues_dgd.getColumnAt(1).headerText = Dictionary.getValue("ld_val_issue_column"); - - //fire event to say we have loaded - _container.contentLoaded(); - } - - - - - /** - * Main resize method, called by scrollpane container/parent - */ - public function setSize(w:Number,h:Number){ - //Debugger.log('setSize',Debugger.GEN,'setSize','org.lamsfoundation.lams.common.ws.WorkspaceDialog'); - //Size the bkg_pnl - - // body_pnl.setSize(w,h-bar_pnl.height); - // bar_pnl.setSize(w); - - validationIssues_dgd.setSize(w,h - (done_btn._height + MARGIN*2)); - done_btn._x = (w - done_btn._width) - MARGIN; - done_btn._y = h - (done_btn._height + MARGIN); - - - } - - /** - * Get the CSSStyleDeclaration objects for each component and applies them - * directly to the instanced - * @usage - * @return - */ - private function setStyles() { - - var styleObj = _tm.getStyleObject('button'); - done_btn.setStyle('styleName',styleObj); - styleObj = _tm.getStyleObject('datagrid'); - validationIssues_dgd.setStyle(styleObj); - - - } - - //Gets+Sets - /** - * set the container refernce to the window holding the dialog - */ - public function set container(value:MovieClip){ - _container = value; - } - - - - /** - * Recieves the click events from the canvas views (inc Property Inspector) buttons. Based on the target - * the relevent method is called to action the user request - * @param evt - */ - /**/ - public function click(e):Void{ - var tgt:String = new String(e.target); - Debugger.log('click tgt:'+tgt,Debugger.GEN,'click','ValidationIssuesDialog'); - _container.deletePopUp(); - } - - public function change(e):Void{ - //Debugger.log(ObjectUtils.toString(e.target.selectedItem),Debugger.GEN,'change','ValidationIssuesDialog'); - Debugger.log('e.target.selectedItem.data.uiid:'+e.target.selectedItem.uiid,Debugger.GEN,'change','ValidationIssuesDialog'); - _canvasModel.setSelectedItemByUIID(e.target.selectedItem.uiid); - } - - -} - +/*************************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.authoring.cv.*; +import org.lamsfoundation.lams.authoring.*; +import org.lamsfoundation.lams.common.util.* +import org.lamsfoundation.lams.common.dict.* +import org.lamsfoundation.lams.common.style.* +import org.lamsfoundation.lams.common.ui.* +import org.lamsfoundation.lams.common.* + +import mx.controls.* +import mx.controls.gridclasses.DataGridColumn; +import mx.utils.* +import mx.managers.* +import mx.events.* + +/* +* +* @author DC +* @version 0.1 +* @comments Shows validation issues in a datagrid +* +*/ +class org.lamsfoundation.lams.authoring.cv.ValidationIssuesDialog extends MovieClip{ + + private var MARGIN = 5; + private var _canvasModel:CanvasModel; + private var _canvasController:CanvasController; + private var _validationIssues:Object; + + //References to components + clips + private var _container:MovieClip; //The container window that holds the dialog. Will contain any init params that were passed into createPopUp + + private var validationIssues_dgd:DataGrid; + private var done_btn:Button; + + private var fm:FocusManager; + private var _tm:ThemeManager; + private var toolDisplayName_lbl:Label; + + //Defined so compiler can 'see' events added at runtime by EventDispatcher + private var dispatchEvent:Function; + public var addEventListener:Function; + public var removeEventListener:Function; + + + /** + * Constructor + */ + function ValidationIssuesDialog(){ + Debugger.log('Constructor',Debugger.GEN,'ValidationIssuesDialog','ValidationIssuesDialog'); + _tm = ThemeManager.getInstance(); + //Set up this class to use the Flash event delegation model + EventDispatcher.initialize(this); + + //let it wait one frame to set up the components. + MovieClipUtils.doLater(Proxy.create(this,init)); + + } + + public function init():Void { + //Delete the enterframe dispatcher + delete this.onEnterFrame; + + _canvasModel = _container.canvasModel; + _canvasController = _container.canvasController; + _validationIssues = _container.validationIssues; + + _canvasModel.addEventListener('viewUpdate',this); + validationIssues_dgd.addEventListener("change",this); + + done_btn.label = Dictionary.getValue('ld_val_done'); + done_btn.addEventListener("click",this); + + //Assign Click (close button) and resize handlers + _container.addEventListener('click',this); + _container.addEventListener('size',this); + + // Should be called by canvasController? + setupContent(); + } + + public function getRowHeight(column_value:DataGridColumn):Number { + var maxStrWidth:Number = 0; + for (var i = 0; i < _validationIssues.length; i++) { + maxStrWidth = Math.max(StringUtils.getButtonWidthForStr(_validationIssues[i].Issue), maxStrWidth); + } + + var numRows:Number = Math.ceil(maxStrWidth/(column_value.width-2*MARGIN)); + var lineHeight:Number; + if (numRows == 1) + lineHeight = 25; + else + lineHeight = 20; + + var _rowHeight:Number = numRows * lineHeight; + return _rowHeight; + } + + public function setupContent():Void { + var column_name:DataGridColumn = new DataGridColumn("Activity"); + column_name.headerText = Dictionary.getValue("ld_val_activity_column"); + column_name.editable = false; + column_name.width = Math.ceil((validationIssues_dgd.width - 15)*0.3); + column_name.cellRenderer = "MultiLineCell"; + + var column_value:DataGridColumn = new DataGridColumn("Issue"); + column_value.headerText = Dictionary.getValue("ld_val_issue_column"); + column_value.editable = false; + column_value.width = Math.ceil((validationIssues_dgd.width - 15)*0.7); + column_value.cellRenderer = "MultiLineCell"; + + validationIssues_dgd.rowHeight = getRowHeight(column_value); + + validationIssues_dgd.addColumn(column_name); + validationIssues_dgd.addColumn(column_value); + + // wait second frame for steppers to be setup + validationIssues_dgd.dataProvider = _validationIssues; + + _container.contentLoaded(); + + this.onEnterFrame = initSetup; + //validationIssues_dgd.setSize(validationIssues_dgd.) + setSize(_width, _height); + } + + private function initSetup():Void { + delete this.onEnterFrame; + + this._visible = true; + + } + + /** + * Main resize method, called by scrollpane container/parent + */ + public function setSize(w:Number,h:Number){ + + validationIssues_dgd.setSize(w,h - (done_btn._height + MARGIN*2)); + done_btn._x = (w - done_btn._width) - MARGIN; + done_btn._y = h - (done_btn._height + MARGIN); + + } + + /** + * Get the CSSStyleDeclaration objects for each component and applies them + * directly to the instanced + * @usage + * @return + */ + private function setStyles() { + + var styleObj = _tm.getStyleObject('button'); + done_btn.setStyle('styleName',styleObj); + styleObj = _tm.getStyleObject('datagrid'); + validationIssues_dgd.setStyle(styleObj); + } + + //Gets+Sets + /** + * set the container refernce to the window holding the dialog + */ + public function set container(value:MovieClip){ + _container = value; + } + + /** + * Recieves the click events from the canvas views (inc Property Inspector) buttons. Based on the target + * the relevent method is called to action the user request + * @param evt + */ + /**/ + public function click(e):Void{ + var tgt:String = new String(e.target); + Debugger.log('click tgt:'+tgt,Debugger.GEN,'click','ValidationIssuesDialog'); + _container.deletePopUp(); + } + + public function change(e):Void{ + Debugger.log('e.target.selectedItem.data.uiid:'+e.target.selectedItem.uiid,Debugger.GEN,'change','ValidationIssuesDialog'); + _canvasModel.setSelectedItemByUIID(e.target.selectedItem.uiid); + } + + +} + Index: lams_flash/src/common/flash/org/lamsfoundation/lams/common/ui/MultiLineCell.as =================================================================== diff -u --- lams_flash/src/common/flash/org/lamsfoundation/lams/common/ui/MultiLineCell.as (revision 0) +++ lams_flash/src/common/flash/org/lamsfoundation/lams/common/ui/MultiLineCell.as (revision 36ff08f56e379e802a469ff880b947b2d36c6908) @@ -0,0 +1,69 @@ +/*************************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.common.ApplicationParent; +import org.lamsfoundation.lams.common.util.Debugger; +import org.lamsfoundation.lams.common.util.ObjectUtils; +import org.lamsfoundation.lams.common.util.StringUtils; +import mx.controls.DataGrid; +import mx.controls.Label; + +class org.lamsfoundation.lams.common.ui.MultiLineCell extends mx.core.UIComponent +{ + var multiLineLabel; + var owner; // row that contains the cell + var listOwner; // List that contains the cell + + function MultiLineCell() { + } + + function createChildren():Void { + var c = multiLineLabel = createLabel("multiLineLabel", 10); + c.styleName = listOwner; + c.selectable = false; + c.tabEnabled = false; + c.border = false; + c.multiline = true; + c.wordWrap = true; + } + + function size():Void { + var c = multiLineLabel; + + c._width = __width; + c._height = __height; + } + + function getPreferredHeight():Number { + return owner.__height - 4; + } + + function setValue(suggested:String, item:Object, selected:Boolean):Void { + multiLineLabel.text = suggested; + } + + function getPreferredWidth() { + return owner.__width; + } +} +