DataGrid(dropTarget).selectedIndex)
dropLoc = dropLoc - 1;
if (dropLoc > IList(dropTarget.dataProvider).length - 1)
dropLoc = dropLoc - 1;
IList(dropTarget.dataProvider).removeItemAt(dropTarget.selectedIndex);
IList(dropTarget.dataProvider).addItemAt(items[i], dropLoc);
callLater(updateSelection, [dropLoc]);
} else {
IList(dropTarget.dataProvider).addItemAt(items[i], dropLoc);
}
}
}
private function updateSelection(index : int) : void
{
boardColumnsGrid.selectedIndex = index;
}
private function doDragExit(event:DragEvent):void
{
var dropTarget:DataGrid = DataGrid(event.currentTarget);
dropTarget.hideDropFeedback(event);
}
private function keyHandler(event:KeyboardEvent): void
{
if (!KeyUtils.isRemoveKey(event)) return;
if (boardColumnsGrid.editable && boardColumnsGrid.editedItemPosition != null) return;
if (KeyUtils.isRemoveKey(event)) removeSelectedColumnsFromGrid();
if (event.keyCode == Keyboard.ESCAPE) {
boardColumnsGrid.selectedIndex = -1;
btnSaveBoard.setFocus();
}
}
private function removeSelectedColumnsFromGrid(): void
{
if (boardColumnsGrid.selectedItems != null && boardColumnsGrid.selectedItems.length > 0) {
for each (var item:ColumnSpecVO in boardColumnsGrid.selectedItems) {
removeColumn(item);
}
}
}
// update columns -------------------------------------------------
private function addColumn(selectedItem: ColumnSpecVO): void
{
if (selectedItem == null) return;
var addEvent: ConfigAddColumnEvent =
new ConfigAddColumnEvent(ConfigAddColumnEvent.EVENT_CONFIG_ADD_COLUMN);
addEvent.data = selectedItem;
addEvent.dispatch();
model.config.availableColumns.refresh();
if (AccessibilityTools.isAccessibilityActive()) InfoDialog.show("Added successfully", "Message", true, addColumnSelector);
}
private function removeColumn(selectedItem: ColumnSpecVO): void
{
if (selectedItem == null) return;
var removeEvent: ConfigRemoveColumnEvent =
new ConfigRemoveColumnEvent(ConfigRemoveColumnEvent.EVENT_CONFIG_REMOVE_COLUMN);
removeEvent.data = selectedItem;
removeEvent.dispatch();
model.config.availableColumns.refresh();
if (AccessibilityTools.isAccessibilityActive()) InfoDialog.show("Removed successfully", "Message", true, boardColumnsGrid);
}
private function changeBoardName():void {
var newBoardName: String = boardNameInput.text;
if (newBoardName != model.config.boards[model.config.boardIndex].label) {
boardList.selectedItem.label = newBoardName;
new ConfigurationEvent(ConfigurationEvent.EVENT_BOARD_MODIFIED).dispatch()
}
}
private function changeColumnSequence(event: IndexChangedEvent): void
{
var changeEvent: ConfigChangeColumnEvent =
new ConfigChangeColumnEvent(ConfigChangeColumnEvent.EVENT_CONFIG_CHANGE_COLUMN_SEQ);
changeEvent.oldIndex = event.oldIndex;
changeEvent.newIndex = event.newIndex;
changeEvent.dispatch();
}
private function changeColumnWidth(event: DataGridEvent): void
{
var changeEvent: ConfigChangeColumnEvent =
new ConfigChangeColumnEvent(ConfigChangeColumnEvent.EVENT_CONFIG_CHANGE_COLUMN_WIDTH);
changeEvent.widths = [];
for (var i: int = 0; i < preview.columns.length; i++) {
changeEvent.widths.push(DataGridColumn(preview.columns[i]).width);
}
changeEvent.dispatch();
}
private function changeRowColor(): void
{
var changeEvent: ConfigChangeColumnEvent =
new ConfigChangeColumnEvent(ConfigChangeColumnEvent.EVENT_CONFIG_CHANGE_ROW_COLOR);
var colorMap: ColorMapVO = rowColor.selectedItem as ColorMapVO;
changeEvent.rowColor = (colorMap != null) ? colorMap.id : "";
changeEvent.dispatch();
}
// update display properties --------------------------------------
private function changeDisplayBoardWidth(): void
{
var changeEvent: ConfigChangeDisplayBoardPropertiesEvent =
new ConfigChangeDisplayBoardPropertiesEvent(ConfigChangeDisplayBoardPropertiesEvent.EVENT_CONFIG_CHANGE_DISPLAY_WIDTH);
var displayWidth: DisplaySizeVO = displaySizeCmb.selectedItem as DisplaySizeVO;
changeEvent.displaySize = displayWidth;
changeEvent.dispatch();
}
private function changeDisplayBoardFontSize(): void
{
var changeEvent: ConfigChangeDisplayBoardPropertiesEvent =
new ConfigChangeDisplayBoardPropertiesEvent(ConfigChangeDisplayBoardPropertiesEvent.EVENT_CONFIG_CHANGE_FONT_SIZE);
var fontSize: int = fntSizeNmStepper.value;
changeEvent.fontSize = fontSize;
changeEvent.dispatch();
for each (var gridColumn:DataGridColumn in preview.columns) {
gridColumn.setStyle("fontSize", fontSize);
}
}
private function changeDisplayBoardScrollDelay(): void
{
var changeEvent: ConfigChangeDisplayBoardPropertiesEvent =
new ConfigChangeDisplayBoardPropertiesEvent(ConfigChangeDisplayBoardPropertiesEvent.EVENT_CONFIG_CHANGE_SCROLL_DELAY);
var scrollDelay: int = ScrollDlyNmStepper.value;
changeEvent.scrollDelay = scrollDelay;
changeEvent.dispatch();
}
private function changeDisplayBoardSquish(): void
{
// prevent setting boardMods during initialization of checkbox
if (model.config.boardLoaded == false) return;
var changeEvent: ConfigChangeDisplayBoardPropertiesEvent =
new ConfigChangeDisplayBoardPropertiesEvent(ConfigChangeDisplayBoardPropertiesEvent.EVENT_CONFIG_CHANGE_SQUISH);
changeEvent.squish = squishChkBox.selected;
changeEvent.dispatch();
}
// label function for color maps
private function showColorMapName(item: Object, column: DataGridColumn): String
{
var c: ColumnSpecVO = item as ColumnSpecVO;
if ((c != null) && (c.colorMap != null)) {
return c.colorMap.name;
} else {
return "";
}
}
private function changeColumnHeader(): void {
if (headerInput.text != boardColumnsGrid.selectedItem.header) {
boardColumnsGrid.selectedItem.header = headerInput.text;
}
}
private function changeColumnColor(): void {
if (boardColumnsGrid.selectedItem.colorMap != columnColor.selectedItem) {
boardColumnsGrid.selectedItem.colorMap = columnColor.selectedItem;
}
}
private function changeColumnSequenceText(): void {
var currentIndex:int = boardColumnsGrid.selectedIndex;
var newIndex:int = int(columnOrderInput.text) - 1;
if (newIndex < 0 || newIndex >= boardColumns.length) return;
if (newIndex != currentIndex) {
boardColumnsGrid.selectedIndex = -1;
var changeEvent: ConfigChangeColumnEvent =
new ConfigChangeColumnEvent(ConfigChangeColumnEvent.EVENT_CONFIG_CHANGE_COLUMN_SEQ);
changeEvent.oldIndex = currentIndex;
changeEvent.newIndex = newIndex;
changeEvent.dispatch();
callLater(updateSelection, [newIndex]);
callLater(columnOrderInput.setFocus);
}
}
private function changeColumnWidthText(): void {
var currentWidth:int = 0;
var newWidth:int = int(widthInput.text);
resizeColumn(preview, boardColumnsGrid.selectedIndex, newWidth);
}
/**
* @private
* If there is no horizontal scroll bar, changes the display width of other columns when
* one column's width is changed.
* @param col column whose width is changed
* @param w width of column
*/
private function resizeColumn(grid:DataGrid, col:int, w:Number):void
{
if (col < 0 || col >= grid.columns.length - 1) // no resize of right most column
return;
if (w < grid.columns[col].minWidth)
w = grid.columns[col].minWidth;
// find the columns in the set of visible columns;
var n:int = grid.columns.length;
var i:int = col;
// we want all cols's new widths to the right of this to be in proportion
// to what they were before the stretch.
// get the original space to the right not taken up by the column
var totalSpace:Number = 0;
var lastColumn:DataGridColumn;
var newWidth:Number;
//non-resizable columns don't count though
for (i = col + 1; i < n; i++)
{
if (grid.columns[i].visible)
if (grid.columns[i].resizable)
totalSpace += grid.columns[i].width;
}
var newTotalSpace:Number = grid.columns[col].width - w + totalSpace;
if (totalSpace)
{
grid.columns[col].width = w;
}
var totX:Number = 0;
// resize the columns to the right proportionally to what they were
for (i = col + 1; i < n; i++)
{
if (grid.columns[i].visible)
if (grid.columns[i].resizable)
{
newWidth = Math.floor(grid.columns[i].width
* newTotalSpace / totalSpace);
if (newWidth < grid.columns[i].minWidth)
newWidth = grid.columns[i].minWidth;
grid.columns[i].width = newWidth;
totX += grid.columns[i].width;
lastColumn = grid.columns[i];
}
}
if (totX > newTotalSpace)
{
// if excess then should be taken out only from changing column
// cause others would have already gone to their minimum
newWidth = grid.columns[col].width - totX + newTotalSpace;
if (newWidth < grid.columns[col].minWidth)
newWidth = grid.columns[col].minWidth;
grid.columns[col].width = newWidth;
}
else if (lastColumn)
{
// if less then should be added in last column
// dont need to check for minWidth as we are adding
lastColumn.width = lastColumn.width - totX + newTotalSpace;
}
invalidateDisplayList();
}
private static function availableColumnsFilterFunction(item:Object):Boolean {
var availableColumn:ColumnSpecVO = item as ColumnSpecVO;
for each (var col:ColumnSpecVO in TrackingModelLocator.getInstance().config.columns) {
if (availableColumn.label == col.label) return false;
}
return true;
}
]]>