source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/widget/InfoDialog.mxml@ 1227

Last change on this file since 1227 was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 3.9 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:widget="gov.va.med.edp.widget.*" paddingTop="0"
3 borderThicknessTop="0" creationComplete="creationCompleteHandler()" keyDown="disposeOnEscape(event)"
4 minWidth="240" minHeight="140" horizontalAlign="center" verticalAlign="top" layout="vertical"
5 defaultButton="{closeBtn}"
6 xmlns:accessibility="flash.accessibility.*">
7 <mx:Script>
8 <![CDATA[
9 import gov.va.med.edp.util.AccessibilityTools;
10 import gov.va.med.edp.control.ModalDialogEvent;
11 import mx.events.CloseEvent;
12 import mx.accessibility.ComboBoxAccImpl;
13 import mx.controls.ComboBox;
14 import mx.managers.FocusManager;
15 import flash.net.sendToURL;
16 import mx.core.Container;
17 import mx.core.UIComponent;
18 import mx.core.Application;
19 import mx.managers.PopUpManager;
20
21 [Bindable]
22 private var message : String;
23 [Bindable]
24 private var closeButtonLabel : String;
25 [Bindable]
26 private var selfDisposing : Boolean;
27 private var closeListener : Function = null;
28 [Bindable]
29 private var invoker : UIComponent;
30
31 public static function show(message:String,
32 title:String = "Alert",
33 selfDisposing:Boolean = false,
34 invokerComponent:UIComponent = null,
35 closeListener:Function = null,
36 closeButtonLabel:String = "Close") : void {
37 var dialog:InfoDialog = InfoDialog(PopUpManager.createPopUp(Application.application as DisplayObject, InfoDialog, true));
38 if (title != null && title.length > 0)
39 dialog.title = title;
40 dialog.closeButtonLabel = closeButtonLabel;
41 dialog.selfDisposing = selfDisposing;
42 dialog.message = message;
43 dialog.closeListener = closeListener;
44
45 dialog.invoker = invokerComponent;
46
47 //Dispatch the event for get clear background
48 Application.application.dispatchEvent(new ModalDialogEvent(ModalDialogEvent.OPEN));
49
50 PopUpManager.centerPopUp(dialog);
51
52 }
53
54 private function creationCompleteHandler() : void {
55 var focusTimer: Timer = new Timer(500, 1);
56 focusTimer.addEventListener(TimerEvent.TIMER, moveFocus);
57 focusTimer.start();
58
59 if (this.selfDisposing) {
60 var disposeTime: Timer = new Timer(800, 1);
61 disposeTime.addEventListener(TimerEvent.TIMER, autoDisposeDialog);
62 disposeTime.start();
63 accessibleMessage.name = this.title;
64 }
65
66
67 }
68
69 private function disposeDialog() : void {
70 if (closeListener != null) {
71 closeListener();
72 }
73
74 //Dispatch the event for remove clear background
75 Application.application.dispatchEvent(new ModalDialogEvent(ModalDialogEvent.CLOSE));
76 PopUpManager.removePopUp(this);
77
78 if (invoker != null) {
79 callLater(setInvokerComponentFocus);
80 }
81 }
82
83 private function setInvokerComponentFocus(): void
84 { // EVENT_OBJECT_SELECTION == 0x8006
85 Accessibility.sendEvent(invoker, 0, 0x8006);
86 invoker.setFocus();
87 }
88
89 private function moveFocus(e: TimerEvent): void
90 {
91 if (AccessibilityTools.isAccessibilityActive()) {
92 messageBox.setFocus();
93 } else {
94 messageBox.editable = false;
95 closeBtn.setFocus();
96 }
97 }
98
99 private function autoDisposeDialog(e: TimerEvent): void
100 {
101 disposeDialog();
102 }
103
104 public function disposeOnEscape(event:KeyboardEvent):void
105 {
106 if (event.keyCode == Keyboard.ESCAPE) {
107 disposeDialog();
108 }
109 }
110
111 ]]>
112 </mx:Script>
113
114 <accessibility:AccessibilityProperties name="Info Dialog {this.title}" id="accessibleMessage"/>
115
116
117 <mx:VBox id="contentBox" width="100%" height="100%">
118 <mx:TextArea restrict="*~_" id="messageBox" text="{message}" borderThickness="0" width="100%" height="100%"
119 focusEnabled="true" tabIndex="1" accessibilityProperties="{accessibleMessage}"/>
120 </mx:VBox>
121 <mx:ControlBar width="100%" horizontalAlign="right">
122 <mx:Button id="closeBtn" label="{closeButtonLabel}" click="disposeDialog()" tabIndex="5"/>
123 </mx:ControlBar>
124</mx:TitleWindow>
Note: See TracBrowser for help on using the repository browser.