1 | /* SaveConfigBoardCommand.as */
|
---|
2 |
|
---|
3 | package gov.va.med.edp.command.config
|
---|
4 | {
|
---|
5 | import com.adobe.cairngorm.commands.ICommand;
|
---|
6 | import com.adobe.cairngorm.control.CairngormEvent;
|
---|
7 |
|
---|
8 | import gov.va.med.edp.business.config.SaveConfigBoardDelegate;
|
---|
9 | import gov.va.med.edp.command.AbstractResponderCommand;
|
---|
10 | import gov.va.med.edp.control.config.BoardConfigEvent;
|
---|
11 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
12 | import gov.va.med.edp.vo.ColumnSpecVO;
|
---|
13 | import gov.va.med.edp.widget.InfoDialog;
|
---|
14 | import gov.va.med.edp.util.BoardTools;
|
---|
15 | import gov.va.med.edp.factory.SessionFactory;
|
---|
16 | import gov.va.med.edp.util.Vista;
|
---|
17 |
|
---|
18 | import mx.rpc.IResponder;
|
---|
19 | import mx.rpc.events.FaultEvent;
|
---|
20 | import mx.rpc.events.ResultEvent;
|
---|
21 |
|
---|
22 | public class SaveConfigBoardCommand extends AbstractResponderCommand implements ICommand, IResponder
|
---|
23 | {
|
---|
24 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
25 |
|
---|
26 | public function execute(event:CairngormEvent):void
|
---|
27 | {
|
---|
28 | var delegate: SaveConfigBoardDelegate = new SaveConfigBoardDelegate(this);
|
---|
29 | var saveEvent: BoardConfigEvent = BoardConfigEvent(event);
|
---|
30 |
|
---|
31 | var xml:XML = <spec />;
|
---|
32 | var row:XML = <row />;
|
---|
33 | row.@color = model.config.rowColorMap.id;
|
---|
34 | xml.appendChild(row);
|
---|
35 |
|
---|
36 | var displayProperties:XML = <displayProperties />;
|
---|
37 | displayProperties.@fontSize = model.config.displayBoardProperties.fontSize;
|
---|
38 | displayProperties.@displayWidth = model.config.displayBoardProperties.displaySize.width;
|
---|
39 | displayProperties.@displayHeight = model.config.displayBoardProperties.displaySize.height;
|
---|
40 | displayProperties.@displayLabel = model.config.displayBoardProperties.displaySize.label;
|
---|
41 | displayProperties.@scrollDelay = model.config.displayBoardProperties.scrollDelay;
|
---|
42 | displayProperties.@squish = model.config.displayBoardProperties.squish;
|
---|
43 | xml.appendChild(displayProperties);
|
---|
44 |
|
---|
45 | var colSpec: ColumnSpecVO;
|
---|
46 | for (var i:int = 0; i < model.config.columns.length; i++) {
|
---|
47 | colSpec = model.config.columns[i] as ColumnSpecVO;
|
---|
48 | var node:XML = <col />;
|
---|
49 | node.@att = colSpec.attribute;
|
---|
50 | node.@header = colSpec.header;
|
---|
51 | node.@color = (colSpec.colorMap != null) ? colSpec.colorMap.id : "";
|
---|
52 | node.@width = colSpec.width;
|
---|
53 | node.@label = colSpec.label;
|
---|
54 | xml.appendChild(node);
|
---|
55 | }
|
---|
56 | model.config.boardLoaded = false;
|
---|
57 | delegate.saveConfigBoard(model.logArea, saveEvent.boardID, saveEvent.boardName, model.config.boardToken, xml);
|
---|
58 | }
|
---|
59 |
|
---|
60 | public override function result(data:Object):void
|
---|
61 | {
|
---|
62 | var xml:XML = ResultEvent(data).result as XML;
|
---|
63 |
|
---|
64 | if ((xml.save.@status == "ok")|| (xml.save.@status == "collide")) {
|
---|
65 | BoardTools.applyBoardSpec(model.config, xml);
|
---|
66 | model.config.boardLoaded = true;
|
---|
67 |
|
---|
68 | if (xml.save.@status == "ok") {
|
---|
69 | InfoDialog.show("New board colors saved.");
|
---|
70 | } else {
|
---|
71 | InfoDialog.show("Save failed: " + xml.save);
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | if (xml.save.@status == "fail") {
|
---|
76 | InfoDialog.show("Save failed: " + xml.save);
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | protected override function getFaultMessage(faultEvent:FaultEvent):String {
|
---|
81 | return "Error saving configuration for display board: " + super.getFaultMessage(faultEvent);
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|