Commit 9ef425a1 authored by Matt Strum's avatar Matt Strum

Added some missing files

parent de5c6bce
<?xml version="1.0" encoding="utf-8"?>
<pgmap:ResizeWindow xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:pgmap="pgmap.*"
layout="vertical"
showCloseButton="true"
borderAlpha=".9" borderColor="#D2E1F0"
height="400" width="700"
close="PopUpManager.removePopUp(this)"
resizable="true">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
]]>
</mx:Script>
</pgmap:ResizeWindow>
<?xml version="1.0" encoding="utf-8"?>
<pgmap:DefaultWindow
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:pgmap="pgmap.*"
title="Log Message">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
public function setMessage(log:LogMessage):void
{
details.text = log.details;
nameField.text = log.name;
groupId.text = log.groupId;
time.text = log.timeStamp.toTimeString();
error.text = log.isError.toString();
}
]]>
</mx:Script>
<mx:Grid width="100%">
<mx:GridRow width="100%" height="100%">
<mx:GridItem height="100%">
<mx:Label text="Group ID"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label text="Error?" id="groupId"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem height="100%">
<mx:Label text="Name"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label text="Error?" id="nameField"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem height="100%">
<mx:Label text="Time"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label text="Error?" id="time"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem height="100%">
<mx:Label text="Error?"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label text="Error?" id="error"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
<mx:TextArea width="100%" height="100%" id="details"/>
</pgmap:DefaultWindow>
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%" borderStyle="solid" backgroundColor="#F6F6F6"
dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"
mouseMove="mouseMoveHandler(event)" mouseUp="mouseUpHandler(event)" borderColor="#CDC2C2">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.List;
import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.managers.PopUpManager;
public var slice:Slice;
public var startNode:SliceNode = null;
public var currentNode:SliceNode = null;
public var tempLink:SliceLink;
public var hostWindow:SliceWindow;
public var allNodes:SliceNodeCollection = new SliceNodeCollection();
public var allLinks:SliceLinkCollection = new SliceLinkCollection();
public var addedRawChildren:ArrayCollection = new ArrayCollection();
public function load(newSlice:Slice):void
{
slice = newSlice.clone(false);
for each(var s:Sliver in slice.slivers)
{
// load!
}
}
private function dragEnterHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("canvas") ||
(event.dragInitiator is List &&
List(event.dragInitiator).selectedItem is PhysicalNode &&
PhysicalNode(List(event.dragInitiator).selectedItem).available &&
!allNodes.containsPhysicalNode(PhysicalNode(List(event.dragInitiator).selectedItem))))
{
DragManager.acceptDragDrop(Canvas(event.currentTarget));
}
}
private function dragDropHandler(event:DragEvent):void {
// Handle dragging new node
if(event.dragInitiator is List && List(event.dragInitiator).selectedItem is PhysicalNode)
{
var pn:PhysicalNode = List(event.dragInitiator).selectedItem as PhysicalNode;
var sn:SliceNode = new SliceNode();
var newVirtualNode:VirtualNode = new VirtualNode(slice.getOrCreateSliverFor(pn.manager));
newVirtualNode.setToPhysicalNode(pn);
sn.setNode(newVirtualNode);
sn.canvas = this;
this.addChild(sn);
sn.x = Canvas(event.currentTarget).mouseX - (sn.width/2);
sn.y = Canvas(event.currentTarget).mouseY - (sn.height/2);
allNodes.addItem(sn);
hostWindow.loadNodes();
newVirtualNode.sliver.nodes.addItem(newVirtualNode);
}
// Handle dragging old one
else if(this.contains(event.dragInitiator as DisplayObject))
{
SliceNode(event.dragInitiator).x = Canvas(event.currentTarget).mouseX - SliceNode(event.dragInitiator).startX;
SliceNode(event.dragInitiator).y = Canvas(event.currentTarget).mouseY - SliceNode(event.dragInitiator).startY;
redrawAllLinks();
}
}
public function startLinkingFrom(node:SliceNode):void
{
startNode = node;
tempLink = new SliceLink(this);
}
protected function mouseMoveHandler(event:MouseEvent):void
{
if(startNode != null)
{
// See if a node is under
currentNode = null;
for each(var sn:SliceNode in allNodes)
{
if(sn != startNode && sn.getRect(this).contains(mouseX, mouseY) && !allLinks.hasLinkFor(startNode, sn)) {
currentNode = sn;
break;
}
}
// Add sprite to Canvas display list
tempLink.drawEstablishing(startNode.x + startNode.width/2,
startNode.y + startNode.height/2,
mouseX,
mouseY, currentNode != null);
addRawChild( tempLink );
} else if(tempLink != null && rawChildren.contains(tempLink))
removeRawChild(tempLink);
}
protected function mouseUpHandler(event:MouseEvent):void
{
// Add link if needed
if(startNode != null && currentNode != null) {
if(tempLink.establish(startNode, currentNode)) {
tempLink.drawEstablished();
}
validateNow();
} else if(tempLink != null && rawChildren.contains(tempLink))
removeRawChild(tempLink);
// Reset
startNode = null;
currentNode = null;
tempLink = null;
redrawAllLinks();
}
// RAW CHILDREN FUNCTIONS
public function redrawAllLinks():void
{
for each(var sl:SliceLink in allLinks)
{
sl.drawEstablished();
sendRawChildToBack(sl);
}
}
public function sendRawChildToBack(child:*):void
{
rawChildren.setChildIndex(child, 1);
}
public function addRawChild(child:*, sendToBack:Boolean = false):void
{
if(sendToBack)
rawChildren.addChildAt(child, 1);
else
rawChildren.addChild(child);
addedRawChildren.addItem(child);
}
public function removeRawChild(child:*):void
{
rawChildren.removeChild(child);
addedRawChildren.removeItemAt(addedRawChildren.getItemIndex(child));
}
public function removeAllRawChildren():void
{
for each(var child:* in addedRawChildren)
{
rawChildren.removeChild(child);
}
addedRawChildren.removeAll();
}
]]>
</mx:Script>
</mx:Canvas>
package pgmap
{
import flash.display.CapsStyle;
import flash.display.LineScaleMode;
import flash.display.Sprite;
import flash.events.MouseEvent;
import mx.core.UIComponent;
public class SliceLink extends Sprite
{
public static var ESTABLISHED_COLOR:uint = 0x0000ff;
public static var TUNNEL_COLOR:uint = 0x00ffff;
public static var INVALID_COLOR:uint = 0xff0000;
public static var VALID_COLOR:uint = 0x00ff00;
public var virtualLink:VirtualLink;
public var startNode:SliceNode;
public var endNode:SliceNode;
public var established:Boolean = false;
public var removeButton:ImageButton;
public var canvas:SliceCanvas;
public function SliceLink(newCanvas:SliceCanvas)
{
super();
canvas = newCanvas;
}
public function isForNodes(first:SliceNode, second:SliceNode):Boolean
{
return ((startNode == first && endNode == second)
|| (startNode == second && endNode == first));
}
public function hasNode(node:SliceNode):Boolean
{
return startNode == node || endNode == node;
}
public function establish(start:SliceNode, end:SliceNode):Boolean
{
if(virtualLink.establish(start.node, end.node))
{
removeButton = new ImageButton();
removeButton.source = Common.notAvailableIcon;
removeButton.addEventListener(MouseEvent.CLICK, removeLink);
canvas.addChild(removeButton);
canvas.allLinks.addItem(this);
startNode.links.addItem(this);
endNode.links.addItem(this);
established = true;
startNode = start;
endNode = end;
return true;
} else {
return false;
}
}
public function removeLink(event:MouseEvent):void
{
virtualLink.remove();
startNode.removeLink(this);
endNode.removeLink(this);
canvas.removeChild(removeButton);
canvas.removeRawChild(this);
canvas.allLinks.removeItemAt(canvas.allLinks.getItemIndex(this));
}
public function drawEstablished():void
{
var color:uint = virtualLink.isTunnel() ? TUNNEL_COLOR : INVALID_COLOR;
drawLink(startNode.getMiddleX(), startNode.getMiddleY(), endNode.getMiddleX(), endNode.getMiddleY(), color);
removeButton.x = ((startNode.getMiddleX() + endNode.getMiddleX()) / 2) - (removeButton.width/2 + 1);
removeButton.y = ((startNode.getMiddleY() + endNode.getMiddleY()) / 2) - (removeButton.height/2);
}
public function drawEstablishing(startX:int, startY:int, endX:int, endY:int, ready:Boolean):void
{
var color:uint = ready ? VALID_COLOR : INVALID_COLOR;
drawLink(startX, startY, endX, endY, color);
}
public function drawLink(startX:int, startY:int, endX:int, endY:int, color:uint):void
{
graphics.clear();
graphics.lineStyle(4, color, 1.0, true,
LineScaleMode.NORMAL, CapsStyle.ROUND);
graphics.moveTo(startX, startY);
graphics.lineTo(endX, endY);
if(established)
{
graphics.moveTo(((startNode.getMiddleX() + endNode.getMiddleX()) / 2), ((startNode.getMiddleY() + endNode.getMiddleY()) / 2));
graphics.lineStyle(2, color, 1.0);
graphics.beginFill(color, 0.8);
graphics.drawCircle(((startNode.getMiddleX() + endNode.getMiddleX()) / 2),
((startNode.getMiddleY() + endNode.getMiddleY()) / 2),
9);
}
}
}
}
\ No newline at end of file
package pgmap
{
import mx.collections.ArrayCollection;
public class SliceLinkCollection extends ArrayCollection
{
public function SliceLinkCollection(source:Array=null)
{
super(source);
}
public function hasLinkFor(first:SliceNode, second:SliceNode):Boolean
{
for each(var sl:SliceLink in this) {
if(sl.isForNodes(first, second))
return true;
}
return false;
}
public function getLinksFor(node:SliceNode):SliceLinkCollection
{
var newSliceCollection:SliceLinkCollection = new SliceLinkCollection();
for each(var sl:SliceLink in this) {
if(sl.hasNode(node))
newSliceCollection.addItem(sl);
}
return newSliceCollection;
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas
xmlns:mx="http://www.adobe.com/2006/mxml"
width="124" height="22" borderStyle="solid" backgroundColor="#EAEAEA" borderThickness="2"
mouseDown="mouseMoveHandler(event)"
xmlns:pgmap="pgmap.*" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:Style>
.failedStyle {
color: red;
textRollOverColor: red;
textSelectedColor: red;
themeColor: red;
}
.validStyle {
color: green;
textRollOverColor: green;
textSelectedColor: green;
themeColor: green;
}
.unknownStyle {
color: grey;
textRollOverColor: grey;
textSelectedColor: grey;
themeColor: grey;
}
.inprogressStyle {
color: #FF7F00;
textRollOverColor: #FF7F00;
textSelectedColor: #FF7F00;
themeColor: #FF7F00;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.core.DragSource;
import mx.graphics.ImageSnapshot;
import mx.managers.DragManager;
[Bindable]
public var node:VirtualNode;
public var links:ArrayCollection;
public var startX:int;
public var startY:int;
public var canvas:SliceCanvas;
public function setNode(n:VirtualNode):void
{
node = n;
toolTip += "Name: " + n.name + "\nURN: " + n.urn;
links = new ArrayCollection();
}
public function removeLink(l:SliceLink):void
{
links.removeItemAt(links.getItemIndex(l));
}
private function mouseMoveHandler(event:MouseEvent):void{
var d:Array = getObjectsUnderPoint(new Point(event.localX, event.localY));
var dragInitiator:Canvas = Canvas(event.currentTarget);
var ds:DragSource = new DragSource();
ds.addData(dragInitiator, "canvas");
startX = event.localX;
startY = event.localY;
DragManager.doDrag(dragInitiator, ds, event);
}
private function mouseDownHandler(event:MouseEvent):void{
event.stopImmediatePropagation();
canvas.startLinkingFrom(this);
}
public function getMiddleX():int
{
return x + width/2;
}
public function getMiddleY():int
{
return y + height/2;
}
]]>
</mx:Script>
<mx:Label x="8" y="0" text="{node.name}" width="91.66667" height="18"/>
<mx:Label x="-1" text="E" width="10" fontSize="8" height="17" y="2" textAlign="center"/>
<pgmap:ImageButton id="addLink" x="100" y="-2" width="22" height="22" source="@Embed('../images/bullet_add.png')" mouseDown="mouseDownHandler(event)"/>
<mx:VRule x="8" y="0" width="2" height="18"/>
</mx:Canvas>
package pgmap
{
import mx.collections.ArrayCollection;
public class SliceNodeCollection extends ArrayCollection
{
public function SliceNodeCollection(source:Array=null)
{
super(source);
}
public function containsPhysicalNode(node:PhysicalNode):Boolean
{
for each (var sn:SliceNode in this)
{
if(!sn.node.isVirtual && sn.node.physicalNode == node)
return true;
}
return false;
}
public function containsVirtualNode(node:VirtualNode):Boolean
{
for each (var sn:SliceNode in this)
{
if(sn.node == node)
return true;
}
return false;
}
public function seperateNodesByComponentManager():Array
{
var completedCms:ArrayCollection = new ArrayCollection();
var completed:Array = new Array();
for each(var sn:SliceNode in this)
{
if(!completedCms.contains(sn.node.manager))
{
var cmNodes:SliceNodeCollection = new SliceNodeCollection();
for each(var sncm:SliceNode in this)
{
if(sncm.node.manager == sn.node.manager)
cmNodes.addItem(sncm);
}
if(cmNodes.length > 0)
completed.push(cmNodes);
}
}
return completed;
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<pgmap:DefaultWindow
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:pgmap="pgmap.*"
title="Slice">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.Sort;
import mx.collections.SortField;
import mx.controls.scrollClasses.ScrollThumb;
import mx.core.DragSource;
import mx.core.UIComponent;
import mx.events.FlexEvent;
[Bindable]
private var slice:Slice;
[Bindable]
private var cms:Array;
[Bindable]
public var nodes:ArrayCollection;
public function loadNodes():void {
var cm:ComponentManager = Common.Main().pgHandler.ComponentManagers[selectCm.selectedIndex] as ComponentManager;
if(this.hideUnavailableCheckBox.selected)
{
nodes = cm.getAvailableNodes();
for each(var sn:SliceNode in this.sliceCanvas.allNodes)
{
if(sn.node.manager == cm && nodes.getItemIndex(sn.node) > -1)
nodes.removeItemAt(nodes.getItemIndex(sn.node));
}
}
else
nodes = cm.AllNodes;
var nameSort:Sort = new Sort();
var dataSortField:SortField = new SortField();
dataSortField.name = "name";
nameSort.fields = [dataSortField];
nodes.sort = nameSort;
nodes.refresh();
}
public function loadSlice(s:Slice):void
{
sliceCanvas.load(s);
cms = new Array();
for each(var cm:ComponentManager in Common.Main().pgHandler.ComponentManagers)
{
cms.push(cm.Hrn);
}
selectCm.selectedIndex = 0;
loadNodes();
}
private function assignAvailableIcon(item:Object):Class {
var node:PhysicalNode = item as PhysicalNode;
if(!this.hideUnavailableCheckBox.selected)
{
for each(var sn:SliceNode in this.sliceCanvas.allNodes)
{
if(!sn.node.isVirtual && sn.node.physicalNode == node)
return Common.notAvailableIcon;
}
}
return Common.assignAvailabilityIcon(item as PhysicalNode);
}
]]>
</mx:Script>
<mx:HBox width="100%">
<mx:Label text="{slice.hrn}" fontSize="17" fontWeight="bold"/>
<mx:Spacer width="100%"/>
<mx:Label text="{slice.urn}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Button label="Embed"/>
<mx:Label text="Slivers"/>
<mx:Button label="Create"/>
<mx:Button label="Boot"/>
<mx:Button label="Delete"/>
</mx:HBox>
<mx:HDividedBox width="100%" height="100%">
<mx:VBox height="100%">
<mx:ComboBox id="selectCm" width="100%" dataProvider="{cms}" change="loadNodes()"></mx:ComboBox>
<mx:CheckBox label="Hide unavailable" selected="true" id="hideUnavailableCheckBox" click="loadNodes()"/>
<mx:List width="100%" height="100%" id="listNodes"
dataProvider="{nodes}"
labelField="name" dragEnabled="true"
iconFunction="assignAvailableIcon">
</mx:List>
<mx:HBox width="100%">
<mx:Button label="Exclusive"/>
<mx:Button label="Shared"/>
</mx:HBox>
</mx:VBox>
<pgmap:SliceCanvas id="sliceCanvas" hostWindow="{this}">
</pgmap:SliceCanvas>
</mx:HDividedBox>
</pgmap:DefaultWindow>
<?xml version="1.0" encoding="utf-8"?>
<pgmap:ResizeWindow
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:pgmap="pgmap.*"
borderAlpha=".9" borderColor="#D2E1F0"
showCloseButton="true"
title="Slices"
close="PopUpManager.removePopUp(this)"
layout="vertical" width="272" height="226">
<mx:Script>
<![CDATA[
import mx.events