source: ComponentRegistry/trunk/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/components/HighlightSelectionItemRenderer.as @ 288

Last change on this file since 288 was 288, checked in by patdui, 14 years ago
  • using Label as the default ItemRenderer? fixes all tooltip problems
  • Added Cardinality edit override on referenced Components
File size: 1.1 KB
Line 
1package clarin.cmdi.componentregistry.common.components {
2        import mx.controls.Label;
3
4        public class HighlightSelectionItemRenderer extends Label {
5
6                private static const OPEN_TAG:String = "<b>";
7                private static const CLOSE_TAG:String = "</b>";
8
9
10                public function HighlightSelectionItemRenderer() {
11                        super();
12                }
13
14                override public function set text(value:String):void {
15                        var highlight:Boolean = false;
16                        if (listData && listData.owner is FilteringDataGrid) {
17                                var _grid:FilteringDataGrid = listData.owner as FilteringDataGrid;
18                                var searchText:String = _grid.searchText;
19                                if (searchText != null && searchText.length > 0) {
20                                        var index:int = _grid.getIndexOfMatch(value, searchText);
21                                        if (index != -1) {
22                                                value = highlightMatch(value, searchText.length, index);
23                                                highlight = true;
24                                        }
25                                }
26                        }
27                        if (highlight) {
28                                super.htmlText = value;
29                        } else {
30                                super.text = value;
31                        }
32                }
33
34                private function highlightMatch(value:String, len:int, index:int):String {
35                        return value.substr(0, index).concat(OPEN_TAG, value.substr(index, len), CLOSE_TAG, value.substr(index + len));
36                }
37
38
39        }
40}
41
Note: See TracBrowser for help on using the repository browser.