Commit c86abaf5 authored by Matt Strum's avatar Matt Strum

Nightly build for supporting exporting a DOT file for component managers

parent 74ff2478
......@@ -191,6 +191,19 @@
main.rspecView.loadXml(cm.Rspec);
});
cmHbox.addChild(rspecButton);
var dotButton:Button = new Button();
dotButton.label = ".";
dotButton.addEventListener(MouseEvent.CLICK,
function openDot():void
{
var cw:ConsoleWindow = new ConsoleWindow();
PopUpManager.addPopUp(cw, main, false);
PopUpManager.centerPopUp(cw);
cw.title = "dot format from " + cm.Hrn;
cw.txt.text = cm.getDotGraph();
});
cmHbox.addChild(dotButton);
}
if(cm.Message.length > 0)
......
......@@ -125,6 +125,14 @@
return phrase.substring(1, 0).toUpperCase()+phrase.substring(1);
}
public static function replaceString(original:String, find:String, replace:String):String {
return original.split(find).join(replace);
}
public static function getDotString(name : String) : String {
return replaceString(replaceString(name, ".", ""), "-", "");
}
// Shortens the given string to a length, taking out from the middle
public static function shortenString(phrase : String, size : int) : String {
if(phrase.length < size)
......
......@@ -282,5 +282,35 @@
myIndex += idx;
}
public function getDotGraph():String {
var added:Dictionary = new Dictionary();
var dot:String = "graph " + Common.getDotString(Hrn) + " {\n" +
"\toverlap=scale;\n";
for each(var currentNodeGroup:PhysicalNodeGroup in Nodes.collection) {
for each(var currentNode:PhysicalNode in currentNodeGroup.collection) {
// Give any special node characteristics
for each(var d:NodeType in currentNode.types) {
if(d.name == "switch")
dot += "\t" + Common.getDotString(currentNode.name) + " [shape=box, style=bold];\n";
}
// Add connections
for each(var connectedNode:PhysicalNode in currentNode.GetNodes()) {
if(added[connectedNode.urn] != null)
continue;
dot += "\t" + Common.getDotString(currentNode.name) + " -- " + Common.getDotString(connectedNode.name) + ";\n";
}
if(currentNode.subNodes != null && currentNode.subNodes.length > 0) {
for each(var subNode:PhysicalNode in currentNode.subNodes) {
dot += "\t" + Common.getDotString(currentNode.name) + " -- " + Common.getDotString(subNode.name) + ";\n";
}
}
added[currentNode.urn] = currentNode;
}
}
return dot + "}";
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment