Changeset 1152


Ignore:
Timestamp:
03/02/11 15:29:47 (13 years ago)
Author:
patdui
Message:

Ticket #99: added busy cursor and preventing repeatedly clicking the component

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/ExpandingComponentLabel.as

    r431 r1152  
    99        import clarin.cmdi.componentregistry.services.ComponentInfoService;
    1010        import clarin.cmdi.componentregistry.services.ComponentListService;
    11        
     11
    1212        import flash.display.DisplayObject;
    1313        import flash.events.MouseEvent;
    14        
     14
    1515        import mx.containers.VBox;
    1616        import mx.controls.Label;
     17        import mx.managers.CursorManager;
    1718
    1819        public class ExpandingComponentLabel extends VBox {
     
    2021                [Bindable]
    2122                public var isExpanded:Boolean = false;
     23                private var expandBusy:Boolean = false;
    2224
    2325                private var expanded:DisplayObject;
     
    3537                        styleName = StyleConstants.EXPANDING_COMPONENT;
    3638                        if (item && item.isInUserSpace) {
    37                             this.setStyle("borderColor", StyleConstants.USER_BORDER_COLOR);
     39                                this.setStyle("borderColor", StyleConstants.USER_BORDER_COLOR);
    3840                        }
    3941                }
     
    5557
    5658                private function handleClick(event:MouseEvent):void {
    57                         if (isExpanded) {
    58                                 unexpand();
    59                                 isExpanded = false;
    60                         } else {
    61                                 expand();
     59                        if (!expandBusy) {
     60                                expandStart();
     61                                try {
     62                                        if (isExpanded) {
     63                                                isExpanded = false;
     64                                                unexpand();
     65                                        } else {
     66                                                isExpanded = true;
     67                                                expand();
     68                                        }
     69                                } catch (err:Error) {
     70                                        trace(err);
     71                                        CursorManager.removeBusyCursor();
     72                                }
    6273                        }
     74                }
     75
     76                private function expandStart():void {
     77                        expandBusy = true;
     78                        CursorManager.setBusyCursor();
     79                }
     80
     81                private function expandFinished():void {
     82                        expandBusy = false;
     83                        CursorManager.removeBusyCursor();
    6384                }
    6485
     
    6788                        if (expanded != null) {
    6889                                removeChild(expanded);
     90                                expanded = null;
    6991                        }
     92                        expandFinished();
    7093                }
    7194
     
    84107                        (expanded as CMDSpecRenderer).cmdSpec = CMDModelFactory.createModel(comp.componentMD.xml, comp.description);
    85108                        addChild(expanded);
    86                         isExpanded = true;
     109                        expandFinished();
    87110                }
    88111
Note: See TracChangeset for help on using the changeset viewer.